001/** 002 * Copyright 2005-2018 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.AddCollectionLineRule; 020import org.kuali.rice.krad.rules.rule.BusinessRule; 021 022/** 023 * Defines the add collection line event fired when a user adds a line in a collection in a document. 024 * 025 * @author Kuali Rice Team (rice.collab@kuali.org) 026 */ 027public class AddCollectionLineEvent extends DocumentEventBase { 028 029 private String collectionName; 030 private Object addLine; 031 032 /** 033 * Constructs an event for a document adding a line to the collection with the name {@code collectionName}. 034 * 035 * @param document the document containing the collection objects 036 * @param collectionName the name of the collection object 037 * @param addLine the object being added to the collection 038 */ 039 public AddCollectionLineEvent(Document document, String collectionName, Object addLine) { 040 this("", document, collectionName, addLine); 041 } 042 043 /** 044 * Constructs an event for a document adding a line to the collection with the name {@code collectionName} with a 045 * specific {@code errorPathPrefix}. 046 * 047 * @param errorPathPrefix the prefix to add to the error path for reporting messages 048 * @param document the document containing the collection objects 049 * @param collectionName the name of the collection object 050 * @param addLine the object being added to the collection 051 */ 052 public AddCollectionLineEvent(String errorPathPrefix, Document document, String collectionName, Object addLine) { 053 this("approve", errorPathPrefix, document, collectionName, addLine); 054 } 055 056 /** 057 * Constructs an event for a document adding a line to the collection with the name {@code collectionName} with a 058 * specific {@code errorPathPrefix} and {@code eventType}. 059 * 060 * @param eventType the name of the type of event 061 * @param errorPathPrefix the prefix to add to the error path for reporting messages 062 * @param document the document containing the collection objects 063 * @param collectionName the name of the collection object 064 * @param addLine the object being added to the collection 065 */ 066 protected AddCollectionLineEvent(String eventType, String errorPathPrefix, Document document, String collectionName, Object addLine) { 067 super("creating " + eventType + " event for document " + DocumentEventBase.getDocumentId(document), errorPathPrefix, document); 068 069 this.collectionName = collectionName; 070 this.addLine = addLine; 071 } 072 073 /** 074 * {@inheritDoc} 075 * 076 * Specifies that this class returns the {@link AddCollectionLineRule} class. 077 */ 078 @Override 079 public Class<AddCollectionLineRule> getRuleInterfaceClass() { 080 return AddCollectionLineRule.class; 081 } 082 083 /** 084 * {@inheritDoc} 085 * 086 * Invokes the specific rule in {@link AddCollectionLineRule}. 087 */ 088 @Override 089 public boolean invokeRuleMethod(BusinessRule rule) { 090 return ((AddCollectionLineRule) rule).processAddCollectionLine(this); 091 } 092 093 /** 094 * The name of the collection being added to. 095 * 096 * @return the collection name 097 */ 098 public String getCollectionName() { 099 return collectionName; 100 } 101 102 /** 103 * The object being added to the collection. 104 * 105 * @return the added object 106 */ 107 public Object getAddLine() { 108 return addLine; 109 } 110 111}