X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fdatarouter%2Fentity%2FSpikeAggregationEntity.java;h=bb528025652a4e8b11780621149ba364cb875873;hb=72da66902a3efaff3068ed2b3f4f7eb3bb5fe43f;hp=5aff3ce6d7107fe277ac40463fbd0c89d4eeb748;hpb=d46b0b9c3ce9ad5eca684ebeccb89f04d3cbcf6c;p=aai%2Fdata-router.git diff --git a/src/main/java/org/onap/aai/datarouter/entity/SpikeAggregationEntity.java b/src/main/java/org/onap/aai/datarouter/entity/SpikeAggregationEntity.java index 5aff3ce..bb52802 100644 --- a/src/main/java/org/onap/aai/datarouter/entity/SpikeAggregationEntity.java +++ b/src/main/java/org/onap/aai/datarouter/entity/SpikeAggregationEntity.java @@ -28,6 +28,7 @@ import java.util.Map.Entry; import org.onap.aai.datarouter.util.NodeUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -36,6 +37,13 @@ import com.fasterxml.jackson.databind.node.ObjectNode; * The Class SpikeAggregationEntity. Mimics functionality of SPIKEUI's AggregationEntity */ public class SpikeAggregationEntity implements DocumentStoreDataEntity, Serializable { + + private Map attributes = new HashMap<>(); + + @JsonIgnore + private ObjectMapper mapper = new ObjectMapper(); + + private String id; private String link; private String lastmodTimestamp; @@ -68,28 +76,23 @@ public class SpikeAggregationEntity implements DocumentStoreDataEntity, Serializ } - Map attributes = new HashMap<>(); - ObjectMapper mapper = new ObjectMapper(); /** * Instantiates a new aggregation entity. */ public SpikeAggregationEntity() {} - public void deriveFields(JsonNode uebPayload) { + public void deriveFields(JsonNode entityProperties) { this.setId(NodeUtils.generateUniqueShaDigest(link)); this.setLastmodTimestamp(Long.toString(System.currentTimeMillis())); - JsonNode entityNode = uebPayload.get("vertex").get("properties"); - Iterator> nodes = entityNode.fields(); + Iterator> nodes = entityProperties.fields(); while (nodes.hasNext()) { Map.Entry entry = (Map.Entry) nodes.next(); attributes.put(entry.getKey(), entry.getValue().asText()); } } - - @Override public String getAsJson() { ObjectNode rootNode = mapper.createObjectNode(); @@ -105,7 +108,12 @@ public class SpikeAggregationEntity implements DocumentStoreDataEntity, Serializ @Override public String toString() { - return "AggregationEntity [id=" + id + ", link=" + link + ", attributes=" + attributes - + ", mapper=" + mapper + "]"; + return "SpikeAggregationEntity [" + + (attributes != null ? "attributes=" + attributes + ", " : "") + + (id != null ? "id=" + id + ", " : "") + (link != null ? "link=" + link + ", " : "") + + (lastmodTimestamp != null ? "lastmodTimestamp=" + lastmodTimestamp : "") + "]"; } + + + }