View Javadoc
1   /*
2    * Copyright 2008 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
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.ole.sys.document.validation.event;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import org.kuali.ole.sys.document.validation.AccountingRuleEngineRule;
22  import org.kuali.rice.krad.document.Document;
23  import org.kuali.rice.krad.rules.rule.BusinessRule;
24  import org.kuali.rice.krad.rules.rule.event.KualiDocumentEventBase;
25  
26  /**
27   * Base abstract implementation of an attributed document event.
28   */
29  public class AttributedDocumentEventBase extends KualiDocumentEventBase implements AttributedDocumentEvent {
30      private Map<String, Object> attributes;
31      private Object iterationSubject;
32  
33      /**
34       * Constructs a AttributedDocumentEventBase
35       * @param description
36       * @param errorPathPrefix
37       */
38      protected AttributedDocumentEventBase(String description, String errorPathPrefix) {
39          super(description, errorPathPrefix);
40          attributes = new HashMap<String, Object>();
41      }
42      
43      /**
44       * @see org.kuali.rice.krad.rule.event.KualiDocumentEventBase#KualiDocumentEventBase(java.lang.String, java.lang.String, org.kuali.rice.krad.document.Document)
45       */
46      public AttributedDocumentEventBase(String description, String errorPathPrefix, Document document) {
47          super(description, errorPathPrefix, document);
48          attributes = new HashMap<String, Object>();
49      }
50  
51      /**
52       * @see org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent#getAttribute(java.lang.String)
53       */
54      public Object getAttribute(String attributeName) {
55          return attributes.get(attributeName);
56      }
57  
58      /**
59       * @see org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent#setAttribute(java.lang.String, java.lang.Object)
60       */
61      public void setAttribute(String attributeName, Object attributeValue) {
62          attributes.put(attributeName, attributeValue);
63      }
64  
65      /**
66       * Gets the iterationSubject attribute. 
67       * @return Returns the iterationSubject.
68       */
69      public Object getIterationSubject() {
70          return iterationSubject;
71      }
72  
73      /**
74       * Sets the iterationSubject attribute value.
75       * @param iterationSubject The iterationSubject to set.
76       */
77      public void setIterationSubject(Object iterationSubject) {
78          this.iterationSubject = iterationSubject;
79      }
80  
81      /**
82       * @see org.kuali.rice.krad.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
83       */
84      public Class getRuleInterfaceClass() {
85          return AccountingRuleEngineRule.class;
86      }
87  
88      /**
89       * @see org.kuali.rice.krad.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.rice.krad.rule.BusinessRule)
90       */
91      public boolean invokeRuleMethod(BusinessRule rule) {
92          return ((AccountingRuleEngineRule)rule).validateForEvent(this);
93      }
94  }