1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.document.web;
17
18 import org.apache.struts.action.ActionForm;
19 import org.apache.struts.action.ActionForward;
20 import org.apache.struts.action.ActionMapping;
21 import org.kuali.ole.select.businessobject.OleLineItemReceivingItem;
22 import org.kuali.ole.select.businessobject.OlePurchaseOrderItem;
23 import org.kuali.ole.select.businessobject.OleReceiptStatus;
24 import org.kuali.ole.select.document.OleLineItemReceivingDocument;
25 import org.kuali.ole.select.document.OleReceivingQueueSearchDocument;
26 import org.kuali.ole.sys.OLEConstants;
27 import org.kuali.ole.sys.context.SpringContext;
28 import org.kuali.rice.core.api.config.property.ConfigurationService;
29 import org.kuali.rice.core.api.datetime.DateTimeService;
30 import org.kuali.rice.core.api.util.RiceConstants;
31 import org.kuali.rice.core.api.util.type.KualiDecimal;
32 import org.kuali.rice.kew.actionlist.service.ActionListService;
33 import org.kuali.rice.kew.actionrequest.ActionRequestValue;
34 import org.kuali.rice.kew.actionrequest.service.ActionRequestService;
35 import org.kuali.rice.kew.api.KewApiConstants;
36 import org.kuali.rice.kew.api.exception.WorkflowException;
37 import org.kuali.rice.kew.service.KEWServiceLocator;
38 import org.kuali.rice.kns.web.struts.action.KualiTransactionalDocumentActionBase;
39 import org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase;
40 import org.kuali.rice.krad.document.Document;
41 import org.kuali.rice.krad.service.BusinessObjectService;
42 import org.kuali.rice.krad.service.KRADServiceLocator;
43 import org.kuali.rice.krad.util.GlobalVariables;
44 import org.kuali.rice.krad.util.KRADConstants;
45 import org.kuali.rice.krad.util.ObjectUtils;
46
47 import javax.servlet.http.HttpServletRequest;
48 import javax.servlet.http.HttpServletResponse;
49 import java.sql.Timestamp;
50 import java.util.ArrayList;
51 import java.util.HashMap;
52 import java.util.List;
53 import java.util.Map;
54 import java.util.regex.Matcher;
55 import java.util.regex.Pattern;
56
57 public class OleReceivingQueueSearchAction extends KualiTransactionalDocumentActionBase {
58
59 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleReceivingQueueSearchAction.class);
60 protected Document document;
61
62
63
64
65 public OleReceivingQueueSearchAction() {
66 super();
67 }
68
69
70
71
72
73
74
75
76
77
78
79 public ActionForward valueSearch(ActionMapping mapping, ActionForm form,
80 HttpServletRequest request, HttpServletResponse response) throws Exception {
81 OleReceivingQueueSearchForm oleReceivingQueueSearchForm = (OleReceivingQueueSearchForm) form;
82 OleReceivingQueueSearchDocument oleReceivingQueueSearchDocument = (OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm.getDocument();
83 oleReceivingQueueSearchDocument.setReceivingDocumentsList(new ArrayList<String>());
84 String purchaseOrderString = oleReceivingQueueSearchDocument.getPurchaseOrderNumber();
85 if (purchaseOrderString != null) {
86 boolean isValidSting = true;
87 String[] purchaseOrderNumbers = purchaseOrderString.split(",");
88 for (String purchaseOrderNumber : purchaseOrderNumbers) {
89 if (!validate(purchaseOrderNumber)) {
90 isValidSting = false;
91 break;
92 }
93 }
94 if (!isValidSting) {
95 oleReceivingQueueSearchDocument.getPurchaseOrders().clear();
96 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ERROR_SELECT_PO_ITM_FORMAT);
97 return mapping.findForward(RiceConstants.MAPPING_BASIC);
98 }
99 }
100 oleReceivingQueueSearchDocument.valueSearch();
101
102 return mapping.findForward(RiceConstants.MAPPING_BASIC);
103 }
104
105 public boolean validate(final String hex) {
106 Pattern pattern = Pattern.compile("[0-9]+");
107 Matcher matcher = pattern.matcher(hex);
108 return matcher.matches();
109
110 }
111
112 @Override
113 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
114 ActionForward actionForward = null;
115 if(((OleReceivingQueueSearchForm) form).getMethodToCall().equalsIgnoreCase("docHandler")){
116 ((OleReceivingQueueSearchForm) form).setDocId(null);
117 }
118 return super.execute(mapping, form, request, response);
119 }
120
121
122
123
124
125
126
127
128
129
130
131 public ActionForward valueClear(ActionMapping mapping, ActionForm form,
132 HttpServletRequest request, HttpServletResponse response) throws Exception {
133 OleReceivingQueueSearchForm oleReceivingQueueSearchForm = (OleReceivingQueueSearchForm) form;
134 OleReceivingQueueSearchDocument oleReceivingQueueSearchDocument = (OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm.getDocument();
135 oleReceivingQueueSearchDocument.setPurchaseOrders(null);
136 oleReceivingQueueSearchDocument.setPurchaseOrderNumber(null);
137 oleReceivingQueueSearchDocument.setVendorName(null);
138
139
140 oleReceivingQueueSearchDocument.setPurchaseOrderStatusDescription(null);
141 oleReceivingQueueSearchDocument.setMonograph(false);
142 oleReceivingQueueSearchDocument.setPurchaseOrderType(null);
143 oleReceivingQueueSearchDocument.setBeginDate(null);
144 oleReceivingQueueSearchDocument.setEndDate(null);
145 oleReceivingQueueSearchDocument.setStandardNumber(null);
146 oleReceivingQueueSearchDocument.setTitle(null);
147 oleReceivingQueueSearchDocument.setReceivingDocumentsList(new ArrayList<String>());
148
149
150 return mapping.findForward(RiceConstants.MAPPING_BASIC);
151 }
152
153
154
155
156
157
158
159 public Document getDocument() {
160 return document;
161 }
162
163
164
165
166
167
168 public void setDocument(Document document) {
169 this.document = document;
170 }
171
172
173
174
175
176
177
178
179
180
181
182 public ActionForward selectAll(ActionMapping mapping, ActionForm form,
183 HttpServletRequest request, HttpServletResponse response) throws Exception {
184 OleReceivingQueueSearchForm oleReceivingQueueSearchForm = (OleReceivingQueueSearchForm) form;
185 List<OlePurchaseOrderItem> items = ((OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm.getDocument()).getPurchaseOrders();
186 List<OlePurchaseOrderItem> refreshItems = new ArrayList<OlePurchaseOrderItem>(0);
187
188 for (OlePurchaseOrderItem item : items) {
189 item.setPoAdded(true);
190 refreshItems.add(item);
191 }
192
193 ((OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm.getDocument()).setPurchaseOrders(refreshItems);
194
195 return mapping.findForward(RiceConstants.MAPPING_BASIC);
196 }
197
198
199
200
201
202
203
204
205
206
207
208 public ActionForward unselectAll(ActionMapping mapping, ActionForm form,
209 HttpServletRequest request, HttpServletResponse response) throws Exception {
210 OleReceivingQueueSearchForm oleReceivingQueueSearchForm = (OleReceivingQueueSearchForm) form;
211 List<OlePurchaseOrderItem> items = ((OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm.getDocument()).getPurchaseOrders();
212 List<OlePurchaseOrderItem> refreshItems = new ArrayList<OlePurchaseOrderItem>(0);
213
214 for (OlePurchaseOrderItem item : items) {
215 item.setPoAdded(false);
216 refreshItems.add(item);
217 }
218
219 ((OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm.getDocument()).setPurchaseOrders(refreshItems);
220
221 return mapping.findForward(RiceConstants.MAPPING_BASIC);
222 }
223
224
225
226
227
228
229
230 protected OleLineItemReceivingDocument createLineItemReceivingDocument() throws WorkflowException {
231 Document doc = getDocumentService().getNewDocument("OLE_RCVL");
232 return (OleLineItemReceivingDocument) doc;
233 }
234
235
236
237
238
239
240
241
242
243
244
245 public ActionForward completeReceiving(ActionMapping mapping, ActionForm form,
246 HttpServletRequest request, HttpServletResponse response) throws Exception {
247 LOG.debug("Inside completeReceiving of OleReceivingQueueSearchDocument");
248 OleReceivingQueueSearchForm oleReceivingQueueSearchForm = (OleReceivingQueueSearchForm) form;
249 OleReceivingQueueSearchDocument oleReceivingQueueSearchDocument = (OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm.getDocument();
250 OleLineItemReceivingDocument rlDoc = null;
251
252 List<OlePurchaseOrderItem> olePurchaseOrderItems = new ArrayList<OlePurchaseOrderItem>();
253 HashMap<Integer, OlePurchaseOrderItem> selectedPOs = getSelectedPurchaseOrders(oleReceivingQueueSearchDocument.getPurchaseOrders());
254 if (selectedPOs.size() == 0) {
255 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ERROR_SELECT_PO_ITM);
256 return mapping.findForward(RiceConstants.MAPPING_BASIC);
257 }
258 boolean isReceivingExist = false;
259 List<String> errorCreatingReceivingForPoIdList = new ArrayList<String>();
260 for (OlePurchaseOrderItem olePurchaseOrderItem : oleReceivingQueueSearchDocument.getPurchaseOrders()) {
261 if (olePurchaseOrderItem.isPoAdded()) {
262
263 if (validateReceivingForProcess(olePurchaseOrderItem)) {
264 isReceivingExist = true;
265 olePurchaseOrderItem.setPoAdded(false);
266 if (!errorCreatingReceivingForPoIdList.contains(olePurchaseOrderItem.getPurchaseOrder().getPurapDocumentIdentifier().toString())) {
267 errorCreatingReceivingForPoIdList.add(olePurchaseOrderItem.getPurchaseOrder().getPurapDocumentIdentifier().toString());
268 }
269 }
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295 }
296 }
297 selectedPOs = getSelectedPurchaseOrders(oleReceivingQueueSearchDocument.getPurchaseOrders());
298
299 HashMap<Integer, Boolean> receivePOStatus = new HashMap<Integer, Boolean>();
300 oleReceivingQueueSearchDocument.getReceivingDocumentsList().clear();
301 boolean isInfoMsg = false;
302 for (Map.Entry<Integer, OlePurchaseOrderItem> entry : selectedPOs.entrySet()) {
303 if (LOG.isDebugEnabled()) {
304 LOG.debug("Creating Line Item Receiving Document for PO ID - " + entry.getKey());
305 }
306 rlDoc = createLineItemReceivingDocument();
307 boolean receivePOSuccess = oleReceivingQueueSearchDocument.receivePO(rlDoc, entry.getKey(), false);
308 if (receivePOSuccess) {
309 oleReceivingQueueSearchDocument.getReceivingDocumentsList().add(rlDoc.getDocumentNumber());
310
311 isInfoMsg = true;
312 }
313 receivePOStatus.put(entry.getKey(), receivePOSuccess);
314 if (LOG.isDebugEnabled()) {
315 LOG.debug("Creating Line Item Receiving Document for PO ID - " + entry.getKey() + " completed successfully");
316 }
317 }
318 List<OlePurchaseOrderItem> refreshedPOList = new ArrayList<OlePurchaseOrderItem>();
319 for (OlePurchaseOrderItem poItem : oleReceivingQueueSearchDocument.getPurchaseOrders()) {
320 Integer poId = poItem.getPurchaseOrder().getPurapDocumentIdentifier();
321 refreshedPOList.add(poItem);
322
323
324
325
326
327
328
329 }
330
331 ((OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm.getDocument()).setPurchaseOrders(refreshedPOList);
332
333 LOG.debug("Leaving completeReceiving of OleReceivingQueueSearchDocument");
334 String errorCreatingReceivingForPoIds = "";
335 for (String string : errorCreatingReceivingForPoIdList) {
336 errorCreatingReceivingForPoIds = errorCreatingReceivingForPoIds + string + ",";
337 }
338 if (isReceivingExist) {
339 errorCreatingReceivingForPoIds = errorCreatingReceivingForPoIds.substring(0, errorCreatingReceivingForPoIds.length() - 1);
340 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ERROR_RECEIVING_EXIST, errorCreatingReceivingForPoIds);
341 }
342
343 return unselectAll(mapping, oleReceivingQueueSearchForm, request, response);
344 }
345
346
347
348
349
350
351
352
353
354
355
356 public ActionForward createReceiving(ActionMapping mapping, ActionForm form, HttpServletRequest request,
357 HttpServletResponse response) throws Exception {
358 LOG.debug("Inside completereceiving of OleReceivingQueueSearchDocument");
359 OleReceivingQueueSearchForm oleReceivingQueueSearchForm = (OleReceivingQueueSearchForm) form;
360 OleReceivingQueueSearchDocument oleReceivingQueueSearchDocument = (OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm
361 .getDocument();
362 OleLineItemReceivingDocument rlDoc = null;
363 HashMap<Integer, OlePurchaseOrderItem> selectedPOs = getSelectedPurchaseOrders(oleReceivingQueueSearchDocument
364 .getPurchaseOrders());
365 List<OlePurchaseOrderItem> olePurchaseOrderItems = new ArrayList<OlePurchaseOrderItem>();
366 if (selectedPOs.size() == 0) {
367 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ERROR_SELECT_PO_ITM);
368 return mapping.findForward(RiceConstants.MAPPING_BASIC);
369 }
370 boolean isReceivingExist = false;
371 List<String> errorCreatingReceivingForPoIdList = new ArrayList<String>();
372 for (OlePurchaseOrderItem olePurchaseOrderItem : oleReceivingQueueSearchDocument.getPurchaseOrders()) {
373 if (olePurchaseOrderItem.isPoAdded()) {
374 if (validateReceivingForProcess(olePurchaseOrderItem)) {
375 isReceivingExist = true;
376 olePurchaseOrderItem.setPoAdded(false);
377 if (!errorCreatingReceivingForPoIdList.contains(olePurchaseOrderItem.getPurchaseOrder().getPurapDocumentIdentifier().toString())) {
378 errorCreatingReceivingForPoIdList.add(olePurchaseOrderItem.getPurchaseOrder().getPurapDocumentIdentifier().toString());
379 }
380 }
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403 }
404 }
405 selectedPOs = getSelectedPurchaseOrders(oleReceivingQueueSearchDocument.getPurchaseOrders());
406
407 HashMap<Integer, Boolean> receivePOStatus = new HashMap<Integer, Boolean>();
408 boolean isInfoMsg = false;
409 for (Map.Entry<Integer, OlePurchaseOrderItem> entry : selectedPOs.entrySet()) {
410 if (LOG.isDebugEnabled()) {
411 LOG.debug("Creating Line Item Receiving Document for PO ID - " + entry.getKey());
412 }
413 rlDoc = createLineItemReceivingDocument();
414 boolean receivePOSuccess = oleReceivingQueueSearchDocument.receivePO(rlDoc, entry.getKey(), true);
415 if (receivePOSuccess) {
416 oleReceivingQueueSearchDocument.getReceivingDocumentsList().add(rlDoc.getDocumentNumber());
417 isInfoMsg = true;
418 }
419 receivePOStatus.put(entry.getKey(), receivePOSuccess);
420 if (LOG.isDebugEnabled()) {
421 LOG.debug("Creating Line Item Receiving Document for PO ID - " + entry.getKey()
422 + " completed successfully");
423 }
424 }
425 List<OlePurchaseOrderItem> refreshedPOList = new ArrayList<OlePurchaseOrderItem>();
426 for (OlePurchaseOrderItem poItem : oleReceivingQueueSearchDocument.getPurchaseOrders()) {
427 Integer poId = poItem.getPurchaseOrder().getPurapDocumentIdentifier();
428 refreshedPOList.add(poItem);
429
430
431
432
433
434
435
436
437 }
438 if (oleReceivingQueueSearchDocument.getReceivingDocumentsList().size() == 1) {
439 ActionForward dest = returnToReceiving(oleReceivingQueueSearchDocument.getReceivingDocumentsList().get(0));
440 return dest;
441 }
442 ((OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm.getDocument())
443 .setPurchaseOrders(refreshedPOList);
444
445 LOG.debug("Leaving completeReceiving of OleReceivingQueueSearchDocument");
446 String errorCreatingReceivingForPoIds = "";
447 for (String string : errorCreatingReceivingForPoIdList) {
448 errorCreatingReceivingForPoIds = errorCreatingReceivingForPoIds + string + ",";
449 }
450 if (isReceivingExist) {
451 errorCreatingReceivingForPoIds = errorCreatingReceivingForPoIds.substring(0, errorCreatingReceivingForPoIds.length() - 1);
452 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ERROR_RECEIVING_EXIST, errorCreatingReceivingForPoIds);
453 }
454
455 return mapping.findForward(RiceConstants.MAPPING_BASIC);
456 }
457
458
459
460
461
462
463
464
465 private HashMap<Integer, OlePurchaseOrderItem> getSelectedPurchaseOrders(List<OlePurchaseOrderItem> purchaseOrders) {
466 LOG.debug("Inside getSelectedPurchaseOrders of OleReceivingQueueSearchDocument");
467 HashMap<Integer, OlePurchaseOrderItem> poItemMap = new HashMap<Integer, OlePurchaseOrderItem>();
468 for (OlePurchaseOrderItem poItem : purchaseOrders) {
469 if (poItem.isPoAdded()) {
470 if (ObjectUtils.isNull(poItemMap.get(poItem.getPurchaseOrder().getPurapDocumentIdentifier()))) {
471 poItemMap.put(poItem.getPurchaseOrder().getPurapDocumentIdentifier(), poItem);
472 }
473 }
474 }
475 if (LOG.isDebugEnabled()) {
476 LOG.debug("Number of actual PO selected in OleReceivingQueueSearchDocument.getSelectedPurchaseOrders - " + poItemMap.size());
477 LOG.debug("Leaving getSelectedPurchaseOrders of OleReceivingQueueSearchDocument");
478 }
479
480 return poItemMap;
481 }
482
483
484
485
486
487 @Override
488 public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
489 KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
490 return returnToSender(request, mapping, kualiDocumentFormBase);
491 }
492
493
494
495
496
497
498
499
500 private ActionForward returnToReceiving(String rcvDocId) {
501 String receivingUrl = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(
502 OLEConstants.WORKFLOW_URL_KEY)
503 + "/DocHandler.do?docId=" + rcvDocId + "&command=displayDocSearchView";
504 return new ActionForward(receivingUrl, true);
505 }
506
507
508
509
510
511
512
513
514
515 private ActionForward returnToPayment(String purchaseOrderId) {
516 String paymentUrl = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(
517 OLEConstants.WORKFLOW_URL_KEY)
518 + "/selectOlePaymentRequest.do?purchaseOrderIdentifier=" + purchaseOrderId
519 + "&methodToCall=docHandler&command=initiate&docTypeName=OLE_PREQ";
520 return new ActionForward(paymentUrl, true);
521 }
522
523
524
525
526
527
528
529
530
531
532
533 public ActionForward createPaymentRequestDocument(ActionMapping mapping, ActionForm form,
534 HttpServletRequest request, HttpServletResponse response) throws Exception {
535
536 return mapping.findForward(RiceConstants.MAPPING_BASIC);
537 }
538
539
540
541
542
543
544
545
546
547
548
549 public ActionForward receiveAndPay(ActionMapping mapping, ActionForm form, HttpServletRequest request,
550 HttpServletResponse response) throws Exception {
551 LOG.debug("Inside receiveAndPay of OleReceivingQueueSearchDocument");
552 OleReceivingQueueSearchForm oleReceivingQueueSearchForm = (OleReceivingQueueSearchForm) form;
553 OleReceivingQueueSearchDocument oleReceivingQueueSearchDocument = (OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm.getDocument();
554 OleLineItemReceivingDocument rlDoc = null;
555
556 HashMap<Integer, OlePurchaseOrderItem> selectedPOs = getSelectedPurchaseOrders(oleReceivingQueueSearchDocument.getPurchaseOrders());
557
558 HashMap<Integer, Boolean> receivePOStatus = new HashMap<Integer, Boolean>();
559 boolean isInfoMsg = false;
560 for (Map.Entry<Integer, OlePurchaseOrderItem> entry : selectedPOs.entrySet()) {
561 if (LOG.isDebugEnabled()) {
562 LOG.debug("Creating Line Item Receiving Document for PO ID - " + entry.getKey());
563 }
564 rlDoc = createLineItemReceivingDocument();
565 boolean receivePOSuccess = oleReceivingQueueSearchDocument.receivePO(rlDoc, entry.getKey(), false);
566 if (receivePOSuccess) {
567 oleReceivingQueueSearchDocument.getReceivingDocumentsList().add(rlDoc.getDocumentNumber());
568
569 isInfoMsg = true;
570 }
571 receivePOStatus.put(entry.getKey(), receivePOSuccess);
572 if (LOG.isDebugEnabled()) {
573 LOG.debug("Creating Line Item Receiving Document for PO ID - " + entry.getKey() + " completed successfully");
574 }
575 }
576 List<OlePurchaseOrderItem> refreshedPOList = new ArrayList<OlePurchaseOrderItem>();
577 for (OlePurchaseOrderItem poItem : oleReceivingQueueSearchDocument.getPurchaseOrders()) {
578 Integer poId = poItem.getPurchaseOrder().getPurapDocumentIdentifier();
579 if (ObjectUtils.isNull(receivePOStatus.get(poId))) {
580 refreshedPOList.add(poItem);
581 } else {
582 if (receivePOStatus.get(poId) == false) {
583 refreshedPOList.add(poItem);
584 }
585 }
586 }
587
588 ((OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm.getDocument()).setPurchaseOrders(refreshedPOList);
589
590 LOG.debug("Leaving receiveAndPay of OleReceivingQueueSearchDocument");
591
592 return mapping.findForward(RiceConstants.MAPPING_BASIC);
593 }
594
595 @Override
596 protected void loadDocument(KualiDocumentFormBase kualiDocumentFormBase) throws WorkflowException {
597 super.loadDocument(kualiDocumentFormBase);
598 OleReceivingQueueSearchForm oleReceivingQueueSearchForm = (OleReceivingQueueSearchForm) kualiDocumentFormBase;
599 OleReceivingQueueSearchDocument oleReceivingQueueSearchDocument = (OleReceivingQueueSearchDocument) oleReceivingQueueSearchForm
600 .getDocument();
601 oleReceivingQueueSearchDocument.setReceivingDocumentsList(new ArrayList<String>());
602 }
603
604
605
606
607 private void assignActionRequests(String routeHeaderId) {
608 LOG.debug("Inside assignActionRequests of OleOrderQueueDocument");
609 Timestamp currentTime = SpringContext.getBean(DateTimeService.class).getCurrentTimestamp();
610 ActionListService actionListSrv = KEWServiceLocator.getActionListService();
611 ActionRequestService actionReqSrv = KEWServiceLocator.getActionRequestService();
612 ActionRequestValue actionRequest = new ActionRequestValue();
613 actionRequest.setActionRequested(KewApiConstants.ACTION_REQUEST_FYI_REQ);
614 actionRequest.setPrincipalId("OLE10003");
615 actionRequest.setCreateDate(currentTime);
616 actionRequest.setForceAction(true);
617 actionReqSrv.saveActionRequest(actionRequest);
618
619
620
621
622
623
624
625
626
627 LOG.debug("Leaving assignActionRequests of OleOrderQueueDocument");
628 }
629
630 public boolean validateReceivingForProcess(OlePurchaseOrderItem purchaseOrderItem) {
631 boolean isValid = false;
632 Map<String, String> map = new HashMap<String, String>();
633 map.put("purchaseOrderIdentifier", purchaseOrderItem.getItemIdentifier().toString());
634 List<OleLineItemReceivingItem> oleLineItemReceivingItems = (List<OleLineItemReceivingItem>) KRADServiceLocator.getBusinessObjectService().findMatching(OleLineItemReceivingItem.class, map);
635
636 if (oleLineItemReceivingItems.size() > 0) {
637 OleLineItemReceivingItem oleLineItemReceivingItem = oleLineItemReceivingItems.get(0);
638 if (oleLineItemReceivingItem.getReceiptStatusId() != null) {
639 if (oleLineItemReceivingItem.getReceiptStatusId().toString().equalsIgnoreCase(getReceiptStatusDetails(OLEConstants.PO_RECEIPT_STATUS_FULLY_RECEIVED) + "")) {
640 isValid = true;
641 }
642 }
643 }
644 return isValid;
645 }
646
647 public int getReceiptStatusDetails(String receiptStatusCd) {
648 int receiptStatusId = 0;
649 Map<String, String> receiptStatusCdMap = new HashMap<String, String>();
650 receiptStatusCdMap.put(OLEConstants.RCPT_STATUS_CD, receiptStatusCd);
651 List<OleReceiptStatus> oleReceiptStatusList = (List) SpringContext.getBean(BusinessObjectService.class)
652 .findMatching(OleReceiptStatus.class, receiptStatusCdMap);
653 for (OleReceiptStatus oleReceiptStatus : oleReceiptStatusList) {
654 receiptStatusId = oleReceiptStatus.getReceiptStatusId().intValue();
655 }
656 return receiptStatusId;
657 }
658
659 }