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.coa.businessobject.Organization;
19 import org.kuali.ole.coa.service.OrganizationService;
20 import org.kuali.ole.module.purap.PurapConstants;
21 import org.kuali.ole.module.purap.PurapKeyConstants;
22 import org.kuali.ole.module.purap.document.RequisitionDocument;
23 import org.kuali.ole.sys.document.validation.GenericValidation;
24 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
25 import org.kuali.rice.krad.util.GlobalVariables;
26 import org.kuali.rice.krad.util.MessageMap;
27
28
29
30 public class RequisitionOrganizationValidation extends GenericValidation {
31 private OrganizationService organizationService;
32
33 public boolean validate(AttributedDocumentEvent event) {
34 boolean valid = true;
35 boolean active;
36 RequisitionDocument purDocument = (RequisitionDocument) event.getDocument();
37 MessageMap errorMap = GlobalVariables.getMessageMap();
38 errorMap.clearErrorPath();
39 Organization org = organizationService.getByPrimaryId(purDocument.getChartOfAccountsCode(), purDocument.getOrganizationCode());
40 if (org != null) {
41 if (!org.isActive()) {
42 errorMap.putError(PurapConstants.PURAP_REQS_ORG_CD, PurapKeyConstants.ERROR_INACTIVE_ORG);
43 valid = false;
44 }
45 }
46 return valid;
47 }
48
49 public void setOrganizationService(OrganizationService orgSer) {
50 this.organizationService = orgSer;
51 }
52
53 }