1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.validation.impl;
17
18 import org.kuali.ole.module.purap.PurapConstants;
19 import org.kuali.ole.module.purap.PurapKeyConstants;
20 import org.kuali.ole.module.purap.document.PaymentRequestDocument;
21 import org.kuali.ole.module.purap.document.service.PurapService;
22 import org.kuali.ole.sys.OLEPropertyConstants;
23 import org.kuali.ole.sys.document.validation.GenericValidation;
24 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
25 import org.kuali.rice.kns.util.KNSGlobalVariables;
26 import org.kuali.rice.kns.util.MessageList;
27 import org.kuali.rice.krad.util.GlobalVariables;
28 import org.kuali.rice.krad.util.ObjectUtils;
29
30 public class PaymentRequestPayDateNotOverThresholdDaysAwayValidation extends GenericValidation {
31
32 private PurapService purapService;
33
34
35
36
37
38
39 public boolean validate(AttributedDocumentEvent event) {
40 PaymentRequestDocument document = (PaymentRequestDocument) event.getDocument();
41 GlobalVariables.getMessageMap().clearErrorPath();
42 GlobalVariables.getMessageMap().addToErrorPath(OLEPropertyConstants.DOCUMENT);
43
44 int thresholdDays = PurapConstants.PREQ_PAY_DATE_DAYS_BEFORE_WARNING;
45 if ((document.getPaymentRequestPayDate() != null) && purapService.isDateMoreThanANumberOfDaysAway(document.getPaymentRequestPayDate(), thresholdDays)) {
46 if (ObjectUtils.isNull(KNSGlobalVariables.getMessageList())) {
47 KNSGlobalVariables.setMessageList(new MessageList());
48 }
49 if (!KNSGlobalVariables.getMessageList().contains(PurapKeyConstants.WARNING_PAYMENT_REQUEST_PAYDATE_OVER_THRESHOLD_DAYS)) {
50 KNSGlobalVariables.getMessageList().add(PurapKeyConstants.WARNING_PAYMENT_REQUEST_PAYDATE_OVER_THRESHOLD_DAYS);
51 }
52 }
53
54 GlobalVariables.getMessageMap().clearErrorPath();
55
56
57 return true;
58 }
59
60 public PurapService getPurapService() {
61 return purapService;
62 }
63
64 public void setPurapService(PurapService purapService) {
65 this.purapService = purapService;
66 }
67
68 }