2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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 * ===================================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 package org.onap.clamp.clds.model.prop;
26 import java.util.HashMap;
27 import java.util.Iterator;
28 import java.util.List;
31 import com.att.eelf.configuration.EELFLogger;
32 import com.att.eelf.configuration.EELFManager;
33 import com.fasterxml.jackson.databind.JsonNode;
36 * Parse serviceConfigurations from StringMatch json properties.
39 * {"StringMatch_0aji7go":{"Group1":[{"name":"rgname","value":"1493749598520"},{
40 * "name":"rgfriendlyname","value":"Group1"},{"name":"policyName","value":
41 * "Policy1"},{"name":"policyId","value":"1"},{"serviceConfigurations":[[{"name"
42 * :"aaiMatchingFields","value":["complex.city","vserver.vserver-name"]},{"name"
43 * :"aaiSendFields","value":["complex.city","vserver.vserver-name"]},{"name":
44 * "eventSeverity","value":["OK"]},{"name":"eventSourceType","value":[""]},{
45 * "name":"timeWindow","value":["100"]},{"name":"ageLimit","value":["100"]},{
46 * "name":"createClosedLoopEventId","value":["Initial"]},{"name":
47 * "outputEventName","value":["ONSET"]}]]}],"Group2":[{"name":"rgname","value":
48 * "1493749665149"},{"name":"rgfriendlyname","value":"Group2"},{"name":
49 * "policyName","value":"Policy2"},{"name":"policyId","value":"2"},{
50 * "serviceConfigurations":[[{"name":"aaiMatchingFields","value":[
51 * "cloud-region.identity-url","vserver.vserver-name"]},{"name":"aaiSendFields",
52 * "value":["cloud-region.identity-url","vserver.vserver-name"]},{"name":
53 * "eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":[""]},{
54 * "name":"timeWindow","value":["1000"]},{"name":"ageLimit","value":["1000"]},{
55 * "name":"createClosedLoopEventId","value":["Initial"]},{"name":
56 * "outputEventName","value":["ONSET"]}],[{"name":"aaiMatchingFields","value":[
57 * "generic-vnf.vnf-name","vserver.vserver-name"]},{"name":"aaiSendFields",
58 * "value":["generic-vnf.vnf-name","vserver.vserver-name"]},{"name":
59 * "eventSeverity","value":["CRITICAL"]},{"name":"eventSourceType","value":[""]}
60 * ,{"name":"timeWindow","value":["3000"]},{"name":"ageLimit","value":["3000"]},
61 * {"name":"createClosedLoopEventId","value":["Initial"]},{"name":
62 * "outputEventName","value":["ABATED"]}]]}]}}
65 public class ServiceConfiguration {
67 protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ServiceConfiguration.class);
68 protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
70 private final List<String> aaiMatchingFields;
71 private final List<String> aaiSendFields;
72 // private final String groupNumber;
73 private final List<String> resourceVf;
74 private final List<String> resourceVfc;
75 private final String timeWindow;
76 private final String ageLimit;
77 private final String createClosedLoopEventId;
78 private final String outputEventName;
79 private final Map<String, String> stringSet;
82 * Parse serviceConfigurations given json node.
86 public ServiceConfiguration(JsonNode node) {
87 aaiMatchingFields = ModelElement.getValuesByName(node, "aaiMatchingFields");
88 aaiSendFields = ModelElement.getValuesByName(node, "aaiSendFields");
89 // groupNumber = ModelElement.getValueByName(node, "groupNumber");
90 resourceVf = ModelElement.getValuesByName(node, "vf");
91 resourceVfc = ModelElement.getValuesByName(node, "vfc");
92 timeWindow = ModelElement.getValueByName(node, "timeWindow");
93 ageLimit = ModelElement.getValueByName(node, "ageLimit");
94 createClosedLoopEventId = ModelElement.getValueByName(node, "createClosedLoopEventId");
95 outputEventName = ModelElement.getValueByName(node, "outputEventName");
97 // process the stringSet fields
98 JsonNode ssNodes = node.findPath("stringSet");
99 Iterator<JsonNode> itr = ssNodes.elements();
100 stringSet = new HashMap<>();
101 while (itr.hasNext()) {
102 JsonNode ssNode = itr.next();
103 String key = ssNode.path("name").asText();
104 String value = ssNode.path("value").path(0).asText();
105 if (key.length() != 0 && value.length() != 0) {
106 // only add string set field if not null
107 logger.debug("stringSet: " + key + "=" + value);
108 stringSet.put(key, value);
114 * @return the aaiMatchingFields
116 public List<String> getaaiMatchingFields() {
117 return aaiMatchingFields;
121 * @return the aaiSendFields
123 public List<String> getaaiSendFields() {
124 return aaiSendFields;
128 * @return the groupNumber
130 * public String getGroupNumber() { return groupNumber; }
133 * @return the resourceVf
135 public List<String> getResourceVf() {
140 * @return the resourceVfc
142 public List<String> getResourceVfc() {
147 * @return the timeWindow
149 public String getTimeWindow() {
154 * @return the ageLimit
156 public String getAgeLimit() {
161 * @return the createClosedLoopEventId
163 public String getCreateClosedLoopEventId() {
164 return createClosedLoopEventId;
168 * @return the outputEventName
170 public String getOutputEventName() {
171 return outputEventName;
175 * @return the stringSet
177 public Map<String, String> getStringSet() {