2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 package org.openecomp.sparky.viewandinspect.entity;
28 import com.fasterxml.jackson.annotation.JsonIgnore;
30 import java.util.Collection;
31 import java.util.HashMap;
34 import org.apache.log4j.Logger;
37 * We can use annotations to differentiate between intermediate data we use to build the node, and
38 * the data that we actually want to appear in the exported JSON.
42 * This is our current ( 14-June-2016 ) working schema that will remain organic until we get it just
45 * { "item-type": "customer", "item-name-key": "subscriber-name", “item-name-value” :
46 * “subscriber-name-123456789-aai847-data-01”, "item-properties": [{ "property-name":
47 * "subscriber-name", "property-value": "subscriber-name-123456789-aai847-data-01" }, {
48 * "property-name": "global-customer-id", "property-value":
49 * "global-customer-id-123456789-aai847-data-01" } ], "node-meta": { “color” : “#f2d2d2”,
50 * "isSearchTarget" : false, "nodeGroups" : "1,2,3,4" }, }
58 public class JsonNode {
61 private String itemType;
62 private String itemNameKey;
63 private String itemNameValue;
64 private Map<String, String> itemProperties;
65 private NodeMeta nodeMeta;
68 private boolean isRootNode;
72 private String resourceKey;
74 private Collection<String> inboundNeighbors;
77 private Collection<String> outboundNeighbors;
81 private static final Logger LOG = Logger.getLogger(JsonNode.class);
84 * Instantiates a new json node.
88 public JsonNode(ActiveInventoryNode ain) {
89 this.resourceKey = ain.getNodeId();
90 this.itemProperties = ain.getProperties();
91 this.setItemType(ain.getEntityType());
92 this.setItemNameKey(ain.getPrimaryKeyName());
93 this.setItemNameValue(ain.getPrimaryKeyValue());
94 this.setId(ain.getNodeId());
95 this.isRootNode = ain.isRootNode();
97 if (LOG.isDebugEnabled()) {
99 LOG.debug("JsonNode constructor using AIN = " + ain.dumpNodeTree(true));
103 inboundNeighbors = ain.getInboundNeighbors();
104 outboundNeighbors = ain.getOutboundNeighbors();
106 nodeMeta = new NodeMeta();
108 nodeMeta.setNodeIssue(ain.isNodeIssue());
109 nodeMeta.setNodeDepth(ain.getNodeDepth());
111 nodeMeta.setNumInboundNeighbors(ain.getInboundNeighbors().size());
112 nodeMeta.setNumOutboundNeighbors(ain.getOutboundNeighbors().size());
114 nodeMeta.setAtMaxDepth(ain.isAtMaxDepth());
115 nodeMeta.setSelfLinkResolved(!ain.isSelflinkRetrievalFailure());
116 nodeMeta.setProcessingErrorOccurred(ain.isProcessingErrorOccurred());
117 nodeMeta.setHasNeighbors(
118 ain.getOutboundNeighbors().size() > 0 || ain.getInboundNeighbors().size() > 0);
119 nodeMeta.setProcessingState(ain.getState());
123 public String getId() {
127 public void setId(String id) {
131 public String getItemNameKey() {
135 public String getItemNameValue() {
136 return itemNameValue;
139 public Map<String, String> getItemProperties() {
140 return itemProperties;
143 public String getItemType() {
147 public String getResourceKey() {
151 public void setItemNameKey(String itemNameKey) {
152 this.itemNameKey = itemNameKey;
155 public void setItemNameValue(String itemNameValue) {
156 this.itemNameValue = itemNameValue;
159 public void setItemProperties(HashMap<String, String> itemProperties) {
160 this.itemProperties = itemProperties;
163 public void setItemType(String itemType) {
164 this.itemType = itemType;
167 public void setResourceKey(String resourceKey) {
168 this.resourceKey = resourceKey;
171 public NodeMeta getNodeMeta() {
175 public void setNodeMeta(NodeMeta nodeMeta) {
176 this.nodeMeta = nodeMeta;
179 public boolean isRootNode() {
184 public String toString() {
185 return "JsonNode [" + (id != null ? "id=" + id + ", " : "")
186 + (itemType != null ? "itemType=" + itemType + ", " : "")
187 + (itemNameKey != null ? "itemNameKey=" + itemNameKey + ", " : "")
188 + (itemNameValue != null ? "itemNameValue=" + itemNameValue + ", " : "")
189 + (itemProperties != null ? "itemProperties=" + itemProperties + ", " : "")
190 + (nodeMeta != null ? "nodeMeta=" + nodeMeta + ", " : "") + "isRootNode=" + isRootNode
191 + ", " + (resourceKey != null ? "resourceKey=" + resourceKey + ", " : "")
192 + (inboundNeighbors != null ? "inboundNeighbors=" + inboundNeighbors + ", " : "")
193 + (outboundNeighbors != null ? "outboundNeighbors=" + outboundNeighbors : "") + "]";