1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.vnd.document.validation.impl;
17
18 import org.kuali.ole.sys.OLEPropertyConstants;
19 import org.kuali.ole.sys.context.SpringContext;
20 import org.kuali.ole.sys.service.PostalCodeValidationService;
21 import org.kuali.ole.vnd.VendorPropertyConstants;
22 import org.kuali.ole.vnd.businessobject.CampusParameter;
23 import org.kuali.rice.kns.document.MaintenanceDocument;
24 import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
25 import org.kuali.rice.krad.util.GlobalVariables;
26
27 public class CampusParameterRule extends MaintenanceDocumentRuleBase {
28
29 protected boolean processCustomApproveDocumentBusinessRules(MaintenanceDocument document) {
30 LOG.info("processCustomApproveDocumentBusinessRules called");
31 this.setupConvenienceObjects();
32 boolean success = this.validateAddress(document);
33 return success && super.processCustomApproveDocumentBusinessRules(document);
34 }
35
36 protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
37 LOG.info("processCustomRouteDocumentBusinessRules called");
38 this.setupConvenienceObjects();
39 boolean success = this.validateAddress(document);
40 return success && super.processCustomRouteDocumentBusinessRules(document);
41 }
42
43 protected boolean validateAddress(MaintenanceDocument document) {
44 CampusParameter newCampusParameter = (CampusParameter) document.getNewMaintainableObject().getBusinessObject();
45 GlobalVariables.getMessageMap().clearErrorPath();
46 GlobalVariables.getMessageMap().addToErrorPath(OLEPropertyConstants.DOCUMENT + "." + OLEPropertyConstants.NEW_MAINTAINABLE_OBJECT);
47 boolean valid = SpringContext.getBean(PostalCodeValidationService.class).validateAddress(newCampusParameter.getPurchasingDepartmentCountryCode(), newCampusParameter.getPurchasingDepartmentStateCode(), newCampusParameter.getPurchasingDepartmentZipCode(), VendorPropertyConstants.PURCHASING_DEPARTMENT_STATE, VendorPropertyConstants.PURCHASING_DEPARTMENT_POSTAL_CODE);
48 GlobalVariables.getMessageMap().clearErrorPath();
49 return valid;
50 }
51
52 }