aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorPavel Paroulek <pavel.paroulek@orange.com>2019-05-24 15:39:49 +0200
committerPavel Paroulek <pavel.paroulek@orange.com>2019-05-24 17:02:53 +0200
commite22629636b27a473f7950d7b684c7017d01f6298 (patch)
treea0403231ec49553758c6a5e66987ac89cc8bdd9d /src/main
parent2dd4055f8fcfd3b003907645d44ee2f0e2d2803e (diff)
Adding property table and layout
Adding a new property table, reading new entity properties, improving layout, distribution configuration changes Change-Id: I59d5ce7f2facd12c23103c275a921ad25c77ed38 Issue-ID: AAI-531 Signed-off-by: Pavel Paroulek <pavel.paroulek@orange.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/aai/graphgraph/SchemaResource.java8
-rw-r--r--src/main/java/org/onap/aai/graphgraph/dto/Graph.java8
-rw-r--r--src/main/java/org/onap/aai/graphgraph/dto/NodeName.java7
-rw-r--r--src/main/java/org/onap/aai/graphgraph/dto/NodeProperty.java83
-rw-r--r--src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java46
-rw-r--r--src/main/java/org/onap/aai/graphgraph/reader/SchemaReader.java5
6 files changed, 125 insertions, 32 deletions
diff --git a/src/main/java/org/onap/aai/graphgraph/SchemaResource.java b/src/main/java/org/onap/aai/graphgraph/SchemaResource.java
index af98289..52c7510 100644
--- a/src/main/java/org/onap/aai/graphgraph/SchemaResource.java
+++ b/src/main/java/org/onap/aai/graphgraph/SchemaResource.java
@@ -21,6 +21,7 @@ package org.onap.aai.graphgraph;
import org.onap.aai.graphgraph.dto.Graph;
import org.onap.aai.graphgraph.dto.NodeName;
+import org.onap.aai.graphgraph.dto.NodeProperty;
import org.onap.aai.graphgraph.dto.Property;
import org.onap.aai.graphgraph.reader.SchemaRepository;
import org.springframework.web.bind.annotation.PathVariable;
@@ -45,12 +46,13 @@ public class SchemaResource {
@RequestMapping("/schemas/{schema}/nodes")
- public List<NodeName> loadVertexNames(@PathVariable("schema") String schemaName) {
- return repository.getSchemaReader(schemaName).getAllVertexNames();
+ public List<NodeName> loadVertexNames(@PathVariable("schema") String schemaName,
+ @RequestParam("edgeFilter") String edgeFilter) {
+ return repository.getSchemaReader(schemaName).getAllVertexNames(edgeFilter);
}
@RequestMapping("/schemas/{schema}/nodes/{node}")
- public List<Property> loadProperties(@PathVariable("schema") String schemaName, @PathVariable("node") String node) {
+ public List<NodeProperty> loadProperties(@PathVariable("schema") String schemaName, @PathVariable("node") String node) {
return repository.getSchemaReader(schemaName).getVertexProperties(node);
}
diff --git a/src/main/java/org/onap/aai/graphgraph/dto/Graph.java b/src/main/java/org/onap/aai/graphgraph/dto/Graph.java
index 0d08e9d..55236ee 100644
--- a/src/main/java/org/onap/aai/graphgraph/dto/Graph.java
+++ b/src/main/java/org/onap/aai/graphgraph/dto/Graph.java
@@ -7,9 +7,9 @@ public class Graph {
private List<NodeName> nodeNames;
private List<Edge> edges;
private List<List<NodeName>> paths;
- private List <Property> startNodeProperties;
+ private List<NodeProperty> startNodeProperties;
- public Graph(List<NodeName> nodeNames, List<Edge> edges, List<List<NodeName>> pathsList, List <Property> startNodeProperties) {
+ public Graph(List<NodeName> nodeNames, List<Edge> edges, List<List<NodeName>> pathsList, List<NodeProperty> startNodeProperties) {
this.nodeNames = nodeNames;
this.edges = edges;
this.paths = pathsList;
@@ -21,11 +21,11 @@ public class Graph {
Collections.emptyList());
}
- public List<Property> getStartNodeProperties() {
+ public List<NodeProperty> getStartNodeProperties() {
return startNodeProperties;
}
- public void setStartNodeProperties(List<Property> startNodeProperties) {
+ public void setStartNodeProperties(List<NodeProperty> startNodeProperties) {
this.startNodeProperties = startNodeProperties;
}
diff --git a/src/main/java/org/onap/aai/graphgraph/dto/NodeName.java b/src/main/java/org/onap/aai/graphgraph/dto/NodeName.java
index b003c84..c920ccf 100644
--- a/src/main/java/org/onap/aai/graphgraph/dto/NodeName.java
+++ b/src/main/java/org/onap/aai/graphgraph/dto/NodeName.java
@@ -34,4 +34,11 @@ public class NodeName {
public int hashCode() {
return id.hashCode();
}
+
+ @Override
+ public String toString() {
+ return "NodeName{" +
+ "id='" + id + '\'' +
+ '}';
+ }
}
diff --git a/src/main/java/org/onap/aai/graphgraph/dto/NodeProperty.java b/src/main/java/org/onap/aai/graphgraph/dto/NodeProperty.java
new file mode 100644
index 0000000..5f45a05
--- /dev/null
+++ b/src/main/java/org/onap/aai/graphgraph/dto/NodeProperty.java
@@ -0,0 +1,83 @@
+package org.onap.aai.graphgraph.dto;
+
+public class NodeProperty extends Property {
+ private String description;
+ private String type;
+ private boolean key;
+ private boolean index;
+ private boolean required;
+
+ public NodeProperty(String propertyName,
+ String description, String type, boolean key, boolean index, boolean required) {
+ super(propertyName, "");
+ this.description = description;
+ this.type = type;
+ this.key = key;
+ this.index = index;
+ this.required = required;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public boolean getKey() {
+ return key;
+ }
+
+ public void setKey(boolean key) {
+ this.key = key;
+ }
+
+ public boolean getIndex() {
+ return index;
+ }
+
+ public void setIndex(boolean index) {
+ this.index = index;
+ }
+
+ public boolean getRequired() {
+ return required;
+ }
+
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ NodeProperty property = (NodeProperty) o;
+
+ return getPropertyName().equals(property.getPropertyName());
+ }
+
+ @Override
+ public int hashCode() {
+ return getPropertyName().hashCode();
+ }
+
+ @Override
+ public int compareTo(Property o) {
+ return o.getPropertyName().compareTo(getPropertyName());
+ }
+}
diff --git a/src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java b/src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java
index aef091c..1367aeb 100644
--- a/src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java
+++ b/src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java
@@ -20,7 +20,7 @@
package org.onap.aai.graphgraph.reader;
import com.google.common.collect.Multimap;
-import java.util.AbstractMap;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -32,7 +32,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import org.jgrapht.Graph;
import org.jgrapht.GraphPath;
import org.jgrapht.alg.shortestpath.FloydWarshallShortestPaths;
@@ -43,8 +42,10 @@ import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.graphgraph.App;
import org.onap.aai.graphgraph.dto.Edge;
import org.onap.aai.graphgraph.dto.NodeName;
+import org.onap.aai.graphgraph.dto.NodeProperty;
import org.onap.aai.graphgraph.dto.Property;
import org.onap.aai.introspection.Introspector;
+import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.setup.SchemaVersion;
public class BasicSchemaReader implements SchemaReader {
@@ -135,44 +136,43 @@ public class BasicSchemaReader implements SchemaReader {
}
@Override
- public List<NodeName> getAllVertexNames() {
+ public List<NodeName> getAllVertexNames(String edgeFilter) {
init();
- return allEntities.keySet().stream().sorted()
+ return createGraph(isParentChildFilter(edgeFilter), isEdgeRulesFilter(edgeFilter))
+ .edgeSet().stream().flatMap(e -> Arrays.asList(e.getSource(), e.getTarget()).stream())
+ .sorted()
+ .distinct()
.map(NodeName::new).collect(
Collectors.toList());
}
@Override
- public List<Property> getVertexProperties(String nodeName) {
+ public List<NodeProperty> getVertexProperties(String nodeName) {
init();
if (!allEntities.containsKey(nodeName)) {
return Collections.emptyList();
}
- Stream<Map.Entry<String, String>> incoming = graph.incomingEdgesOf(nodeName).stream()
- .filter(e -> e.getType().equals(EdgeType.EDGE_RULE.getTypeName()))
- .map(e -> new AbstractMap.SimpleEntry<>(e.getTarget(), e.getLabel()));
- Stream<Map.Entry<String, String>> outgoing = graph.outgoingEdgesOf(nodeName).stream()
- .map(e -> new AbstractMap.SimpleEntry<>(e.getSource(), e.getLabel()));
-
- List<Property> neighbours = Stream.concat(incoming, outgoing)
- .map(t -> new Property(
- String.format("This node is in relationship %s to node %s", t.getValue(), t.getKey()),
- String.format("%s/%s", t.getValue(), t.getKey())))
- .distinct()
- .sorted()
- .collect(Collectors.toList());
-
- List<Property> properties = allEntities.get(nodeName).getProperties().stream()
+ Introspector introspector = allEntities.get(nodeName);
+ List<String> properties = introspector.getProperties().stream()
.filter(p -> !allEntities.containsKey(p))
- .map(p -> new Property(p, ""))
.sorted()
.collect(Collectors.toList());
- properties.addAll(neighbours);
- return properties;
+ List<NodeProperty> result = properties.stream().map( p ->
+ new NodeProperty(
+ p,
+ introspector.getPropertyMetadata(p)
+ .getOrDefault(PropertyMetadata.DESCRIPTION,"no description available"),
+ "I dont know", //TODO how to get this information????
+ introspector.getAllKeys().contains(p),
+ introspector.getIndexedProperties().contains(p),
+ introspector.getRequiredProperties().contains(p))
+ ).collect(Collectors.toList());
+
+ return result;
}
@Override
diff --git a/src/main/java/org/onap/aai/graphgraph/reader/SchemaReader.java b/src/main/java/org/onap/aai/graphgraph/reader/SchemaReader.java
index 689a30d..a924e63 100644
--- a/src/main/java/org/onap/aai/graphgraph/reader/SchemaReader.java
+++ b/src/main/java/org/onap/aai/graphgraph/reader/SchemaReader.java
@@ -21,14 +21,15 @@ package org.onap.aai.graphgraph.reader;
import org.onap.aai.graphgraph.dto.Graph;
import org.onap.aai.graphgraph.dto.NodeName;
+import org.onap.aai.graphgraph.dto.NodeProperty;
import org.onap.aai.graphgraph.dto.Property;
import java.util.List;
public interface SchemaReader {
String getSchemaName();
- List<NodeName> getAllVertexNames();
- List<Property> getVertexProperties(String nodeName);
+ List<NodeName> getAllVertexNames(String edgeFilter);
+ List<NodeProperty> getVertexProperties(String nodeName);
List<Property> getEdgeProperties(String fromNode, String toNode, String type);
Graph getGraph(String initialNode, int parentHops, int cousinHops, int childHops,
String edgeFilter);