View Javadoc

1   package org.kuali.ole.license.lookup;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.kuali.incubator.SolrRequestReponseHandler;
5   import org.kuali.ole.OLEConstants;
6   import org.kuali.ole.license.bo.OleLicenseRequestBo;
7   import org.kuali.ole.license.bo.OleLicenseRequestItemTitle;
8   import org.kuali.ole.license.controller.LicenceRoutingRuleDelegationMaintainable;
9   import org.kuali.ole.service.OleLicenseRequestService;
10  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
11  import org.kuali.rice.kew.doctype.bo.DocumentType;
12  import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
13  import org.kuali.rice.krad.lookup.LookupableImpl;
14  import org.kuali.rice.krad.service.BusinessObjectService;
15  import org.kuali.rice.krad.service.KRADServiceLocator;
16  import org.kuali.rice.krad.uif.UifConstants;
17  import org.kuali.rice.krad.uif.UifParameters;
18  import org.kuali.rice.krad.uif.view.LookupView;
19  import org.kuali.rice.krad.util.KRADConstants;
20  import org.kuali.rice.krad.util.KRADUtils;
21  import org.kuali.rice.krad.util.ObjectUtils;
22  import org.kuali.rice.krad.util.UrlFactory;
23  import org.kuali.rice.krad.web.form.LookupForm;
24  
25  import java.util.*;
26  
27  /**
28   * OleLicenseRequestLookupableImpl is the view helper service class for Ole License Request Document
29   */
30  public class OleLicenseRequestLookupableImpl extends LookupableImpl {
31  
32      private OleLicenseRequestService oleLicenseRequestService;
33  
34      private String returnLocation ="";
35  
36      /**
37       *  Gets the returnLocation attribute.
38       * @return  Returns the returnLocation
39       */
40      public String getReturnLocation() {
41          return returnLocation;
42      }
43  
44      /**
45       * Sets the returnLocation attribute value.
46       * @param returnLocation The returnLocation to set.
47       */
48      public void setReturnLocation(String returnLocation) {
49          this.returnLocation = returnLocation;
50      }
51      /**
52       * This method returns action URL as oleLicenseRequest.
53       * @param lookupForm
54       * @param dataObject
55       * @param methodToCall
56       * @param pkNames
57       * @return String
58       */
59      @Override
60      protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
61                                        List<String> pkNames) {
62          LookupView lookupView = (LookupView) lookupForm.getView();
63  
64          Properties props = new Properties();
65          props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
66  
67          Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
68          for (String primaryKey : primaryKeyValues.keySet()) {
69              String primaryKeyValue = primaryKeyValues.get(primaryKey);
70  
71              props.put(primaryKey, primaryKeyValue);
72          }
73  
74          if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
75              props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
76              returnLocation = lookupForm.getReturnLocation();
77          }
78  
79          props.put(UifParameters.DATA_OBJECT_CLASS_NAME, lookupForm.getDataObjectClassName());
80          props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
81  
82          String maintenanceMapping = "oleLicenseRequest";
83  
84          return UrlFactory.parameterizeUrl(maintenanceMapping, props);
85      }
86  
87      /**
88       * This method performs the search for license request based on the search criterias
89       * @param form
90       * @param criteria
91       * @param bounded
92       * @return
93       */
94      @Override
95      public Collection<?> performSearch(LookupForm form, Map<String, String> criteria, boolean bounded) {
96          returnLocation = form.getReturnLocation();
97          Collection<?> displayList = getOleLicenseRequestservice().findLicenseRequestByCriteria(criteria);
98          return displayList;
99      }
100 
101 
102     /**
103      * This method returns the url for viewing the Requisition Document
104      * @param object
105      * @return url
106      */
107     public String viewParticularDocument(Object object) {
108         OleLicenseRequestBo oleLicenseRequestBo = (OleLicenseRequestBo)object;
109         String url = "";
110         if(returnLocation != null & !returnLocation.isEmpty())
111             url = returnLocation.substring(0,returnLocation.indexOf("portal.do"));
112         return url +"kew/DocHandler.do?command=displayDocSearchView&docId="+oleLicenseRequestBo.getDocumentNumber();
113     }
114 
115     /**
116      * This method returns the OleLicenseRequestService object
117      * @return
118      */
119     public OleLicenseRequestService getOleLicenseRequestservice() {
120         if(oleLicenseRequestService == null ) {
121             oleLicenseRequestService = GlobalResourceLoader.getService("oleLicenseRequestService");
122         }
123         return oleLicenseRequestService;
124     }
125 
126 }