f7bbac0de5353b19cb3167df8bb36708ba7b584c
[clamp.git] / src / main / java / org / onap / clamp / clds / model / prop / Tca.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 Tca json properties.
36  *
37  * Example json:
38  * {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab",
39  * "value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value"
40  * :"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{
41  * "name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1",
42  * ">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value":
43  * "Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"},
44  * {"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":
45  * "tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{
46  * "serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">"
47  * ,"2"]]}]}}
48  *
49  *
50  */
51 public class Tca extends AbstractModelElement {
52
53     protected static final EELFLogger logger      = EELFManager.getInstance().getLogger(Tca.class);
54     protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
55
56     private List<TcaItem>             tcaItems;
57
58     private static final String       TYPE_TCA    = "tca";
59
60     /**
61      * Parse Tca given json node
62      *
63      * @param modelProp
64      * @param modelBpmn
65      * @param modelJson
66      */
67     public Tca(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) {
68         super(TYPE_TCA, modelProp, modelBpmn, modelJson);
69
70         // process Server_Configurations
71         if (modelElementJsonNode != null) {
72             Iterator<JsonNode> itr = modelElementJsonNode.elements();
73             tcaItems = new ArrayList<>();
74             while (itr.hasNext()) {
75                 tcaItems.add(new TcaItem(itr.next()));
76             }
77         }
78     }
79
80     public List<TcaItem> getTcaItems() {
81         return tcaItems;
82     }
83
84     public static final String getType() {
85         return TYPE_TCA;
86     }
87
88 }