Sonar Critical Fix
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-plugins / src / main / java / org / openecomp / dcae / apod / analytics / cdap / plugins / domain / config / tca / SimpleTCAPluginConfig.java
1 /*\r
2  * ===============================LICENSE_START======================================\r
3  *  dcae-analytics\r
4  * ================================================================================\r
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  *  Licensed under the Apache License, Version 2.0 (the "License");\r
8  *  you may not use this file except in compliance with the License.\r
9  *   You may obtain a copy of the License at\r
10  *\r
11  *          http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  *  Unless required by applicable law or agreed to in writing, software\r
14  *  distributed under the License is distributed on an "AS IS" BASIS,\r
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  *  See the License for the specific language governing permissions and\r
17  *  limitations under the License.\r
18  *  ============================LICENSE_END===========================================\r
19  */\r
20 \r
21 package org.openecomp.dcae.apod.analytics.cdap.plugins.domain.config.tca;\r
22 \r
23 import co.cask.cdap.api.annotation.Description;\r
24 import co.cask.cdap.api.annotation.Macro;\r
25 import com.google.common.base.Objects;\r
26 import org.openecomp.dcae.apod.analytics.cdap.common.settings.CDAPBasePluginConfig;\r
27 \r
28 import javax.annotation.Nullable;\r
29 \r
30 /**\r
31  * Simple TCA Plugin Configuration\r
32  * <p>\r
33  * @author Rajiv Singla . Creation Date: 2/13/2017.\r
34  */\r
35 public class SimpleTCAPluginConfig extends CDAPBasePluginConfig {\r
36 \r
37     private static final long serialVersionUID = 1L;\r
38 \r
39     @Description("Field name containing VES Message")\r
40     @Macro\r
41     protected String vesMessageFieldName;\r
42 \r
43     @Description("Policy JSON that need to be applied to VES Message")\r
44     @Macro\r
45     protected String policyJson;\r
46 \r
47     @Description("Name of the output field that will contain the alert")\r
48     @Macro\r
49     protected String alertFieldName;\r
50 \r
51     @Description("Name of the output field that will contain message type: INAPPLICABLE, COMPLIANT, NON_COMPLIANT")\r
52     @Macro\r
53     protected String messageTypeFieldName;\r
54 \r
55     @Description("Specifies the output schema")\r
56     protected String schema;\r
57 \r
58     @Description("Enables")\r
59     @Nullable\r
60     @Macro\r
61     protected Boolean enableAlertCEFFormat;\r
62 \r
63 \r
64     /**\r
65      * Creates an instance of TCA Plugin Configs\r
66      *\r
67      * @param vesMessageFieldName Ves message field name from incoming plugin schema\r
68      * @param policyJson TCA Policy Json String\r
69      * @param alertFieldName Alert field name that will be added in TCA plugin output schema\r
70      * @param messageTypeFieldName Message type field name that will be added in TCA plugin output schema\r
71      * @param schema TCA Plugin output schema\r
72      * @param enableAlertCEFFormat enables alert message to be formatted in VES format\r
73      */\r
74     public SimpleTCAPluginConfig(final String vesMessageFieldName, final String policyJson,\r
75                                  final String alertFieldName, final String messageTypeFieldName,\r
76                                  final String schema, final Boolean enableAlertCEFFormat) {\r
77         this.vesMessageFieldName = vesMessageFieldName;\r
78         this.policyJson = policyJson;\r
79         this.alertFieldName = alertFieldName;\r
80         this.messageTypeFieldName = messageTypeFieldName;\r
81         this.schema = schema;\r
82         this.enableAlertCEFFormat = enableAlertCEFFormat;\r
83     }\r
84 \r
85     /**\r
86      * Name of the field containing VES Message\r
87      *\r
88      * @return VES Message field name\r
89      */\r
90     public String getVesMessageFieldName() {\r
91         return vesMessageFieldName;\r
92     }\r
93 \r
94     /**\r
95      * Policy Json String\r
96      *\r
97      * @return Policy Json String\r
98      */\r
99     public String getPolicyJson() {\r
100         return policyJson;\r
101     }\r
102 \r
103 \r
104     /**\r
105      * Alert Field name in outgoing schema\r
106      *\r
107      * @return alert field name in outgoing schema\r
108      */\r
109     public String getAlertFieldName() {\r
110         return alertFieldName;\r
111     }\r
112 \r
113     /**\r
114      * Returns output schema string\r
115      *\r
116      * @return output schema string\r
117      */\r
118     public String getSchema() {\r
119         return schema;\r
120     }\r
121 \r
122     /**\r
123      * Return TCA message type - INAPPLICABLE, COMPLIANT, NON_COMPLIANT\r
124      *\r
125      * @return tca message type\r
126      */\r
127     public String getMessageTypeFieldName() {\r
128         return messageTypeFieldName;\r
129     }\r
130 \r
131 \r
132     /**\r
133      * Returns if Alert output in Common Event format\r
134      *\r
135      * @return true if alert output is in common event format\r
136      */\r
137     @Nullable\r
138     public Boolean getEnableAlertCEFFormat() {\r
139         return enableAlertCEFFormat;\r
140     }\r
141 \r
142     @Override\r
143     public String toString() {\r
144         return Objects.toStringHelper(this)\r
145                 .add("referenceName", referenceName)\r
146                 .add("vesMessageFieldName", vesMessageFieldName)\r
147                 .add("policyJson", policyJson)\r
148                 .add("alertFieldName", alertFieldName)\r
149                 .add("messageTypeFieldName", messageTypeFieldName)\r
150                 .add("schema", schema)\r
151                 .add("enableAlertCEFFormat", true)\r
152                 .toString();\r
153     }\r
154 }\r