diff options
author | Pavel Paroulek <pavel.paroulek@orange.com> | 2019-05-24 15:39:49 +0200 |
---|---|---|
committer | Pavel Paroulek <pavel.paroulek@orange.com> | 2019-05-24 17:02:53 +0200 |
commit | e22629636b27a473f7950d7b684c7017d01f6298 (patch) | |
tree | a0403231ec49553758c6a5e66987ac89cc8bdd9d | |
parent | 2dd4055f8fcfd3b003907645d44ee2f0e2d2803e (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>
-rw-r--r-- | graphgraph-fe/package.json | 2 | ||||
-rw-r--r-- | graphgraph-fe/src/GraphInfoMenu.js | 56 | ||||
-rw-r--r-- | graphgraph-fe/src/GraphSettings.js | 16 | ||||
-rw-r--r-- | graphgraph-fe/src/GraphSettingsMenu.css | 6 | ||||
-rw-r--r-- | graphgraph-fe/src/GraphSettingsMenu.js | 11 | ||||
-rw-r--r-- | graphgraph-fe/src/requests.js | 4 | ||||
-rw-r--r-- | pom.xml | 75 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/graphgraph/SchemaResource.java | 8 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/graphgraph/dto/Graph.java | 8 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/graphgraph/dto/NodeName.java | 7 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/graphgraph/dto/NodeProperty.java | 83 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java | 46 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/graphgraph/reader/SchemaReader.java | 5 |
13 files changed, 247 insertions, 80 deletions
diff --git a/graphgraph-fe/package.json b/graphgraph-fe/package.json index 103d0b8..eaae97a 100644 --- a/graphgraph-fe/package.json +++ b/graphgraph-fe/package.json @@ -7,7 +7,7 @@ "d3": "5.7.0", "eslint-config-react-app": "3.0.6", "react": "^16.8.6", - "react-basic-table": "1.0.14", + "react-table": "6.10.0", "react-bootstrap": "0.32.4", "react-dom": "^16.8.6", "react-numeric-input": "2.2.3", diff --git a/graphgraph-fe/src/GraphInfoMenu.js b/graphgraph-fe/src/GraphInfoMenu.js index c22a504..3f21194 100644 --- a/graphgraph-fe/src/GraphInfoMenu.js +++ b/graphgraph-fe/src/GraphInfoMenu.js @@ -2,29 +2,12 @@ import React from 'react' import './GraphInfoMenu.css' import PathBreadCrumb from './PathBreadCrumb' import _ from 'underscore' -import ReactBasicTable from 'react-basic-table' - -var getRows = function (nodeProps) { - return _.map(nodeProps, path => { - return ( - [ - <span>{path.propertyName}</span>, - <span>{path.propertyValue}</span> - ] - ) - }) -} +import ReactTable from "react-table"; +import "react-table/react-table.css"; class GraphInfoMenu extends React.Component { constructor (props) { super(props) - this.basicTable = React.createRef() - } - - // ReactBasicTable does not reset pagination after - // changing data, we need to do it manually - componentDidUpdate (prevProps) { - this.basicTable.current.setPage(1) } render () { @@ -39,7 +22,40 @@ class GraphInfoMenu extends React.Component { {breadcrumbs} </div> <div className="kv-table datatable"> - <ReactBasicTable ref={this.basicTable} pageSize={3} rows={getRows(this.props.nodeProperties)} columns={['Property Name', 'Value']} /> + <ReactTable pageSizeOptions={[4, 25]} data={this.props.nodeProperties} + columns={[ + { + Header: "Attribute", + accessor: "propertyName", + minWidth: 50 + }, + { + Header: "Description", + accessor: "description", + minWidth: 300 + }, + { + id: "Key", + Header: "Key", + accessor: p => p.key ? "yes" : "", + minWidth: 30 + }, + { + id: "Index", + Header: "Index", + accessor: p => p.index ? "yes" : "", + minWidth: 30 + }, + { + id: "Required", + Header: "Required", + accessor: p => p.required ? "yes" : "", + minWidth: 30 + } + ]} + defaultPageSize={4} + className="-striped -highlight" + /> </div> </div> ) diff --git a/graphgraph-fe/src/GraphSettings.js b/graphgraph-fe/src/GraphSettings.js index 54e2f4c..0c036db 100644 --- a/graphgraph-fe/src/GraphSettings.js +++ b/graphgraph-fe/src/GraphSettings.js @@ -44,6 +44,9 @@ class GraphSettings extends React.Component { loadInitialGraph (startNode, endNode, parentHops, cousinHops, childHops, edgeFilter) { if (this.state.selectedSchema === '' || startNode === 'none') { + var s = this.state + s['edgeFilter'] = edgeFilter + this.setState(s) return } if (startNode === 'all') { @@ -71,7 +74,7 @@ class GraphSettings extends React.Component { s['toNode'] = endNode s['graph'] = g s['edgeFilter'] = edgeFilter - s['showHops'] = endNode === 'none' && startNode !== 'none' && startNode !== 'all' + s['showHops'] = endNode === 'none' && startNode !== 'none' && startNode !== 'all' && edgeFilter !== 'Edgerules' s['enableDestinationNode'] = startNode !== 'none' && startNode !== 'all' this.setState(s) @@ -84,7 +87,7 @@ class GraphSettings extends React.Component { selectSchema (schema) { var s = this.state s['selectedSchema'] = schema - fetch(nodeNames(schema)) + fetch(nodeNames(schema, s['edgeFilter'])) .then(response => response.json()) .then(nodeNames => { s['fromNode'] = s['toNode'] = 'none' @@ -94,6 +97,15 @@ class GraphSettings extends React.Component { } changeEdgeFilter (edgeFilter) { + fetch(nodeNames(this.state.selectedSchema, edgeFilter)) + .then(response => response.json()) + .then(nodeNames => { + let s = this.state + s['edgeFilter'] = edgeFilter + s['fromNode'] = s['toNode'] = 'none' + s['nodeNames'] = nodeNames + this.setState(s) + }) this.loadInitialGraph( this.state.fromNode, this.state.toNode, diff --git a/graphgraph-fe/src/GraphSettingsMenu.css b/graphgraph-fe/src/GraphSettingsMenu.css index 3288e62..466d07d 100644 --- a/graphgraph-fe/src/GraphSettingsMenu.css +++ b/graphgraph-fe/src/GraphSettingsMenu.css @@ -3,4 +3,10 @@ margin-bottom: 0px; } +.navbar-adjust .container { +margin-left: 0; +} +.navbar-adjust .container .navbar-header { +margin-right: 250px; +} diff --git a/graphgraph-fe/src/GraphSettingsMenu.js b/graphgraph-fe/src/GraphSettingsMenu.js index d1b31ba..819537d 100644 --- a/graphgraph-fe/src/GraphSettingsMenu.js +++ b/graphgraph-fe/src/GraphSettingsMenu.js @@ -1,6 +1,6 @@ import React from 'react' import GraphSettings from './GraphSettings' -import { Navbar, FormGroup } from 'react-bootstrap' +import { Navbar, FormGroup, Nav } from 'react-bootstrap' import './GraphSettingsMenu.css' class GraphSettingsMenu extends React.Component { @@ -11,15 +11,12 @@ class GraphSettingsMenu extends React.Component { <Navbar.Brand> <a href="https://gerrit.onap.org/r/gitweb?p=aai/graphgraph.git">GraphGraph</a> </Navbar.Brand> - <Navbar.Toggle /> </Navbar.Header> - <Navbar.Collapse> - <Navbar.Form pullLeft> - <FormGroup> + <Nav className="mr-auto"> + <Navbar.Collapse className='mr-sm-2'> <GraphSettings selectedNode={this.props.selectedNode} graphData={this.props.graphData} nodePropsLoader={this.props.nodePropsLoader} /> - </FormGroup>{' '} - </Navbar.Form> </Navbar.Collapse> +</Nav> </Navbar>) } } diff --git a/graphgraph-fe/src/requests.js b/graphgraph-fe/src/requests.js index a468d35..7155ea7 100644 --- a/graphgraph-fe/src/requests.js +++ b/graphgraph-fe/src/requests.js @@ -3,8 +3,8 @@ export function schemas () { return 'http://localhost:8080/schemas' } -export function nodeNames (schema) { - return `http://localhost:8080/schemas/${schema}/nodes` +export function nodeNames (schema, edgeFilter) { + return `http://localhost:8080/schemas/${schema}/nodes?edgeFilter=${edgeFilter}` } export function basicGraph (schema, node, parentHops, cousinHops, childHops, edgeFilter) { @@ -150,6 +150,17 @@ </resources> <plugins> <plugin> + <groupId>org.sonatype.plugins</groupId> + <artifactId>nexus-staging-maven-plugin</artifactId> + <version>1.6.7</version> + <extensions>true</extensions> + <configuration> + <nexusUrl>${nexusproxy}</nexusUrl> + <stagingProfileId>176c31dfe190a</stagingProfileId> + <serverId>ecomp-staging</serverId> + </configuration> + </plugin> + <plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <version>1.7.6</version> @@ -225,20 +236,52 @@ </plugin> </plugins> </build> - <distributionManagement> - <repository> - <id>ecomp-releases</id> - <name>ECOMP Release Repository</name> - <url>${nexusproxy}${release.path}</url> - </repository> - <snapshotRepository> - <id>ecomp-snapshots</id> - <name>ECOMP Snapshot Repository</name> - <url>${nexusproxy}${snapshot.path}</url> - </snapshotRepository> - <site> - <id>ecomp-site</id> - <url>dav:${nexusproxy}${site.path}</url> - </site> - </distributionManagement> + <!-- Start of ONAP Specific Repositories --> + <repositories> + <repository> + <id>AJSC</id> + <name>AJSC repository</name> + <url>https://mvnrepository.com/artifact/com.att.ajsc</url> + </repository> + <repository> + <id>restlet</id> + <name>maven reslet</name> + <url>https://maven.restlet.com/</url> + </repository> + + <repository> + <id>central</id> + <name>Maven 2 repository 2</name> + <url>http://repo2.maven.org/maven2/</url> + </repository> + <repository> + <id>ecomp-releases</id> + <name>ECOMP Release Repository</name> + <url>${onap.nexus.url}/content/repositories/releases/</url> + </repository> + <repository> + <id>ecomp-staging</id> + <name>ECOMP Staging Repository</name> + <url>${onap.nexus.url}/content/repositories/staging/</url> + </repository> + <repository> + <id>ecomp-snapshots</id> + <name>ECOMP Snapshot Repository</name> + <url>${onap.nexus.url}/content/repositories/snapshots/</url> + </repository> + </repositories> + <!-- End of ONAP Specific Repositories --> + + <distributionManagement> + <snapshotRepository> + <id>ecomp-snapshots</id> + <name>ECOMP Snapshot Repository</name> + <url>${onap.nexus.url}/content/repositories/snapshots/</url> + </snapshotRepository> + <site> + <id>ecomp-site</id> + <url>dav:${onap.nexus.url}${sitePath}</url> + </site> + </distributionManagement> + </project> 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); |