View Javadoc

1   package org.kuali.ole.license.lookup;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.kuali.ole.OLEConstants;
5   import org.kuali.ole.license.bo.OleCheckListBo;
6   import org.kuali.rice.krad.lookup.LookupableImpl;
7   import org.kuali.rice.krad.uif.UifConstants;
8   import org.kuali.rice.krad.uif.UifParameters;
9   import org.kuali.rice.krad.uif.view.LookupView;
10  import org.kuali.rice.krad.util.KRADConstants;
11  import org.kuali.rice.krad.util.KRADUtils;
12  import org.kuali.rice.krad.util.UrlFactory;
13  import org.kuali.rice.krad.web.form.LookupForm;
14  
15  import java.util.List;
16  import java.util.Map;
17  import java.util.Properties;
18  
19  /**
20   * OleCheckListLookupableImpl is the view helper service class for Check List Maintenance Document
21   */
22  public class OleCheckListLookupableImpl extends LookupableImpl {
23      private String returnLocation ="";
24  
25      /**
26       *  Gets the returnLocation attribute.
27       * @return  Returns the returnLocation
28       */
29      public String getReturnLocation() {
30          return returnLocation;
31      }
32  
33      /**
34       * Sets the returnLocation attribute value.
35       * @param returnLocation The returnLocation to set.
36       */
37      public void setReturnLocation(String returnLocation) {
38          this.returnLocation = returnLocation;
39      }
40  
41      /**
42       *   This method returns  URL for checklist maintenance action.
43       * @param lookupForm
44       * @param dataObject
45       * @param methodToCall
46       * @param pkNames
47       * @return String
48       */
49      @Override
50      protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
51                                        List<String> pkNames) {
52          LookupView lookupView = (LookupView) lookupForm.getView();
53  
54          Properties props = new Properties();
55          props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
56  
57          Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
58          for (String primaryKey : primaryKeyValues.keySet()) {
59              String primaryKeyValue = primaryKeyValues.get(primaryKey);
60  
61              props.put(primaryKey, primaryKeyValue);
62          }
63  
64          if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
65              props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
66              returnLocation = lookupForm.getReturnLocation();
67          }
68  
69          props.put(UifParameters.DATA_OBJECT_CLASS_NAME, lookupForm.getDataObjectClassName());
70          props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
71  
72          String maintenanceMapping = OLEConstants.OleCheckList.CHECK_LIST_MAINTENANCE_ACTION_LINK;
73          return UrlFactory.parameterizeUrl(maintenanceMapping, props);
74      }
75  
76      /**
77       *   This method returns URL for downloading the checklist template.
78       * @param object
79       * @return  url
80       */
81      public String performDownload(Object object) {
82          OleCheckListBo oleCheckListBo = (OleCheckListBo)object;
83          String url = OLEConstants.OleCheckList.CHECK_LIST_LINK+getReturnLocation()+OLEConstants.OleCheckList.METHOD_TO_CALL
84                  +oleCheckListBo.getOleCheckListId();
85  
86          return url;
87      }
88  
89      /**
90       *  This method returns checklist name, to be displayed in the result field. 
91       * @param object
92       * @return  checkListName
93       */
94      public String getCheckListName(Object object) {
95          String checkListName = "";
96          OleCheckListBo oleCheckListBo = (OleCheckListBo)object;
97          checkListName = oleCheckListBo.getName();
98          return checkListName;
99      }
100 }