Upgrade SDC from Titan to Janus Graph
[sdc.git] / asdctool / src / main / java / org / openecomp / sdc / asdctool / impl / JanusGraphInitializer.java
 
 package org.openecomp.sdc.asdctool.impl;
 
-import com.thinkaurelius.titan.core.*;
-import com.thinkaurelius.titan.core.schema.ConsistencyModifier;
-import com.thinkaurelius.titan.core.schema.TitanGraphIndex;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
+import org.janusgraph.core.*;
+import org.janusgraph.core.schema.ConsistencyModifier;
+import org.janusgraph.core.schema.JanusGraphIndex;
+import org.janusgraph.core.schema.JanusGraphManagement;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum;
@@ -43,34 +43,34 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 
-public class TitanGraphInitializer {
+public class JanusGraphInitializer {
 
-       private static Logger logger = LoggerFactory.getLogger(TitanGraphInitializer.class.getName());
-       private static TitanGraph graph;
+       private static Logger logger = LoggerFactory.getLogger(JanusGraphInitializer.class.getName());
+       private static JanusGraph graph;
 
-       public static boolean createGraph(String titanCfgFile) {
-               logger.info("** createGraph with {}", titanCfgFile);
+       public static boolean createGraph(String janusGraphCfgFile) {
+               logger.info("** createGraph with {}", janusGraphCfgFile);
                try {
-                       logger.info("createGraph : try to load file {}", titanCfgFile);
-                       graph = TitanFactory.open(titanCfgFile);
+                       logger.info("createGraph : try to load file {}", janusGraphCfgFile);
+                       graph = JanusGraphFactory.open(janusGraphCfgFile);
                        if (graph.isClosed()) {
                                return false;
                        }
 
-               } catch (TitanException e) {
-                       logger.info("createGraph : failed to open Titan graph with configuration file: {}", titanCfgFile, e);
+               } catch (JanusGraphException e) {
+                       logger.info("createGraph : failed to open JanusGraph graph with configuration file: {}", janusGraphCfgFile, e);
                        return false;
                }
 
                createIndexesAndDefaults();
 
-               logger.info("** Titan graph created ");
+               logger.info("** JanusGraph graph created ");
 
                return true;
        }
 
        private static boolean isVertexExist(Map<String, Object> properties) {
-               TitanGraphQuery query = graph.query();
+               JanusGraphQuery query = graph.query();
 
                if (properties != null && !properties.isEmpty()) {
                        for (Map.Entry<String, Object> entry : properties.entrySet()) {
@@ -127,8 +127,8 @@ public class TitanGraphInitializer {
        private static void createVertexIndixes() {
                logger.info("** createVertexIndixes started");
 
-               TitanManagement graphMgt = graph.openManagement();
-               TitanGraphIndex index = null;
+               JanusGraphManagement graphMgt = graph.openManagement();
+               JanusGraphIndex index = null;
                for (GraphPropertiesDictionary prop : GraphPropertiesDictionary.values()) {
                        PropertyKey propKey = null;
                        if (!graphMgt.containsPropertyKey(prop.getProperty())) {
@@ -170,7 +170,7 @@ public class TitanGraphInitializer {
 
        private static void createEdgeIndixes() {
                logger.info("** createEdgeIndixes started");
-               TitanManagement graphMgt = graph.openManagement();
+               JanusGraphManagement graphMgt = graph.openManagement();
                for (GraphEdgePropertiesDictionary prop : GraphEdgePropertiesDictionary.values()) {
                        if (!graphMgt.containsGraphIndex(prop.getProperty())) {
                                PropertyKey propKey = graphMgt.makePropertyKey(prop.getProperty()).dataType(prop.getClazz()).make();