aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Paroulek <pavel.paroulek@orange.com>2019-08-16 16:23:43 +0200
committerPavel Paroulek <pavel.paroulek@orange.com>2019-08-16 16:23:43 +0200
commit27cf4637958855cb2c5f7fe092fe7fee60b5dbf2 (patch)
tree76a9a07fbd1b6ef658b3c659e41ca22442b43fd1
parentaaa166d1fd35fa712f20623a12ecb088fb9051bf (diff)
Adding directionality and aai-keystore fix
Adding directionality of associations based on an edgerules property and enabling GrapGraph to be started locally without needing to copy keystore information for local use Change-Id: I8fe2523cb6a9c23806647d2da23998172d6d7296 Signed-off-by: Pavel Paroulek <pavel.paroulek@orange.com> Issue-ID: AAI-531
-rw-r--r--README.md19
-rw-r--r--pom.xml10
-rw-r--r--src/main/java/org/onap/aai/graphgraph/App.java28
-rw-r--r--src/main/java/org/onap/aai/graphgraph/ArgumentParser.java24
-rw-r--r--src/main/java/org/onap/aai/graphgraph/ModelExporter.java39
-rw-r--r--src/main/resources/application.properties2
6 files changed, 103 insertions, 19 deletions
diff --git a/README.md b/README.md
index 9cfa65c..3251be3 100644
--- a/README.md
+++ b/README.md
@@ -10,13 +10,26 @@ GraphGraph is a tool for viewing A&AI schemas.
To start the frontend just run the following command:
-### `cd ./graphgraph-fe && npm install && npm start
+### `cd ./graphgraph-fe && npm install && npm start`
-Then go to http://localhost:3000
+The UI will be available on http://localhost:3000
In order to start the webservices run the App.java from your Java IDE (the service runs on localhost port 8080).
## Building docker images
+### `mvn clean install -Pdocker`
-### `mvn clean install -Pdocker
+## Running GraphGraph locally
+
+You have to start a local instance (i.e. localhost) of schema-service. Afterwards build the GraphGraph JAR file with:
+
+### `mvn clean install`
+
+Go into the target directory and run the JAR file with -d switch:
+
+### `java -jar graphgraph-X.Y.jar -d`
+
+where X.Y is the current version. For more options run the help via:
+
+### `java -jar graphgraph-X.Y.jar -h` \ No newline at end of file
diff --git a/pom.xml b/pom.xml
index d360960..dd2eae1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -162,6 +162,16 @@
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
+ <excludes>
+ <exclude>etc/auth/aai_keystore</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>etc/auth/aai_keystore</include>
+ </includes>
</resource>
</resources>
<plugins>
diff --git a/src/main/java/org/onap/aai/graphgraph/App.java b/src/main/java/org/onap/aai/graphgraph/App.java
index 33172ca..58e0d66 100644
--- a/src/main/java/org/onap/aai/graphgraph/App.java
+++ b/src/main/java/org/onap/aai/graphgraph/App.java
@@ -21,8 +21,14 @@ package org.onap.aai.graphgraph;
import static org.onap.aai.graphgraph.ModelExporter.exportModel;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
+import org.apache.commons.io.FileUtils;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.introspection.MoxyLoader;
import org.onap.aai.nodes.NodeIngestor;
@@ -48,9 +54,20 @@ public class App{
}
}
- public static void main( String[] args ) {
+ public static void main( String[] args ) throws IOException {
ArgumentParser parser = new ArgumentParser().parseArguments(args);
+
+ if (parser.isPrintHelp()){
+ parser.printHelp();
+ return;
+ }
+
SpringApplication app = new SpringApplication(App.class);
+
+ if (parser.isRunLocally()){
+ copyKeystore(app);
+ }
+
app.addInitializers(new PropertyPasswordConfiguration());
ConfigurableApplicationContext context = app.run(args);
loadSchemes(context);
@@ -61,4 +78,13 @@ public class App{
System.exit(0);
}
}
+
+ private static void copyKeystore(SpringApplication app) throws IOException {
+ Path path = Paths.get("etc/auth/aai_keystore");
+ if (Files.notExists(path)) {
+ FileUtils.copyInputStreamToFile(Objects
+ .requireNonNull(app.getClassLoader().getResourceAsStream("etc/auth/aai_keystore")),
+ path.toFile());
+ }
+ }
}
diff --git a/src/main/java/org/onap/aai/graphgraph/ArgumentParser.java b/src/main/java/org/onap/aai/graphgraph/ArgumentParser.java
index 4940a25..4405723 100644
--- a/src/main/java/org/onap/aai/graphgraph/ArgumentParser.java
+++ b/src/main/java/org/onap/aai/graphgraph/ArgumentParser.java
@@ -24,11 +24,19 @@ import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
public class ArgumentParser {
- @Option(name = "-g", usage = "schema to be generated", metaVar = "schema")
+ @Option(name = "-g", usage = "generates schema model for Papyrus and exits where XY is the version", metaVar = "vXY")
private String schemaVersion;
+ @Option(name = "-d", usage = "connect to dev version of schema-service (use JAR bundled keystore)")
+ private boolean runLocally;
+
+ @Option(name = "-h", usage = "print help and exit")
+ private boolean printHelp;
+
+ CmdLineParser parser;
+
public ArgumentParser parseArguments(String [] args){
- CmdLineParser parser = new CmdLineParser(this);
+ parser = new CmdLineParser(this);
try {
parser.parseArgument(args);
@@ -51,4 +59,16 @@ public class ArgumentParser {
public boolean shoudGenerateUml(){
return schemaVersion != null;
}
+
+ public boolean isRunLocally() {
+ return runLocally;
+ }
+
+ public boolean isPrintHelp() {
+ return printHelp;
+ }
+
+ public void printHelp(){
+ parser.printUsage(System.out);
+ }
}
diff --git a/src/main/java/org/onap/aai/graphgraph/ModelExporter.java b/src/main/java/org/onap/aai/graphgraph/ModelExporter.java
index 0410250..3180c4c 100644
--- a/src/main/java/org/onap/aai/graphgraph/ModelExporter.java
+++ b/src/main/java/org/onap/aai/graphgraph/ModelExporter.java
@@ -24,7 +24,6 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -151,17 +150,33 @@ public class ModelExporter {
private static Set<VelocityAssociation> createVelocityAssociations(Set<VelocityEntity> entities,
Multimap<String, EdgeRule> edgeRules) {
- Set<VelocityAssociation> result = new HashSet<>();
- result.addAll(edgeRules.values().stream().map(er ->
- new VelocityAssociation(
- findVelocityEntity(er.getFrom(), entities),
- findVelocityEntity(er.getTo(), entities),
- String.format("%s - %s (label: %s)", er.getFrom(), er.getTo(), er.getLabel()),
- er.getMultiplicityRule().name(),
- er.getLabel().equals("org.onap.relationships.inventory.BelongsTo")
- )).collect(Collectors.toSet()));
-
- return result;
+ return edgeRules.values().stream().flatMap(er -> {
+ VelocityAssociation out = createVelocityAssociation(entities, er.getFrom(), er.getTo(),
+ er.getLabel(), er.getMultiplicityRule().name());
+ VelocityAssociation in = createVelocityAssociation(entities, er.getTo(), er.getFrom(),
+ er.getLabel(), er.getMultiplicityRule().name());
+ switch (er.getDirection()) {
+ case OUT:
+ return Stream.of(out);
+ case IN:
+ return Stream.of(in);
+ case BOTH:
+ return Stream.of(out, in);
+ default:
+ return null;
+ }
+ }).collect(Collectors.toSet());
+ }
+
+ private static VelocityAssociation createVelocityAssociation(Set<VelocityEntity> entities,
+ String from, String to, String label, String multiplicity) {
+ return new VelocityAssociation(
+ findVelocityEntity(from, entities),
+ findVelocityEntity(to, entities),
+ String.format("%s - %s (label: %s)", from, to, label),
+ multiplicity,
+ label.equals("org.onap.relationships.inventory.BelongsTo")
+ );
}
private static VelocityEntity findVelocityEntity(String from, Set<VelocityEntity> entities) {
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 060041a..9094f48 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -7,7 +7,7 @@ schema.source.name=onap
schema.nodes.location=${server.local.startpath}/schema/${schema.source.name}/oxm/
schema.edges.location=${server.local.startpath}/schema/${schema.source.name}/dbedgerules/
-server.local.startpath=${graphgraph.startpath}
+server.local.startpath=${graphgraph.startpath:./}
schema.ingest.file=${server.local.startpath}/application.properties
# Schema Version Related Attributes