package org.onap.aai.dbmap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.io.FileNotFoundException;
+import java.util.Properties;
+
import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.io.IoCore;
import org.janusgraph.core.JanusGraph;
import org.onap.aai.dbgen.SchemaGenerator4Hist;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.util.AAIConstants;
-
-import java.io.FileNotFoundException;
-import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Database Mapping class which acts as the middle man between the REST
protected JanusGraph graph;
private static boolean isInit = false;
-
-
/**
* Instantiates a new AAI graph.
*/
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.getFullStackTrace(e)));
+ logger.info(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s",
+ ExceptionUtils.getStackTrace(e)));
throw new RuntimeException(e);
}
}
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);
}
}