View Javadoc
1   /**
2    * Copyright 2005-2014 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.rice.krms.impl.repository;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.krad.lookup.LookupableImpl;
20  import org.kuali.rice.krad.uif.UifConstants;
21  import org.kuali.rice.krad.uif.UifParameters;
22  import org.kuali.rice.krad.util.KRADConstants;
23  import org.kuali.rice.krad.util.KRADUtils;
24  import org.kuali.rice.krad.util.UrlFactory;
25  import org.kuali.rice.krad.lookup.LookupForm;
26  
27  import java.util.List;
28  import java.util.Map;
29  import java.util.Properties;
30  
31  public class PropositionLookupableHelperServiceImpl extends LookupableImpl {
32  
33      @Override
34      public boolean allowsMaintenanceNewOrCopyAction() {
35          return true;
36      }
37  
38      @Override
39      public boolean allowsMaintenanceEditAction(Object dataObject) {
40          return true;
41      }
42  
43      @Override
44      public boolean allowsMaintenanceDeleteAction(Object dataObject) {
45          return true;
46      }
47  
48      @Override
49      protected String getMaintenanceActionUrl(LookupForm lookupForm, Object dataObject, String methodToCall,
50              List<String> pkNames) {
51          Properties props = new Properties();
52          props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
53  
54          Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
55          for (String primaryKey : primaryKeyValues.keySet()) {
56              String primaryKeyValue = primaryKeyValues.get(primaryKey);
57  
58              props.put(primaryKey, primaryKeyValue);
59              props.put(KRADConstants.OVERRIDE_KEYS, primaryKey);
60          }
61  
62          if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
63              props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
64          }
65  
66          props.put(UifParameters.DATA_OBJECT_CLASS_NAME, PropositionBo.class.getName());
67          props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
68  
69          return UrlFactory.parameterizeUrl(org.kuali.rice.krms.impl.util.KrmsImplConstants.WebPaths.PROPOSITION_PATH, props);
70      }
71  }