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.apache.commons.lang.StringUtils;
19 import org.kuali.ole.select.OleSelectConstant;
20 import org.kuali.ole.select.businessobject.OleLineItemReceivingDoc;
21 import org.kuali.ole.select.businessobject.OlePaymentRequestItem;
22 import org.kuali.ole.select.businessobject.OlePurchaseOrderItem;
23 import org.kuali.ole.select.businessobject.OleRequisitionItem;
24 import org.kuali.ole.select.service.OleUuidCheckWebService;
25 import org.kuali.ole.sys.context.SpringContext;
26 import org.kuali.rice.krad.service.BusinessObjectService;
27
28 import java.util.*;
29
30 public class OleUuidCheckWebServiceImpl implements OleUuidCheckWebService {
31
32 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleUuidCheckWebServiceImpl.class);
33 private BusinessObjectService businessObjectService;
34
35
36
37
38 @Override
39 public String checkUuidExsistence(String uuids) {
40
41 String[] uuidArr = StringUtils.split(uuids, ",");
42 List<String> uuidList = new ArrayList(Arrays.asList(uuidArr));
43 uuidList = checkUuidInRequisitionItem(uuidList);
44 if (uuidList.size() > 0)
45 uuidList = checkUuidInPOItem(uuidList);
46 if (uuidList.size() > 0)
47 uuidList = checkUuidInPaymentRequestItem(uuidList);
48 if (uuidList.size() > 0)
49 uuidList = checkUuidInReceivingLineItem(uuidList);
50 StringBuilder titleIds = new StringBuilder();
51 for (String titleId : uuidList) {
52 titleIds.append(titleId);
53 titleIds.append(",");
54 }
55 if (titleIds.length() > 0) {
56 return titleIds.substring(0, titleIds.length() - 1);
57 } else {
58 return "";
59 }
60
61 }
62
63
64
65
66
67
68
69 public List<String> checkUuidInRequisitionItem(List<String> uuid) {
70
71 Map<String, List> uuidMap = new HashMap<String, List>();
72 uuidMap.put(OleSelectConstant.ITEMTITLEID, uuid);
73 List<OleRequisitionItem> requisitionItems = (List<OleRequisitionItem>) getBusinessObjectService().findMatching(OleRequisitionItem.class, uuidMap);
74 if (requisitionItems.size() > 0) {
75 for (OleRequisitionItem requisitionItem : requisitionItems) {
76 for (int i = 0; i < uuid.size(); i++) {
77 if (uuid.get(i).equalsIgnoreCase(requisitionItem.getItemTitleId()))
78 uuid.remove(i);
79 }
80 }
81 }
82 return uuid;
83 }
84
85
86
87
88
89
90
91 public List<String> checkUuidInPOItem(List<String> uuid) {
92
93 Map<String, List> uuidMap = new HashMap<String, List>();
94 uuidMap.put(OleSelectConstant.ITEMTITLEID, uuid);
95 List<OlePurchaseOrderItem> poItems = (List<OlePurchaseOrderItem>) getBusinessObjectService().findMatching(OlePurchaseOrderItem.class, uuidMap);
96 if (poItems.size() > 0) {
97 for (OlePurchaseOrderItem purchaseOrderItem : poItems) {
98 for (int i = 0; i < uuid.size(); i++) {
99 if (uuid.get(i).equalsIgnoreCase(purchaseOrderItem.getItemTitleId()))
100 uuid.remove(i);
101 }
102 }
103 }
104 return uuid;
105 }
106
107
108
109
110
111
112
113 public List<String> checkUuidInPaymentRequestItem(List<String> uuid) {
114
115 Map<String, List> uuidMap = new HashMap<String, List>();
116 uuidMap.put(OleSelectConstant.ITEMTITLEID, uuid);
117 List<OlePaymentRequestItem> paymentRequestItems = (List<OlePaymentRequestItem>) getBusinessObjectService().findMatching(OlePaymentRequestItem.class, uuidMap);
118 if (paymentRequestItems.size() > 0) {
119 for (OlePaymentRequestItem paymentRequestItem : paymentRequestItems) {
120 for (int i = 0; i < uuid.size(); i++) {
121 if (uuid.get(i).equalsIgnoreCase(paymentRequestItem.getItemTitleId()))
122 uuid.remove(i);
123 }
124 }
125 }
126 return uuid;
127 }
128
129
130
131
132
133
134
135 public List<String> checkUuidInReceivingLineItem(List<String> uuid) {
136
137 Map<String, List> uuidMap = new HashMap<String, List>();
138 uuidMap.put(OleSelectConstant.ITEMTITLEID, uuid);
139 List<OleLineItemReceivingDoc> lineItemReceivingItems = (List<OleLineItemReceivingDoc>) getBusinessObjectService().findMatching(OleLineItemReceivingDoc.class, uuidMap);
140 if (lineItemReceivingItems.size() > 0) {
141 for (OleLineItemReceivingDoc linItemReceivingDocItem : lineItemReceivingItems) {
142 for (int i = 0; i < uuid.size(); i++) {
143 if (uuid.get(i).equalsIgnoreCase(linItemReceivingDocItem.getItemTitleId()))
144 uuid.remove(i);
145 }
146 }
147 }
148 return uuid;
149 }
150
151
152
153
154
155
156 public BusinessObjectService getBusinessObjectService() {
157 if (businessObjectService == null)
158 businessObjectService = SpringContext.getBean(org.kuali.rice.krad.service.BusinessObjectService.class);
159 return businessObjectService;
160 }
161
162 }