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