001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.module.chart.rules;
017:
018: import org.kuali.core.document.MaintenanceDocument;
019: import org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase;
020: import org.kuali.module.chart.bo.ProjectCode;
021:
022: /**
023: * This class implements the business rules specific to the {@link ProjectCode} Maintenance Document.
024: */
025: public class ProjectCodeRule extends MaintenanceDocumentRuleBase {
026:
027: protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
028: .getLogger(ProjectCodeRule.class);
029:
030: private ProjectCode oldProjectCode;
031: private ProjectCode newProjectCode;
032:
033: public ProjectCodeRule() {
034: super ();
035: }
036:
037: /**
038: * This performs rules checks on document approve
039: * <ul>
040: * <li>{@link ProjectCodeRule#checkExistenceAndActive()}</li>
041: * </ul>
042: * This rule fails on business rule failures
043: * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomApproveDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
044: */
045: protected boolean processCustomApproveDocumentBusinessRules(
046: MaintenanceDocument document) {
047:
048: LOG
049: .info("Entering processCustomApproveDocumentBusinessRules()");
050:
051: // check that all sub-objects whose keys are specified have matching objects in the db
052: checkExistenceAndActive();
053:
054: return true;
055: }
056:
057: /**
058: * This performs rules checks on document route
059: * <ul>
060: * <li>{@link ProjectCodeRule#checkExistenceAndActive()}</li>
061: * </ul>
062: * This rule fails on business rule failures
063: * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
064: */
065: protected boolean processCustomRouteDocumentBusinessRules(
066: MaintenanceDocument document) {
067:
068: boolean success = true;
069:
070: LOG.info("Entering processCustomRouteDocumentBusinessRules()");
071:
072: // check that all sub-objects whose keys are specified have matching objects in the db
073: success &= checkExistenceAndActive();
074:
075: return success;
076: }
077:
078: /**
079: * This performs rules checks on document save
080: * <ul>
081: * <li>{@link ProjectCodeRule#checkExistenceAndActive()}</li>
082: * </ul>
083: * This rule does not fail on business rule failures
084: * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomSaveDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
085: */
086: protected boolean processCustomSaveDocumentBusinessRules(
087: MaintenanceDocument document) {
088:
089: boolean success = true;
090:
091: LOG.info("Entering processCustomSaveDocumentBusinessRules()");
092:
093: // check that all sub-objects whose keys are specified have matching objects in the db
094: success &= checkExistenceAndActive();
095:
096: return success;
097: }
098:
099: /**
100: * This method sets the convenience objects like newProjectCode and oldProjectCode, so you have short and easy handles to the new and
101: * old objects contained in the maintenance document. It also calls the BusinessObjectBase.refresh(), which will attempt to load
102: * all sub-objects from the DB by their primary keys, if available.
103: *
104: * @param document - the maintenanceDocument being evaluated
105: */
106: public void setupConvenienceObjects() {
107:
108: // setup oldAccount convenience objects, make sure all possible sub-objects are populated
109: oldProjectCode = (ProjectCode) super .getOldBo();
110:
111: // setup newAccount convenience objects, make sure all possible sub-objects are populated
112: newProjectCode = (ProjectCode) super .getNewBo();
113: }
114:
115: /**
116: *
117: * This method currently doesn't do anything
118: * @return true
119: */
120: protected boolean checkExistenceAndActive() {
121:
122: LOG.info("Entering checkExistenceAndActive()");
123: boolean success = true;
124:
125: return success;
126: }
127:
128: }
|