summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authork.kedron <k.kedron@partner.samsung.com>2021-08-04 11:27:51 +0200
committerVijay Venkatesh Kumar <vv770d@att.com>2021-08-06 13:09:06 +0000
commitb99c434d9f33399eb552759a3482c03fe14ab753 (patch)
tree4038e866598ccaadb57143fa2fc939886c77d046
parent52854e6b0c51124a10e57f689b083745bec8fe04 (diff)
Add AaiSerializer1.2.2
To prevent the duplication entry Issue-ID: DCAEGEN2-2878 Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com> Change-Id: I139b33a138f2e7e37eee10dfbbc48dc9b65eefe5 (cherry picked from commit 86e553e419232b59b4853fe52963011c53de5bb3)
-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();
+ }
+}