Enhance SchemaGenerator to also generate indices for relationships
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / dbmap / InMemoryGraph.java
index ac9407e..cca11c6 100644 (file)
@@ -20,9 +20,6 @@
 
 package org.onap.aai.dbmap;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -36,6 +33,8 @@ import org.janusgraph.core.schema.JanusGraphManagement;
 import org.onap.aai.dbgen.GraphSONPartialIO;
 import org.onap.aai.dbgen.SchemaGenerator;
 import org.onap.aai.logging.LogFormatTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class InMemoryGraph {
 
@@ -46,15 +45,14 @@ public class InMemoryGraph {
         /*
          * Create a In-memory graph
          */
-        try(InputStream is = new FileInputStream(builder.propertyFile)){
+        try (InputStream is = new FileInputStream(builder.propertyFile)) {
             graph = JanusGraphFactory.open(builder.propertyFile);
 
             Properties graphProps = new Properties();
             graphProps.load(is);
-            JanusGraphManagement graphMgt = graph.openManagement();
             if (builder.isSchemaEnabled) {
                 LOGGER.info("Schema Enabled");
-                SchemaGenerator.loadSchemaIntoJanusGraph(graphMgt, graphProps.getProperty("storage.backend"));
+                SchemaGenerator.loadSchemaIntoJanusGraph(graph, graphProps.getProperty("storage.backend"), false);
             }
             try (JanusGraphTransaction transaction = graph.newTransaction()) {
                 LOGGER.info("Loading snapshot");
@@ -63,7 +61,7 @@ public class InMemoryGraph {
                         transaction.io(GraphSONPartialIO.build()).readGraph(builder.graphsonLocation);
                     } else {
                         transaction.io(GraphSONPartialIO.build()).reader().create().readGraph(builder.seqInputStream,
-                            graph);
+                                graph);
                     }
                 } else {
                     if ((builder.graphsonLocation != null) && (builder.graphsonLocation.length() > 0)) {
@@ -76,7 +74,8 @@ public class InMemoryGraph {
             }
 
         } catch (Exception e) {
-            LOGGER.error(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s", LogFormatTools.getStackTop(e)));
+            LOGGER.error(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s",
+                    LogFormatTools.getStackTop(e)));
             throw new IllegalStateException("Could not load datasnapshot to in memory graph");
 
         }