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.PurchaseOrderVoidDocument;
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 OlePurchaseOrderVoidDocument extends PurchaseOrderVoidDocument {
38 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OlePurchaseOrderVoidDocument.class);
39 private String vendorPoNumber;
40 private static transient OlePurapService olePurapService;
41
42
43
44
45 public OlePurchaseOrderVoidDocument() {
46 super();
47 }
48
49
50
51
52
53
54 @Override
55 public void populatePurchaseOrderFromRequisition(RequisitionDocument requisitionDocument) {
56 SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).populatePurchaseOrderFromRequisition(this, requisitionDocument);
57 }
58
59
60
61
62
63
64 @Override
65 public void prepareForSave(KualiDocumentEvent event) {
66 SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).prepareForSave(this, event);
67 super.prepareForSave(event);
68 }
69
70
71
72
73
74
75 @Override
76 public void processAfterRetrieve() {
77 if (this.getVendorAliasName() == null) {
78 populateVendorAliasName();
79 }
80 try {
81 List<OlePurchaseOrderItem> items = this.getItems();
82 Iterator iterator = items.iterator();
83 while (iterator.hasNext()) {
84 Object object = iterator.next();
85 if (object instanceof OlePurchaseOrderItem) {
86 OlePurchaseOrderItem singleItem = (OlePurchaseOrderItem) object;
87 if(singleItem.getCopyList().size() > 0) {
88
89 getOlePurapService().setInvoiceDocumentsForPO(this,singleItem);
90 }
91 }
92 }
93 } catch (Exception e) {
94 LOG.error("Exception in OlePurchaseOrderCloseDocument:processAfterRetrieve" + e.getMessage());
95 throw new RuntimeException(e);
96 }
97 SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).processAfterRetrieve(this);
98 }
99
100 @Override
101 public List getItemsActiveOnly() {
102 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getItemsActiveOnly(this);
103 }
104
105
106
107
108
109
110 @Override
111 public List getItemsActiveOnlySetupAlternateAmount() {
112 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getItemsActiveOnlySetupAlternateAmount(this);
113 }
114
115 @Override
116 public boolean getAdditionalChargesExist() {
117 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getAdditionalChargesExist(this);
118 }
119
120
121
122
123
124
125 public boolean getIsFinalReqs() {
126 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getIsFinalReqs(this);
127 }
128
129 public boolean getIsSplitPO() {
130 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getIsSplitPO(this);
131 }
132
133 public boolean getIsReOpenPO() {
134 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getIsReOpenPO(this);
135 }
136
137
138
139
140
141
142 public String getBibeditorCreateURL() {
143 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorCreateURL();
144 }
145
146 public String getBibSearchURL() {
147 LOG.debug("Inside getBibSearchURL of OlePurchaseOrderVoidDocument");
148 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibSearchURL();
149 }
150
151
152
153
154
155
156 public String getBibeditorEditURL() {
157 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorEditURL();
158 }
159
160
161
162
163
164
165 public String getDublinEditorEditURL() {
166 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorEditURL();
167 }
168
169
170
171
172
173 public String getInstanceEditorURL() {
174 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getInstanceEditorURL();
175 }
176
177
178
179
180
181
182 public String getBibeditorViewURL() {
183 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorViewURL();
184 }
185
186
187
188
189
190
191 public String getDublinEditorViewURL() {
192 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorViewURL();
193 }
194
195
196
197
198
199 public String getMarcXMLFileDirLocation() throws Exception {
200 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getMarcXMLFileDirLocation();
201 }
202
203 public String getVendorPoNumber() {
204 return vendorPoNumber;
205 }
206
207 public void setVendorPoNumber(String vendorPoNumber) {
208 this.vendorPoNumber = vendorPoNumber;
209 }
210
211
212
213
214
215
216
217 public boolean getIsSaved() {
218 if (this.getDocumentHeader().getWorkflowDocument().isSaved() || this.getDocumentHeader().getWorkflowDocument().isInitiated()) {
219 return true;
220 }
221 return false;
222 }
223
224 public boolean getIsATypeOfRCVGDoc() {
225 return false;
226 }
227
228 public boolean getIsATypeOfCORRDoc() {
229 return false;
230 }
231
232 private void populateVendorAliasName() {
233 Map vendorDetailMap = new HashMap();
234 vendorDetailMap.put(OLEConstants.VENDOR_HEADER_IDENTIFIER, this.getVendorHeaderGeneratedIdentifier());
235 vendorDetailMap.put(OLEConstants.VENDOR_DETAIL_IDENTIFIER, this.getVendorDetailAssignedIdentifier());
236 List<VendorAlias> vendorDetailList = (List) getBusinessObjectService().findMatching(VendorAlias.class, vendorDetailMap);
237 if (vendorDetailList != null && vendorDetailList.size() > 0) {
238 this.setVendorAliasName(vendorDetailList.get(0).getVendorAliasName());
239 }
240 }
241
242 public static OlePurapService getOlePurapService() {
243 if (olePurapService == null) {
244 olePurapService = SpringContext.getBean(OlePurapService.class);
245 }
246 return olePurapService;
247 }
248 }