X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fdatarouter%2Fentity%2FAggregationEntity.java;h=e6cad7d7d2a4d4834e6af0993d490733003df260;hb=0f03ce7eea220df68d84a7f0f088a38ebb088039;hp=44927eb36dbe7f153c2b2fa201b640e03f6391a1;hpb=da309841ad25ab47537a6d2de00cd98bd113392c;p=aai%2Fdata-router.git diff --git a/src/main/java/org/onap/aai/datarouter/entity/AggregationEntity.java b/src/main/java/org/onap/aai/datarouter/entity/AggregationEntity.java index 44927eb..e6cad7d 100644 --- a/src/main/java/org/onap/aai/datarouter/entity/AggregationEntity.java +++ b/src/main/java/org/onap/aai/datarouter/entity/AggregationEntity.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017 Amdocs + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ package org.onap.aai.datarouter.entity; @@ -29,7 +27,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; -import org.openecomp.datarouter.util.NodeUtils; +import org.onap.aai.datarouter.util.NodeUtils; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -49,6 +47,8 @@ public class AggregationEntity implements DocumentStoreDataEntity, Serializable public void setLink(String link) { this.link = link; } + + @Override public String getId() { // make sure that deliveFields() is called before getting the id return id; @@ -66,7 +66,7 @@ public class AggregationEntity implements DocumentStoreDataEntity, Serializable } - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); /** @@ -86,30 +86,34 @@ public class AggregationEntity implements DocumentStoreDataEntity, Serializable while (nodes.hasNext()) { Map.Entry entry = (Map.Entry) nodes.next(); - if (!entry.getKey().equalsIgnoreCase("relationship-list")){ + if (!"relationship-list".equalsIgnoreCase(entry.getKey())){ attributes.put(entry.getKey(), entry.getValue().asText()); } } } public void copyAttributeKeyValuePair(Map map){ - for(String key: map.keySet()){ - if (!key.equalsIgnoreCase("relationship-list")){ // ignore relationship data which is not required in aggregation - this.attributes.put(key, map.get(key).toString()); // not sure if entity attribute can contain an object as value + for(Map.Entry entry: map.entrySet()){ + String key = entry.getKey(); + Object value = entry.getValue(); + if (!"relationship-list".equalsIgnoreCase(key)){ // ignore relationship data which is not required in aggregation + this.attributes.put(key, value.toString()); // not sure if entity attribute can contain an object as value } } } - + public void addAttributeKeyValuePair(String key, String value){ this.attributes.put(key, value); } - + @Override public String getAsJson() { ObjectNode rootNode = mapper.createObjectNode(); rootNode.put("link", this.getLink()); rootNode.put("lastmodTimestamp", lastmodTimestamp); - for (String key: this.attributes.keySet()){ - rootNode.put(key, this.attributes.get(key)); + for (Map.Entry entry: this.attributes.entrySet()){ + String key = entry.getKey(); + String value = entry.getValue(); + rootNode.put(key, value); } return rootNode.toString(); }