Update janusgraph to 0.3.3
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / dbmap / AAIGraph.java
index 62ac4f0..15f57c1 100644 (file)
@@ -58,8 +58,6 @@ public class AAIGraph {
     protected JanusGraph graph;
     private static boolean isInit = false;
 
-
-
     /**
      * Instantiates a new AAI graph.
      */
@@ -72,6 +70,7 @@ public class AAIGraph {
             }
             this.loadGraph(rtConfig, serviceName);
         } catch (Exception e) {
+            logger.error("Failed to instantiate graph", e);
             throw new RuntimeException("Failed to instantiate graphs", e);
         }
     }
@@ -139,7 +138,8 @@ public class AAIGraph {
                     transaction.tx().commit();
                     logger.info("Snapshot loaded to inmemory graph.");
                 } catch (Exception e) {
-                    logger.info(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s", ExceptionUtils.getStackTrace(e)));
+                    logger.info(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s",
+                            ExceptionUtils.getStackTrace(e)));
                     throw new RuntimeException(e);
                 }
             }
@@ -148,13 +148,14 @@ public class AAIGraph {
 
     private void loadSchema(JanusGraph graph) {
         // Load the propertyKeys, indexes and edge-Labels into the DB
-        JanusGraphManagement graphMgt = graph.openManagement();
-
+        boolean dbNotEmpty = graph.traversal().V().limit(1).hasNext();
         logger.info("-- loading schema into JanusGraph");
-        if ("true".equals(SpringContextAware.getApplicationContext().getEnvironment().getProperty("history.enabled", "false"))) {
+        if ("true".equals(
+            SpringContextAware.getApplicationContext().getEnvironment().getProperty("history.enabled", "false"))) {
+            JanusGraphManagement graphMgt = graph.openManagement();
             SchemaGenerator4Hist.loadSchemaIntoJanusGraph(graphMgt, IN_MEMORY);
         } else {
-            SchemaGenerator.loadSchemaIntoJanusGraph(graphMgt, IN_MEMORY);
+            SchemaGenerator.loadSchemaIntoJanusGraph(graph, IN_MEMORY, dbNotEmpty);
         }
     }