1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.pdp.businessobject.lookup;
17
18 import java.util.ArrayList;
19 import java.util.HashMap;
20 import java.util.List;
21 import java.util.Map;
22 import java.util.Properties;
23
24 import org.kuali.ole.pdp.PdpConstants;
25 import org.kuali.ole.pdp.PdpKeyConstants;
26 import org.kuali.ole.pdp.PdpParameterConstants;
27 import org.kuali.ole.pdp.PdpPropertyConstants;
28 import org.kuali.ole.pdp.businessobject.FormatProcess;
29 import org.kuali.ole.pdp.businessobject.PaymentProcess;
30 import org.kuali.ole.pdp.service.PdpAuthorizationService;
31 import org.kuali.ole.sys.OLEConstants;
32 import org.kuali.rice.core.api.config.property.ConfigurationService;
33 import org.kuali.rice.kim.api.identity.Person;
34 import org.kuali.rice.kns.lookup.HtmlData;
35 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
36 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
37 import org.kuali.rice.krad.bo.BusinessObject;
38 import org.kuali.rice.krad.util.GlobalVariables;
39 import org.kuali.rice.krad.util.ObjectUtils;
40 import org.kuali.rice.krad.util.UrlFactory;
41
42
43
44
45 public class FormatProcessLookupableHelperService extends KualiLookupableHelperServiceImpl {
46
47 private ConfigurationService configurationService;
48 private PdpAuthorizationService pdpAuthorizationService;
49
50
51
52
53 @Override
54 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
55 return super.getSearchResults(fieldValues);
56 }
57
58
59
60
61 @Override
62 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
63 List<HtmlData> anchorHtmlDataList = new ArrayList<HtmlData>();
64 if (businessObject instanceof FormatProcess) {
65 Person person = GlobalVariables.getUserSession().getPerson();
66 FormatProcess formatProcess = (FormatProcess) businessObject;
67 int processId = formatProcess.getPaymentProcIdentifier();
68
69 Map primaryKeys = new HashMap();
70 primaryKeys.put(PdpPropertyConstants.PaymentProcess.PAYMENT_PROCESS_ID, processId);
71 PaymentProcess paymentProcess = (PaymentProcess) getBusinessObjectService().findByPrimaryKey(PaymentProcess.class, primaryKeys);
72
73 String linkText = OLEConstants.EMPTY_STRING;
74 String url = OLEConstants.EMPTY_STRING;
75 String basePath = configurationService.getPropertyValueAsString(OLEConstants.APPLICATION_URL_KEY) + "/" + PdpConstants.Actions.FORMAT_PROCESS_ACTION;
76
77 if (pdpAuthorizationService.hasRemoveFormatLockPermission(person.getPrincipalId()) && ObjectUtils.isNotNull(paymentProcess) && !paymentProcess.isFormattedIndicator()) {
78 Properties params = new Properties();
79 params.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, PdpConstants.ActionMethods.CLEAR_FORMAT_PROCESS_ACTION);
80 params.put(PdpParameterConstants.FormatProcess.PROCESS_ID_PARAM, UrlFactory.encode(String.valueOf(processId)));
81 url = UrlFactory.parameterizeUrl(basePath, params);
82
83 linkText = configurationService.getPropertyValueAsString(PdpKeyConstants.FormatProcess.CLEAR_UNFINISHED_FORMAT_PROCESS);
84
85 AnchorHtmlData anchorHtmlData = new AnchorHtmlData(url, PdpConstants.ActionMethods.CONFIRM_CANCEL_ACTION, linkText);
86 anchorHtmlDataList.add(anchorHtmlData);
87 }
88 else {
89 AnchorHtmlData anchorHtmlData = new AnchorHtmlData(" ", "", "");
90 anchorHtmlDataList.add(anchorHtmlData);
91 }
92
93 }
94 return anchorHtmlDataList;
95 }
96
97
98
99
100
101
102 public ConfigurationService getConfigurationService() {
103 return configurationService;
104 }
105
106
107
108
109
110 public void setConfigurationService(ConfigurationService configurationService) {
111 this.configurationService = configurationService;
112 }
113
114
115
116
117
118 public void setPdpAuthorizationService(PdpAuthorizationService pdpAuthorizationService) {
119 this.pdpAuthorizationService = pdpAuthorizationService;
120 }
121 }