Change the model to fix TCA
[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 com.att.eelf.configuration.EELFLogger;
27 import com.att.eelf.configuration.EELFManager;
28 import com.fasterxml.jackson.databind.JsonNode;
29
30 import java.util.ArrayList;
31 import java.util.Iterator;
32 import java.util.List;
33
34 /**
35  * Parse ONAP Tca Item json properties.
36  *
37  */
38 public class TcaItem {
39
40     protected static final EELFLogger logger      = EELFManager.getInstance().getLogger(TcaItem.class);
41     protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
42
43     private String                    tcaName;
44     private String                    tcaUuId;
45     private String                    policyId;
46     private String                    eventName;
47     private List<TcaThreshold>        tcaThresholds;
48
49     /**
50      * Parse Tca Item given json node
51      *
52      * @param node
53      */
54     public TcaItem(JsonNode node) {
55
56         tcaName = AbstractModelElement.getValueByName(node, "tname");
57         tcaUuId = AbstractModelElement.getValueByName(node, "tuuid");
58         policyId = AbstractModelElement.getValueByName(node, "tcaPolId");
59         eventName = AbstractModelElement.getValueByName(node, "eventName");
60         // process service Configurations
61         JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations");
62         Iterator<JsonNode> itr = serviceConfigurationsNode.elements();
63         tcaThresholds = new ArrayList<>();
64         while (itr.hasNext()) {
65             tcaThresholds.add(new TcaThreshold(itr.next()));
66         }
67     }
68
69     public String getTcaName() {
70         return tcaName;
71     }
72
73     public void setTcaName(String tcaName) {
74         this.tcaName = tcaName;
75     }
76
77     public String getTcaUuId() {
78         return tcaUuId;
79     }
80
81     public void setTcaUuId(String tcaUuId) {
82         this.tcaUuId = tcaUuId;
83     }
84
85     public String getPolicyId() {
86         return policyId;
87     }
88
89     public void setPolicyId(String policyId) {
90         this.policyId = policyId;
91     }
92
93     public List<TcaThreshold> getTcaThresholds() {
94         return tcaThresholds;
95     }
96
97     public String getEventName() {
98         return eventName;
99     }
100
101     public void setEventName(String eventName) {
102         this.eventName = eventName;
103     }
104
105 }