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 com.fasterxml.jackson.databind.JsonNode;
28 import java.util.HashMap;
29 import java.util.Iterator;
30 import java.util.List;
32 import java.util.logging.Logger;
35 * Parse serviceConfigurations from StringMatch json properties.
37 * Example json: "StringMatch_0c2cy0c":[[{"name":"topicPublishes","value":"DCAE-CL-EVENT"}],{"serviceConfigurations":[[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VNFNAME","LOCID"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Initial"]},{"name":"outputEventName","value":["OnSet"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}],[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VMID","Identiy","VNFNAME"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Close"]},{"name":"outputEventName","value":["Abatement"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}]]}]
39 public class ServiceConfiguration {
41 private static final Logger logger = Logger.getLogger(ServiceConfiguration.class.getName());
43 private final List<String> aaiMatchingFields;
44 private final List<String> aaiSendFields;
45 private final String groupNumber;
46 private final List<String> resourceVf;
47 private final List<String> resourceVfc;
48 private final String timeWindow;
49 private final String ageLimit;
50 private final String createClosedLoopEventId;
51 private final String outputEventName;
52 private final Map<String, String> stringSet;
55 * Parse serviceConfigurations given json node.
59 public ServiceConfiguration(JsonNode node) {
60 aaiMatchingFields = ModelElement.getValuesByName(node, "aaiMatchingFields");
61 aaiSendFields = ModelElement.getValuesByName(node, "aaiSendFields");
62 groupNumber = ModelElement.getValueByName(node, "groupNumber");
63 resourceVf = ModelElement.getValuesByName(node, "vf");
64 resourceVfc = ModelElement.getValuesByName(node, "vfc");
65 timeWindow = ModelElement.getValueByName(node, "timeWindow");
66 ageLimit = ModelElement.getValueByName(node, "ageLimit");
67 createClosedLoopEventId = ModelElement.getValueByName(node, "createClosedLoopEventId");
68 outputEventName = ModelElement.getValueByName(node, "outputEventName");
70 // process the stringSet fields
71 JsonNode ssNodes = node.findPath("stringSet");
72 Iterator<JsonNode> itr = ssNodes.elements();
73 stringSet = new HashMap<>();
74 while (itr.hasNext()) {
75 JsonNode ssNode = itr.next();
76 String key = ssNode.path("name").asText();
77 String value = ssNode.path("value").path(0).asText();
78 if (key.length() != 0 && value.length() != 0) {
79 // only add string set field if not null
80 logger.fine("stringSet: " + key + "=" + value);
81 stringSet.put(key, value);
87 * @return the aaiMatchingFields
89 public List<String> getaaiMatchingFields() {
90 return aaiMatchingFields;
94 * @return the aaiSendFields
96 public List<String> getaaiSendFields() {
101 * @return the groupNumber
103 public String getGroupNumber() {
108 * @return the resourceVf
110 public List<String> getResourceVf() {
115 * @return the resourceVfc
117 public List<String> getResourceVfc() {
122 * @return the timeWindow
124 public String getTimeWindow() {
129 * @return the ageLimit
131 public String getAgeLimit() {
136 * @return the createClosedLoopEventId
138 public String getCreateClosedLoopEventId() {
139 return createClosedLoopEventId;
143 * @return the outputEventName
145 public String getOutputEventName() {
146 return outputEventName;
150 * @return the stringSet
152 public Map<String, String> getStringSet() {