f104b09172369c34e6fe6740802d8b01a776b292
[clamp.git] / src / main / java / org / onap / clamp / clds / model / prop / TcaItem.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ===================================================================
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23
24 package org.onap.clamp.clds.model.prop;
25
26 import java.util.ArrayList;
27 import java.util.Iterator;
28 import java.util.List;
29
30 import com.att.eelf.configuration.EELFLogger;
31 import com.att.eelf.configuration.EELFManager;
32 import com.fasterxml.jackson.databind.JsonNode;
33
34 /**
35  * Parse Tca Item json properties.
36  *
37  * Example json:
38  * {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab",
39  * "value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value"
40  * :"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{
41  * "name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1",
42  * ">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value":
43  * "Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"},
44  * {"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":
45  * "tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{
46  * "serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">"
47  * ,"2"]]}]}}
48  *
49  *
50  */
51 public class TcaItem {
52
53     protected static final EELFLogger       logger      = EELFManager.getInstance().getLogger(TcaItem.class);
54     protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
55
56     private String                  tcaName;
57     private String                  tcaUuId;
58     private String                  nfNamingCode;
59     private String                  tcaEnable;
60     private String                  policyId;
61     private Integer                 interval;
62     private String                  severity;
63     private Integer                 violations;
64     private List<TcaThreshhold>     tcaThreshholds;
65
66     /**
67      * Parse Tca Item given json node
68      *
69      * @param node
70      */
71     public TcaItem(JsonNode node) {
72
73         tcaName = AbstractModelElement.getValueByName(node, "tname");
74         tcaUuId = AbstractModelElement.getValueByName(node, "tuuid");
75         nfNamingCode = AbstractModelElement.getValueByName(node, "tnfc");
76         tcaEnable = AbstractModelElement.getValueByName(node, "tcaEnab");
77         policyId = AbstractModelElement.getValueByName(node, "tcaPolId");
78         if (AbstractModelElement.getValueByName(node, "tcaInt") != null) {
79             interval = Integer.valueOf(AbstractModelElement.getValueByName(node, "tcaInt"));
80         }
81         severity = AbstractModelElement.getValueByName(node, "tcaSev");
82         if (AbstractModelElement.getValueByName(node, "tcaVio") != null) {
83             violations = Integer.valueOf(AbstractModelElement.getValueByName(node, "tcaVio"));
84         }
85
86         // process service Configurations
87         JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations");
88         Iterator<JsonNode> itr = serviceConfigurationsNode.elements();
89         tcaThreshholds = new ArrayList<TcaThreshhold>();
90         while (itr.hasNext()) {
91             tcaThreshholds.add(new TcaThreshhold(itr.next()));
92         }
93     }
94
95     public String getTcaName() {
96         return tcaName;
97     }
98
99     public void setTcaName(String tcaName) {
100         this.tcaName = tcaName;
101     }
102
103     public String getTcaUuId() {
104         return tcaUuId;
105     }
106
107     public void setTcaUuId(String tcaUuId) {
108         this.tcaUuId = tcaUuId;
109     }
110
111     public String getNfNamingCode() {
112         return nfNamingCode;
113     }
114
115     public void setNfNamingCode(String nfNamingCode) {
116         this.nfNamingCode = nfNamingCode;
117     }
118
119     public String getTcaEnable() {
120         return tcaEnable;
121     }
122
123     public void setTcaEnable(String tcaEnable) {
124         this.tcaEnable = tcaEnable;
125     }
126
127     public String getPolicyId() {
128         return policyId;
129     }
130
131     public void setPolicyId(String policyId) {
132         this.policyId = policyId;
133     }
134
135     public Integer getInterval() {
136         return interval;
137     }
138
139     public void setInterval(Integer interval) {
140         this.interval = interval;
141     }
142
143     public String getSeverity() {
144         return severity;
145     }
146
147     public void setSeverity(String severity) {
148         this.severity = severity;
149     }
150
151     public Integer getViolations() {
152         return violations;
153     }
154
155     public void setViolations(Integer violations) {
156         this.violations = violations;
157     }
158
159     public List<TcaThreshhold> getTcaThreshholds() {
160         return tcaThreshholds;
161     }
162
163 }