1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.service.impl;
17
18 import org.kuali.ole.coa.businessobject.Account;
19 import org.kuali.ole.select.service.OleAccountService;
20 import org.kuali.ole.sys.OLEConstants;
21 import org.kuali.ole.sys.context.SpringContext;
22 import org.kuali.rice.kew.api.exception.WorkflowException;
23 import org.kuali.rice.kns.document.MaintenanceDocument;
24 import org.kuali.rice.krad.service.BusinessObjectService;
25 import org.kuali.rice.krad.service.DocumentService;
26 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
27 import org.kuali.rice.krad.util.ObjectUtils;
28
29 import java.util.HashMap;
30 import java.util.List;
31 import java.util.Map;
32
33 public class OleAccountServiceImpl implements OleAccountService {
34
35 private BusinessObjectService businessObjectService;
36
37
38
39
40
41
42 public BusinessObjectService getBusinessObjectService() {
43 if (businessObjectService == null) {
44 businessObjectService = SpringContext.getBean(org.kuali.rice.krad.service.BusinessObjectService.class);
45 }
46 return businessObjectService;
47 }
48
49
50
51
52 @Override
53 public List<Account> getTemporaryRestrictedAccounts() {
54
55 String accountRestrictedStatusCode = "T";
56 Map TRestrictedAccountMap = new HashMap();
57 TRestrictedAccountMap.put("accountRestrictedStatusCode", accountRestrictedStatusCode);
58 businessObjectService = getBusinessObjectService();
59 List<Account> accountList = (List<Account>) businessObjectService.findMatching(Account.class, TRestrictedAccountMap);
60 return accountList;
61 }
62
63
64
65
66 @Override
67 public Account getAccountDetailsWithAccountNumber(String accountNumber) {
68
69 Map accountNumberMap = new HashMap();
70 accountNumberMap.put("accountNumber", accountNumber);
71 businessObjectService = getBusinessObjectService();
72 return (Account) businessObjectService.findMatching(Account.class, accountNumberMap);
73 }
74
75
76
77
78 @Override
79 public List<Account> getAllAccountDetails() {
80
81 businessObjectService = getBusinessObjectService();
82 return (List<Account>) businessObjectService.findAll(Account.class);
83 }
84
85
86
87
88 @Override
89 public List<Account> getMatchingAccountDetails(Map<String, String> parameters) {
90
91 businessObjectService = getBusinessObjectService();
92 return (List<Account>) businessObjectService.findMatching(Account.class, parameters);
93 }
94
95
96
97
98 @Override
99 public boolean shouldAccountRouteForApproval(String documentId) {
100 boolean shouldRoute = false;
101 MaintenanceDocument newDoc = null;
102 try {
103 DocumentService documentService = KRADServiceLocatorWeb.getDocumentService();
104 newDoc = (MaintenanceDocument) documentService.getByDocumentHeaderId(documentId);
105 } catch (WorkflowException we) {
106 throw new RuntimeException("A WorkflowException was thrown which prevented the loading of " + "the comparison document (" + documentId + ")", we);
107 }
108
109 if (ObjectUtils.isNotNull(newDoc)) {
110 Account account = (Account) newDoc.getNewMaintainableObject().getBusinessObject();
111 if (account.getSubFundGroupCode() != null && !account.getSubFundGroupCode().isEmpty() &&
112 account.getSubFundGroupCode().equals(OLEConstants.CLEARING_ACCOUNT_CODE)) {
113 shouldRoute = true;
114 }
115 }
116 return shouldRoute;
117 }
118
119
120 }