01: /*
02: * Copyright 2006-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.Document;
19: import org.kuali.core.rule.event.ApproveDocumentEvent;
20: import org.kuali.core.rules.DocumentRuleBase;
21: import org.kuali.core.util.GlobalVariables;
22: import org.kuali.module.kra.document.ResearchDocument;
23:
24: /**
25: * This class...
26: */
27: public class ResearchDocumentRuleBase extends DocumentRuleBase {
28:
29: /**
30: * @see org.kuali.core.rule.RouteDocumentRule#processRouteDocument(org.kuali.core.document.Document)
31: */
32: @Override
33: public boolean processRouteDocument(Document document) {
34: // TODO Auto-generated method stub
35: return true;
36: }
37:
38: /**
39: * @see org.kuali.core.rule.ApproveDocumentRule#processApproveDocument(org.kuali.core.rule.event.ApproveDocumentEvent)
40: */
41: @Override
42: public boolean processApproveDocument(
43: ApproveDocumentEvent approveEvent) {
44: // TODO Auto-generated method stub
45: return true;
46: }
47:
48: /**
49: * @see org.kuali.core.rule.SaveDocumentRule#processSaveDocument(org.kuali.core.document.Document)
50: */
51: @Override
52: public boolean processSaveDocument(Document document) {
53: ResearchDocument researchDocument = (ResearchDocument) document;
54:
55: boolean isValidForSave;
56:
57: GlobalVariables.getErrorMap().addToErrorPath("document");
58:
59: if (isDocumentValidForSave(researchDocument)) {
60: isValidForSave = processCustomSaveDocumentBusinessRules(researchDocument);
61: } else {
62: isValidForSave = false;
63: }
64:
65: GlobalVariables.getErrorMap().removeFromErrorPath("document");
66:
67: return isValidForSave;
68: }
69:
70: /**
71: * This method should be overridden by children rule classes as a hook to implement document specific business rule checks for
72: * the "save document" event.
73: *
74: * @param document
75: * @return boolean True if the rules checks passed, false otherwise.
76: */
77: protected boolean processCustomSaveDocumentBusinessRules(
78: ResearchDocument document) {
79: return true;
80: }
81:
82: /**
83: * Performs common validation for Research Document saves.
84: *
85: * @param transactionalDocument
86: * @return boolean True if the document is valid for saving, false otherwise.
87: */
88: protected boolean isDocumentValidForSave(
89: ResearchDocument researchDocument) {
90: boolean valid = true;
91:
92: return valid;
93: }
94:
95: }
|