View Javadoc
1   /*
2    * Copyright 2008 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.sys.businessobject.lookup;
17  
18  import java.util.Properties;
19  
20  import org.kuali.ole.sys.businessobject.TaxRegion;
21  import org.kuali.ole.sys.businessobject.TaxRegionType;
22  import org.kuali.ole.sys.context.SpringContext;
23  import org.kuali.rice.core.api.config.property.ConfigurationService;
24  import org.kuali.rice.kns.lookup.KualiLookupableImpl;
25  import org.kuali.rice.krad.util.KRADConstants;
26  import org.kuali.rice.krad.util.UrlFactory;
27  
28  public class TaxRegionLookupableImpl extends KualiLookupableImpl {
29  
30      /**
31       * Make create new action go to Tax Region Type lookup first. Adding the tax region from lookup indicator
32       * (CREATE_TAX_REGION_FROM_LOOKUP_INDICATOR) to the conversion fields to control when you should do a regular tax region type
33       * code lookup vs. one that actually creates a tax region.  This indicator is then used in
34       * TaxRegionTypeLookupableImpl.
35       * 
36       * @see org.kuali.core.lookup.KualiLookupableImpl#getCreateNewUrl()
37       */
38      @Override
39      public String getCreateNewUrl() {
40          String url = "";
41  
42          if (getLookupableHelperService().allowsMaintenanceNewOrCopyAction()) {
43              Properties parameters = new Properties();
44              parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, TaxRegionType.class.getName());
45              parameters.put(KRADConstants.RETURN_LOCATION_PARAMETER, SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KRADConstants.APPLICATION_URL_KEY) + "/" + KRADConstants.MAPPING_PORTAL);
46              parameters.put(KRADConstants.DOC_FORM_KEY, getTaxRegionDocumentTypeName()); 
47              parameters.put(KRADConstants.CONVERSION_FIELDS_PARAMETER, "taxRegionTypeCode:taxRegionTypeCode");
48              url = getCreateNewUrl(UrlFactory.parameterizeUrl(KRADConstants.LOOKUP_ACTION, parameters)); 
49          }
50  
51          return url;
52      }
53      
54      private String getTaxRegionDocumentTypeName() {
55          return getDataDictionaryService().getDataDictionary().getMaintenanceDocumentEntryForBusinessObjectClass(TaxRegion.class).getDocumentTypeName();
56      } 
57  
58  }