01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.kra.budget.rules;
17:
18: import org.kuali.core.document.MaintenanceDocument;
19: import org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase;
20: import org.kuali.core.util.GlobalVariables;
21: import org.kuali.core.util.ObjectUtils;
22: import org.kuali.module.kra.KraKeyConstants;
23: import org.kuali.module.kra.KraPropertyConstants;
24: import org.kuali.module.kra.budget.bo.AppointmentType;
25:
26: /**
27: * This class...
28: */
29: public class AppointmentTypeMaintenanceDocumentRule extends
30: MaintenanceDocumentRuleBase {
31: protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
32: .getLogger(IndirectCostLookupRule.class);
33:
34: private AppointmentType appointmentType;
35:
36: /**
37: * This method performs any necessary custom business rules on the document.
38: *
39: * @param document An instance of the maintenance document that is being processed.
40: * @return True if all the business rule checks succeed, false otherwise.
41: * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomSaveDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
42: */
43: @Override
44: protected boolean processCustomSaveDocumentBusinessRules(
45: MaintenanceDocument document) {
46: boolean success = true;
47:
48: setupConvenienceObjects();
49:
50: success &= super
51: .processCustomSaveDocumentBusinessRules(document);
52: success &= validateAppointmentTypes(appointmentType);
53:
54: return true;
55: }
56:
57: private boolean validateAppointmentTypes(
58: AppointmentType appointmentType) {
59: boolean success = true;
60:
61: if (ObjectUtils.isNotNull(appointmentType
62: .getRelatedAppointmentTypeCode())
63: && appointmentType.getRelatedAppointmentTypeCode()
64: .equals(
65: appointmentType
66: .getAppointmentTypeCode())) {
67: String propertyName = KraPropertyConstants.DOCUMENT + "."
68: + KraPropertyConstants.NEW_MAINTAINABLE_OBJECT
69: + "." + "relatedAppointmentTypeCode";
70: GlobalVariables
71: .getErrorMap()
72: .putError(
73: propertyName,
74: KraKeyConstants.ERROR_APPOINTMENT_TYPE_RELATED_TYPE_CODE);
75: success = false;
76: }
77: return success;
78: }
79:
80: /**
81: * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#setupConvenienceObjects()
82: */
83: @Override
84: public void setupConvenienceObjects() {
85: appointmentType = (AppointmentType) super.getNewBo();
86: }
87:
88: }
|