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.core.JsonProcessingException;
29 import com.fasterxml.jackson.databind.ObjectMapper;
30 import com.fasterxml.jackson.databind.ObjectWriter;
32 import java.util.ArrayList;
33 import java.util.List;
36 * The Class D3VisualizationOutput.
38 public class D3VisualizationOutput {
40 public GraphMeta graphMeta;
41 public List<JsonNode> nodes;
42 public List<JsonNodeLink> links;
43 public InlineMessage inlineMessage;
46 * Instantiates a new d 3 visualization output.
48 public D3VisualizationOutput() {
49 nodes = new ArrayList<JsonNode>();
50 links = new ArrayList<JsonNodeLink>();
54 public GraphMeta getGraphMeta() {
61 * @param counterName the counter name
63 public void pegCounter(String counterName) {
64 graphMeta.pegCounter(counterName);
67 public void setGraphMeta(GraphMeta graphMeta) {
68 this.graphMeta = graphMeta;
74 * @param nodes the nodes
76 public void addNodes(List<JsonNode> nodes) {
77 this.nodes.addAll(nodes);
83 * @param links the links
85 public void addLinks(List<JsonNodeLink> links) {
86 this.links.addAll(links);
89 public InlineMessage getInlineMessage() {
93 public void setInlineMessage(InlineMessage inlineMessage) {
94 this.inlineMessage = inlineMessage;
100 * @param args the arguments
101 * @throws JsonProcessingException the json processing exception
103 public static final void main(String[] args) throws JsonProcessingException {
105 ActiveInventoryNode pserverAin = new ActiveInventoryNode();
106 pserverAin.setNodeId("pserver.76786asd87asgd");
107 JsonNode pserver = new JsonNode(pserverAin);
109 List<JsonNode> nodes = new ArrayList<JsonNode>();
112 JsonNodeLink l1 = new JsonNodeLink();
113 l1.setSource(pserverAin.getNodeId());
114 l1.setTarget(pserverAin.getNodeId());
115 l1.setId(l1.getSource() + "_" + l1.getTarget());
117 List<JsonNodeLink> links = new ArrayList<JsonNodeLink>();
120 D3VisualizationOutput output = new D3VisualizationOutput();
121 output.addNodes(nodes);
122 output.addLinks(links);
125 ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
126 String json = ow.writeValueAsString(output);
128 System.out.println(json);