001: /*
002: * Copyright 2005-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.core.rule.event;
017:
018: import java.util.ArrayList;
019: import java.util.List;
020:
021: import org.kuali.core.document.Document;
022: import org.kuali.core.rule.BusinessRule;
023: import org.kuali.core.rule.SaveDocumentRule;
024: import org.kuali.core.service.KualiRuleService;
025: import org.kuali.rice.KNSServiceLocator;
026:
027: /**
028: * This class represents the save event that is part of an eDoc in Kuali. This could be triggered when a user presses the save
029: * button for a given document or it could happen when another piece of code calls the save method in the document service.
030: *
031: *
032: */
033: public class SaveDocumentEvent extends KualiDocumentEventBase implements
034: SaveEvent {
035: /**
036: * Constructs a SaveDocumentEvent with the specified errorPathPrefix and document
037: *
038: * @param document
039: * @param errorPathPrefix
040: */
041: public SaveDocumentEvent(String errorPathPrefix, Document document) {
042: this ("creating save event for document "
043: + getDocumentId(document), errorPathPrefix, document);
044: }
045:
046: /**
047: * Constructs a SaveDocumentEvent with the given document
048: *
049: * @param document
050: */
051: public SaveDocumentEvent(Document document) {
052: this ("", document);
053: }
054:
055: /**
056: * @see org.kuali.core.rule.event.KualiDocumentEventBase#KualiDocumentEventBase(java.lang.String, java.lang.String, org.kuali.core.document.Document)
057: */
058: public SaveDocumentEvent(String description,
059: String errorPathPrefix, Document document) {
060: super (description, errorPathPrefix, document);
061: }
062:
063: /**
064: * @see org.kuali.core.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
065: */
066: public Class getRuleInterfaceClass() {
067: return SaveDocumentRule.class;
068: }
069:
070: /**
071: * @see org.kuali.core.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.core.rule.BusinessRule)
072: */
073: public boolean invokeRuleMethod(BusinessRule rule) {
074: return ((SaveDocumentRule) rule).processSaveDocument(document);
075: }
076:
077: /**
078: * @see org.kuali.core.rule.event.KualiDocumentEvent#generateEvents()
079: */
080: @Override
081: public List generateEvents() {
082: KualiRuleService ruleService = KNSServiceLocator
083: .getKualiRuleService();
084:
085: List events = new ArrayList();
086: events.addAll(ruleService
087: .generateAdHocRoutePersonEvents(getDocument()));
088: events.addAll(ruleService
089: .generateAdHocRouteWorkgroupEvents(getDocument()));
090:
091: events.addAll(getDocument().generateSaveEvents());
092:
093: /*
094: if (getDocument() instanceof CashReceiptDocument) {
095: events.addAll(ruleService.generateCheckEvents((CashReceiptDocument) getDocument()));
096: }
097:
098: if (getDocument() instanceof AccountingDocument) {
099: events.addAll(ruleService.generateAccountingLineEvents((AccountingDocument) getDocument()));
100: }
101: */
102: return events;
103: }
104: }
|