b20db0aff6afaf43ab0fc8d05b8bc94977ca7141
[clamp.git] / src / main / java / org / onap / clamp / clds / model / prop / StringMatch.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 java.util.ArrayList;
27 import java.util.Iterator;
28 import java.util.List;
29
30 import com.att.eelf.configuration.EELFLogger;
31 import com.att.eelf.configuration.EELFManager;
32 import com.fasterxml.jackson.databind.JsonNode;
33
34 /**
35  * Parse StringMatch json properties.
36  * <p>
37  * Example json:
38  * {"StringMatch_0aji7go":{"Group1":[{"name":"rgname","value":"1493749598520"},{
39  * "name":"rgfriendlyname","value":"Group1"},{"name":"policyName","value":
40  * "Policy1"},{"name":"policyId","value":"1"},{"serviceConfigurations":[[{"name"
41  * :"aaiMatchingFields","value":["complex.city","vserver.vserver-name"]},{"name"
42  * :"aaiSendFields","value":["complex.city","vserver.vserver-name"]},{"name":
43  * "eventSeverity","value":["OK"]},{"name":"eventSourceType","value":[""]},{
44  * "name":"timeWindow","value":["100"]},{"name":"ageLimit","value":["100"]},{
45  * "name":"createClosedLoopEventId","value":["Initial"]},{"name":
46  * "outputEventName","value":["ONSET"]}]]}],"Group2":[{"name":"rgname","value":
47  * "1493749665149"},{"name":"rgfriendlyname","value":"Group2"},{"name":
48  * "policyName","value":"Policy2"},{"name":"policyId","value":"2"},{
49  * "serviceConfigurations":[[{"name":"aaiMatchingFields","value":[
50  * "cloud-region.identity-url","vserver.vserver-name"]},{"name":"aaiSendFields",
51  * "value":["cloud-region.identity-url","vserver.vserver-name"]},{"name":
52  * "eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":[""]},{
53  * "name":"timeWindow","value":["1000"]},{"name":"ageLimit","value":["1000"]},{
54  * "name":"createClosedLoopEventId","value":["Initial"]},{"name":
55  * "outputEventName","value":["ONSET"]}],[{"name":"aaiMatchingFields","value":[
56  * "generic-vnf.vnf-name","vserver.vserver-name"]},{"name":"aaiSendFields",
57  * "value":["generic-vnf.vnf-name","vserver.vserver-name"]},{"name":
58  * "eventSeverity","value":["CRITICAL"]},{"name":"eventSourceType","value":[""]}
59  * ,{"name":"timeWindow","value":["3000"]},{"name":"ageLimit","value":["3000"]},
60  * {"name":"createClosedLoopEventId","value":["Initial"]},{"name":
61  * "outputEventName","value":["ABATED"]}]]}]}}
62  *
63  */
64 public class StringMatch extends ModelElement {
65     protected static final EELFLogger       logger            = EELFManager.getInstance().getLogger(StringMatch.class);
66     protected static final EELFLogger auditLogger       = EELFManager.getInstance().getAuditLogger();
67
68     private List<ResourceGroup>     resourceGroups;
69
70     private static final String     TYPE_STRING_MATCH = "stringMatch";
71
72     /**
73      * Parse StringMatch given json node.
74      *
75      * @param modelBpmn
76      * @param modelJson
77      */
78     public StringMatch(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) {
79         super(TYPE_STRING_MATCH, modelProp, modelBpmn, modelJson);
80
81         // process Server_Configurations
82         if (meNode != null) {
83             Iterator<JsonNode> itr = meNode.elements();
84             resourceGroups = new ArrayList<ResourceGroup>();
85             while (itr.hasNext()) {
86                 resourceGroups.add(new ResourceGroup(itr.next()));
87             }
88         }
89     }
90
91     /**
92      * @return the resourceGroups
93      */
94     public List<ResourceGroup> getResourceGroups() {
95         return resourceGroups;
96     }
97
98     public static final String getType() {
99         return TYPE_STRING_MATCH;
100     }
101
102 }