001/** 002 * Copyright 2005-2015 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.bo.AdHocRoutePerson; 019import org.kuali.rice.krad.document.Document; 020import org.kuali.rice.krad.rules.rule.AddAdHocRoutePersonRule; 021import org.kuali.rice.krad.rules.rule.BusinessRule; 022 023/** 024 * This class represents the add AdHocRoutePerson event that is part of an eDoc in Kuali. This is triggered when a user presses the 025 * add button for a given adHocRoutePerson. 026 * 027 * 028 */ 029public final class AddAdHocRoutePersonEvent extends KualiDocumentEventBase { 030 private AdHocRoutePerson adHocRoutePerson; 031 032 /** 033 * Constructs an AddAdHocRoutePersonEvent with the specified errorPathPrefix, document, and adHocRoutePerson 034 * 035 * @param document 036 * @param adHocRoutePerson 037 * @param errorPathPrefix 038 */ 039 public AddAdHocRoutePersonEvent(String errorPathPrefix, Document document, AdHocRoutePerson adHocRoutePerson) { 040 super("creating add ad hoc route person event for document " + KualiDocumentEventBase.getDocumentId(document), errorPathPrefix, document); 041 this.adHocRoutePerson = adHocRoutePerson; 042 } 043 044 /** 045 * Constructs an AddAdHocRoutePersonEvent with the given document 046 * 047 * @param document 048 * @param adHocRoutePerson 049 */ 050 public AddAdHocRoutePersonEvent(Document document, AdHocRoutePerson adHocRoutePerson) { 051 this("", document, adHocRoutePerson); 052 } 053 054 /** 055 * This method retrieves the document adHocRoutePerson associated with this event. 056 * 057 * @return AdHocRoutePerson 058 */ 059 public AdHocRoutePerson getAdHocRoutePerson() { 060 return adHocRoutePerson; 061 } 062 063 /** 064 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#validate() 065 */ 066 @Override 067 public void validate() { 068 super.validate(); 069 if (this.adHocRoutePerson == null) { 070 throw new IllegalArgumentException("invalid (null) document adHocRoutePerson"); 071 } 072 } 073 074 /** 075 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#getRuleInterfaceClass() 076 */ 077 public Class<? extends BusinessRule> getRuleInterfaceClass() { 078 return AddAdHocRoutePersonRule.class; 079 } 080 081 /** 082 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.rice.krad.rules.rule.BusinessRule) 083 */ 084 public boolean invokeRuleMethod(BusinessRule rule) { 085 return ((AddAdHocRoutePersonRule) rule).processAddAdHocRoutePerson(getDocument(), this.adHocRoutePerson); 086 } 087}