1 package org.kuali.ole.deliver.request.lookup;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.ole.OLEConstants;
5
6 import org.kuali.ole.deliver.loan.bo.OleItemSearch;
7 import org.kuali.ole.deliver.request.bo.OleDeliverRequestBo;
8 import org.kuali.ole.deliver.request.service.OleDeliverRequestDocumentHelperServiceImpl;
9 import org.kuali.rice.krad.lookup.LookupableImpl;
10 import org.kuali.rice.krad.uif.UifConstants;
11 import org.kuali.rice.krad.uif.UifParameters;
12 import org.kuali.rice.krad.uif.view.LookupView;
13 import org.kuali.rice.krad.util.KRADConstants;
14 import org.kuali.rice.krad.util.KRADUtils;
15 import org.kuali.rice.krad.util.UrlFactory;
16 import org.kuali.rice.krad.web.form.LookupForm;
17
18 import java.util.*;
19
20
21
22
23
24
25
26
27
28 public class OleDeliverRequestLookupableImpl extends LookupableImpl {
29 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleDeliverRequestLookupableImpl.class);
30 private OleDeliverRequestDocumentHelperServiceImpl oleDeliverRequestDocumentHelperService = new OleDeliverRequestDocumentHelperServiceImpl();
31 private String itemTitle;
32 @Override
33 protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
34 List<String> pkNames) {
35 LOG.debug("Inside getActionUrlHref()");
36 LookupView lookupView = (LookupView) lookupForm.getView();
37
38 Properties props = new Properties();
39 props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
40 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
41 for (String primaryKey : primaryKeyValues.keySet()) {
42 String primaryKeyValue = primaryKeyValues.get(primaryKey);
43
44 props.put(primaryKey, primaryKeyValue);
45 }
46
47 if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
48 props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
49 }
50
51 props.put(UifParameters.DATA_OBJECT_CLASS_NAME, OleDeliverRequestBo.class.getName());
52 props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
53
54 String maintenanceMapping = OLEConstants.OleDeliverRequest.DELIVER_REQUEST_MAINTENANCE_ACTION_LINK;
55
56 return UrlFactory.parameterizeUrl(maintenanceMapping, props);
57 }
58
59
60 @Override
61 public Collection<?> performSearch(LookupForm form, Map<String, String> searchCriteria, boolean bounded) {
62 LOG.debug("Inside performSearch()");
63
64 itemTitle =searchCriteria.get("title");
65 searchCriteria.remove("title");
66 List<OleDeliverRequestBo> displayList= (List<OleDeliverRequestBo>) super.performSearch(form,searchCriteria,bounded);
67 searchCriteria.put("title",itemTitle);
68 OleItemSearch oleItemSearch;
69 try{
70 for(int i=0;i<displayList.size();i++){
71 oleItemSearch= oleDeliverRequestDocumentHelperService.getItemDetails(displayList.get(i).getItemId());
72 if(itemTitle!=null && !itemTitle.isEmpty()&&!oleItemSearch.getTitle().toUpperCase().contains(itemTitle.toUpperCase())){
73 displayList.remove(i);
74 }
75 else{
76 displayList.get(i).setTitle(oleItemSearch.getTitle());
77 displayList.get(i).setCallNumber(oleItemSearch.getCallNumber());
78 }
79 }
80 }
81 catch(Exception e){
82 }
83
84 return displayList;
85 }
86
87
88 }
89
90