001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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.kfs.coa.document.validation.impl;
017
018 import org.kuali.kfs.coa.businessobject.ProjectCode;
019 import org.kuali.rice.kns.document.MaintenanceDocument;
020 import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
021 /**
022 * This class implements the business rules specific to the {@link ProjectCode} Maintenance Document.
023 */
024 public class ProjectCodeRule extends MaintenanceDocumentRuleBase {
025
026 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ProjectCodeRule.class);
027
028 protected ProjectCode oldProjectCode;
029 protected ProjectCode newProjectCode;
030
031 public ProjectCodeRule() {
032 super();
033 }
034
035 /**
036 * This performs rules checks on document approve
037 * <ul>
038 * <li>{@link ProjectCodeRule#checkExistenceAndActive()}</li>
039 * </ul>
040 * This rule fails on business rule failures
041 * @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomApproveDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)
042 */
043 protected boolean processCustomApproveDocumentBusinessRules(MaintenanceDocument document) {
044
045 LOG.info("Entering processCustomApproveDocumentBusinessRules()");
046
047 // check that all sub-objects whose keys are specified have matching objects in the db
048 checkExistenceAndActive();
049
050 return true;
051 }
052
053 /**
054 * This performs rules checks on document route
055 * <ul>
056 * <li>{@link ProjectCodeRule#checkExistenceAndActive()}</li>
057 * </ul>
058 * This rule fails on business rule failures
059 * @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)
060 */
061 protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
062
063 boolean success = true;
064
065 LOG.info("Entering processCustomRouteDocumentBusinessRules()");
066
067 // check that all sub-objects whose keys are specified have matching objects in the db
068 success &= checkExistenceAndActive();
069
070 return success;
071 }
072
073 /**
074 * This performs rules checks on document save
075 * <ul>
076 * <li>{@link ProjectCodeRule#checkExistenceAndActive()}</li>
077 * </ul>
078 * This rule does not fail on business rule failures
079 * @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomSaveDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)
080 */
081 protected boolean processCustomSaveDocumentBusinessRules(MaintenanceDocument document) {
082
083 boolean success = true;
084
085 LOG.info("Entering processCustomSaveDocumentBusinessRules()");
086
087 // check that all sub-objects whose keys are specified have matching objects in the db
088 success &= checkExistenceAndActive();
089
090 return success;
091 }
092
093 /**
094 * This method sets the convenience objects like newProjectCode and oldProjectCode, so you have short and easy handles to the new and
095 * old objects contained in the maintenance document. It also calls the BusinessObjectBase.refresh(), which will attempt to load
096 * all sub-objects from the DB by their primary keys, if available.
097 *
098 * @param document - the maintenanceDocument being evaluated
099 */
100 public void setupConvenienceObjects() {
101
102 // setup oldAccount convenience objects, make sure all possible sub-objects are populated
103 oldProjectCode = (ProjectCode) super.getOldBo();
104
105 // setup newAccount convenience objects, make sure all possible sub-objects are populated
106 newProjectCode = (ProjectCode) super.getNewBo();
107 }
108
109 /**
110 *
111 * This method currently doesn't do anything
112 * @return true
113 */
114 protected boolean checkExistenceAndActive() {
115
116 LOG.info("Entering checkExistenceAndActive()");
117 boolean success = true;
118
119 return success;
120 }
121
122 }