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;
* The Class SpikeAggregationEntity. Mimics functionality of SPIKEUI's AggregationEntity
*/
public class SpikeAggregationEntity implements DocumentStoreDataEntity, Serializable {
+
+ private Map<String, String> attributes = new HashMap<>();
+
+ @JsonIgnore
+ private ObjectMapper mapper = new ObjectMapper();
+
+
private String id;
private String link;
private String lastmodTimestamp;
}
- Map<String, String> 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<Entry<String, JsonNode>> nodes = entityNode.fields();
+ Iterator<Entry<String, JsonNode>> nodes = entityProperties.fields();
while (nodes.hasNext()) {
Map.Entry<String, JsonNode> entry = (Map.Entry<String, JsonNode>) nodes.next();
attributes.put(entry.getKey(), entry.getValue().asText());
}
}
-
-
@Override
public String getAsJson() {
ObjectNode rootNode = mapper.createObjectNode();
@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 : "") + "]";
}
+
+
+
}