2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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 * ===================================================================
24 package org.onap.clamp.clds.model.properties;
26 import com.att.eelf.configuration.EELFLogger;
27 import com.att.eelf.configuration.EELFManager;
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;
37 * Parse ONAP Tca Item json properties.
40 public class TcaItem {
42 protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaItem.class);
43 protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
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;
53 * Parse Tca Item given json node.
55 * @param tcaJson The tac json
57 public TcaItem(JsonElement tcaJson) {
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()));
75 public String getControlLoopSchemaType() {
76 return controlLoopSchemaType;
79 public void setControlLoopSchemaType(String controlLoopSchemaType) {
80 this.controlLoopSchemaType = controlLoopSchemaType;
83 public String getTcaName() {
87 public void setTcaName(String tcaName) {
88 this.tcaName = tcaName;
91 public String getTcaUuId() {
95 public void setTcaUuId(String tcaUuId) {
96 this.tcaUuId = tcaUuId;
99 public String getPolicyId() {
103 public void setPolicyId(String policyId) {
104 this.policyId = policyId;
107 public List<TcaThreshold> getTcaThresholds() {
108 return tcaThresholds;
111 public String getEventName() {
115 public void setEventName(String eventName) {
116 this.eventName = eventName;