summaryrefslogtreecommitdiffstats
path: root/dcae-analytics
diff options
context:
space:
mode:
authorVijay Venkatesh Kumar <vv770d@att.com>2021-08-06 13:08:22 +0000
committerGerrit Code Review <gerrit@onap.org>2021-08-06 13:08:22 +0000
commitff6ca57c1fd4d0352300215d9706b14120c519a9 (patch)
tree9637981b886318fe7e6ae812fb31a634209cfa33 /dcae-analytics
parent5a0c2cefdb993cdfbb0b88e8bedb4df871911dd9 (diff)
parent86e553e419232b59b4853fe52963011c53de5bb3 (diff)
Merge "Add AaiSerializer"
Diffstat (limited to 'dcae-analytics')
-rw-r--r--dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/Aai.java11
-rw-r--r--dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/serializer/AaiSerializer.java68
2 files changed, 75 insertions, 4 deletions
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/Aai.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/Aai.java
index 796587b..46e71fb 100644
--- a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/Aai.java
+++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/Aai.java
@@ -1,7 +1,8 @@
/*
- * ================================================================================
+ * ==================================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Intellectual Property. All rights reserved.
+ * ==================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -13,22 +14,24 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ============LICENSE_END=========================================================
+ * ============LICENSE_END===========================================================
*
*/
package org.onap.dcae.analytics.tca.model.facade;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import lombok.EqualsAndHashCode;
-
import org.onap.dcae.analytics.model.common.BaseDynamicPropertiesProvider;
+import org.onap.dcae.analytics.tca.model.util.json.serializer.AaiSerializer;
/**
* @author Rajiv Singla
*/
@Data
@EqualsAndHashCode(callSuper = true)
+@JsonSerialize(using = AaiSerializer.class)
public class Aai extends BaseDynamicPropertiesProvider implements TcaFacadeModel {
private static final long serialVersionUID = 1L;
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/serializer/AaiSerializer.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/serializer/AaiSerializer.java
new file mode 100644
index 0000000..f21ea53
--- /dev/null
+++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/serializer/AaiSerializer.java
@@ -0,0 +1,68 @@
+/*
+ * ==================================================================================
+ * Copyright (C) 2021 Samsung Electronics Intellectual Property. All rights reserved.
+ * ==================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END===========================================================
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.serializer;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.onap.dcae.analytics.tca.model.facade.Aai;
+
+public class AaiSerializer extends StdSerializer<Aai> {
+
+ private static final String SERVER_NAME_KEY = "vserver.vserver-name";
+ private static final String VNF_NAME_KEY = "generic-vnf.vnf-name";
+
+ public AaiSerializer(){
+ this(Aai.class);
+ }
+
+ protected AaiSerializer(Class<Aai> t) {
+ super(t);
+ }
+
+ @Override
+ public void serialize(Aai aai, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
+ throws IOException {
+
+ jsonGenerator.writeStartObject();
+
+ List<String> filters = new ArrayList<>();
+ if (aai.getGenericVNFName() != null) {
+ serializerProvider.defaultSerializeField(VNF_NAME_KEY, aai.getGenericVNFName(), jsonGenerator);
+ filters.add(VNF_NAME_KEY);
+ }
+
+ if (aai.getGenericServerName() != null) {
+ serializerProvider.defaultSerializeField(SERVER_NAME_KEY, aai.getGenericServerName(), jsonGenerator);
+ filters.add(SERVER_NAME_KEY);
+ }
+
+ for (Map.Entry<String, Object> prop : aai.getDynamicProperties().entrySet()) {
+ if (!filters.contains(prop.getKey())) {
+ serializerProvider.defaultSerializeField(prop.getKey(), prop.getValue(), jsonGenerator);
+ }
+ }
+
+ jsonGenerator.writeEndObject();
+ }
+}