207d1e1bb84ba516adfab00641cc9878a4e5c310
[dcaegen2/analytics/tca.git] / dcae-analytics-tca / src / main / java / org / openecomp / dcae / apod / analytics / tca / processor / TCACEFProcessorContext.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *   You may obtain a copy of the License at
10  *
11  *          http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  *  ============================LICENSE_END===========================================
19  */
20
21 package org.openecomp.dcae.apod.analytics.tca.processor;
22
23 import org.openecomp.dcae.apod.analytics.common.service.processor.AbstractProcessorContext;
24 import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener;
25 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.MetricsPerEventName;
26 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;
27
28 /**
29  *  TCA CEF Policy Processor Context
30  *
31  * @author Rajiv Singla . Creation Date: 11/7/2016.
32  */
33 public class TCACEFProcessorContext extends AbstractProcessorContext {
34
35     private static final long serialVersionUID = 1L;
36
37     private final TCAPolicy tcaPolicy;
38     private EventListener eventListener;
39     private MetricsPerEventName metricsPerEventName;
40
41     public TCACEFProcessorContext(final String message, boolean canProcessingContinue, final TCAPolicy tcaPolicy) {
42         super(message, canProcessingContinue);
43         this.tcaPolicy = tcaPolicy;
44         // present only if cef incoming message can be parsed successfully to Event Listener Object
45         this.eventListener = null;
46         // present only if there are any threshold violations are detected
47         this.metricsPerEventName = null;
48     }
49
50     // Auxiliary Constructor which default canProcessingContinue Flag to true
51     public TCACEFProcessorContext(final String message, final TCAPolicy tcaPolicy) {
52         this(message, true, tcaPolicy);
53     }
54
55     /**
56      * Returns {@link TCAPolicy} Object
57      *
58      * @return TCA Policy
59      */
60     public TCAPolicy getTCAPolicy() {
61         return tcaPolicy;
62     }
63
64     /**
65      * Returns Common Event Format {@link EventListener} if present else null
66      *
67      * @return CEF Event Listener
68      */
69     public EventListener getCEFEventListener() {
70         return eventListener;
71     }
72
73
74     /**
75      * Sets new {@link EventListener}
76      *
77      * @param eventListener set new value for CEF event listener
78      */
79     public void setCEFEventListener(final EventListener eventListener) {
80         this.eventListener = eventListener;
81     }
82
83
84     /**
85      * Returns TCA Policy {@link MetricsPerEventName} which was has violated Threshold for the CEF Message if
86      * present else null
87      *
88      * @return Violated Threshold
89      */
90     public MetricsPerEventName getMetricsPerEventName() {
91         return metricsPerEventName;
92     }
93
94     /**
95      * Assign new TCA Policy {@link MetricsPerEventName} which was has violated Threshold for the CEF Message
96      *
97      * @param metricsPerEventName new value for Metrics Per Functional Role with violated threshold
98      */
99     public void setMetricsPerEventName(MetricsPerEventName metricsPerEventName) {
100         this.metricsPerEventName = metricsPerEventName;
101     }
102
103 }