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
29
30 public class OleLicenseRequestLookupableImpl extends LookupableImpl {
31
32 private OleLicenseRequestService oleLicenseRequestService;
33
34 private String returnLocation ="";
35
36
37
38
39
40 public String getReturnLocation() {
41 return returnLocation;
42 }
43
44
45
46
47
48 public void setReturnLocation(String returnLocation) {
49 this.returnLocation = returnLocation;
50 }
51
52
53
54
55
56
57
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
89
90
91
92
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
104
105
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
117
118
119 public OleLicenseRequestService getOleLicenseRequestservice() {
120 if(oleLicenseRequestService == null ) {
121 oleLicenseRequestService = GlobalResourceLoader.getService("oleLicenseRequestService");
122 }
123 return oleLicenseRequestService;
124 }
125
126 }