View Javadoc

1   /**
2    * Copyright 2013 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   *
15   * Created by Charles on 9/13/13
16   */
17  package org.kuali.student.poc.eventproc.event;
18  
19  import org.apache.log4j.Logger;
20  import org.kuali.student.poc.eventproc.api.KSEventAuditTrail;
21  import org.kuali.student.r2.common.exceptions.OperationFailedException;
22  
23  import java.util.ArrayList;
24  import java.util.HashMap;
25  import java.util.List;
26  import java.util.Map;
27  
28  /**
29   * Base class for event.  Subclassing is convenient, but not required.  Can always use this base class.
30   *
31   * @author Kuali Student Team
32   */
33  public abstract class KSEvent implements KSEventAuditTrail {
34      private static final Logger LOGGER = Logger.getLogger(KSEvent.class);
35  
36      private KSEventType eventType;
37      private Map<KSEventAttributeKey, String> eventAttributeKeyValueMap;
38  
39      private List<KSHandlerResult> handlerResults = new ArrayList<KSHandlerResult>();
40  
41      private List<KSEvent> downstreamEvents = new ArrayList<KSEvent>();
42  
43      public KSEvent(KSEventType eventType) {
44          this.eventType = eventType;
45          this.eventAttributeKeyValueMap = new HashMap<KSEventAttributeKey, String>();
46      }
47  
48      public abstract boolean hasAttribute(KSEventAttributeKey key);
49  
50      public KSEventType getEventType() {
51          return eventType;
52      }
53  
54      public abstract String getAttributeValueByKey(KSEventAttributeKey key);
55  
56      @Override
57      public void addHandlerResult(KSHandlerResult result) {
58          handlerResults.add(result);
59      }
60  
61      @Override
62      public void addDownstreamEvent(KSEvent event) {
63          downstreamEvents.add(event);
64      }
65  }