1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.validation.impl;
17
18 import static org.kuali.ole.sys.OLEPropertyConstants.REFERENCE_NUMBER;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.ole.fp.document.NonCheckDisbursementDocument;
22 import org.kuali.ole.sys.OLEKeyConstants;
23 import org.kuali.ole.sys.businessobject.AccountingLine;
24 import org.kuali.ole.sys.document.validation.GenericValidation;
25 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
26 import org.kuali.rice.kns.service.DataDictionaryService;
27 import org.kuali.rice.krad.datadictionary.BusinessObjectEntry;
28 import org.kuali.rice.krad.util.GlobalVariables;
29
30
31
32
33 public class NonCheckDisbursementRequiredReferenceFieldValidation extends GenericValidation {
34 private DataDictionaryService dataDictionaryService;
35 private AccountingLine accountingLineForValidation;
36
37
38
39
40
41
42
43
44 public boolean validate(AttributedDocumentEvent event) {
45
46 NonCheckDisbursementDocument document = (NonCheckDisbursementDocument)event.getDocument();
47
48 boolean valid = true;
49 Class alclass = null;
50 BusinessObjectEntry boe;
51
52 if (accountingLineForValidation.isSourceAccountingLine()) {
53 alclass = document.getSourceAccountingLineClass();
54 }
55 else if (accountingLineForValidation.isTargetAccountingLine()) {
56 alclass = document.getTargetAccountingLineClass();
57 }
58
59 boe = getDataDictionaryService().getDataDictionary().getBusinessObjectEntry(alclass.getName());
60
61 if (StringUtils.isEmpty(accountingLineForValidation.getReferenceNumber())) {
62 putRequiredPropertyError(boe, REFERENCE_NUMBER);
63 valid = false;
64 }
65 return valid;
66 }
67
68
69
70
71
72
73
74
75 protected void putRequiredPropertyError(BusinessObjectEntry boe, String propertyName) {
76
77 String label = boe.getAttributeDefinition(propertyName).getShortLabel();
78 GlobalVariables.getMessageMap().putError(propertyName, OLEKeyConstants.ERROR_REQUIRED, label);
79
80 }
81
82
83
84
85
86 public AccountingLine getAccountingLineForValidation() {
87 return accountingLineForValidation;
88 }
89
90
91
92
93
94 public void setAccountingLineForValidation(AccountingLine accountingLineForValidation) {
95 this.accountingLineForValidation = accountingLineForValidation;
96 }
97
98
99
100
101
102 public DataDictionaryService getDataDictionaryService() {
103 return dataDictionaryService;
104 }
105
106
107
108
109
110 public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
111 this.dataDictionaryService = dataDictionaryService;
112 }
113 }