Update TCA config json send to Policy
[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 String                    controlLoopSchemaType;
48     private List<TcaThreshold>        tcaThresholds;
49
50     /**
51      * Parse Tca Item given json node
52      *
53      * @param node
54      */
55     public TcaItem(JsonNode node) {
56
57         tcaName = AbstractModelElement.getValueByName(node, "tname");
58         tcaUuId = AbstractModelElement.getValueByName(node, "tuuid");
59         policyId = AbstractModelElement.getValueByName(node, "tcaPolId");
60         eventName = AbstractModelElement.getValueByName(node, "eventName");
61         controlLoopSchemaType = AbstractModelElement.getValueByName(node, "controlLoopSchemaType");
62         // process service Configurations
63         JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations");
64         Iterator<JsonNode> itr = serviceConfigurationsNode.elements();
65         tcaThresholds = new ArrayList<>();
66         while (itr.hasNext()) {
67             tcaThresholds.add(new TcaThreshold(itr.next()));
68         }
69     }
70
71     public String getControlLoopSchemaType() {
72         return controlLoopSchemaType;
73     }
74
75     public void setControlLoopSchemaType(String controlLoopSchemaType) {
76         this.controlLoopSchemaType = controlLoopSchemaType;
77     }
78
79     public String getTcaName() {
80         return tcaName;
81     }
82
83     public void setTcaName(String tcaName) {
84         this.tcaName = tcaName;
85     }
86
87     public String getTcaUuId() {
88         return tcaUuId;
89     }
90
91     public void setTcaUuId(String tcaUuId) {
92         this.tcaUuId = tcaUuId;
93     }
94
95     public String getPolicyId() {
96         return policyId;
97     }
98
99     public void setPolicyId(String policyId) {
100         this.policyId = policyId;
101     }
102
103     public List<TcaThreshold> getTcaThresholds() {
104         return tcaThresholds;
105     }
106
107     public String getEventName() {
108         return eventName;
109     }
110
111     public void setEventName(String eventName) {
112         this.eventName = eventName;
113     }
114
115 }