001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.sys.businessobject.lookup;
017
018 import java.util.Properties;
019
020 import org.kuali.kfs.sys.KFSConstants;
021 import org.kuali.kfs.sys.businessobject.TaxRegion;
022 import org.kuali.kfs.sys.businessobject.TaxRegionType;
023 import org.kuali.rice.kns.lookup.KualiLookupableImpl;
024 import org.kuali.rice.kns.service.KNSServiceLocator;
025 import org.kuali.rice.kns.util.KNSConstants;
026 import org.kuali.rice.kns.util.UrlFactory;
027
028 public class TaxRegionLookupableImpl extends KualiLookupableImpl {
029
030 /**
031 * Make create new action go to Tax Region Type lookup first. Adding the tax region from lookup indicator
032 * (CREATE_TAX_REGION_FROM_LOOKUP_INDICATOR) to the conversion fields to control when you should do a regular tax region type
033 * code lookup vs. one that actually creates a tax region. This indicator is then used in
034 * TaxRegionTypeLookupableImpl.
035 *
036 * @see org.kuali.core.lookup.KualiLookupableImpl#getCreateNewUrl()
037 */
038 @Override
039 public String getCreateNewUrl() {
040 String url = "";
041
042 if (getLookupableHelperService().allowsMaintenanceNewOrCopyAction()) {
043 Properties parameters = new Properties();
044 parameters.put(KNSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, TaxRegionType.class.getName());
045 parameters.put(KNSConstants.RETURN_LOCATION_PARAMETER, KNSServiceLocator.getKualiConfigurationService().getPropertyString(KNSConstants.APPLICATION_URL_KEY) + "/" + KNSConstants.MAPPING_PORTAL);
046 parameters.put(KNSConstants.DOC_FORM_KEY, getTaxRegionDocumentTypeName());
047 parameters.put(KNSConstants.CONVERSION_FIELDS_PARAMETER, "taxRegionTypeCode:taxRegionTypeCode");
048 url = getCreateNewUrl(UrlFactory.parameterizeUrl(KNSConstants.LOOKUP_ACTION, parameters));
049 }
050
051 return url;
052 }
053
054 private String getTaxRegionDocumentTypeName() {
055 return getDataDictionaryService().getDataDictionary().getMaintenanceDocumentEntryForBusinessObjectClass(TaxRegion.class).getDocumentTypeName();
056 }
057
058 }