Fix check style issues
[clamp.git] / src / main / java / org / onap / clamp / clds / model / properties / TcaItem.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017-2018 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  * 
22  */
23
24 package org.onap.clamp.clds.model.properties;
25
26 import com.att.eelf.configuration.EELFLogger;
27 import com.att.eelf.configuration.EELFManager;
28
29 import com.google.gson.JsonArray;
30 import com.google.gson.JsonElement;
31 import java.util.ArrayList;
32 import java.util.Iterator;
33 import java.util.List;
34 import org.onap.clamp.clds.util.JsonUtils;
35
36 /**
37  * Parse ONAP Tca Item json properties.
38  *
39  */
40 public class TcaItem {
41
42     protected static final EELFLogger logger      = EELFManager.getInstance().getLogger(TcaItem.class);
43     protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
44
45     private String                    tcaName;
46     private String                    tcaUuId;
47     private String                    policyId;
48     private String                    eventName;
49     private String                    controlLoopSchemaType;
50     private List<TcaThreshold>        tcaThresholds;
51
52     /**
53      * Parse Tca Item given json node.
54      *
55      * @param tcaJson The tac json
56      */
57     public TcaItem(JsonElement tcaJson) {
58
59         tcaName = JsonUtils.getStringValueByName(tcaJson, "tname");
60         tcaUuId = JsonUtils.getStringValueByName(tcaJson, "tuuid");
61         policyId = JsonUtils.getStringValueByName(tcaJson, "tcaPolId");
62         eventName = JsonUtils.getStringValueByName(tcaJson, "eventName");
63         controlLoopSchemaType = JsonUtils.getStringValueByName(tcaJson, "controlLoopSchemaType");
64         // process service Configurations
65         JsonArray tcaConfigurationArray = tcaJson.getAsJsonArray();
66         JsonArray serviceConfigurationsNode = tcaConfigurationArray.get(tcaConfigurationArray.size() - 1)
67             .getAsJsonObject().get("serviceConfigurations").getAsJsonArray();
68         Iterator<JsonElement> itr = serviceConfigurationsNode.iterator();
69         tcaThresholds = new ArrayList<>();
70         while (itr.hasNext()) {
71             tcaThresholds.add(new TcaThreshold(itr.next().getAsJsonArray()));
72         }
73     }
74
75     public String getControlLoopSchemaType() {
76         return controlLoopSchemaType;
77     }
78
79     public void setControlLoopSchemaType(String controlLoopSchemaType) {
80         this.controlLoopSchemaType = controlLoopSchemaType;
81     }
82
83     public String getTcaName() {
84         return tcaName;
85     }
86
87     public void setTcaName(String tcaName) {
88         this.tcaName = tcaName;
89     }
90
91     public String getTcaUuId() {
92         return tcaUuId;
93     }
94
95     public void setTcaUuId(String tcaUuId) {
96         this.tcaUuId = tcaUuId;
97     }
98
99     public String getPolicyId() {
100         return policyId;
101     }
102
103     public void setPolicyId(String policyId) {
104         this.policyId = policyId;
105     }
106
107     public List<TcaThreshold> getTcaThresholds() {
108         return tcaThresholds;
109     }
110
111     public String getEventName() {
112         return eventName;
113     }
114
115     public void setEventName(String eventName) {
116         this.eventName = eventName;
117     }
118
119 }