[CLAMP-1] Initial ONAP CLAMP seed code commit
[clamp.git] / src / main / java / org / onap / clamp / clds / model / prop / TcaItem.java
1 package org.onap.clamp.clds.model.prop;
2
3 import java.util.ArrayList;
4 import java.util.Iterator;
5 import java.util.List;
6 import java.util.logging.Logger;
7
8 import com.fasterxml.jackson.databind.JsonNode;
9
10 /**
11  * Parse Tca Item json properties.
12  * 
13  * Example json: {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1",">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value":"Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">","2"]]}]}}
14  * 
15  *
16  */
17 public class TcaItem {
18
19     private static final Logger logger = Logger.getLogger(TcaItem.class.getName());
20         
21         private String tcaName;
22         private String tcaUuId;
23         private String nfNamingCode;
24         private String tcaEnable;
25         private String policyId;
26         private Integer interval;
27         private String severity;
28         private Integer violations;
29         private List<TcaThreshhold> tcaThreshholds;
30         
31         /**
32          * Parse Tca Item given json node
33          * 
34          * @param node
35          */
36         public TcaItem(JsonNode node) {
37                 
38                 tcaName = ModelElement.getValueByName(node, "tname");
39                 tcaUuId = ModelElement.getValueByName(node, "tuuid");
40                 nfNamingCode = ModelElement.getValueByName(node, "tnfc");
41                 tcaEnable = ModelElement.getValueByName(node, "tcaEnab");
42                 policyId = ModelElement.getValueByName(node, "tcaPolId");
43                 if(ModelElement.getValueByName(node, "tcaInt") != null){
44                         interval = Integer.valueOf(ModelElement.getValueByName(node, "tcaInt"));
45                 }
46                 severity = ModelElement.getValueByName(node, "tcaSev");
47                 if(ModelElement.getValueByName(node, "tcaVio") != null){
48                         violations = Integer.valueOf(ModelElement.getValueByName(node, "tcaVio"));
49                 }
50                 
51                 // process service Configurations
52                 JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations");
53                 Iterator<JsonNode> itr = serviceConfigurationsNode.elements();
54                 tcaThreshholds = new ArrayList<TcaThreshhold>();
55                 while(itr.hasNext()) {
56                         tcaThreshholds.add(new TcaThreshhold(itr.next()));
57                 }
58         }
59
60         public String getTcaName() {
61                 return tcaName;
62         }
63
64         public void setTcaName(String tcaName) {
65                 this.tcaName = tcaName;
66         }
67         
68         public String getTcaUuId() {
69                 return tcaUuId;
70         }
71
72         public void setTcaUuId(String tcaUuId) {
73                 this.tcaUuId = tcaUuId;
74         }
75
76         public String getNfNamingCode() {
77                 return nfNamingCode;
78         }
79
80         public void setNfNamingCode(String nfNamingCode) {
81                 this.nfNamingCode = nfNamingCode;
82         }
83
84         public String getTcaEnable() {
85                 return tcaEnable;
86         }
87
88         public void setTcaEnable(String tcaEnable) {
89                 this.tcaEnable = tcaEnable;
90         }
91         
92         public String getPolicyId() {
93                 return policyId;
94         }
95
96         public void setPolicyId(String policyId) {
97                 this.policyId = policyId;
98         }
99
100         public Integer getInterval() {
101                 return interval;
102         }
103
104         public void setInterval(Integer interval) {
105                 this.interval = interval;
106         }
107
108         public String getSeverity() {
109                 return severity;
110         }
111
112         public void setSeverity(String severity) {
113                 this.severity = severity;
114         }
115
116         public Integer getViolations() {
117                 return violations;
118         }
119
120         public void setViolations(Integer violations) {
121                 this.violations = violations;
122         }
123
124         public List<TcaThreshhold> getTcaThreshholds() {
125                 return tcaThreshholds;
126         }
127         
128 }