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