1 /*******************************************************************************
2 * Copyright (c) 2017 Politecnico di Torino and others.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Apache License, Version 2.0
6 * which accompanies this distribution, and is available at
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *******************************************************************************/
10 package it.polito.escape.verify.model;
12 import java.util.HashMap;
13 import java.util.HashSet;
17 import javax.xml.bind.annotation.XmlRootElement;
18 import javax.xml.bind.annotation.XmlTransient;
20 import com.fasterxml.jackson.annotation.JsonInclude;
21 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
22 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
24 import io.swagger.annotations.ApiModel;
25 import io.swagger.annotations.ApiModelProperty;
26 import it.polito.escape.verify.deserializer.GraphCustomDeserializer;
27 import it.polito.escape.verify.serializer.CustomMapSerializer;
29 @ApiModel(value = "Graph")
31 @JsonDeserialize(using = GraphCustomDeserializer.class)
32 @JsonInclude(JsonInclude.Include.NON_EMPTY)
35 @ApiModelProperty(required = false, hidden = true)
39 @ApiModelProperty(name = "nodes", notes = "Nodes", dataType = "List[it.polito.escape.verify.model.Node]")
40 private Map<Long, Node> nodes = new HashMap<Long, Node>();
42 @ApiModelProperty(required = false, hidden = true)
44 private Set<Link> links = new HashSet<Link>();
50 public Graph(long id) {
58 public void setId(long id) {
62 @JsonSerialize(using = CustomMapSerializer.class)
63 public Map<Long, Node> getNodes() {
67 public void setNodes(Map<Long, Node> nodes) {
72 public Set<Link> getLinks() {
76 public void setLinks(Set<Link> links) {
80 public void addLink(String url, String rel) {
81 Link link = new Link();
87 public Node searchNodeByName(String name) {
88 for (Node node : this.nodes.values()) {
89 if (node.getName().equals(name))
95 public int nodesWithName(String name) {
97 for (Node node : this.nodes.values()) {
98 if (node.getName().equals(name))