001/** 002 * Copyright 2005-2016 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 */ 016package org.kuali.rice.krad.rules.rule.event; 017 018import org.kuali.rice.krad.document.Document; 019import org.kuali.rice.krad.rules.rule.BusinessRule; 020import org.kuali.rice.krad.rules.rule.SaveDocumentRule; 021import org.kuali.rice.krad.service.KRADServiceLocatorWeb; 022import org.kuali.rice.krad.service.KualiRuleService; 023 024import java.util.ArrayList; 025import java.util.List; 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 */ 033public class SaveDocumentEvent extends KualiDocumentEventBase implements SaveEvent { 034 /** 035 * Constructs a SaveDocumentEvent with the specified errorPathPrefix and document 036 * 037 * @param document 038 * @param errorPathPrefix 039 */ 040 public SaveDocumentEvent(String errorPathPrefix, Document document) { 041 this("creating save event for document " + getDocumentId(document), errorPathPrefix, document); 042 } 043 044 /** 045 * Constructs a SaveDocumentEvent with the given document 046 * 047 * @param document 048 */ 049 public SaveDocumentEvent(Document document) { 050 this("", document); 051 } 052 053 /** 054 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEventBase#KualiDocumentEventBase(java.lang.String, java.lang.String, org.kuali.rice.krad.document.Document) 055 */ 056 public SaveDocumentEvent(String description, String errorPathPrefix, Document document) { 057 super(description, errorPathPrefix, document); 058 } 059 060 /** 061 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#getRuleInterfaceClass() 062 */ 063 public Class<? extends BusinessRule> getRuleInterfaceClass() { 064 return SaveDocumentRule.class; 065 } 066 067 /** 068 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.rice.krad.rules.rule.BusinessRule) 069 */ 070 public boolean invokeRuleMethod(BusinessRule rule) { 071 return ((SaveDocumentRule) rule).processSaveDocument(document); 072 } 073 074 /** 075 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#generateEvents() 076 */ 077 @Override 078 public List<KualiDocumentEvent> generateEvents() { 079 KualiRuleService ruleService = KRADServiceLocatorWeb.getKualiRuleService(); 080 081 List<KualiDocumentEvent> events = new ArrayList<KualiDocumentEvent>(); 082 events.addAll(ruleService.generateAdHocRoutePersonEvents(getDocument())); 083 events.addAll(ruleService.generateAdHocRouteWorkgroupEvents(getDocument())); 084 085 events.addAll(getDocument().generateSaveEvents()); 086 087 /* 088 if (getDocument() instanceof CashReceiptDocument) { 089 events.addAll(ruleService.generateCheckEvents((CashReceiptDocument) getDocument())); 090 } 091 092 if (getDocument() instanceof AccountingDocument) { 093 events.addAll(ruleService.generateAccountingLineEvents((AccountingDocument) getDocument())); 094 } 095 */ 096 return events; 097 } 098}