1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.service.impl;
17
18 import java.util.ArrayList;
19 import java.util.Collection;
20 import java.util.List;
21 import java.util.Map;
22
23 import org.apache.commons.lang.StringUtils;
24 import org.apache.struts.action.ActionForward;
25 import org.apache.struts.action.ActionMapping;
26 import org.kuali.ole.sys.businessobject.ElectronicPaymentClaim;
27 import org.kuali.ole.sys.service.ElectronicFundTransferActionHelper;
28 import org.kuali.ole.sys.service.ElectronicPaymentClaimingService;
29 import org.kuali.ole.sys.web.struts.ElectronicFundTransferForm;
30 import org.kuali.rice.kim.api.identity.Person;
31 import org.kuali.rice.kns.lookup.LookupResultsService;
32 import org.kuali.rice.kns.service.DataDictionaryService;
33 import org.kuali.rice.krad.exception.AuthorizationException;
34 import org.kuali.rice.krad.util.GlobalVariables;
35
36
37
38
39 public class ElectronicFundTransferRefreshActionHelper implements ElectronicFundTransferActionHelper {
40 private ElectronicPaymentClaimingService electronicPaymentClaimingService;
41 private DataDictionaryService ddService;
42 protected LookupResultsService lookupResultsService;
43
44 protected static final String BASIC_FORWARD = "basic";
45 protected static final String ACTION_NAME = "claim";
46 protected static final String PORTAL_FORWARD = "portal";
47
48
49
50
51 public ActionForward performAction(ElectronicFundTransferForm form, ActionMapping mapping, Map params, String basePath) {
52
53 Person currentUser = GlobalVariables.getUserSession().getPerson();
54 if (!form.hasAvailableClaimingDocumentStrategies()) {
55 throw new AuthorizationException(currentUser.getPrincipalName(), ElectronicFundTransferRefreshActionHelper.ACTION_NAME, ddService.getDataDictionary().getBusinessObjectEntry(ElectronicPaymentClaim.class.getName()).getObjectLabel());
56 }
57
58 String lookupResultsSequenceNumber = null;
59 if (params.get("lookupResultsSequenceNumber") != null) {
60 lookupResultsSequenceNumber = ((String[])params.get("lookupResultsSequenceNumber"))[0];
61 }
62 if (StringUtils.isBlank(lookupResultsSequenceNumber)) {
63 return mapping.findForward(PORTAL_FORWARD);
64 }
65 List<ElectronicPaymentClaim> claims = getClaimedPayments(currentUser, lookupResultsSequenceNumber);
66 if (claims.size() == 0) {
67 return mapping.findForward(PORTAL_FORWARD);
68 }
69
70 form.setClaims(claims);
71
72 return mapping.findForward(BASIC_FORWARD);
73 }
74
75
76
77
78
79
80
81 protected List<ElectronicPaymentClaim> getClaimedPayments(Person currentUser, String lookupResultsSequenceNumber) {
82 List<ElectronicPaymentClaim> claims = new ArrayList<ElectronicPaymentClaim>();
83 try {
84 Collection selectedClaims = lookupResultsService.retrieveSelectedResultBOs(lookupResultsSequenceNumber, ElectronicPaymentClaim.class, currentUser.getPrincipalId());
85 for (Object claimAsObj : selectedClaims) {
86 ElectronicPaymentClaim claim = (ElectronicPaymentClaim) claimAsObj;
87 if (!claim.getPaymentClaimStatusCode().equals(ElectronicPaymentClaim.ClaimStatusCodes.CLAIMED) && StringUtils.isBlank(claim.getReferenceFinancialDocumentNumber())) {
88 claims.add(claim);
89 }
90 }
91 }
92 catch (Exception e) {
93 throw new RuntimeException(e);
94 }
95 return claims;
96 }
97
98
99
100
101
102 public void setElectronicPaymentClaimingService(ElectronicPaymentClaimingService electronicPaymentClaimingService) {
103 this.electronicPaymentClaimingService = electronicPaymentClaimingService;
104 }
105
106
107
108
109
110 public void setDataDictonaryService(DataDictionaryService ddService) {
111 this.ddService = ddService;
112 }
113
114
115
116
117
118 public void setLookupResultsService(LookupResultsService lookupResultsService) {
119 this.lookupResultsService = lookupResultsService;
120 }
121
122
123 }
124