1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.document;
17
18 import org.kuali.ole.module.purap.document.PurchaseOrderSplitDocument;
19 import org.kuali.ole.module.purap.document.RequisitionDocument;
20 import org.kuali.ole.module.purap.document.service.OlePurapService;
21 import org.kuali.ole.select.businessobject.OlePurchaseOrderItem;
22 import org.kuali.ole.select.document.service.OlePurchaseOrderDocumentHelperService;
23 import org.kuali.ole.sys.OLEConstants;
24 import org.kuali.ole.sys.context.SpringContext;
25 import org.kuali.ole.vnd.businessobject.VendorAlias;
26 import org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent;
27
28 import java.util.HashMap;
29 import java.util.Iterator;
30 import java.util.List;
31 import java.util.Map;
32
33
34
35
36
37 public class OlePurchaseOrderSplitDocument extends PurchaseOrderSplitDocument {
38
39 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OlePurchaseOrderSplitDocument.class);
40
41 private String vendorPoNumber;
42 private static transient OlePurapService olePurapService;
43
44 public String getVendorPoNumber() {
45 return vendorPoNumber;
46 }
47
48 public void setVendorPoNumber(String vendorPoNumber) {
49 this.vendorPoNumber = vendorPoNumber;
50 }
51
52
53
54
55
56
57 @Override
58 public void populatePurchaseOrderFromRequisition(RequisitionDocument requisitionDocument) {
59
60 if (LOG.isDebugEnabled()) {
61 LOG.debug("Inside populatePurchaseOrderFromRequisition of OlePurchaseOrderSplitDocument");
62 }
63 SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).populatePurchaseOrderFromRequisition(this, requisitionDocument);
64 }
65
66
67
68
69
70
71 @Override
72 public void prepareForSave(KualiDocumentEvent event) {
73
74 if (LOG.isDebugEnabled()) {
75 LOG.debug("Inside prepareForSave of OlePurchaseOrderSplitDocument");
76 }
77 SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).prepareForSave(this, event);
78 super.prepareForSave(event);
79
80 }
81
82
83
84
85
86
87 @Override
88 public void processAfterRetrieve() {
89 if (LOG.isDebugEnabled()) {
90 LOG.debug("Inside processAfterRetrieve of OlePurchaseOrderSplitDocument");
91 }
92 if (this.getVendorAliasName() == null) {
93 populateVendorAliasName();
94 }
95 try {
96 List<OlePurchaseOrderItem> items = this.getItems();
97 Iterator iterator = items.iterator();
98 while (iterator.hasNext()) {
99 Object object = iterator.next();
100 if (object instanceof OlePurchaseOrderItem) {
101 OlePurchaseOrderItem singleItem = (OlePurchaseOrderItem) object;
102 if(singleItem.getCopyList().size() > 0) {
103
104 getOlePurapService().setInvoiceDocumentsForPO(this,singleItem);
105 }
106 }
107 }
108 } catch (Exception e) {
109 LOG.error("Exception in OlePurchaseOrderCloseDocument:processAfterRetrieve" + e.getMessage());
110 throw new RuntimeException(e);
111 }
112 SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).processAfterRetrieve(this);
113 }
114
115 @Override
116 public List getItemsActiveOnly() {
117 if (LOG.isDebugEnabled()) {
118 LOG.debug("Inside getItemsActiveOnly of OlePurchaseOrderSplitDocument");
119 }
120 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getItemsActiveOnly(this);
121 }
122
123
124
125
126
127
128 @Override
129 public List getItemsActiveOnlySetupAlternateAmount() {
130 if (LOG.isDebugEnabled()) {
131 LOG.debug("Inside getItemsActiveOnlySetupAlternateAmount of OlePurchaseOrderSplitDocument");
132 }
133 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getItemsActiveOnlySetupAlternateAmount(this);
134 }
135
136 @Override
137 public boolean getAdditionalChargesExist() {
138 if (LOG.isDebugEnabled()) {
139 LOG.debug("Inside getAdditionalChargesExist of OlePurchaseOrderSplitDocument");
140 }
141 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getAdditionalChargesExist(this);
142 }
143
144
145
146
147
148
149 public boolean getIsFinalReqs() {
150 if (LOG.isDebugEnabled()) {
151 LOG.debug("Inside getIsFinalReqs of OlePurchaseOrderSplitDocument");
152 }
153
154 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getIsFinalReqs(this);
155 }
156
157 public boolean getIsSplitPO() {
158 if (LOG.isDebugEnabled()) {
159 LOG.debug("Inside getIsSplitPO of OlePurchaseOrderSplitDocument");
160 }
161 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getIsSplitPO(this);
162 }
163
164 public boolean getIsReOpenPO() {
165 if (LOG.isDebugEnabled()) {
166 LOG.debug("Inside getIsReOpenPO of OlePurchaseOrderSplitDocument");
167 }
168 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getIsReOpenPO(this);
169 }
170
171
172
173
174
175
176 public String getBibeditorCreateURL() {
177 if (LOG.isDebugEnabled()) {
178 LOG.debug("Inside getBibeditorCreateURL of OlePurchaseOrderSplitDocument");
179 }
180 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorCreateURL();
181 }
182
183 public String getBibSearchURL() {
184 LOG.debug("Inside getBibSearchURL of OlePurchaseOrderSplitDocument");
185 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibSearchURL();
186 }
187
188
189
190
191
192
193 public String getBibeditorEditURL() {
194 if (LOG.isDebugEnabled()) {
195 LOG.debug("Inside getBibeditorEditURL of OlePurchaseOrderSplitDocument");
196 }
197 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorEditURL();
198 }
199
200
201
202
203
204
205 public String getInstanceEditorURL() {
206 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getInstanceEditorURL();
207 }
208
209
210
211
212
213
214 public String getBibeditorViewURL() {
215 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorViewURL();
216 }
217
218
219
220
221
222
223 public String getDublinEditorEditURL() {
224 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorEditURL();
225 }
226
227
228
229
230
231
232 public String getDublinEditorViewURL() {
233 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorViewURL();
234 }
235
236
237
238
239
240
241 public String getMarcXMLFileDirLocation() throws Exception {
242 if (LOG.isDebugEnabled()) {
243 LOG.debug("Inside getMarcXMLFileDirLocation of OlePurchaseOrderSplitDocument");
244 }
245 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getMarcXMLFileDirLocation();
246 }
247
248 @Override
249 public Class getItemClass() {
250 return OlePurchaseOrderItem.class;
251 }
252
253
254
255
256
257
258 public boolean getIsSaved() {
259 if (this.getDocumentHeader().getWorkflowDocument().isSaved() || this.getDocumentHeader().getWorkflowDocument().isInitiated()) {
260 return true;
261 }
262 return false;
263 }
264
265 public boolean getIsATypeOfRCVGDoc() {
266 return false;
267 }
268
269 public boolean getIsATypeOfCORRDoc() {
270 return false;
271 }
272
273 private void populateVendorAliasName() {
274 Map vendorDetailMap = new HashMap();
275 vendorDetailMap.put(OLEConstants.VENDOR_HEADER_IDENTIFIER, this.getVendorHeaderGeneratedIdentifier());
276 vendorDetailMap.put(OLEConstants.VENDOR_DETAIL_IDENTIFIER, this.getVendorDetailAssignedIdentifier());
277 List<VendorAlias> vendorDetailList = (List) getBusinessObjectService().findMatching(VendorAlias.class, vendorDetailMap);
278 if (vendorDetailList != null && vendorDetailList.size() > 0) {
279 this.setVendorAliasName(vendorDetailList.get(0).getVendorAliasName());
280 }
281 }
282
283 public static OlePurapService getOlePurapService() {
284 if (olePurapService == null) {
285 olePurapService = SpringContext.getBean(OlePurapService.class);
286 }
287 return olePurapService;
288 }
289 }