2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.onap.aai.sparky.viewandinspect.entity;
25 import com.fasterxml.jackson.annotation.JsonIgnore;
27 import java.util.Collection;
28 import java.util.HashMap;
31 import org.apache.log4j.Logger;
34 * We can use annotations to differentiate between intermediate data we use to build the node, and
35 * the data that we actually want to appear in the exported JSON.
39 * This is our current ( 14-June-2016 ) working schema that will remain organic until we get it just
42 * { "item-type": "customer", "item-name-key": "subscriber-name", “item-name-value” :
43 * “subscriber-name-123456789-aai847-data-01”, "item-properties": [{ "property-name":
44 * "subscriber-name", "property-value": "subscriber-name-123456789-aai847-data-01" }, {
45 * "property-name": "global-customer-id", "property-value":
46 * "global-customer-id-123456789-aai847-data-01" } ], "node-meta": { “color” : “#f2d2d2”,
47 * "isSearchTarget" : false, "nodeGroups" : "1,2,3,4" }, }
55 public class JsonNode {
58 private String itemType;
59 private String itemNameKey;
60 private String itemNameValue;
61 private Map<String, String> itemProperties;
62 private NodeMeta nodeMeta;
65 private boolean isRootNode;
69 private String resourceKey;
71 private Collection<String> inboundNeighbors;
74 private Collection<String> outboundNeighbors;
78 private static final Logger LOG = Logger.getLogger(JsonNode.class);
81 * Instantiates a new json node.
85 public JsonNode(ActiveInventoryNode ain) {
86 this.resourceKey = ain.getNodeId();
87 this.itemProperties = ain.getProperties();
88 this.setItemType(ain.getEntityType());
89 this.setItemNameKey(ain.getPrimaryKeyName());
90 this.setItemNameValue(ain.getPrimaryKeyValue());
91 this.setId(ain.getNodeId());
92 this.isRootNode = ain.isRootNode();
94 if (LOG.isDebugEnabled()) {
96 LOG.debug("JsonNode constructor using AIN = " + ain.dumpNodeTree(true));
100 inboundNeighbors = ain.getInboundNeighbors();
101 outboundNeighbors = ain.getOutboundNeighbors();
103 nodeMeta = new NodeMeta();
105 nodeMeta.setNodeIssue(ain.isNodeIssue());
106 nodeMeta.setNodeDepth(ain.getNodeDepth());
108 nodeMeta.setNumInboundNeighbors(ain.getInboundNeighbors().size());
109 nodeMeta.setNumOutboundNeighbors(ain.getOutboundNeighbors().size());
111 nodeMeta.setAtMaxDepth(ain.isAtMaxDepth());
112 nodeMeta.setSelfLinkResolved(!ain.isSelflinkRetrievalFailure());
113 nodeMeta.setProcessingErrorOccurred(ain.isProcessingErrorOccurred());
114 nodeMeta.setHasNeighbors(
115 ain.getOutboundNeighbors().size() > 0 || ain.getInboundNeighbors().size() > 0);
116 nodeMeta.setProcessingState(ain.getState());
120 public String getId() {
124 public void setId(String id) {
128 public String getItemNameKey() {
132 public String getItemNameValue() {
133 return itemNameValue;
136 public Map<String, String> getItemProperties() {
137 return itemProperties;
140 public String getItemType() {
144 public String getResourceKey() {
148 public void setItemNameKey(String itemNameKey) {
149 this.itemNameKey = itemNameKey;
152 public void setItemNameValue(String itemNameValue) {
153 this.itemNameValue = itemNameValue;
156 public void setItemProperties(HashMap<String, String> itemProperties) {
157 this.itemProperties = itemProperties;
160 public void setItemType(String itemType) {
161 this.itemType = itemType;
164 public void setResourceKey(String resourceKey) {
165 this.resourceKey = resourceKey;
168 public NodeMeta getNodeMeta() {
172 public void setNodeMeta(NodeMeta nodeMeta) {
173 this.nodeMeta = nodeMeta;
176 public boolean isRootNode() {
181 public String toString() {
182 return "JsonNode [" + (id != null ? "id=" + id + ", " : "")
183 + (itemType != null ? "itemType=" + itemType + ", " : "")
184 + (itemNameKey != null ? "itemNameKey=" + itemNameKey + ", " : "")
185 + (itemNameValue != null ? "itemNameValue=" + itemNameValue + ", " : "")
186 + (itemProperties != null ? "itemProperties=" + itemProperties + ", " : "")
187 + (nodeMeta != null ? "nodeMeta=" + nodeMeta + ", " : "") + "isRootNode=" + isRootNode
188 + ", " + (resourceKey != null ? "resourceKey=" + resourceKey + ", " : "")
189 + (inboundNeighbors != null ? "inboundNeighbors=" + inboundNeighbors + ", " : "")
190 + (outboundNeighbors != null ? "outboundNeighbors=" + outboundNeighbors : "") + "]";