1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.cg.document.validation.impl;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.apache.log4j.Logger;
20 import org.kuali.ole.module.cg.businessobject.Proposal;
21 import org.kuali.ole.module.cg.businessobject.ProposalOrganization;
22 import org.kuali.ole.module.cg.businessobject.ProposalProjectDirector;
23 import org.kuali.ole.module.cg.businessobject.ProposalSubcontractor;
24 import org.kuali.ole.sys.OLEKeyConstants;
25 import org.kuali.ole.sys.OLEPropertyConstants;
26 import org.kuali.rice.kns.document.MaintenanceDocument;
27 import org.kuali.rice.krad.bo.PersistableBusinessObject;
28 import org.kuali.rice.krad.util.GlobalVariables;
29
30
31
32
33 public class ProposalRule extends CGMaintenanceDocumentRuleBase {
34 protected static Logger LOG = org.apache.log4j.Logger.getLogger(ProposalRule.class);
35
36 protected Proposal newProposalCopy;
37
38 @Override
39 protected boolean processCustomSaveDocumentBusinessRules(MaintenanceDocument documentCopy) {
40 LOG.debug("Entering ProposalRule.processCustomSaveDocumentBusinessRules");
41 processCustomRouteDocumentBusinessRules(documentCopy);
42 LOG.info("Leaving ProposalRule.processCustomSaveDocumentBusinessRules");
43 return true;
44 }
45
46 @Override
47 protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument documentCopy) {
48 LOG.debug("Entering ProposalRule.processCustomRouteDocumentBusinessRules");
49 boolean success = true;
50 success &= checkEndAfterBegin(newProposalCopy.getProposalBeginningDate(), newProposalCopy.getProposalEndingDate(), OLEPropertyConstants.PROPOSAL_ENDING_DATE);
51 success &= checkPrimary(newProposalCopy.getProposalOrganizations(), ProposalOrganization.class, OLEPropertyConstants.PROPOSAL_ORGANIZATIONS, Proposal.class);
52 success &= checkPrimary(newProposalCopy.getProposalProjectDirectors(), ProposalProjectDirector.class, OLEPropertyConstants.PROPOSAL_PROJECT_DIRECTORS, Proposal.class);
53 success &= checkProjectDirectorsAreDirectors(newProposalCopy.getProposalProjectDirectors(), ProposalProjectDirector.class, OLEPropertyConstants.PROPOSAL_PROJECT_DIRECTORS);
54 success &= checkProjectDirectorsExist(newProposalCopy.getProposalProjectDirectors(), ProposalProjectDirector.class, OLEPropertyConstants.PROPOSAL_PROJECT_DIRECTORS);
55 success &= checkProjectDirectorsStatuses(newProposalCopy.getProposalProjectDirectors(), ProposalProjectDirector.class, OLEPropertyConstants.PROPOSAL_PROJECT_DIRECTORS);
56 success &= checkFederalPassThrough(newProposalCopy.getProposalFederalPassThroughIndicator(), newProposalCopy.getAgency(), newProposalCopy.getFederalPassThroughAgencyNumber(), Proposal.class, OLEPropertyConstants.PROPOSAL_FEDERAL_PASS_THROUGH_INDICATOR);
57 success &= checkAgencyNotEqualToFederalPassThroughAgency(newProposalCopy.getAgency(), newProposalCopy.getFederalPassThroughAgency(), OLEPropertyConstants.AGENCY_NUMBER, OLEPropertyConstants.FEDERAL_PASS_THROUGH_AGENCY_NUMBER);
58 LOG.info("Leaving ProposalRule.processCustomRouteDocumentBusinessRules");
59 return success;
60 }
61
62
63
64
65 @Override
66 public boolean processCustomAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject line) {
67 if (LOG.isDebugEnabled()) {
68 LOG.debug("Entering ProposalRule.processCustomAddNewCollectionLineBusinessRules( " + collectionName + " )");
69 }
70 boolean success = true;
71 success &= validateAddSubcontractor(line);
72 if (LOG.isDebugEnabled()) {
73 LOG.debug("Leaving ProposalRule.processCustomAddNewCollectionLineBusinessRules( " + collectionName + " )");
74 }
75 return success;
76 }
77
78
79
80
81
82
83
84
85
86 protected boolean validateAddSubcontractor(PersistableBusinessObject addLine) {
87 boolean success = true;
88 if (addLine.getClass().isAssignableFrom(ProposalSubcontractor.class)) {
89 ProposalSubcontractor subc = (ProposalSubcontractor) addLine;
90 if (StringUtils.isBlank(subc.getSubcontractorNumber())) {
91 String propertyName = OLEPropertyConstants.SUBCONTRACTOR_NUMBER;
92 String errorKey = OLEKeyConstants.ERROR_PROPOSAL_SUBCONTRACTOR_NUMBER_REQUIRED_FOR_ADD;
93 GlobalVariables.getMessageMap().putError(propertyName, errorKey);
94 success = false;
95 }
96 }
97 return success;
98 }
99
100
101
102
103
104
105
106
107 @Override
108 public void setupConvenienceObjects() {
109
110 newProposalCopy = (Proposal) super.getNewBo();
111 }
112
113
114 }