/*
* The Kuali Financial System, a comprehensive financial management system for higher education.
*
* Copyright 2005-2014 The Kuali Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.kuali.kfs.coa.document.validation.impl;
import org.kuali.kfs.coa.businessobject.ProjectCode;
import org.kuali.rice.kns.document.MaintenanceDocument;
import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
/**
* This class implements the business rules specific to the {@link ProjectCode} Maintenance Document.
*/
public class ProjectCodeRule extends MaintenanceDocumentRuleBase {
protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ProjectCodeRule.class);
protected ProjectCode oldProjectCode;
protected ProjectCode newProjectCode;
public ProjectCodeRule() {
super();
}
/**
* This performs rules checks on document approve
* <ul>
* <li>{@link ProjectCodeRule#checkExistenceAndActive()}</li>
* </ul>
* This rule fails on business rule failures
* @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomApproveDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)
*/
protected boolean processCustomApproveDocumentBusinessRules(MaintenanceDocument document) {
LOG.debug("Entering processCustomApproveDocumentBusinessRules()");
// check that all sub-objects whose keys are specified have matching objects in the db
checkExistenceAndActive();
return true;
}
/**
* This performs rules checks on document route
* <ul>
* <li>{@link ProjectCodeRule#checkExistenceAndActive()}</li>
* </ul>
* This rule fails on business rule failures
* @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)
*/
protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
boolean success = true;
LOG.debug("Entering processCustomRouteDocumentBusinessRules()");
// check that all sub-objects whose keys are specified have matching objects in the db
success &= checkExistenceAndActive();
return success;
}
/**
* This performs rules checks on document save
* <ul>
* <li>{@link ProjectCodeRule#checkExistenceAndActive()}</li>
* </ul>
* This rule does not fail on business rule failures
* @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomSaveDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)
*/
protected boolean processCustomSaveDocumentBusinessRules(MaintenanceDocument document) {
boolean success = true;
LOG.debug("Entering processCustomSaveDocumentBusinessRules()");
// check that all sub-objects whose keys are specified have matching objects in the db
success &= checkExistenceAndActive();
return success;
}
/**
* This method sets the convenience objects like newProjectCode and oldProjectCode, so you have short and easy handles to the new and
* old objects contained in the maintenance document. It also calls the BusinessObjectBase.refresh(), which will attempt to load
* all sub-objects from the DB by their primary keys, if available.
*
* @param document - the maintenanceDocument being evaluated
*/
public void setupConvenienceObjects() {
// setup oldAccount convenience objects, make sure all possible sub-objects are populated
oldProjectCode = (ProjectCode) super.getOldBo();
// setup newAccount convenience objects, make sure all possible sub-objects are populated
newProjectCode = (ProjectCode) super.getNewBo();
}
/**
*
* This method currently doesn't do anything
* @return true
*/
protected boolean checkExistenceAndActive() {
LOG.debug("Entering checkExistenceAndActive()");
boolean success = true;
return success;
}
}