1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.pdp.document.validation.impl;
17
18 import org.kuali.ole.pdp.PdpConstants;
19 import org.kuali.ole.pdp.businessobject.ACHBank;
20 import org.kuali.ole.sys.OLEKeyConstants;
21 import org.kuali.rice.kns.document.MaintenanceDocument;
22 import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
23 import org.kuali.rice.krad.util.ObjectUtils;
24
25 public class AchBankRule extends MaintenanceDocumentRuleBase {
26
27 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ACHBank.class);
28
29 protected ACHBank oldAchBank;
30 protected ACHBank newAchBank;
31
32
33
34
35
36
37
38
39 public void setupConvenienceObjects() {
40
41 LOG.info("setupConvenienceObjects called");
42
43
44 oldAchBank = (ACHBank) super.getOldBo();
45
46
47 newAchBank = (ACHBank) super.getNewBo();
48 }
49
50 protected boolean processCustomSaveDocumentBusinessRules(MaintenanceDocument document) {
51
52 LOG.info("processCustomSaveDocumentBusinessRules called");
53
54 processCustomRouteDocumentBusinessRules(document);
55
56
57 return true;
58 }
59
60 protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
61
62 boolean validEntry = true;
63
64 LOG.info("processCustomRouteDocumentBusinessRules called");
65 setupConvenienceObjects();
66
67 String officeCode = newAchBank.getBankOfficeCode();
68 if ((ObjectUtils.isNotNull(officeCode)) && !officeCode.equals(PdpConstants.AchBankOfficeCodes.AchBankOfficeCode_O) && !officeCode.equals(PdpConstants.AchBankOfficeCodes.AchBankOfficeCode_B)) {
69 putFieldError("bankOfficeCode", OLEKeyConstants.ERROR_DOCUMENT_ACHBANKMAINT_INVALID_OFFICE_CODE);
70 validEntry = false;
71 }
72
73 String typeCode = newAchBank.getBankTypeCode();
74 if ((typeCode != null) && !typeCode.equals(PdpConstants.AchBankTypeCodes.AchBankTypeCode_0) && !typeCode.equals(PdpConstants.AchBankTypeCodes.AchBankTypeCode_1) && !typeCode.equals(PdpConstants.AchBankTypeCodes.AchBankTypeCode_2)) {
75 putFieldError("bankTypeCode", OLEKeyConstants.ERROR_DOCUMENT_ACHBANKMAINT_INVALID_TYPE_CODE);
76 validEntry = false;
77 }
78
79 String bankInstitutionStatusCode = newAchBank.getBankInstitutionStatusCode();
80 if ((ObjectUtils.isNotNull(bankInstitutionStatusCode) ) && !bankInstitutionStatusCode.equals(PdpConstants.ACH_BANK_INSTITUTION_CODE_DEFAULT)) {
81 putFieldError("bankInstitutionStatusCode", OLEKeyConstants.ERROR_DOCUMENT_ACHBANKMAINT_INVALID_INST_STATUS_CODE);
82 validEntry = false;
83 }
84
85 String bankDataViewCode = newAchBank.getBankDataViewCode();
86 if ((ObjectUtils.isNotNull(bankDataViewCode) ) && !bankDataViewCode.equals(PdpConstants.ACH_BANK_DATA_VIEW_CODE_DEFAULT)) {
87 putFieldError("bankDataViewCode", OLEKeyConstants.ERROR_DOCUMENT_ACHBANKMAINT_INVALID_DATA_VIEW_CODE);
88 validEntry = false;
89 }
90
91 return validEntry;
92 }
93
94 }