summaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/main/java
diff options
context:
space:
mode:
authorshrikantawachar <shrikant.awachar@amdocs.com>2019-05-20 12:11:54 +0530
committerAvi Gaffa <avi.gaffa@amdocs.com>2019-06-12 08:05:21 +0000
commit2623c8402a57e2035db69a9d92d2851050916801 (patch)
treef7311f32a5566702921a2e650b476f1ff6bf0de1 /catalog-dao/src/main/java
parent799bc7e3c75de762dea7448c6f8f5d6e5f3f9671 (diff)
Upgrade SDC from Titan to Janus Graph
Upgrade SDC from Titan to Janus Graph Change-Id: I67fb8b8e60cc6751697bc5ff2f06754c92803786 Issue-ID: SDC-2296 Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
Diffstat (limited to 'catalog-dao/src/main/java')
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOJanusGraphStrategy.java (renamed from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOTitanStrategy.java)4
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/JanusGraphClientStrategy.java (renamed from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/TitanClientStrategy.java)2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/JanusGraphSpringConfig.java54
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java53
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java14
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java (renamed from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealTitanGraphDao.java)10
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java4
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/HealingJanusGraphGenericDao.java (renamed from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/HealingTitanGenericDao.java)42
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphClient.java (renamed from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGraphClient.java)186
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java (renamed from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java)575
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphOperationStatus.java (renamed from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanOperationStatus.java)6
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java27
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/QueryType.java (renamed from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/QueryType.java)2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/transactions/SimpleJanusGraphTransactionManager.java (renamed from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/transactions/SimpleTitanTransactionManager.java)40
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingJanusGraphDao.java (renamed from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingTitanDao.java)18
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java (renamed from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java)333
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractJanusGraphVertexHeal.java (renamed from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractTitanVertexHeal.java)2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanUtils.java27
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java2
22 files changed, 708 insertions, 705 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOTitanStrategy.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOJanusGraphStrategy.java
index 2452245616..1a96ebf87b 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOTitanStrategy.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOJanusGraphStrategy.java
@@ -22,11 +22,11 @@ package org.openecomp.sdc.be.dao;
import org.openecomp.sdc.be.config.ConfigurationManager;
-public class DAOTitanStrategy implements TitanClientStrategy {
+public class DAOJanusGraphStrategy implements JanusGraphClientStrategy {
@Override
public String getConfigFile() {
- return ConfigurationManager.getConfigurationManager().getConfiguration().getTitanCfgFile();
+ return ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphCfgFile();
}
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/TitanClientStrategy.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/JanusGraphClientStrategy.java
index 36aaec8684..14e12e9b04 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/TitanClientStrategy.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/JanusGraphClientStrategy.java
@@ -20,7 +20,7 @@
package org.openecomp.sdc.be.dao;
-public interface TitanClientStrategy {
+public interface JanusGraphClientStrategy {
String getConfigFile();
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java
index 5af12a8af1..53d71fe3cf 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java
@@ -120,7 +120,7 @@ public class SdcSchemaBuilder {
Map<String, Map<String, List<String>>> cassndraMetadata = parseKeyspaceMetadata(keyspacesMetadateFromCassandra);
log.info("Cassandra Metadata: {}" ,cassndraMetadata);
cassndraMetadata.forEach((k, v) -> {
- if (AuditingTypesConstants.TITAN_KEYSPACE.equals(k)) {
+ if (AuditingTypesConstants.janusGraph_KEYSPACE.equals(k)) {
// session.execute("")
} else if (AuditingTypesConstants.ARTIFACT_KEYSPACE.equals(k)) {
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
index 99acb3b62b..e40b5aa237 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
@@ -26,7 +26,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
@Configuration
-@Import({TitanSpringConfig.class})
+@Import({JanusGraphSpringConfig.class})
@ComponentScan({
"org.openecomp.sdc.be.dao.cassandra",
"org.openecomp.sdc.be.dao.neo4j",
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/JanusGraphSpringConfig.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/JanusGraphSpringConfig.java
new file mode 100644
index 0000000000..d30caf1845
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/JanusGraphSpringConfig.java
@@ -0,0 +1,54 @@
+package org.openecomp.sdc.be.dao.config;
+
+import org.openecomp.sdc.be.dao.DAOJanusGraphStrategy;
+import org.openecomp.sdc.be.dao.JanusGraphClientStrategy;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
+import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.janusgraph.transactions.SimpleJanusGraphTransactionManager;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@Configuration
+@ComponentScan({
+ "org.openecomp.sdc.be.dao.jsongraph",
+})
+@EnableTransactionManagement
+public class JanusGraphSpringConfig {
+
+ @Bean(name = "janusgraph-generic-dao")
+ @Primary
+ public HealingJanusGraphGenericDao janusGraphGenericDao(@Qualifier("janusgraph-client") JanusGraphClient janusGraphClient) {
+ return new HealingJanusGraphGenericDao(janusGraphClient);
+ }
+
+ @Bean(name = "janusgraph-client", initMethod = "createGraph")
+ @Primary
+ public JanusGraphClient janusGraphClient(@Qualifier("dao-client-strategy")
+ JanusGraphClientStrategy janusGraphClientStrategy) {
+ return new JanusGraphClient(janusGraphClientStrategy);
+ }
+
+ @Bean(name = "dao-client-strategy")
+ public JanusGraphClientStrategy janusGraphClientStrategy() {
+ return new DAOJanusGraphStrategy();
+ }
+
+ @Bean
+ public PlatformTransactionManager txManager() {
+ return new SimpleJanusGraphTransactionManager(janusGraphClient(janusGraphClientStrategy()));
+ }
+
+ @Bean(name = "healingPipelineDao")
+ public HealingPipelineDao healingPipeline(){
+ HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
+ healingPipelineDao.setHealVersion(1);
+ healingPipelineDao.initHealVersion();
+ return healingPipelineDao;
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java
deleted file mode 100644
index 34a860ddd2..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.openecomp.sdc.be.dao.config;
-
-import org.openecomp.sdc.be.dao.DAOTitanStrategy;
-import org.openecomp.sdc.be.dao.TitanClientStrategy;
-import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
-import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.transactions.SimpleTitanTransactionManager;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-@Configuration
-@ComponentScan({
- "org.openecomp.sdc.be.dao.jsongraph",
-})
-@EnableTransactionManagement
-public class TitanSpringConfig {
-
- @Bean(name = "titan-generic-dao")
- @Primary
- public HealingTitanGenericDao titanGenericDao(@Qualifier("titan-client") TitanGraphClient titanGraphClient) {
- return new HealingTitanGenericDao(titanGraphClient);
- }
-
- @Bean(name = "titan-client", initMethod = "createGraph")
- @Primary
- public TitanGraphClient titanGraphClient(@Qualifier("dao-client-strategy") TitanClientStrategy titanClientStrategy) {
- return new TitanGraphClient(titanClientStrategy);
- }
-
- @Bean(name = "dao-client-strategy")
- public TitanClientStrategy titanClientStrategy() {
- return new DAOTitanStrategy();
- }
-
- @Bean
- public PlatformTransactionManager txManager() {
- return new SimpleTitanTransactionManager(titanGraphClient(titanClientStrategy()));
- }
-
- @Bean(name = "healingPipelineDao")
- public HealingPipelineDao healingPipeline(){
- HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
- healingPipelineDao.setHealVersion(1);
- healingPipelineDao.initHealVersion();
- return healingPipelineDao;
- }
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
index 5b219b2371..f757b58455 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
@@ -20,7 +20,7 @@ import static java.util.stream.Collectors.joining;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
-import com.thinkaurelius.titan.core.TitanVertex;
+import org.janusgraph.core.JanusGraphVertex;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -33,7 +33,7 @@ import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.impl.heal.HealGraphDao;
import org.openecomp.sdc.be.dao.impl.heal.HealNodeGraphDao;
-import org.openecomp.sdc.be.dao.impl.heal.HealTitanGraphDao;
+import org.openecomp.sdc.be.dao.impl.heal.HealJanusGraphDao;
import org.openecomp.sdc.be.dao.impl.heal.HealVertexGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
@@ -58,7 +58,7 @@ public class HealingPipelineDao {
private HealGraphDao healNodeGraphDao;
private HealGraphDao healVertexGraphDao;
- private HealGraphDao healTitanVertexGraphDao;
+ private HealGraphDao healJanusGraphVertexGraphDao;
public HealingPipelineDao() {
healingPipeline = ImmutableListMultimap.of();
@@ -74,7 +74,7 @@ public class HealingPipelineDao {
public void initGraphHealers() {
healNodeGraphDao = new HealNodeGraphDao(this);
healVertexGraphDao = new HealVertexGraphDao(this);
- healTitanVertexGraphDao = new HealTitanGraphDao(this);
+ healJanusGraphVertexGraphDao = new HealJanusGraphDao(this);
}
@@ -85,8 +85,8 @@ public class HealingPipelineDao {
if (graphNode instanceof GraphElement) {
return healNodeGraphDao;
}
- if (graphNode instanceof TitanVertex) {
- return healTitanVertexGraphDao;
+ if (graphNode instanceof JanusGraphVertex) {
+ return healJanusGraphVertexGraphDao;
}
return null;
@@ -133,7 +133,7 @@ public class HealingPipelineDao {
graphVertex.addMetadataProperty(GraphPropertyEnum.HEALING_VERSION, currentHealVersion.getVersion());
}
- public void setHealingVersion(TitanVertex graphVertex) {
+ public void setHealingVersion(JanusGraphVertex graphVertex) {
graphVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(), currentHealVersion.getVersion());
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealTitanGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java
index 1e33c61b9f..76be4a6e12 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealTitanGraphDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java
@@ -1,6 +1,6 @@
package org.openecomp.sdc.be.dao.impl.heal;
-import com.thinkaurelius.titan.core.TitanVertex;
+import org.janusgraph.core.JanusGraphVertex;
import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
import org.openecomp.sdc.be.dao.jsongraph.heal.HealConstants;
@@ -9,16 +9,16 @@ import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
-public class HealTitanGraphDao implements HealGraphDao<TitanVertex, GraphEdgeLabels> {
+public class HealJanusGraphDao implements HealGraphDao<JanusGraphVertex, GraphEdgeLabels> {
private HealingPipelineDao healingPipelineDao;
- public HealTitanGraphDao(HealingPipelineDao healingPipelineDao) {
+ public HealJanusGraphDao(HealingPipelineDao healingPipelineDao) {
this.healingPipelineDao = healingPipelineDao;
}
@Override
- public TitanVertex performGraphReadHealing(TitanVertex childVertex, GraphEdgeLabels graphEdgeLabels) {
+ public JanusGraphVertex performGraphReadHealing(JanusGraphVertex childVertex, GraphEdgeLabels graphEdgeLabels) {
final Integer healingVersionInt = (Integer) childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty()).orElse(HealConstants.DEFAULT_HEAL_VERSION);
HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
healingPipelineDao.getHealersForVertex(graphEdgeLabels.name(), healingVersion).forEach(heal -> healGraphVertex(childVertex, heal));
@@ -27,7 +27,7 @@ public class HealTitanGraphDao implements HealGraphDao<TitanVertex, GraphEdgeLab
}
- private TitanVertex healGraphVertex(TitanVertex childVertex, Heal<TitanVertex> heal) {
+ private JanusGraphVertex healGraphVertex(JanusGraphVertex childVertex, Heal<JanusGraphVertex> heal) {
heal.healData(childVertex);
final HealVersion<Integer> healVersion = heal.fromVersion();
HealVersion newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java
index 2fc5c8fc5d..9bc75a0ba1 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java
@@ -20,12 +20,12 @@ public class HealNodeGraphDao implements HealGraphDao<GraphNode, GraphEdge> {
public GraphNode performGraphReadHealing(GraphNode childVertex, GraphEdge graphEdge) {
Integer healingVersionInt = childVertex.getHealingVersion();
HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
- healingPipelineDao.getHealersForVertex(graphEdge.getEdgeType().getProperty(), healingVersion).forEach(heal -> healTitanVertex(childVertex, heal));
+ healingPipelineDao.getHealersForVertex(graphEdge.getEdgeType().getProperty(), healingVersion).forEach(heal -> healJanusGraphVertex(childVertex, heal));
childVertex.setHealingVersion(healingPipelineDao.getCurrentHealVersion().getVersion());
return childVertex;
}
- private GraphNode healTitanVertex(GraphNode childVertex, Heal<GraphNode> heal) {
+ private GraphNode healJanusGraphVertex(GraphNode childVertex, Heal<GraphNode> heal) {
heal.healData(childVertex);
final HealVersion<Integer> healVersion = heal.fromVersion();
HealVersion<Integer> newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/HealingTitanGenericDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/HealingJanusGraphGenericDao.java
index 37546a5c2a..f8ab531f04 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/HealingTitanGenericDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/HealingJanusGraphGenericDao.java
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.openecomp.sdc.be.dao.titan;
+package org.openecomp.sdc.be.dao.janusgraph;
-import com.thinkaurelius.titan.core.TitanVertex;
+import org.janusgraph.core.JanusGraphVertex;
import fj.data.Either;
import java.util.List;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -25,9 +25,7 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
-import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
import org.openecomp.sdc.be.dao.jsongraph.heal.HealConstants;
-import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersion;
import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
@@ -35,28 +33,28 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-@Component("titan-generic-dao")
-public class HealingTitanGenericDao extends TitanGenericDao {
+@Component("janusgraph-generic-dao")
+public class HealingJanusGraphGenericDao extends JanusGraphGenericDao {
@Autowired
private HealingPipelineDao healingPipelineDao;
- public HealingTitanGenericDao(TitanGraphClient titanClient) {
- super(titanClient);
+ public HealingJanusGraphGenericDao(JanusGraphClient janusGraphClient) {
+ super(janusGraphClient);
}
@Override
- public ImmutablePair<TitanVertex, Edge> getChildVertex(TitanVertex childVertex, GraphEdgeLabels edgeType) {
- ImmutablePair<TitanVertex, Edge> childVertexEdgeImmutablePair = super.getChildVertex(childVertex, edgeType);
- final TitanVertex graphVertex = childVertexEdgeImmutablePair.left;
+ public ImmutablePair<JanusGraphVertex, Edge> getChildVertex(JanusGraphVertex childVertex, GraphEdgeLabels edgeType) {
+ ImmutablePair<JanusGraphVertex, Edge> childVertexEdgeImmutablePair = super.getChildVertex(childVertex, edgeType);
+ final JanusGraphVertex graphVertex = childVertexEdgeImmutablePair.left;
healingPipelineDao.performGraphReadHealing(graphVertex, edgeType);
healingPipelineDao.setHealingVersion(graphVertex);
return childVertexEdgeImmutablePair;
}
@Override
- public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, boolean withEdges) {
- Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> either = super.getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz, withEdges);
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, boolean withEdges) {
+ Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> either = super.getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz, withEdges);
if (either.isRight()) {
return either;
}
@@ -66,8 +64,8 @@ public class HealingTitanGenericDao extends TitanGenericDao {
}
@Override
- public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, TitanOperationStatus> getChild(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
- Either<ImmutablePair<T, GraphEdge>, TitanOperationStatus> eitherChild = super.getChild(key, uniqueId, edgeType, nodeTypeEnum, clazz);
+ public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChild(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+ Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> eitherChild = super.getChild(key, uniqueId, edgeType, nodeTypeEnum, clazz);
if (eitherChild.isRight()) {
return eitherChild;
}
@@ -89,19 +87,19 @@ public class HealingTitanGenericDao extends TitanGenericDao {
}
@Override
- public Either<List<ImmutablePair<TitanVertex, Edge>>, TitanOperationStatus> getChildrenVertecies(String key, String uniqueId, GraphEdgeLabels edgeType) {
- Either<List<ImmutablePair<TitanVertex, Edge>>, TitanOperationStatus> either = super.getChildrenVertecies(key, uniqueId, edgeType);
+ public Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> getChildrenVertecies(String key, String uniqueId, GraphEdgeLabels edgeType) {
+ Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> either = super.getChildrenVertecies(key, uniqueId, edgeType);
if (either.isRight()) {
return either;
}
- List<ImmutablePair<TitanVertex, Edge>> list = either.left().value();
+ List<ImmutablePair<JanusGraphVertex, Edge>> list = either.left().value();
list.forEach(this::transformVertexPair);
return either;
}
- private void transformVertexPair(ImmutablePair<TitanVertex, Edge> either) {
+ private void transformVertexPair(ImmutablePair<JanusGraphVertex, Edge> either) {
String edgeType = either.right.label();
- TitanVertex childVertex = either.left;
+ JanusGraphVertex childVertex = either.left;
VertexProperty<Integer> healingVersionProperty = childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty());
Integer healingVersioInt = healingVersionProperty.orElse(HealConstants.DEFAULT_HEAL_VERSION);
HealVersionBuilder.build(healingVersioInt);
@@ -110,13 +108,13 @@ public class HealingTitanGenericDao extends TitanGenericDao {
}
@Override
- public <T extends GraphNode> Either<T, TitanOperationStatus> updateNode(GraphNode node, Class<T> clazz) {
+ public <T extends GraphNode> Either<T, JanusGraphOperationStatus> updateNode(GraphNode node, Class<T> clazz) {
healingPipelineDao.setHealingVersion(node);
return super.updateNode(node, clazz);
}
@Override
- public TitanOperationStatus updateVertex(GraphNode node, Vertex vertex) {
+ public JanusGraphOperationStatus updateVertex(GraphNode node, Vertex vertex) {
healingPipelineDao.setHealingVersion(node);
return super.updateVertex(node, vertex);
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGraphClient.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphClient.java
index 9d5ff9d226..5be907cc86 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGraphClient.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphClient.java
@@ -18,24 +18,24 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.be.dao.titan;
-
-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 com.thinkaurelius.titan.core.util.TitanCleanup;
-import com.thinkaurelius.titan.diskstorage.ResourceUnavailableException;
-import com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException;
-import com.thinkaurelius.titan.graphdb.database.idassigner.IDPoolExhaustedException;
+package org.openecomp.sdc.be.dao.janusgraph;
+
+import org.janusgraph.core.*;
+import org.janusgraph.core.schema.ConsistencyModifier;
+import org.janusgraph.core.schema.JanusGraphIndex;
+import org.janusgraph.core.schema.JanusGraphManagement;
+import org.janusgraph.diskstorage.BackendException;
+import org.janusgraph.diskstorage.ResourceUnavailableException;
+import org.janusgraph.diskstorage.locking.PermanentLockingException;
+import org.janusgraph.graphdb.database.idassigner.IDPoolExhaustedException;
import fj.data.Either;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.dao.DAOTitanStrategy;
-import org.openecomp.sdc.be.dao.TitanClientStrategy;
+import org.openecomp.sdc.be.dao.DAOJanusGraphStrategy;
+import org.openecomp.sdc.be.dao.JanusGraphClientStrategy;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,23 +47,23 @@ import java.util.HashMap;
import java.util.concurrent.*;
-@Component("titan-client")
-public class TitanGraphClient {
- private static Logger logger = LoggerFactory.getLogger(TitanGraphClient.class.getName());
- private static Logger healthLogger = LoggerFactory.getLogger("titan.healthcheck");
+@Component("janusgraph-client")
+public class JanusGraphClient {
+ private static Logger logger = LoggerFactory.getLogger(JanusGraphClient.class.getName());
+ private static Logger healthLogger = LoggerFactory.getLogger("janusgraph.healthcheck");
private static final String HEALTH_CHECK = GraphPropertiesDictionary.HEALTH_CHECK.getProperty();
private static final String OK = "GOOD";
- public TitanGraphClient() {
+ public JanusGraphClient() {
}
private class HealthCheckTask implements Callable<Vertex> {
@Override
public Vertex call() {
- TitanVertex v = (TitanVertex) graph.query().has(HEALTH_CHECK, OK).vertices().iterator().next();
- TitanVertexProperty<String> property = v.property("healthcheck", OK + "_" + System.currentTimeMillis());
+ JanusGraphVertex v = (JanusGraphVertex) graph.query().has(HEALTH_CHECK, OK).vertices().iterator().next();
+ JanusGraphVertexProperty<String> property = v.property("healthcheck", OK + "_" + System.currentTimeMillis());
healthLogger.trace("Health Check Node Found...{}", v.property(HEALTH_CHECK));
graph.tx().commit();
@@ -74,11 +74,11 @@ public class TitanGraphClient {
private class HealthCheckScheduledTask implements Runnable {
@Override
public void run() {
- healthLogger.trace("Executing TITAN Health Check Task - Start");
+ healthLogger.trace("Executing janusGraph Health Check Task - Start");
boolean healthStatus = isGraphOpen();
- healthLogger.trace("Executing TITAN Health Check Task - Status = {}", healthStatus);
+ healthLogger.trace("Executing janusGraph Health Check Task - Status = {}", healthStatus);
if (healthStatus != lastHealthState) {
- logger.trace("TITAN Health State Changed to {}. Issuing alarm / recovery alarm...", healthStatus);
+ logger.trace("janusGraph Health State Changed to {}. Issuing alarm / recovery alarm...", healthStatus);
lastHealthState = healthStatus;
logAlarm();
}
@@ -88,14 +88,14 @@ public class TitanGraphClient {
private class ReconnectTask implements Runnable {
@Override
public void run() {
- logger.trace("Trying to reconnect to Titan...");
+ logger.trace("Trying to reconnect to JanusGraph...");
if (graph == null) {
- createGraph(titanCfgFile);
+ createGraph(janusGraphCfgFile);
}
}
}
- private TitanGraph graph;
+ private JanusGraph graph;
// Health Check Variables
@@ -105,7 +105,7 @@ public class TitanGraphClient {
ExecutorService healthCheckExecutor = Executors.newSingleThreadExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
- return new Thread(r, "Titan-Health-Check-Thread");
+ return new Thread(r, "JanusGraph-Health-Check-Thread");
}
});
private long healthCheckReadTimeout = 2;
@@ -121,51 +121,51 @@ public class TitanGraphClient {
@SuppressWarnings("rawtypes")
private Future reconnectFuture;
- private String titanCfgFile = null;
- TitanClientStrategy titanClientStrategy;
+ private String janusGraphCfgFile = null;
+ JanusGraphClientStrategy janusGraphClientStrategy;
- public TitanGraphClient(TitanClientStrategy titanClientStrategy) {
+ public JanusGraphClient(JanusGraphClientStrategy janusGraphClientStrategy) {
super();
- this.titanClientStrategy = titanClientStrategy;
+ this.janusGraphClientStrategy = janusGraphClientStrategy;
// Initialize a single threaded scheduler for health-check
this.healthCheckScheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
- return new Thread(r, "Titan-Health-Check-Task");
+ return new Thread(r, "JanusGraph-Health-Check-Task");
}
});
- healthCheckReadTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getTitanHealthCheckReadTimeout(2);
- reconnectInterval = ConfigurationManager.getConfigurationManager().getConfiguration().getTitanReconnectIntervalInSeconds(3);
+ healthCheckReadTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphHealthCheckReadTimeout(2);
+ reconnectInterval = ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphReconnectIntervalInSeconds(3);
- logger.info("** TitanGraphClient created");
+ logger.info("** JanusGraphClient created");
}
@PostConstruct
- public TitanOperationStatus createGraph() {
+ public JanusGraphOperationStatus createGraph() {
logger.info("** createGraph started **");
- if (ConfigurationManager.getConfigurationManager().getConfiguration().getTitanInMemoryGraph()) {
+ if (ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphInMemoryGraph()) {
BaseConfiguration conf = new BaseConfiguration();
conf.setProperty("storage.backend", "inmemory");
- graph = TitanFactory.open(conf);
- createTitanSchema();
+ graph = JanusGraphFactory.open(conf);
+ createJanusGraphSchema();
logger.info("** in memory graph created");
- return TitanOperationStatus.OK;
+ return JanusGraphOperationStatus.OK;
} else {
- this.titanCfgFile = titanClientStrategy.getConfigFile();
- if (titanCfgFile == null || titanCfgFile.isEmpty()) {
- titanCfgFile = "config/titan.properties";
+ this.janusGraphCfgFile = janusGraphClientStrategy.getConfigFile();
+ if (janusGraphCfgFile == null || janusGraphCfgFile.isEmpty()) {
+ janusGraphCfgFile = "config/janusgraph.properties";
}
// yavivi
// In case connection failed on init time, schedule a reconnect task
// in the BG
- TitanOperationStatus status = createGraph(titanCfgFile);
- logger.debug("Create Titan graph status {}", status);
- if (status != TitanOperationStatus.OK) {
+ JanusGraphOperationStatus status = createGraph(janusGraphCfgFile);
+ logger.debug("Create JanusGraph graph status {}", status);
+ if (status != JanusGraphOperationStatus.OK) {
this.startReconnectTask();
}
@@ -178,7 +178,7 @@ public class TitanGraphClient {
}
/**
- * This method will be invoked ONLY on init time in case Titan storage is down.
+ * This method will be invoked ONLY on init time in case JanusGraph storage is down.
*/
private void startReconnectTask() {
this.reconnectTask = new ReconnectTask();
@@ -186,7 +186,7 @@ public class TitanGraphClient {
this.reconnectScheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
- return new Thread(r, "Titan-Reconnect-Task");
+ return new Thread(r, "JanusGraph-Reconnect-Task");
}
});
@@ -198,45 +198,49 @@ public class TitanGraphClient {
if (graph != null) {
// graph.shutdown();
graph.close();
- TitanCleanup.clear(graph);
+ try {
+ JanusGraphFactory.drop(graph);
+ } catch (BackendException e) {
+ e.printStackTrace();
+ }
}
}
private boolean graphInitialized(){
- TitanManagement graphMgmt = graph.openManagement();
+ JanusGraphManagement graphMgmt = graph.openManagement();
return graphMgmt.containsPropertyKey(HEALTH_CHECK) && graphMgmt.containsGraphIndex(HEALTH_CHECK);
}
- public TitanOperationStatus createGraph(String titanCfgFile) {
- logger.info("** open graph with {} started", titanCfgFile);
+ public JanusGraphOperationStatus createGraph(String janusGraphCfgFile) {
+ logger.info("** open graph with {} started", janusGraphCfgFile);
try {
- logger.info("openGraph : try to load file {}", titanCfgFile);
- graph = TitanFactory.open(titanCfgFile);
+ logger.info("openGraph : try to load file {}", janusGraphCfgFile);
+ graph = JanusGraphFactory.open(janusGraphCfgFile);
if (graph.isClosed() || !graphInitialized()) {
- logger.error("titan graph was not initialized");
- return TitanOperationStatus.NOT_CREATED;
+ logger.error("janusgraph graph was not initialized");
+ return JanusGraphOperationStatus.NOT_CREATED;
}
} catch (Exception e) {
this.graph = null;
- logger.info("createGraph : failed to open Titan graph with configuration file: {}", titanCfgFile);
+ logger.info("createGraph : failed to open JanusGraph graph with configuration file: {}", janusGraphCfgFile);
logger.debug("createGraph : failed with exception.", e);
- return TitanOperationStatus.NOT_CONNECTED;
+ return JanusGraphOperationStatus.NOT_CONNECTED;
}
- logger.info("** Titan graph created ");
+ logger.info("** JanusGraph graph created ");
// Do some post creation actions
this.onGraphOpened();
- return TitanOperationStatus.OK;
+ return JanusGraphOperationStatus.OK;
}
private void onGraphOpened() {
// if a reconnect task is running, cancel it.
if (this.reconnectFuture != null) {
- logger.info("** Cancelling Titan reconnect task");
+ logger.info("** Cancelling JanusGraph reconnect task");
reconnectFuture.cancel(true);
}
@@ -254,72 +258,72 @@ public class TitanGraphClient {
}
- public Either<TitanGraph, TitanOperationStatus> getGraph() {
+ public Either<JanusGraph, JanusGraphOperationStatus> getGraph() {
if (graph != null) {
return Either.left(graph);
} else {
- return Either.right(TitanOperationStatus.NOT_CREATED);
+ return Either.right(JanusGraphOperationStatus.NOT_CREATED);
}
}
- public TitanOperationStatus commit() {
+ public JanusGraphOperationStatus commit() {
if (graph != null) {
try {
graph.tx().commit();
- return TitanOperationStatus.OK;
+ return JanusGraphOperationStatus.OK;
} catch (Exception e) {
- return handleTitanException(e);
+ return handleJanusGraphException(e);
}
} else {
- return TitanOperationStatus.NOT_CREATED;
+ return JanusGraphOperationStatus.NOT_CREATED;
}
}
- public TitanOperationStatus rollback() {
+ public JanusGraphOperationStatus rollback() {
if (graph != null) {
try {
// graph.rollback();
graph.tx().rollback();
- return TitanOperationStatus.OK;
+ return JanusGraphOperationStatus.OK;
} catch (Exception e) {
- return handleTitanException(e);
+ return handleJanusGraphException(e);
}
} else {
- return TitanOperationStatus.NOT_CREATED;
+ return JanusGraphOperationStatus.NOT_CREATED;
}
}
- public static TitanOperationStatus handleTitanException(Exception e) {
- if (e instanceof TitanConfigurationException) {
- return TitanOperationStatus.TITAN_CONFIGURATION;
+ public static JanusGraphOperationStatus handleJanusGraphException(Exception e) {
+ if (e instanceof JanusGraphConfigurationException) {
+ return JanusGraphOperationStatus.JANUSGRAPH_CONFIGURATION;
}
if (e instanceof SchemaViolationException) {
- return TitanOperationStatus.TITAN_SCHEMA_VIOLATION;
+ return JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION;
}
if (e instanceof PermanentLockingException) {
- return TitanOperationStatus.TITAN_SCHEMA_VIOLATION;
+ return JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION;
}
if (e instanceof IDPoolExhaustedException) {
- return TitanOperationStatus.GENERAL_ERROR;
+ return JanusGraphOperationStatus.GENERAL_ERROR;
}
if (e instanceof InvalidElementException) {
- return TitanOperationStatus.INVALID_ELEMENT;
+ return JanusGraphOperationStatus.INVALID_ELEMENT;
}
if (e instanceof InvalidIDException) {
- return TitanOperationStatus.INVALID_ID;
+ return JanusGraphOperationStatus.INVALID_ID;
}
if (e instanceof QueryException) {
- return TitanOperationStatus.INVALID_QUERY;
+ return JanusGraphOperationStatus.INVALID_QUERY;
}
if (e instanceof ResourceUnavailableException) {
- return TitanOperationStatus.RESOURCE_UNAVAILABLE;
+ return JanusGraphOperationStatus.RESOURCE_UNAVAILABLE;
}
if (e instanceof IllegalArgumentException) {
// TODO check the error message??
- return TitanOperationStatus.ILLEGAL_ARGUMENT;
+ return JanusGraphOperationStatus.ILLEGAL_ARGUMENT;
}
- return TitanOperationStatus.GENERAL_ERROR;
+ return JanusGraphOperationStatus.GENERAL_ERROR;
}
public boolean getHealth() {
@@ -327,7 +331,7 @@ public class TitanGraphClient {
}
private boolean isGraphOpen() {
- healthLogger.trace("Invoking Titan health check ...");
+ healthLogger.trace("Invoking JanusGraph health check ...");
Vertex v = null;
if (graph != null) {
try {
@@ -340,7 +344,7 @@ public class TitanGraphClient {
if (message == null) {
message = e.getClass().getName();
}
- logger.error("Titan Health Check Failed. {}", message);
+ logger.error("JanusGraph Health Check Failed. {}", message);
return false;
}
return true;
@@ -351,7 +355,7 @@ public class TitanGraphClient {
public static void main(String[] args) throws InterruptedException {
- TitanGraphClient client = new TitanGraphClient(new DAOTitanStrategy());
+ JanusGraphClient client = new JanusGraphClient(new DAOJanusGraphStrategy());
client.createGraph();
while (true) {
@@ -363,20 +367,20 @@ public class TitanGraphClient {
}
- private static final String TITAN_HEALTH_CHECK_STR = "titanHealthCheck";
+ private static final String JANUSGRAPH_HEALTH_CHECK = "janusgraphHealthCheck";
private void logAlarm() {
if (lastHealthState) {
- BeEcompErrorManager.getInstance().logBeHealthCheckTitanRecovery(TITAN_HEALTH_CHECK_STR);
+ BeEcompErrorManager.getInstance().logBeHealthCheckJanusGraphRecovery(JANUSGRAPH_HEALTH_CHECK);
} else {
- BeEcompErrorManager.getInstance().logBeHealthCheckTitanError(TITAN_HEALTH_CHECK_STR);
+ BeEcompErrorManager.getInstance().logBeHealthCheckJanusGraphError(JANUSGRAPH_HEALTH_CHECK);
}
}
- private void createTitanSchema() {
+ private void createJanusGraphSchema() {
- 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())) {
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java
index 2123910650..591d7f32d7 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java
@@ -18,15 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.be.dao.titan;
-
-import com.thinkaurelius.titan.core.PropertyKey;
-import com.thinkaurelius.titan.core.TitanEdge;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanGraphQuery;
-import com.thinkaurelius.titan.core.TitanVertex;
-import com.thinkaurelius.titan.core.TitanVertexQuery;
-import com.thinkaurelius.titan.graphdb.query.TitanPredicate;
+package org.openecomp.sdc.be.dao.janusgraph;
+
+import org.janusgraph.core.PropertyKey;
+import org.janusgraph.core.JanusGraphEdge;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphQuery;
+import org.janusgraph.core.JanusGraphVertex;
+import org.janusgraph.core.JanusGraphVertexQuery;
+import org.janusgraph.graphdb.query.JanusGraphPredicate;
import fj.data.Either;
import java.util.ArrayList;
import java.util.HashMap;
@@ -58,28 +58,28 @@ import org.openecomp.sdc.be.resources.data.GraphNodeLock;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Qualifier;
-public class TitanGenericDao {
+public class JanusGraphGenericDao {
private static final String FAILED_TO_RETRIEVE_GRAPH_STATUS_IS = "Failed to retrieve graph. status is {}";
private static final String NO_EDGES_IN_GRAPH_FOR_CRITERIA = "No edges in graph for criteria";
private static final String FAILED_TO_CREATE_EDGE_FROM_TO = "Failed to create edge from [{}] to [{}]";
- private TitanGraphClient titanClient;
- private static Logger log = Logger.getLogger(TitanGenericDao.class.getName());
+ private JanusGraphClient janusGraphClient;
+ private static Logger log = Logger.getLogger(JanusGraphGenericDao.class.getName());
private static final String LOCK_NODE_PREFIX = "lock_";
- public TitanGenericDao(@Qualifier("titan-client") TitanGraphClient titanClient) {
- this.titanClient = titanClient;
- log.info("** TitanGenericDao created");
+ public JanusGraphGenericDao(@Qualifier("janusgraph-client") JanusGraphClient janusGraphClient) {
+ this.janusGraphClient = janusGraphClient;
+ log.info("** JanusGraphGenericDao created");
}
- public TitanOperationStatus commit() {
+ public JanusGraphOperationStatus commit() {
log.debug("doing commit.");
- return titanClient.commit();
+ return janusGraphClient.commit();
}
- public TitanOperationStatus rollback() {
+ public JanusGraphOperationStatus rollback() {
log.error("Going to execute rollback on graph.");
- return titanClient.rollback();
+ return janusGraphClient.rollback();
}
public <T, TStatus> void handleTransactionCommitRollback(boolean inTransaction, Either<T, TStatus> result) {
@@ -92,13 +92,13 @@ public class TitanGenericDao {
}
}
- public Either<TitanGraph, TitanOperationStatus> getGraph() {
- return titanClient.getGraph();
+ public Either<JanusGraph, JanusGraphOperationStatus> getGraph() {
+ return janusGraphClient.getGraph();
}
// For healthCheck
public boolean isGraphOpen() {
- return titanClient.getHealth();
+ return janusGraphClient.getHealth();
}
/**
@@ -107,13 +107,13 @@ public class TitanGenericDao {
* @param clazz
* @return
*/
- public <T extends GraphNode> Either<T, TitanOperationStatus> createNode(T node, Class<T> clazz) {
+ public <T extends GraphNode> Either<T, JanusGraphOperationStatus> createNode(T node, Class<T> clazz) {
log.debug("try to create node for ID [{}]", node.getKeyValueId());
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
T newNode;
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
Vertex vertex = tGraph.addVertex();
@@ -131,7 +131,7 @@ public class TitanGenericDao {
} catch (Exception e) {
log.debug("Failed to create Node for ID [{}]", node.getKeyValueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -140,14 +140,14 @@ public class TitanGenericDao {
}
}
- public Either<TitanVertex, TitanOperationStatus> createNode(GraphNode node) {
+ public Either<JanusGraphVertex, JanusGraphOperationStatus> createNode(GraphNode node) {
log.debug("try to create node for ID [{}]", node.getKeyValueId());
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
- TitanVertex vertex = tGraph.addVertex();
+ JanusGraphVertex vertex = tGraph.addVertex();
vertex.property(GraphPropertiesDictionary.LABEL.getProperty(), node.getLabel());
@@ -160,7 +160,7 @@ public class TitanGenericDao {
} catch (Exception e) {
log.debug("Failed to create Node for ID [{}]", node.getKeyValueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -174,7 +174,7 @@ public class TitanGenericDao {
* @param relation
* @return
*/
- public Either<GraphRelation, TitanOperationStatus> createRelation(GraphRelation relation) {
+ public Either<GraphRelation, JanusGraphOperationStatus> createRelation(GraphRelation relation) {
log.debug("try to create relation from [{}] to [{}] ", relation.getFrom(), relation.getTo());
RelationEndPoint from = relation.getFrom();
@@ -186,25 +186,25 @@ public class TitanGenericDao {
}
- private Either<GraphRelation, TitanOperationStatus> createEdge(String type, ImmutablePair<String, Object> from, ImmutablePair<String, Object> to, String fromLabel, String toLabel, Map<String, Object> properties) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ private Either<GraphRelation, JanusGraphOperationStatus> createEdge(String type, ImmutablePair<String, Object> from, ImmutablePair<String, Object> to, String fromLabel, String toLabel, Map<String, Object> properties) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- Either<Vertex, TitanOperationStatus> fromV = getVertexByPropertyAndLabel(from.getKey(), from.getValue(), fromLabel);
+ Either<Vertex, JanusGraphOperationStatus> fromV = getVertexByPropertyAndLabel(from.getKey(), from.getValue(), fromLabel);
if (fromV.isRight()) {
- TitanOperationStatus error = fromV.right().value();
- if (TitanOperationStatus.NOT_FOUND.equals(error)) {
- return Either.right(TitanOperationStatus.INVALID_ID);
+ JanusGraphOperationStatus error = fromV.right().value();
+ if (JanusGraphOperationStatus.NOT_FOUND.equals(error)) {
+ return Either.right(JanusGraphOperationStatus.INVALID_ID);
} else {
return Either.right(error);
}
}
- Either<Vertex, TitanOperationStatus> toV = getVertexByPropertyAndLabel(to.getKey(), to.getValue(), toLabel);
+ Either<Vertex, JanusGraphOperationStatus> toV = getVertexByPropertyAndLabel(to.getKey(), to.getValue(), toLabel);
if (toV.isRight()) {
- TitanOperationStatus error = toV.right().value();
- if (TitanOperationStatus.NOT_FOUND.equals(error)) {
- return Either.right(TitanOperationStatus.INVALID_ID);
+ JanusGraphOperationStatus error = toV.right().value();
+ if (JanusGraphOperationStatus.NOT_FOUND.equals(error)) {
+ return Either.right(JanusGraphOperationStatus.INVALID_ID);
} else {
return Either.right(error);
}
@@ -230,7 +230,7 @@ public class TitanGenericDao {
return Either.left(newRelation);
} catch (Exception e) {
log.debug(FAILED_TO_CREATE_EDGE_FROM_TO, from, to, e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
log.debug("Failed to create edge from [{}] to [{}] {}", from, to, graph.right().value());
@@ -238,14 +238,14 @@ public class TitanGenericDao {
}
}
- public TitanOperationStatus createEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
+ public JanusGraphOperationStatus createEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
try {
Edge edge = addEdge(vertexOut, vertexIn, type, properties);
} catch (Exception e) {
log.debug(FAILED_TO_CREATE_EDGE_FROM_TO, vertexOut, vertexIn, e);
- return TitanGraphClient.handleTitanException(e);
+ return JanusGraphClient.handleJanusGraphException(e);
}
- return TitanOperationStatus.OK;
+ return JanusGraphOperationStatus.OK;
}
@@ -264,7 +264,7 @@ public class TitanGenericDao {
* @param edge
* @return the copy operation status
*/
- public Either<Edge, TitanOperationStatus> copyEdge(Vertex out, Vertex in, Edge edge) {
+ public Either<Edge, JanusGraphOperationStatus> copyEdge(Vertex out, Vertex in, Edge edge) {
GraphEdgeLabels byName = GraphEdgeLabels.getByName(edge.label());
return this.saveEdge(out, in, byName, edgePropertiesToMap(edge));
}
@@ -274,30 +274,30 @@ public class TitanGenericDao {
return StreamSupport.stream(propertiesIterable.spliterator(), false).collect(Collectors.toMap(Property::key, Property::value));
}
- public Either<Edge, TitanOperationStatus> saveEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
+ public Either<Edge, JanusGraphOperationStatus> saveEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
try {
Edge edge = addEdge(vertexOut, vertexIn, type, properties);
return Either.left(edge);
} catch (Exception e) {
log.debug(FAILED_TO_CREATE_EDGE_FROM_TO, vertexOut, vertexIn, e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
}
- public TitanOperationStatus createEdge(TitanVertex vertexOut, GraphNode to, GraphEdgeLabels type, Map<String, Object> properties) {
+ public JanusGraphOperationStatus createEdge(JanusGraphVertex vertexOut, GraphNode to, GraphEdgeLabels type, Map<String, Object> properties) {
- TitanVertex vertexIn;
- Either<Vertex, TitanOperationStatus> toV = getVertexByPropertyAndLabel(to.getUniqueIdKey(), to.getUniqueId(), to.getLabel());
+ JanusGraphVertex vertexIn;
+ Either<Vertex, JanusGraphOperationStatus> toV = getVertexByPropertyAndLabel(to.getUniqueIdKey(), to.getUniqueId(), to.getLabel());
if (toV.isRight()) {
- TitanOperationStatus error = toV.right().value();
- if (TitanOperationStatus.NOT_FOUND.equals(error)) {
- return TitanOperationStatus.INVALID_ID;
+ JanusGraphOperationStatus error = toV.right().value();
+ if (JanusGraphOperationStatus.NOT_FOUND.equals(error)) {
+ return JanusGraphOperationStatus.INVALID_ID;
} else {
return error;
}
}
- vertexIn = (TitanVertex) toV.left().value();
+ vertexIn = (JanusGraphVertex) toV.left().value();
return createEdge(vertexOut, vertexIn, type, properties);
}
@@ -309,26 +309,26 @@ public class TitanGenericDao {
* @param properties
* @return
*/
- public Either<GraphRelation, TitanOperationStatus> createRelation(GraphNode from, GraphNode to, GraphEdgeLabels label, Map<String, Object> properties) {
+ public Either<GraphRelation, JanusGraphOperationStatus> createRelation(GraphNode from, GraphNode to, GraphEdgeLabels label, Map<String, Object> properties) {
log.debug("try to create relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
return createEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel(), properties);
}
- public Either<GraphRelation, TitanOperationStatus> replaceRelationLabel(GraphNode from, GraphNode to, GraphEdgeLabels label, GraphEdgeLabels newLabel) {
+ public Either<GraphRelation, JanusGraphOperationStatus> replaceRelationLabel(GraphNode from, GraphNode to, GraphEdgeLabels label, GraphEdgeLabels newLabel) {
log.debug("try to replace relation {} to {} from [{}] to [{}]", label.name(), newLabel.name(), from.getKeyValueId(), to.getKeyValueId());
- Either<GraphRelation, TitanOperationStatus> getRelationResult = getRelation(from, to, label);
+ Either<GraphRelation, JanusGraphOperationStatus> getRelationResult = getRelation(from, to, label);
if (getRelationResult.isRight()) {
return getRelationResult;
}
GraphRelation origRelation = getRelationResult.left().value();
- Either<GraphRelation, TitanOperationStatus> createRelationResult = createRelation(from, to, newLabel, origRelation.toGraphMap());
+ Either<GraphRelation, JanusGraphOperationStatus> createRelationResult = createRelation(from, to, newLabel, origRelation.toGraphMap());
if (createRelationResult.isRight()) {
return createRelationResult;
}
- Either<GraphRelation, TitanOperationStatus> deleteRelationResult = deleteRelation(origRelation);
+ Either<GraphRelation, JanusGraphOperationStatus> deleteRelationResult = deleteRelation(origRelation);
if (deleteRelationResult.isRight()) {
return deleteRelationResult;
}
@@ -342,11 +342,11 @@ public class TitanGenericDao {
* @param clazz
* @return
*/
- public <T extends GraphNode> Either<T, TitanOperationStatus> getNode(String keyName, Object keyValue, Class<T> clazz) {
+ public <T extends GraphNode> Either<T, JanusGraphOperationStatus> getNode(String keyName, Object keyValue, Class<T> clazz) {
log.debug("Try to get node for key [{}] with value [{}] ", keyName, keyValue);
- Either<TitanVertex, TitanOperationStatus> vertexByProperty = getVertexByProperty(keyName, keyValue);
+ Either<JanusGraphVertex, JanusGraphOperationStatus> vertexByProperty = getVertexByProperty(keyName, keyValue);
if (vertexByProperty.isLeft()) {
try {
@@ -356,7 +356,7 @@ public class TitanGenericDao {
return Either.left(node);
} catch (Exception e) {
log.debug("Failed to get node for key [{}] with value [{}] ", keyName, keyValue, e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
log.debug("Failed to get node for key [{}] with value [{}] ", keyName, keyValue, vertexByProperty.right().value());
@@ -371,10 +371,10 @@ public class TitanGenericDao {
* @param label
* @return
*/
- public Either<GraphRelation, TitanOperationStatus> getRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
+ public Either<GraphRelation, JanusGraphOperationStatus> getRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
log.debug("try to get relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
- Either<Edge, TitanOperationStatus> edge = getEdgeByNodes(from, to, label);
+ Either<Edge, JanusGraphOperationStatus> edge = getEdgeByNodes(from, to, label);
if (edge.isLeft()) {
try {
@@ -383,7 +383,7 @@ public class TitanGenericDao {
return Either.left(relation);
} catch (Exception e) {
log.debug("Failed to get get relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
log.debug("Failed to get get relation from [{}] to [{}] {}", from.getKeyValueId(), to.getKeyValueId(), edge.right().value());
@@ -391,18 +391,18 @@ public class TitanGenericDao {
}
}
- public Either<Edge, TitanOperationStatus> getEdgeByNodes(GraphNode from, GraphNode to, GraphEdgeLabels label) {
+ public Either<Edge, JanusGraphOperationStatus> getEdgeByNodes(GraphNode from, GraphNode to, GraphEdgeLabels label) {
ImmutablePair<String, Object> keyValueIdFrom = from.getKeyValueId();
ImmutablePair<String, Object> keyValueIdTo = to.getKeyValueId();
return getEdgeByVerticies(keyValueIdFrom.getKey(), keyValueIdFrom.getValue(), keyValueIdTo.getKey(), keyValueIdTo.getValue(), label.getProperty());
}
- public Either<GraphRelation, TitanOperationStatus> deleteIncomingRelationByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
+ public Either<GraphRelation, JanusGraphOperationStatus> deleteIncomingRelationByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
- Either<Edge, TitanOperationStatus> edgeByCriteria = getIncomingEdgeByCriteria(to, label, props);
+ Either<Edge, JanusGraphOperationStatus> edgeByCriteria = getIncomingEdgeByCriteria(to, label, props);
if (edgeByCriteria.isLeft()) {
- Either<TitanGraph, TitanOperationStatus> graph = getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = getGraph();
if (graph.isLeft()) {
Edge edge = edgeByCriteria.left().value();
log.debug("delete edge {} to {} ", label.getProperty(), to.getUniqueId());
@@ -425,11 +425,11 @@ public class TitanGenericDao {
}
- public Either<GraphRelation, TitanOperationStatus> getIncomingRelationByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
+ public Either<GraphRelation, JanusGraphOperationStatus> getIncomingRelationByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
- Either<Edge, TitanOperationStatus> edgeByCriteria = getIncomingEdgeByCriteria(to, label, props);
+ Either<Edge, JanusGraphOperationStatus> edgeByCriteria = getIncomingEdgeByCriteria(to, label, props);
if (edgeByCriteria.isLeft()) {
- Either<TitanGraph, TitanOperationStatus> graph = getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = getGraph();
if (graph.isLeft()) {
Edge edge = edgeByCriteria.left().value();
Map<String, Object> properties = getProperties(edge);
@@ -450,17 +450,17 @@ public class TitanGenericDao {
}
- public Either<Edge, TitanOperationStatus> getIncomingEdgeByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
+ public Either<Edge, JanusGraphOperationStatus> getIncomingEdgeByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
ImmutablePair<String, Object> keyValueIdTo = to.getKeyValueId();
- Either<TitanVertex, TitanOperationStatus> vertexFrom = getVertexByProperty(keyValueIdTo.getKey(), keyValueIdTo.getValue());
+ Either<JanusGraphVertex, JanusGraphOperationStatus> vertexFrom = getVertexByProperty(keyValueIdTo.getKey(), keyValueIdTo.getValue());
if (vertexFrom.isRight()) {
return Either.right(vertexFrom.right().value());
}
Vertex vertex = vertexFrom.left().value();
- TitanVertex titanVertex = (TitanVertex) vertex;
- TitanVertexQuery<?> query = titanVertex.query();
+ JanusGraphVertex janusGraphVertex = (JanusGraphVertex) vertex;
+ JanusGraphVertexQuery<?> query = janusGraphVertex.query();
query = query.labels(label.getProperty());
if (props != null && !props.isEmpty()) {
@@ -469,34 +469,34 @@ public class TitanGenericDao {
}
}
Edge matchingEdge = null;
- Iterable<TitanEdge> edges = query.edges();
+ Iterable<JanusGraphEdge> edges = query.edges();
if (edges == null) {
log.debug(NO_EDGES_IN_GRAPH_FOR_CRITERIA);
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
- Iterator<TitanEdge> eIter = edges.iterator();
+ Iterator<JanusGraphEdge> eIter = edges.iterator();
if (eIter.hasNext()) {
matchingEdge = eIter.next();
}
if (matchingEdge == null) {
log.debug(NO_EDGES_IN_GRAPH_FOR_CRITERIA);
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(matchingEdge);
}
- public Either<Edge, TitanOperationStatus> getEdgeByVerticies(String keyNameFrom, Object keyValueFrom, String keyNameTo, Object keyValueTo, String label) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ public Either<Edge, JanusGraphOperationStatus> getEdgeByVerticies(String keyNameFrom, Object keyValueFrom, String keyNameTo, Object keyValueTo, String label) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- Either<TitanVertex, TitanOperationStatus> vertexFrom = getVertexByProperty(keyNameFrom, keyValueFrom);
+ Either<JanusGraphVertex, JanusGraphOperationStatus> vertexFrom = getVertexByProperty(keyNameFrom, keyValueFrom);
if (vertexFrom.isRight()) {
return Either.right(vertexFrom.right().value());
}
- Iterable<TitanEdge> edges = vertexFrom.left().value().query().labels(label).edges();
- Iterator<TitanEdge> eIter = edges.iterator();
+ Iterable<JanusGraphEdge> edges = vertexFrom.left().value().query().labels(label).edges();
+ Iterator<JanusGraphEdge> eIter = edges.iterator();
while (eIter.hasNext()) {
Edge edge = eIter.next();
Vertex vertexIn = edge.inVertex();
@@ -505,22 +505,22 @@ public class TitanGenericDao {
}
}
log.debug("No relation in graph from [{}={}] to [{}={}]", keyNameFrom, keyValueFrom, keyNameTo, keyValueTo);
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
} catch (Exception e) {
log.debug("Failed to get get relation from [{}={}] to [{}={}]", keyNameFrom, keyValueFrom, keyNameTo, keyValueTo, e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
return Either.right(graph.right().value());
}
}
- public Either<List<Edge>, TitanOperationStatus> getEdgesForNode(GraphNode node, Direction requestedDirection) {
+ public Either<List<Edge>, JanusGraphOperationStatus> getEdgesForNode(GraphNode node, Direction requestedDirection) {
- Either<List<Edge>, TitanOperationStatus> result;
+ Either<List<Edge>, JanusGraphOperationStatus> result;
ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
- Either<TitanVertex, TitanOperationStatus> eitherVertex = getVertexByProperty(keyValueId.getKey(), keyValueId.getValue());
+ Either<JanusGraphVertex, JanusGraphOperationStatus> eitherVertex = getVertexByProperty(keyValueId.getKey(), keyValueId.getValue());
if (eitherVertex.isLeft()) {
List<Edge> edges = prepareEdgesList(eitherVertex.left().value(), requestedDirection);
@@ -534,7 +534,7 @@ public class TitanGenericDao {
private List<Edge> prepareEdgesList(Vertex vertex, Direction requestedDirection) {
List<Edge> edges = new ArrayList<>();
- Iterator<TitanEdge> edgesItr = ((TitanVertex) vertex).query().edges().iterator();
+ Iterator<JanusGraphEdge> edgesItr = ((JanusGraphVertex) vertex).query().edges().iterator();
while (edgesItr.hasNext()) {
Edge edge = edgesItr.next();
Direction currEdgeDirection = getEdgeDirection(vertex, edge);
@@ -566,14 +566,14 @@ public class TitanGenericDao {
* @param properties
* @return
*/
- public Either<GraphRelation, TitanOperationStatus> updateRelation(GraphNode from, GraphNode to, GraphEdgeLabels label, Map<String, Object> properties) {
+ public Either<GraphRelation, JanusGraphOperationStatus> updateRelation(GraphNode from, GraphNode to, GraphEdgeLabels label, Map<String, Object> properties) {
log.debug("try to update relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
return updateEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel(), properties);
}
- private Either<GraphRelation, TitanOperationStatus> updateEdge(String type, ImmutablePair<String, Object> from, ImmutablePair<String, Object> to, String fromLabel, String toLabel, Map<String, Object> properties) {
+ private Either<GraphRelation, JanusGraphOperationStatus> updateEdge(String type, ImmutablePair<String, Object> from, ImmutablePair<String, Object> to, String fromLabel, String toLabel, Map<String, Object> properties) {
- Either<Edge, TitanOperationStatus> edgeS = getEdgeByVerticies(from.getKey(), from.getValue(), to.getKey(), to.getValue(), type);
+ Either<Edge, JanusGraphOperationStatus> edgeS = getEdgeByVerticies(from.getKey(), from.getValue(), to.getKey(), to.getValue(), type);
if (edgeS.isLeft()) {
try {
@@ -597,7 +597,7 @@ public class TitanGenericDao {
if (log.isDebugEnabled()) {
log.debug("Failed to update relation from [{}] to [{}] ", from, to, e);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
if (log.isDebugEnabled()) {
@@ -612,7 +612,7 @@ public class TitanGenericDao {
* @param relation
* @return
*/
- public Either<GraphRelation, TitanOperationStatus> updateRelation(GraphRelation relation) {
+ public Either<GraphRelation, JanusGraphOperationStatus> updateRelation(GraphRelation relation) {
log.debug("try to update relation from [{}] to [{}]", relation.getFrom(), relation.getTo());
RelationEndPoint from = relation.getFrom();
RelationEndPoint to = relation.getTo();
@@ -623,17 +623,17 @@ public class TitanGenericDao {
}
- private Either<Vertex, TitanOperationStatus> getVertexByPropertyAndLabel(String name, Object value, String label) {
+ private Either<Vertex, JanusGraphOperationStatus> getVertexByPropertyAndLabel(String name, Object value, String label) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
@SuppressWarnings("unchecked")
- Iterable<TitanVertex> vertecies = tGraph.query().has(name, value).has(GraphPropertiesDictionary.LABEL.getProperty(), label).vertices();
+ Iterable<JanusGraphVertex> vertecies = tGraph.query().has(name, value).has(GraphPropertiesDictionary.LABEL.getProperty(), label).vertices();
- java.util.Iterator<TitanVertex> iterator = vertecies.iterator();
+ java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
if (iterator.hasNext()) {
Vertex vertex = iterator.next();
return Either.left(vertex);
@@ -641,12 +641,12 @@ public class TitanGenericDao {
if (log.isDebugEnabled()) {
log.debug("No vertex in graph for key =" + name + " and value = " + value + " label = " + label);
}
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Failed to get vertex in graph for key ={} and value = {} label = {}",name,value,label);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -657,37 +657,37 @@ public class TitanGenericDao {
}
}
- public Either<TitanVertex, TitanOperationStatus> getVertexByProperty(String name, Object value) {
+ public Either<JanusGraphVertex, JanusGraphOperationStatus> getVertexByProperty(String name, Object value) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (value == null) {
if (log.isDebugEnabled()) {
log.debug("No vertex in graph for key = {} and value = {}", name, value);
}
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
@SuppressWarnings("unchecked")
- Iterable<TitanVertex> vertecies = tGraph.query().has(name, value).vertices();
+ Iterable<JanusGraphVertex> vertecies = tGraph.query().has(name, value).vertices();
- java.util.Iterator<TitanVertex> iterator = vertecies.iterator();
+ java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
if (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
+ JanusGraphVertex vertex = iterator.next();
return Either.left(vertex);
} else {
if (log.isDebugEnabled()) {
log.debug("No vertex in graph for key ={} and value = {}", name, value);
}
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Failed to get vertex in graph for key = {} and value = ", name, value);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
if (log.isDebugEnabled()) {
@@ -697,13 +697,13 @@ public class TitanGenericDao {
}
}
- public <T extends GraphNode> Either<List<T>, TitanOperationStatus> getByCriteria(NodeTypeEnum type, Map<String, Object> hasProps, Map<String, Object> hasNotProps, Class<T> clazz) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteria(NodeTypeEnum type, Map<String, Object> hasProps, Map<String, Object> hasNotProps, Class<T> clazz) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
- TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+ JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
if (hasProps != null && !hasProps.isEmpty()) {
@@ -716,12 +716,12 @@ public class TitanGenericDao {
query = query.hasNot(entry.getKey(), entry.getValue());
}
}
- Iterable<TitanVertex> vertices = query.vertices();
+ Iterable<JanusGraphVertex> vertices = query.vertices();
if (vertices == null) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
- Iterator<TitanVertex> iterator = vertices.iterator();
+ Iterator<JanusGraphVertex> iterator = vertices.iterator();
List<T> result = new ArrayList<>();
while (iterator.hasNext()) {
@@ -736,7 +736,7 @@ public class TitanGenericDao {
log.debug("Number of fetced nodes in graph for criteria : from type = {} and properties has = {}, properties hasNot = {} is {}", type, hasProps, hasNotProps, result.size());
}
if (result.size() == 0) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(result);
@@ -744,7 +744,7 @@ public class TitanGenericDao {
if (log.isDebugEnabled()) {
log.debug("Failed get by criteria for type = {}", type, e);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -755,13 +755,13 @@ public class TitanGenericDao {
}
}
- public <T extends GraphNode> Either<List<T>, TitanOperationStatus> getByCriteria(NodeTypeEnum type, Class<T> clazz, List<ImmutableTriple<QueryType, String, Object>> props) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteria(NodeTypeEnum type, Class<T> clazz, List<ImmutableTriple<QueryType, String, Object>> props) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
- TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+ JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
for (ImmutableTriple<QueryType, String, Object> prop : props) {
if (QueryType.HAS.equals(prop.getLeft())) {
@@ -770,12 +770,12 @@ public class TitanGenericDao {
query = query.hasNot(prop.getMiddle(), prop.getRight());
}
}
- Iterable<TitanVertex> vertices = query.vertices();
+ Iterable<JanusGraphVertex> vertices = query.vertices();
if (vertices == null) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
- Iterator<TitanVertex> iterator = vertices.iterator();
+ Iterator<JanusGraphVertex> iterator = vertices.iterator();
List<T> result = new ArrayList<>();
while (iterator.hasNext()) {
@@ -787,7 +787,7 @@ public class TitanGenericDao {
result.add(element);
}
if (result.size() == 0) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(result);
@@ -795,7 +795,7 @@ public class TitanGenericDao {
if (log.isDebugEnabled()) {
log.debug("Failed get by criteria for type = {}", type, e);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -806,13 +806,13 @@ public class TitanGenericDao {
}
}
- public <T extends GraphNode> Either<List<T>, TitanOperationStatus> getByCriteria(NodeTypeEnum type, Map<String, Object> props, Class<T> clazz) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteria(NodeTypeEnum type, Map<String, Object> props, Class<T> clazz) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
- TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+ JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
if (props != null && !props.isEmpty()) {
@@ -820,12 +820,12 @@ public class TitanGenericDao {
query = query.has(entry.getKey(), entry.getValue());
}
}
- Iterable<TitanVertex> vertices = query.vertices();
+ Iterable<JanusGraphVertex> vertices = query.vertices();
if (vertices == null) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
- Iterator<TitanVertex> iterator = vertices.iterator();
+ Iterator<JanusGraphVertex> iterator = vertices.iterator();
List<T> result = new ArrayList<>();
while (iterator.hasNext()) {
@@ -840,7 +840,7 @@ public class TitanGenericDao {
log.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
}
if (result.size() == 0) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(result);
@@ -848,7 +848,7 @@ public class TitanGenericDao {
if (log.isDebugEnabled()) {
log.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -859,30 +859,30 @@ public class TitanGenericDao {
}
}
- public <T extends GraphNode> Either<List<T>, TitanOperationStatus> getByCriteriaWithPredicate(NodeTypeEnum type, Map<String, Entry<TitanPredicate, Object>> props, Class<T> clazz) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteriaWithPredicate(NodeTypeEnum type, Map<String, Entry<JanusGraphPredicate, Object>> props, Class<T> clazz) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
- TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+ JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
if (props != null && !props.isEmpty()) {
- TitanPredicate predicate = null;
+ JanusGraphPredicate predicate = null;
Object object = null;
- for (Map.Entry<String, Entry<TitanPredicate, Object>> entry : props.entrySet()) {
+ for (Map.Entry<String, Entry<JanusGraphPredicate, Object>> entry : props.entrySet()) {
predicate = entry.getValue().getKey();
object = entry.getValue().getValue();
query = query.has(entry.getKey(), predicate, object);
}
}
- Iterable<TitanVertex> vertices = query.vertices();
+ Iterable<JanusGraphVertex> vertices = query.vertices();
if (vertices == null) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
- Iterator<TitanVertex> iterator = vertices.iterator();
+ Iterator<JanusGraphVertex> iterator = vertices.iterator();
List<T> result = new ArrayList<>();
while (iterator.hasNext()) {
@@ -893,7 +893,7 @@ public class TitanGenericDao {
result.add(element);
}
if (result.size() == 0) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
if (log.isDebugEnabled()) {
log.debug("No nodes in graph for criteria : from type = {} and properties = {}", type, props);
@@ -903,7 +903,7 @@ public class TitanGenericDao {
if (log.isDebugEnabled()) {
log.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -914,7 +914,7 @@ public class TitanGenericDao {
}
}
- public <T extends GraphNode> Either<List<T>, TitanOperationStatus> getAll(NodeTypeEnum type, Class<T> clazz) {
+ public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getAll(NodeTypeEnum type, Class<T> clazz) {
return getByCriteria(type, null, clazz);
}
@@ -924,11 +924,11 @@ public class TitanGenericDao {
* @param clazz
* @return
*/
- public <T extends GraphNode> Either<T, TitanOperationStatus> updateNode(GraphNode node, Class<T> clazz) {
+ public <T extends GraphNode> Either<T, JanusGraphOperationStatus> updateNode(GraphNode node, Class<T> clazz) {
log.debug("Try to update node for {}", node.getKeyValueId());
ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
- Either<Vertex, TitanOperationStatus> vertexByProperty = getVertexByPropertyAndLabel(keyValueId.getKey(), keyValueId.getValue(), node.getLabel());
+ Either<Vertex, JanusGraphOperationStatus> vertexByProperty = getVertexByPropertyAndLabel(keyValueId.getKey(), keyValueId.getValue(), node.getLabel());
if (vertexByProperty.isLeft()) {
try {
@@ -942,7 +942,7 @@ public class TitanGenericDao {
}
}
- Either<Vertex, TitanOperationStatus> vertexByPropertyAndLabel = getVertexByPropertyAndLabel(keyValueId.getKey(), keyValueId.getValue(), node.getLabel());
+ Either<Vertex, JanusGraphOperationStatus> vertexByPropertyAndLabel = getVertexByPropertyAndLabel(keyValueId.getKey(), keyValueId.getValue(), node.getLabel());
if (vertexByPropertyAndLabel.isRight()) {
return Either.right(vertexByPropertyAndLabel.right().value());
} else {
@@ -954,7 +954,7 @@ public class TitanGenericDao {
if (log.isDebugEnabled()) {
log.debug("Failed to update node for {}", node.getKeyValueId(), e);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
if (log.isDebugEnabled()) {
@@ -965,7 +965,7 @@ public class TitanGenericDao {
}
- public TitanOperationStatus updateVertex(GraphNode node, Vertex vertex) {
+ public JanusGraphOperationStatus updateVertex(GraphNode node, Vertex vertex) {
log.debug("Try to update node for {}", node.getKeyValueId());
try {
@@ -981,9 +981,9 @@ public class TitanGenericDao {
if (log.isDebugEnabled()) {
log.debug("Failed to update node for {}", node.getKeyValueId(), e);
}
- return TitanGraphClient.handleTitanException(e);
+ return JanusGraphClient.handleJanusGraphException(e);
}
- return TitanOperationStatus.OK;
+ return JanusGraphOperationStatus.OK;
}
@@ -993,7 +993,7 @@ public class TitanGenericDao {
* @param clazz
* @return
*/
- public <T extends GraphNode> Either<T, TitanOperationStatus> deleteNode(GraphNode node, Class<T> clazz) {
+ public <T extends GraphNode> Either<T, JanusGraphOperationStatus> deleteNode(GraphNode node, Class<T> clazz) {
log.debug("Try to delete node for {}", node.getKeyValueId());
ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
return deleteNode(keyValueId.getKey(), keyValueId.getValue(), clazz);
@@ -1006,8 +1006,8 @@ public class TitanGenericDao {
* @param clazz
* @return
*/
- public <T extends GraphNode> Either<T, TitanOperationStatus> deleteNode(String keyName, Object keyValue, Class<T> clazz) {
- Either<TitanVertex, TitanOperationStatus> vertexByProperty = getVertexByProperty(keyName, keyValue);
+ public <T extends GraphNode> Either<T, JanusGraphOperationStatus> deleteNode(String keyName, Object keyValue, Class<T> clazz) {
+ Either<JanusGraphVertex, JanusGraphOperationStatus> vertexByProperty = getVertexByProperty(keyName, keyValue);
if (vertexByProperty.isLeft()) {
try {
@@ -1019,9 +1019,9 @@ public class TitanGenericDao {
T node = GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties, clazz);
if (node != null) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
vertex.remove();
} else {
return Either.right(graph.right().value());
@@ -1031,19 +1031,19 @@ public class TitanGenericDao {
if (log.isDebugEnabled()) {
log.debug("Failed to delete node for {} = {} Missing label property on node", keyName, keyValue);
}
- return Either.right(TitanOperationStatus.MISSING_NODE_LABEL);
+ return Either.right(JanusGraphOperationStatus.MISSING_NODE_LABEL);
}
} else {
if (log.isDebugEnabled()) {
log.debug("Failed to delete node for {} = {} Missing label property on node", keyName, keyValue);
}
- return Either.right(TitanOperationStatus.MISSING_NODE_LABEL);
+ return Either.right(JanusGraphOperationStatus.MISSING_NODE_LABEL);
}
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Failed to delete node for {} = {}", keyName, keyValue, e);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -1051,7 +1051,7 @@ public class TitanGenericDao {
}
}
- public Either<GraphRelation, TitanOperationStatus> deleteRelation(GraphRelation relation) {
+ public Either<GraphRelation, JanusGraphOperationStatus> deleteRelation(GraphRelation relation) {
log.debug("try to delete relation from [{}] to [{}]", relation.getFrom(), relation.getTo());
RelationEndPoint from = relation.getFrom();
RelationEndPoint to = relation.getTo();
@@ -1062,21 +1062,21 @@ public class TitanGenericDao {
}
- public Either<Boolean, TitanOperationStatus> isRelationExist(GraphNode from, GraphNode to, GraphEdgeLabels edgeLabel) {
+ public Either<Boolean, JanusGraphOperationStatus> isRelationExist(GraphNode from, GraphNode to, GraphEdgeLabels edgeLabel) {
return getEdgeByNodes(from, to, edgeLabel)
.left()
.map(edge -> true)
.right()
- .bind(err -> err == TitanOperationStatus.NOT_FOUND ? Either.left(false): Either.right(err));
+ .bind(err -> err == JanusGraphOperationStatus.NOT_FOUND ? Either.left(false): Either.right(err));
}
- public Either<GraphRelation, TitanOperationStatus> deleteRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
+ public Either<GraphRelation, JanusGraphOperationStatus> deleteRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
log.debug("try to delete relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
return deleteEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel());
}
- private Either<GraphRelation, TitanOperationStatus> deleteEdge(String type, ImmutablePair<String, Object> fromKeyId, ImmutablePair<String, Object> toKeyId, String fromLabel, String toLabel) {
- Either<Edge, TitanOperationStatus> edgeS = getEdgeByVerticies(fromKeyId.getKey(), fromKeyId.getValue(), toKeyId.getKey(), toKeyId.getValue(), type);
+ private Either<GraphRelation, JanusGraphOperationStatus> deleteEdge(String type, ImmutablePair<String, Object> fromKeyId, ImmutablePair<String, Object> toKeyId, String fromLabel, String toLabel) {
+ Either<Edge, JanusGraphOperationStatus> edgeS = getEdgeByVerticies(fromKeyId.getKey(), fromKeyId.getValue(), toKeyId.getKey(), toKeyId.getValue(), type);
if (edgeS.isLeft()) {
try {
Edge edge = edgeS.left().value();
@@ -1089,7 +1089,7 @@ public class TitanGenericDao {
GraphRelation newRelation = GraphElementFactory.createRelation(edge.label(), getProperties(edge), nodeOut, nodeIn);
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
edge.remove();
@@ -1105,7 +1105,7 @@ public class TitanGenericDao {
if (log.isDebugEnabled()) {
log.debug("Failed to delete relation {} from {} to {}", type, fromKeyId, toKeyId, e);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
if (log.isDebugEnabled()) {
@@ -1115,11 +1115,11 @@ public class TitanGenericDao {
}
}
- public void setTitanGraphClient(TitanGraphClient titanGraphClient) {
- this.titanClient = titanGraphClient;
+ public void setJanusGraphClient(JanusGraphClient janusGraphClient) {
+ this.janusGraphClient = janusGraphClient;
}
- public Either<GraphRelation, TitanOperationStatus> deleteIncomingRelation(GraphRelation relation) {
+ public Either<GraphRelation, JanusGraphOperationStatus> deleteIncomingRelation(GraphRelation relation) {
RelationEndPoint to = relation.getTo();
ImmutablePair<String, Object> toKeyId = new ImmutablePair<>(to.getIdName(), to.getIdValue());
@@ -1128,12 +1128,12 @@ public class TitanGenericDao {
}
- private Either<GraphRelation, TitanOperationStatus> deleteIncomingEdge(String type, ImmutablePair<String, Object> toKeyId) {
+ private Either<GraphRelation, JanusGraphOperationStatus> deleteIncomingEdge(String type, ImmutablePair<String, Object> toKeyId) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
- Either<TitanVertex, TitanOperationStatus> rootVertexResult = getVertexByProperty(toKeyId.getKey(), toKeyId.getValue());
+ Either<JanusGraphVertex, JanusGraphOperationStatus> rootVertexResult = getVertexByProperty(toKeyId.getKey(), toKeyId.getValue());
if (rootVertexResult.isLeft()) {
Vertex rootVertex = rootVertexResult.left().value();
Iterator<Edge> edgesIterator = rootVertex.edges(Direction.IN, type);
@@ -1144,10 +1144,10 @@ public class TitanGenericDao {
if (edgesIterator.hasNext()) {
edge = edgesIterator.next();
if (edgesIterator.hasNext()) {
- return Either.right(TitanOperationStatus.MULTIPLE_EDGES_WITH_SAME_LABEL);
+ return Either.right(JanusGraphOperationStatus.MULTIPLE_EDGES_WITH_SAME_LABEL);
}
} else {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
log.debug("Find the tail vertex of the edge of type {} to vertex {}", type, toKeyId);
@@ -1166,7 +1166,7 @@ public class TitanGenericDao {
return Either.left(newRelation);
} else {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
} else {
@@ -1179,7 +1179,7 @@ public class TitanGenericDao {
}
- public Either<GraphRelation, TitanOperationStatus> deleteOutgoingRelation(GraphRelation relation) {
+ public Either<GraphRelation, JanusGraphOperationStatus> deleteOutgoingRelation(GraphRelation relation) {
RelationEndPoint from = relation.getFrom();
ImmutablePair<String, Object> fromKeyId = new ImmutablePair<>(from.getIdName(), from.getIdValue());
@@ -1188,12 +1188,12 @@ public class TitanGenericDao {
}
- private Either<GraphRelation, TitanOperationStatus> deleteOutgoingEdge(String type, ImmutablePair<String, Object> toKeyId) {
+ private Either<GraphRelation, JanusGraphOperationStatus> deleteOutgoingEdge(String type, ImmutablePair<String, Object> toKeyId) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
- Either<TitanVertex, TitanOperationStatus> rootVertexResult = getVertexByProperty(toKeyId.getKey(), toKeyId.getValue());
+ Either<JanusGraphVertex, JanusGraphOperationStatus> rootVertexResult = getVertexByProperty(toKeyId.getKey(), toKeyId.getValue());
if (rootVertexResult.isLeft()) {
Vertex rootVertex = rootVertexResult.left().value();
Iterator<Edge> edgesIterator = rootVertex.edges(Direction.OUT, type);
@@ -1204,10 +1204,10 @@ public class TitanGenericDao {
if (edgesIterator.hasNext()) {
edge = edgesIterator.next();
if (edgesIterator.hasNext()) {
- return Either.right(TitanOperationStatus.MULTIPLE_EDGES_WITH_SAME_LABEL);
+ return Either.right(JanusGraphOperationStatus.MULTIPLE_EDGES_WITH_SAME_LABEL);
}
} else {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
log.debug("Find the tail vertex of the edge of type {} to vertex ", type, toKeyId);
@@ -1226,7 +1226,7 @@ public class TitanGenericDao {
return Either.left(newRelation);
} else {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
} else {
@@ -1244,34 +1244,34 @@ public class TitanGenericDao {
* @return
*/
- public TitanOperationStatus lockElement(String id, NodeTypeEnum type) {
+ public JanusGraphOperationStatus lockElement(String id, NodeTypeEnum type) {
StringBuffer lockId = new StringBuffer(LOCK_NODE_PREFIX);
lockId.append(type.getName()).append("_").append(id);
return lockNode(lockId.toString());
}
- public TitanOperationStatus lockElement(GraphNode node) {
+ public JanusGraphOperationStatus lockElement(GraphNode node) {
StringBuffer lockId = createLockElementId(node);
return lockNode(lockId.toString());
}
- private TitanOperationStatus lockNode(String lockId) {
- TitanOperationStatus status = TitanOperationStatus.OK;
+ private JanusGraphOperationStatus lockNode(String lockId) {
+ JanusGraphOperationStatus status = JanusGraphOperationStatus.OK;
GraphNodeLock lockNode = new GraphNodeLock(lockId);
- Either<GraphNodeLock, TitanOperationStatus> lockNodeNew = createNode(lockNode, GraphNodeLock.class);
+ Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew = createNode(lockNode, GraphNodeLock.class);
if (lockNodeNew.isLeft()) {
log.debug("before commit, Lock node created for {}", lockId);
- return titanClient.commit();
+ return janusGraphClient.commit();
} else {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
- TitanGraph tGraph = graph.left().value();
- Either<TitanVertex, TitanOperationStatus> vertex = getVertexByProperty(lockNode.getUniqueIdKey(), lockNode.getUniqueId());
+ JanusGraph tGraph = graph.left().value();
+ Either<JanusGraphVertex, JanusGraphOperationStatus> vertex = getVertexByProperty(lockNode.getUniqueIdKey(), lockNode.getUniqueId());
if (vertex.isLeft()) {
status = relockNode(lockNode, lockNodeNew, tGraph, vertex);
} else {
@@ -1284,45 +1284,45 @@ public class TitanGenericDao {
return status;
}
- private TitanOperationStatus relockNode(GraphNodeLock lockNode, Either<GraphNodeLock, TitanOperationStatus> lockNodeNew, TitanGraph tGraph, Either<TitanVertex, TitanOperationStatus> vertex) {
- TitanOperationStatus status = TitanOperationStatus.OK;
+ private JanusGraphOperationStatus relockNode(GraphNodeLock lockNode, Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew, JanusGraph tGraph, Either<JanusGraphVertex, JanusGraphOperationStatus> vertex) {
+ JanusGraphOperationStatus status = JanusGraphOperationStatus.OK;
Long time = vertex.left().value().value(GraphPropertiesDictionary.CREATION_DATE.getProperty());
- Long lockTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getTitanLockTimeout();
+ Long lockTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphLockTimeout();
if (time + lockTimeout * 1000 < System.currentTimeMillis()) {
log.debug("Found not released lock node with id {}", lockNode.getUniqueId());
vertex.left().value().remove();
lockNodeNew = createNode(lockNode, GraphNodeLock.class);
if (lockNodeNew.isLeft()) {
log.debug("Lock node created for {}", lockNode.getUniqueIdKey());
- return titanClient.commit();
+ return janusGraphClient.commit();
} else {
log.debug("Failed Lock node for {} . Commit transacton for deleted previous vertex .", lockNode.getUniqueIdKey());
- titanClient.commit();
+ janusGraphClient.commit();
status = checkLockError(lockNode.getUniqueIdKey(), lockNodeNew);
}
} else {
log.debug("Failed Lock node for {} rollback transacton", lockNode.getUniqueIdKey());
- titanClient.rollback();
+ janusGraphClient.rollback();
status = checkLockError(lockNode.getUniqueIdKey(), lockNodeNew);
}
return status;
}
- public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, boolean withEdges) {
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, boolean withEdges) {
List<ImmutablePair<T, GraphEdge>> immutablePairs = new ArrayList<>();
- Either<TitanGraph, TitanOperationStatus> graphRes = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
if (graphRes.isRight()) {
log.error(FAILED_TO_RETRIEVE_GRAPH_STATUS_IS, graphRes);
return Either.right(graphRes.right().value());
}
- TitanGraph titanGraph = graphRes.left().value();
+ JanusGraph janusGraph = graphRes.left().value();
@SuppressWarnings("unchecked")
- Iterable<TitanVertex> vertices = titanGraph.query().has(key, uniqueId).vertices();
+ Iterable<JanusGraphVertex> vertices = janusGraph.query().has(key, uniqueId).vertices();
if (vertices == null || !vertices.iterator().hasNext()) {
- return Either.right(TitanOperationStatus.INVALID_ID);
+ return Either.right(JanusGraphOperationStatus.INVALID_ID);
}
Vertex rootVertex = vertices.iterator().next();
@@ -1349,28 +1349,28 @@ public class TitanGenericDao {
}
if (immutablePairs.isEmpty()) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(immutablePairs);
}
- public Either<List<ImmutablePair<TitanVertex, Edge>>, TitanOperationStatus> getChildrenVertecies(String key, String uniqueId, GraphEdgeLabels edgeType) {
+ public Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> getChildrenVertecies(String key, String uniqueId, GraphEdgeLabels edgeType) {
- List<ImmutablePair<TitanVertex, Edge>> immutablePairs = new ArrayList<>();
+ List<ImmutablePair<JanusGraphVertex, Edge>> immutablePairs = new ArrayList<>();
- Either<TitanGraph, TitanOperationStatus> graphRes = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
if (graphRes.isRight()) {
log.error(FAILED_TO_RETRIEVE_GRAPH_STATUS_IS, graphRes);
return Either.right(graphRes.right().value());
}
- TitanGraph titanGraph = graphRes.left().value();
+ JanusGraph janusGraph = graphRes.left().value();
@SuppressWarnings("unchecked")
- Iterable<TitanVertex> vertices = titanGraph.query().has(key, uniqueId).vertices();
+ Iterable<JanusGraphVertex> vertices = janusGraph.query().has(key, uniqueId).vertices();
if (vertices == null || !vertices.iterator().hasNext()) {
- return Either.right(TitanOperationStatus.INVALID_ID);
+ return Either.right(JanusGraphOperationStatus.INVALID_ID);
}
Vertex rootVertex = vertices.iterator().next();
@@ -1379,30 +1379,31 @@ public class TitanGenericDao {
if (edgesCreatorIterator != null) {
while (edgesCreatorIterator.hasNext()) {
Edge edge = edgesCreatorIterator.next();
- TitanVertex vertex = (TitanVertex) edge.inVertex();
+ JanusGraphVertex vertex = (JanusGraphVertex) edge.inVertex();
- ImmutablePair<TitanVertex, Edge> immutablePair = new ImmutablePair<>(vertex, edge);
+ ImmutablePair<JanusGraphVertex, Edge> immutablePair = new ImmutablePair<>(vertex, edge);
immutablePairs.add(immutablePair);
}
}
if (immutablePairs.isEmpty()) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(immutablePairs);
}
- public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
return this.getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz, true);
}
- private TitanOperationStatus checkLockError(String lockId, Either<GraphNodeLock, TitanOperationStatus> lockNodeNew) {
- TitanOperationStatus status;
- TitanOperationStatus error = lockNodeNew.right().value();
+ private JanusGraphOperationStatus checkLockError(String lockId, Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew) {
+ JanusGraphOperationStatus status;
+ JanusGraphOperationStatus error = lockNodeNew.right().value();
log.debug("Failed to Lock node for {} error = {}", lockId, error);
- if (error.equals(TitanOperationStatus.TITAN_SCHEMA_VIOLATION) || error.equals(TitanOperationStatus.ILLEGAL_ARGUMENT)) {
- status = TitanOperationStatus.ALREADY_LOCKED;
+ if (error.equals(JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION) || error.equals(
+ JanusGraphOperationStatus.ILLEGAL_ARGUMENT)) {
+ status = JanusGraphOperationStatus.ALREADY_LOCKED;
} else {
status = error;
}
@@ -1414,28 +1415,28 @@ public class TitanGenericDao {
* @param node
* @return
*/
- public TitanOperationStatus releaseElement(GraphNode node) {
+ public JanusGraphOperationStatus releaseElement(GraphNode node) {
StringBuffer lockId = createLockElementId(node);
return unlockNode(lockId);
}
- private TitanOperationStatus unlockNode(StringBuffer lockId) {
+ private JanusGraphOperationStatus unlockNode(StringBuffer lockId) {
GraphNodeLock lockNode = new GraphNodeLock(lockId.toString());
- Either<GraphNodeLock, TitanOperationStatus> lockNodeNew = deleteNode(lockNode, GraphNodeLock.class);
+ Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew = deleteNode(lockNode, GraphNodeLock.class);
if (lockNodeNew.isLeft()) {
log.debug("Lock node released for lock id = {}", lockId);
- return titanClient.commit();
+ return janusGraphClient.commit();
} else {
- titanClient.rollback();
- TitanOperationStatus error = lockNodeNew.right().value();
+ janusGraphClient.rollback();
+ JanusGraphOperationStatus error = lockNodeNew.right().value();
log.debug("Failed to Release node for lock id {} error = {}", lockId, error);
return error;
}
}
- public TitanOperationStatus releaseElement(String id, NodeTypeEnum type) {
+ public JanusGraphOperationStatus releaseElement(String id, NodeTypeEnum type) {
StringBuffer lockId = new StringBuffer(LOCK_NODE_PREFIX);
lockId.append(type.getName()).append("_").append(id);
return unlockNode(lockId);
@@ -1447,9 +1448,9 @@ public class TitanGenericDao {
return lockId;
}
- public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, TitanOperationStatus> getChild(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+ public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChild(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
- Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> childrenNodes = getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
+ Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> childrenNodes = getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
if (childrenNodes.isRight()) {
return Either.right(childrenNodes.right().value());
@@ -1458,43 +1459,43 @@ public class TitanGenericDao {
List<ImmutablePair<T, GraphEdge>> value = childrenNodes.left().value();
if (value.size() > 1) {
- return Either.right(TitanOperationStatus.MULTIPLE_CHILDS_WITH_SAME_EDGE);
+ return Either.right(JanusGraphOperationStatus.MULTIPLE_CHILDS_WITH_SAME_EDGE);
}
return Either.left(value.get(0));
}
- public ImmutablePair<TitanVertex, Edge> getChildVertex(TitanVertex vertex, GraphEdgeLabels edgeType) {
+ public ImmutablePair<JanusGraphVertex, Edge> getChildVertex(JanusGraphVertex vertex, GraphEdgeLabels edgeType) {
- ImmutablePair<TitanVertex, Edge> pair = null;
+ ImmutablePair<JanusGraphVertex, Edge> pair = null;
Iterator<Edge> edges = vertex.edges(Direction.OUT, edgeType.getProperty());
if (edges.hasNext()) {
// get only first edge
Edge edge = edges.next();
- pair = new ImmutablePair<>((TitanVertex) edge.inVertex(), edge);
+ pair = new ImmutablePair<>((JanusGraphVertex) edge.inVertex(), edge);
}
return pair;
}
- public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> getParentNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getParentNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
List<ImmutablePair<T, GraphEdge>> immutablePairs = new ArrayList<>();
T data = null;
GraphEdge graphEdge = null;
- Either<TitanGraph, TitanOperationStatus> graphRes = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
if (graphRes.isRight()) {
log.error(FAILED_TO_RETRIEVE_GRAPH_STATUS_IS, graphRes);
return Either.right(graphRes.right().value());
}
- TitanGraph titanGraph = graphRes.left().value();
+ JanusGraph janusGraph = graphRes.left().value();
@SuppressWarnings("unchecked")
- Iterable<TitanVertex> vertices = titanGraph.query().has(key, uniqueId).vertices();
+ Iterable<JanusGraphVertex> vertices = janusGraph.query().has(key, uniqueId).vertices();
if (vertices == null || !vertices.iterator().hasNext()) {
- return Either.right(TitanOperationStatus.INVALID_ID);
+ return Either.right(JanusGraphOperationStatus.INVALID_ID);
}
Vertex rootVertex = vertices.iterator().next();
@@ -1517,16 +1518,16 @@ public class TitanGenericDao {
}
if (immutablePairs.isEmpty()) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(immutablePairs);
}
- public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, TitanOperationStatus> getParentNode(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+ public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getParentNode(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
- Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> parentNodesRes = this.getParentNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
+ Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> parentNodesRes = this.getParentNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
if (parentNodesRes.isRight()) {
log.debug("failed to get edge key:{} uniqueId:{} edgeType {} nodeTypeEnum: {}, reason:{}", key, uniqueId, edgeType, nodeTypeEnum, parentNodesRes.right().value());
@@ -1536,17 +1537,17 @@ public class TitanGenericDao {
List<ImmutablePair<T, GraphEdge>> value = parentNodesRes.left().value();
if (value.size() > 1) {
- return Either.right(TitanOperationStatus.MULTIPLE_CHILDS_WITH_SAME_EDGE);
+ return Either.right(JanusGraphOperationStatus.MULTIPLE_CHILDS_WITH_SAME_EDGE);
}
return Either.left(value.get(0));
}
- public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, TitanOperationStatus> getChildByEdgeCriteria(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, Map<String, Object> edgeProperties) {
+ public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChildByEdgeCriteria(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, Map<String, Object> edgeProperties) {
- Either<Edge, TitanOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgeByCriteria(key, uniqueId, edgeType, edgeProperties);
+ Either<Edge, JanusGraphOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgeByCriteria(key, uniqueId, edgeType, edgeProperties);
if (outgoingEdgeByCriteria.isRight()) {
- TitanOperationStatus status = outgoingEdgeByCriteria.right().value();
+ JanusGraphOperationStatus status = outgoingEdgeByCriteria.right().value();
log.debug("Cannot find outgoing edge from vertex {} with label {} and properties {}" + uniqueId, edgeType, edgeProperties);
return Either.right(status);
}
@@ -1565,30 +1566,30 @@ public class TitanGenericDao {
return Either.left(immutablePair);
}
- public Either<ImmutablePair<TitanVertex, Edge>, TitanOperationStatus> getChildByEdgeCriteria(TitanVertex vertex, GraphEdgeLabels edgeType, Map<String, Object> edgeProperties) {
+ public Either<ImmutablePair<JanusGraphVertex, Edge>, JanusGraphOperationStatus> getChildByEdgeCriteria(JanusGraphVertex vertex, GraphEdgeLabels edgeType, Map<String, Object> edgeProperties) {
- Either<Edge, TitanOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgeByCriteria(vertex, edgeType, edgeProperties);
+ Either<Edge, JanusGraphOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgeByCriteria(vertex, edgeType, edgeProperties);
if (outgoingEdgeByCriteria.isRight()) {
- TitanOperationStatus status = outgoingEdgeByCriteria.right().value();
+ JanusGraphOperationStatus status = outgoingEdgeByCriteria.right().value();
log.debug("Cannot find outgoing edge from vertex {} with label {} and properties {}", vertex, edgeType, edgeProperties);
return Either.right(status);
}
Edge edge = outgoingEdgeByCriteria.left().value();
- TitanVertex outgoingVertex = (TitanVertex) edge.inVertex();
+ JanusGraphVertex outgoingVertex = (JanusGraphVertex) edge.inVertex();
- ImmutablePair<TitanVertex, Edge> immutablePair = new ImmutablePair<>(outgoingVertex, edge);
+ ImmutablePair<JanusGraphVertex, Edge> immutablePair = new ImmutablePair<>(outgoingVertex, edge);
return Either.left(immutablePair);
}
- public Either<Edge, TitanOperationStatus> getOutgoingEdgeByCriteria(String key, String value, GraphEdgeLabels label, Map<String, Object> props) {
+ public Either<Edge, JanusGraphOperationStatus> getOutgoingEdgeByCriteria(String key, String value, GraphEdgeLabels label, Map<String, Object> props) {
- Either<TitanVertex, TitanOperationStatus> vertexFrom = getVertexByProperty(key, value);
+ Either<JanusGraphVertex, JanusGraphOperationStatus> vertexFrom = getVertexByProperty(key, value);
if (vertexFrom.isRight()) {
- TitanOperationStatus status = vertexFrom.right().value();
- if (status == TitanOperationStatus.NOT_FOUND) {
- return Either.right(TitanOperationStatus.INVALID_ID);
+ JanusGraphOperationStatus status = vertexFrom.right().value();
+ if (status == JanusGraphOperationStatus.NOT_FOUND) {
+ return Either.right(JanusGraphOperationStatus.INVALID_ID);
}
return Either.right(status);
}
@@ -1596,9 +1597,9 @@ public class TitanGenericDao {
return getOutgoingEdgeByCriteria(vertexFrom.left().value(), label, props);
}
- public Either<Edge, TitanOperationStatus> getOutgoingEdgeByCriteria(TitanVertex vertex, GraphEdgeLabels label, Map<String, Object> props) {
+ public Either<Edge, JanusGraphOperationStatus> getOutgoingEdgeByCriteria(JanusGraphVertex vertex, GraphEdgeLabels label, Map<String, Object> props) {
- TitanVertexQuery<?> query = vertex.query();
+ JanusGraphVertexQuery<?> query = vertex.query();
query = query.direction(Direction.OUT).labels(label.getProperty());
if (props != null && !props.isEmpty()) {
@@ -1607,40 +1608,40 @@ public class TitanGenericDao {
}
}
Edge matchingEdge = null;
- Iterable<TitanEdge> edges = query.edges();
+ Iterable<JanusGraphEdge> edges = query.edges();
if (edges == null) {
log.debug(NO_EDGES_IN_GRAPH_FOR_CRITERIA);
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
- Iterator<TitanEdge> eIter = edges.iterator();
+ Iterator<JanusGraphEdge> eIter = edges.iterator();
if (eIter.hasNext()) {
matchingEdge = eIter.next();
}
if (matchingEdge == null) {
log.debug(NO_EDGES_IN_GRAPH_FOR_CRITERIA);
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(matchingEdge);
}
- public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> deleteChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> deleteChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
List<ImmutablePair<T, GraphEdge>> result = new ArrayList<>();
- Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> childrenNodesRes = getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
+ Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> childrenNodesRes = getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
if (childrenNodesRes.isRight()) {
- TitanOperationStatus status = childrenNodesRes.right().value();
+ JanusGraphOperationStatus status = childrenNodesRes.right().value();
return Either.right(status);
}
List<ImmutablePair<T, GraphEdge>> list = childrenNodesRes.left().value();
for (ImmutablePair<T, GraphEdge> pair : list) {
T node = pair.getKey();
- Either<T, TitanOperationStatus> deleteNodeRes = this.deleteNode(node, clazz);
+ Either<T, JanusGraphOperationStatus> deleteNodeRes = this.deleteNode(node, clazz);
if (deleteNodeRes.isRight()) {
- TitanOperationStatus status = deleteNodeRes.right().value();
+ JanusGraphOperationStatus status = deleteNodeRes.right().value();
log.error("Failed to delete node {} . status is {}", node, status);
return Either.right(status);
}
@@ -1686,8 +1687,8 @@ public class TitanGenericDao {
return result;
}
- public Object getProperty(TitanVertex vertex, String key) {
- PropertyKey propertyKey = titanClient.getGraph().left().value().getPropertyKey(key);
+ public Object getProperty(JanusGraphVertex vertex, String key) {
+ PropertyKey propertyKey = janusGraphClient.getGraph().left().value().getPropertyKey(key);
return vertex.valueOrNull(propertyKey);
}
@@ -1700,14 +1701,14 @@ public class TitanGenericDao {
return value;
}
- public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> getChildrenByEdgeCriteria(Vertex vertex, String vertexUniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz,
- Map<String, Object> edgeProperties) {
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenByEdgeCriteria(Vertex vertex, String vertexUniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz,
+ Map<String, Object> edgeProperties) {
List<ImmutablePair<T, GraphEdge>> result = new ArrayList<>();
- Either<List<Edge>, TitanOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgesByCriteria(vertex, edgeType, edgeProperties);
+ Either<List<Edge>, JanusGraphOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgesByCriteria(vertex, edgeType, edgeProperties);
if (outgoingEdgeByCriteria.isRight()) {
- TitanOperationStatus status = outgoingEdgeByCriteria.right().value();
+ JanusGraphOperationStatus status = outgoingEdgeByCriteria.right().value();
log.debug("Cannot find outgoing edge from vertex {} with label {} and properties {}", vertexUniqueId, edgeType, edgeProperties);
return Either.right(status);
}
@@ -1731,12 +1732,12 @@ public class TitanGenericDao {
return Either.left(result);
}
- public Either<List<Edge>, TitanOperationStatus> getOutgoingEdgesByCriteria(Vertex vertexFrom, GraphEdgeLabels label, Map<String, Object> props) {
+ public Either<List<Edge>, JanusGraphOperationStatus> getOutgoingEdgesByCriteria(Vertex vertexFrom, GraphEdgeLabels label, Map<String, Object> props) {
List<Edge> edgesResult = new ArrayList<>();
- TitanVertex titanVertex = (TitanVertex) vertexFrom;
- TitanVertexQuery<?> query = titanVertex.query();
+ JanusGraphVertex janusGraphVertex = (JanusGraphVertex) vertexFrom;
+ JanusGraphVertexQuery<?> query = janusGraphVertex.query();
query = query.direction(Direction.OUT).labels(label.getProperty());
@@ -1746,11 +1747,11 @@ public class TitanGenericDao {
}
}
- Iterable<TitanEdge> edges = query.edges();
- Iterator<TitanEdge> eIter = edges.iterator();
+ Iterable<JanusGraphEdge> edges = query.edges();
+ Iterator<JanusGraphEdge> eIter = edges.iterator();
if (edges == null || !eIter.hasNext()) {
log.debug("No edges found in graph for criteria (label = {} properties={})", label.getProperty(), props);
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
while (eIter.hasNext()) {
@@ -1760,7 +1761,7 @@ public class TitanGenericDao {
if (edgesResult.isEmpty()) {
log.debug("No edges found in graph for criteria (label = {} properties={})", label.getProperty(), props);
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(edgesResult);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanOperationStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphOperationStatus.java
index dc9ed02fca..a4ebcf79e0 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanOperationStatus.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphOperationStatus.java
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.be.dao.titan;
+package org.openecomp.sdc.be.dao.janusgraph;
-public enum TitanOperationStatus {
- OK, NOT_CONNECTED, NOT_CREATED, INDEX_CANNOT_BE_CHANGED, NOT_FOUND, MISSING_UNIQUE_ID, MISSING_NODE_LABEL, MULTIPLE_EDGES_WITH_SAME_LABEL, CANNOT_DELETE_NON_LEAF_NODE, MULTIPLE_NODES_WITH_SAME_ID, GRAPH_IS_NOT_AVAILABLE, TITAN_CONFIGURATION, TITAN_SCHEMA_VIOLATION, INVALID_ELEMENT, INVALID_QUERY, INVALID_ID, RESOURCE_UNAVAILABLE, ILLEGAL_ARGUMENT, ALREADY_LOCKED, ALREADY_EXIST, MULTIPLE_CHILDS_WITH_SAME_EDGE, GENERAL_ERROR, MATCH_NOT_FOUND, INVALID_TYPE, PROPERTY_NAME_ALREADY_EXISTS, INVALID_PROPERTY,
+public enum JanusGraphOperationStatus {
+ OK, NOT_CONNECTED, NOT_CREATED, INDEX_CANNOT_BE_CHANGED, NOT_FOUND, MISSING_UNIQUE_ID, MISSING_NODE_LABEL, MULTIPLE_EDGES_WITH_SAME_LABEL, CANNOT_DELETE_NON_LEAF_NODE, MULTIPLE_NODES_WITH_SAME_ID, GRAPH_IS_NOT_AVAILABLE, JANUSGRAPH_CONFIGURATION, JANUSGRAPH_SCHEMA_VIOLATION, INVALID_ELEMENT, INVALID_QUERY, INVALID_ID, RESOURCE_UNAVAILABLE, ILLEGAL_ARGUMENT, ALREADY_LOCKED, ALREADY_EXIST, MULTIPLE_CHILDS_WITH_SAME_EDGE, GENERAL_ERROR, MATCH_NOT_FOUND, INVALID_TYPE, PROPERTY_NAME_ALREADY_EXISTS, INVALID_PROPERTY,
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java
new file mode 100644
index 0000000000..fd9856b373
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java
@@ -0,0 +1,27 @@
+package org.openecomp.sdc.be.dao.janusgraph;
+
+import org.janusgraph.graphdb.query.JanusGraphPredicate;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import static org.janusgraph.core.attribute.Contain.NOT_IN;
+import static java.util.Collections.emptyMap;
+import static org.apache.commons.collections.CollectionUtils.isEmpty;
+
+public class JanusGraphUtils {
+
+ private JanusGraphUtils() {
+ }
+
+ public static <T> Map<String, Entry<JanusGraphPredicate, Object>> buildNotInPredicate(String propKey, Collection<T> notInCollection) {
+ if (isEmpty(notInCollection)) {
+ return emptyMap();
+ }
+ Map<String, Entry<JanusGraphPredicate, Object>> predicateCriteria = new HashMap<>();
+ predicateCriteria.put(propKey, new HashMap.SimpleEntry<>(NOT_IN, notInCollection));
+ return predicateCriteria;
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/QueryType.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/QueryType.java
index 689ed32a8a..fc2f2d0643 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/QueryType.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/QueryType.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.be.dao.titan;
+package org.openecomp.sdc.be.dao.janusgraph;
/**
* Created by mlando on 9/21/2016.
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/transactions/SimpleTitanTransactionManager.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/transactions/SimpleJanusGraphTransactionManager.java
index 2e5b7ea84c..8c67254da8 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/transactions/SimpleTitanTransactionManager.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/transactions/SimpleJanusGraphTransactionManager.java
@@ -1,9 +1,9 @@
-package org.openecomp.sdc.be.dao.titan.transactions;
+package org.openecomp.sdc.be.dao.janusgraph.transactions;
-import com.thinkaurelius.titan.core.TitanException;
-import com.thinkaurelius.titan.core.TitanGraph;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.janusgraph.core.JanusGraphException;
+import org.janusgraph.core.JanusGraph;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
@@ -15,23 +15,23 @@ import org.springframework.transaction.support.SimpleTransactionStatus;
import javax.annotation.PostConstruct;
/**
- * Simple transaction manager for the titan database.
+ * Simple transaction manager for the janusgraph database.
* This manager does not deal with transactions propagation and relies on the fact that transactions are automatically created with the first operation on the graph
*/
@Component
-public class SimpleTitanTransactionManager implements PlatformTransactionManager {
+public class SimpleJanusGraphTransactionManager implements PlatformTransactionManager {
- private static final Logger log = Logger.getLogger(SimpleTitanTransactionManager.class.getName());
- private final TitanGraphClient titanClient;
- private TitanGraph titanGraph;
+ private static final Logger log = Logger.getLogger(SimpleJanusGraphTransactionManager.class.getName());
+ private final JanusGraphClient janusGraphClient;
+ private JanusGraph janusGraph;
- public SimpleTitanTransactionManager(TitanGraphClient titanClient) {
- this.titanClient = titanClient;
+ public SimpleJanusGraphTransactionManager(JanusGraphClient janusGraphClient) {
+ this.janusGraphClient = janusGraphClient;
}
@PostConstruct
public void onInit() {
- titanGraph = titanClient.getGraph().left().on(this::onFailingToStartTitan);
+ janusGraph = janusGraphClient.getGraph().left().on(this::onFailingToStartJanusGraph);
}
@Override
@@ -44,8 +44,8 @@ public class SimpleTitanTransactionManager implements PlatformTransactionManager
public void commit(TransactionStatus transactionStatus) {
log.debug("#commit - committing transaction");
try {
- titanGraph.tx().commit();
- } catch (TitanException e) {
+ janusGraph.tx().commit();
+ } catch (JanusGraphException e) {
log.debug("#commit - failed to commit transaction", e);
throw new TransactionSystemException("failed to commit transaction", e);
}
@@ -55,16 +55,16 @@ public class SimpleTitanTransactionManager implements PlatformTransactionManager
public void rollback(TransactionStatus transactionStatus) {
log.debug("#rollback - committing transaction");
try {
- titanGraph.tx().rollback();
- } catch (TitanException e) {
+ janusGraph.tx().rollback();
+ } catch (JanusGraphException e) {
log.debug("#rollback - failed to rollback transaction", e);
throw new TransactionSystemException("failed to rollback transaction", e);
}
}
- private TitanGraph onFailingToStartTitan(TitanOperationStatus err) {
- log.debug("#onFailingToStartTitan - could not open titan client");
- throw new IllegalStateException("titan could not be initialized: " + err);
+ private JanusGraph onFailingToStartJanusGraph(JanusGraphOperationStatus err) {
+ log.debug("#onFailingToStartJanusGraph - could not open janusgraph client");
+ throw new IllegalStateException("janusgraph could not be initialized: " + err);
}
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java
index 74852944d0..2db22a72b0 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java
@@ -20,7 +20,7 @@
package org.openecomp.sdc.be.dao.jsongraph;
-import com.thinkaurelius.titan.core.TitanVertex;
+import org.janusgraph.core.JanusGraphVertex;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
@@ -37,7 +37,7 @@ import java.util.Map.Entry;
public class GraphVertex {
private String uniqueId;
- private TitanVertex vertex;
+ private JanusGraphVertex vertex;
private VertexTypeEnum label;
private Map<String, ? extends ToscaDataDefinition> json;
@@ -70,11 +70,11 @@ public class GraphVertex {
this.json = json;
}
- public TitanVertex getVertex() {
+ public JanusGraphVertex getVertex() {
return vertex;
}
- public void setVertex(TitanVertex vertex) {
+ public void setVertex(JanusGraphVertex vertex) {
this.vertex = vertex;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingTitanDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingJanusGraphDao.java
index fb6b9d8fa3..c2ef659c65 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingTitanDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingJanusGraphDao.java
@@ -21,29 +21,29 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-@Component("titan-dao")
-public class HealingTitanDao extends TitanDao {
+@Component("janusgraph-dao")
+public class HealingJanusGraphDao extends JanusGraphDao {
@Autowired
private HealingPipelineDao healingPipelineDao;
- public HealingTitanDao(TitanGraphClient titanClient) {
- super(titanClient);
+ public HealingJanusGraphDao(JanusGraphClient janusGraphClient) {
+ super(janusGraphClient);
}
@Override
- public Either<List<GraphVertex>, TitanOperationStatus> getChildrenVertecies(GraphVertex parentVertex,
- EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
- Either<List<GraphVertex>, TitanOperationStatus> childrenVertecies =
+ public Either<List<GraphVertex>, JanusGraphOperationStatus> getChildrenVertecies(GraphVertex parentVertex,
+ EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ Either<List<GraphVertex>, JanusGraphOperationStatus> childrenVertecies =
super.getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
return Either.iif(childrenVertecies.isRight(), () -> childrenVertecies.right().value(),
() -> childrenVertecies.left().value().stream()
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java
index a31900acce..5917b14fd3 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java
@@ -20,19 +20,19 @@
package org.openecomp.sdc.be.dao.jsongraph;
-import com.thinkaurelius.titan.core.*;
+import org.janusgraph.core.*;
import fj.data.Either;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.tinkerpop.gremlin.structure.*;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.dao.jsongraph.utils.JsonParserUtils;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
@@ -40,7 +40,6 @@ import org.openecomp.sdc.common.jsongraph.util.CommonUtility;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.*;
@@ -49,28 +48,28 @@ import java.util.Map.Entry;
import static org.apache.commons.collections.CollectionUtils.isEmpty;
-public class TitanDao {
- TitanGraphClient titanClient;
+public class JanusGraphDao {
+ JanusGraphClient janusGraphClient;
- private static Logger logger = Logger.getLogger(TitanDao.class.getName());
+ private static Logger logger = Logger.getLogger(JanusGraphDao.class.getName());
- public TitanDao(@Qualifier("titan-client") TitanGraphClient titanClient) {
- this.titanClient = titanClient;
- logger.info("** TitanDao created");
+ public JanusGraphDao(@Qualifier("janusgraph-client") JanusGraphClient janusGraphClient) {
+ this.janusGraphClient = janusGraphClient;
+ logger.info("** JanusGraphDao created");
}
- public TitanOperationStatus commit() {
+ public JanusGraphOperationStatus commit() {
logger.debug("#commit - The operation succeeded. Doing commit...");
- return titanClient.commit();
+ return janusGraphClient.commit();
}
- public TitanOperationStatus rollback() {
+ public JanusGraphOperationStatus rollback() {
logger.debug("#rollback - The operation failed. Doing rollback...");
- return titanClient.rollback();
+ return janusGraphClient.rollback();
}
- public Either<TitanGraph, TitanOperationStatus> getGraph() {
- return titanClient.getGraph();
+ public Either<JanusGraph, JanusGraphOperationStatus> getGraph() {
+ return janusGraphClient.getGraph();
}
/**
@@ -78,14 +77,14 @@ public class TitanDao {
* @param graphVertex
* @return
*/
- public Either<GraphVertex, TitanOperationStatus> createVertex(GraphVertex graphVertex) {
+ public Either<GraphVertex, JanusGraphOperationStatus> createVertex(GraphVertex graphVertex) {
logger.trace("try to create vertex for ID [{}]", graphVertex.getUniqueId());
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
- TitanVertex vertex = tGraph.addVertex();
+ JanusGraphVertex vertex = tGraph.addVertex();
setVertexProperties(vertex, graphVertex);
@@ -95,7 +94,7 @@ public class TitanDao {
} catch (Exception e) {
logger.debug("Failed to create Node for ID [{}]", graphVertex.getUniqueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
logger.debug("Failed to create vertex for ID [{}] {}", graphVertex.getUniqueId(), graph.right().value());
@@ -110,23 +109,23 @@ public class TitanDao {
* @param label
* @return
*/
- public Either<GraphVertex, TitanOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label) {
+ public Either<GraphVertex, JanusGraphOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label) {
return getVertexByPropertyAndLabel(name, value, label, JsonParseFlagEnum.ParseAll);
}
- public Either<GraphVertex, TitanOperationStatus> getVertexByLabel(VertexTypeEnum label) {
- return titanClient.getGraph().left().map(graph -> graph.query().has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices()).left().bind(titanVertices -> getFirstFoundVertex(JsonParseFlagEnum.NoParse, titanVertices));
+ public Either<GraphVertex, JanusGraphOperationStatus> getVertexByLabel(VertexTypeEnum label) {
+ return janusGraphClient.getGraph().left().map(graph -> graph.query().has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices()).left().bind(janusGraphVertices -> getFirstFoundVertex(JsonParseFlagEnum.NoParse, janusGraphVertices));
}
- private Either<GraphVertex, TitanOperationStatus> getFirstFoundVertex(JsonParseFlagEnum parseFlag, Iterable<TitanVertex> vertices) {
- Iterator<TitanVertex> iterator = vertices.iterator();
+ private Either<GraphVertex, JanusGraphOperationStatus> getFirstFoundVertex(JsonParseFlagEnum parseFlag, Iterable<JanusGraphVertex> vertices) {
+ Iterator<JanusGraphVertex> iterator = vertices.iterator();
if (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
+ JanusGraphVertex vertex = iterator.next();
GraphVertex graphVertex = createAndFill(vertex, parseFlag);
return Either.left(graphVertex);
}
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
/**
@@ -137,19 +136,19 @@ public class TitanDao {
* @param parseFlag
* @return
*/
- public Either<GraphVertex, TitanOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label, JsonParseFlagEnum parseFlag) {
+ public Either<GraphVertex, JanusGraphOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label, JsonParseFlagEnum parseFlag) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
@SuppressWarnings("unchecked")
- Iterable<TitanVertex> vertecies = tGraph.query().has(name.getProperty(), value).has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices();
+ Iterable<JanusGraphVertex> vertecies = tGraph.query().has(name.getProperty(), value).has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices();
- java.util.Iterator<TitanVertex> iterator = vertecies.iterator();
+ java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
if (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
+ JanusGraphVertex vertex = iterator.next();
GraphVertex graphVertex = createAndFill(vertex, parseFlag);
return Either.left(graphVertex);
@@ -157,12 +156,12 @@ public class TitanDao {
if (logger.isDebugEnabled()) {
logger.debug("No vertex in graph for key = {} and value = {} label = {}" + name, value, label);
}
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to get vertex in graph for key ={} and value = {} label = {}", name, value, label);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -178,7 +177,7 @@ public class TitanDao {
* @param id
* @return
*/
- public Either<GraphVertex, TitanOperationStatus> getVertexById(String id) {
+ public Either<GraphVertex, JanusGraphOperationStatus> getVertexById(String id) {
return getVertexById(id, JsonParseFlagEnum.ParseAll);
}
@@ -188,38 +187,38 @@ public class TitanDao {
* @param parseFlag
* @return
*/
- public Either<GraphVertex, TitanOperationStatus> getVertexById(String id, JsonParseFlagEnum parseFlag) {
+ public Either<GraphVertex, JanusGraphOperationStatus> getVertexById(String id, JsonParseFlagEnum parseFlag) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (id == null) {
if (logger.isDebugEnabled()) {
logger.debug("No vertex in graph for id = {} ", id);
}
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
@SuppressWarnings("unchecked")
- Iterable<TitanVertex> vertecies = tGraph.query().has(GraphPropertyEnum.UNIQUE_ID.getProperty(), id).vertices();
+ Iterable<JanusGraphVertex> vertecies = tGraph.query().has(GraphPropertyEnum.UNIQUE_ID.getProperty(), id).vertices();
- java.util.Iterator<TitanVertex> iterator = vertecies.iterator();
+ java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
if (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
+ JanusGraphVertex vertex = iterator.next();
GraphVertex graphVertex = createAndFill(vertex, parseFlag);
return Either.left(graphVertex);
} else {
if (logger.isDebugEnabled()) {
logger.debug("No vertex in graph for id = {}", id);
}
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to get vertex in graph for id {} ", id);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
if (logger.isDebugEnabled()) {
@@ -229,7 +228,7 @@ public class TitanDao {
}
}
- private void setVertexProperties(TitanVertex vertex, GraphVertex graphVertex) throws IOException {
+ private void setVertexProperties(JanusGraphVertex vertex, GraphVertex graphVertex) throws IOException {
if (graphVertex.getMetadataProperties() != null) {
for (Map.Entry<GraphPropertyEnum, Object> entry : graphVertex.getMetadataProperties().entrySet()) {
@@ -261,7 +260,7 @@ public class TitanDao {
}
}
- private GraphVertex createAndFill(TitanVertex vertex, JsonParseFlagEnum parseFlag) {
+ private GraphVertex createAndFill(JanusGraphVertex vertex, JsonParseFlagEnum parseFlag) {
GraphVertex graphVertex = new GraphVertex();
graphVertex.setVertex(vertex);
parseVertexProperties(graphVertex, parseFlag);
@@ -269,7 +268,7 @@ public class TitanDao {
}
public void parseVertexProperties(GraphVertex graphVertex, JsonParseFlagEnum parseFlag) {
- TitanVertex vertex = graphVertex.getVertex();
+ JanusGraphVertex vertex = graphVertex.getVertex();
Map<GraphPropertyEnum, Object> properties = getVertexProperties(vertex);
VertexTypeEnum label = VertexTypeEnum.getByName((String) (properties.get(GraphPropertyEnum.LABEL)));
for (Map.Entry<GraphPropertyEnum, Object> entry : properties.entrySet()) {
@@ -308,30 +307,30 @@ public class TitanDao {
}
}
- public TitanOperationStatus createEdge(GraphVertex from, GraphVertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
+ public JanusGraphOperationStatus createEdge(GraphVertex from, GraphVertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
return createEdge(from.getVertex(), to.getVertex(), label, properties);
}
- public TitanOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
+ public JanusGraphOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
if (logger.isTraceEnabled()) {
logger.trace("Try to connect {} with {} label {} properties {}",
from == null ? "NULL" : from.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
to == null ? "NULL" : to.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), label, properties);
}
if (from == null || to == null) {
- logger.trace("No Titan vertex for id from {} or id to {}",
+ logger.trace("No JanusGraph vertex for id from {} or id to {}",
from == null ? "NULL" : from.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
to == null ? "NULL" : to.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
- return TitanOperationStatus.NOT_FOUND;
+ return JanusGraphOperationStatus.NOT_FOUND;
}
Edge edge = from.addEdge(label.name(), to);
- TitanOperationStatus status;
+ JanusGraphOperationStatus status;
try {
setEdgeProperties(edge, properties);
- status = TitanOperationStatus.OK;
+ status = JanusGraphOperationStatus.OK;
} catch (IOException e) {
logger.debug("Failed to set properties on edge properties [{}]", properties, e);
- status = TitanOperationStatus.GENERAL_ERROR;
+ status = JanusGraphOperationStatus.GENERAL_ERROR;
}
return status;
}
@@ -401,17 +400,17 @@ public class TitanDao {
}
}
- public Either<List<GraphVertex>, TitanOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props) {
+ public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props) {
return getByCriteria(type, props, JsonParseFlagEnum.ParseAll);
}
- public Either<List<GraphVertex>, TitanOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, JsonParseFlagEnum parseFlag) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, JsonParseFlagEnum parseFlag) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
- TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+ JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
if (type != null) {
query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
}
@@ -421,16 +420,16 @@ public class TitanDao {
query = query.has(entry.getKey().getProperty(), entry.getValue());
}
}
- Iterable<TitanVertex> vertices = query.vertices();
+ Iterable<JanusGraphVertex> vertices = query.vertices();
if (vertices == null) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
- Iterator<TitanVertex> iterator = vertices.iterator();
+ Iterator<JanusGraphVertex> iterator = vertices.iterator();
List<GraphVertex> result = new ArrayList<>();
while (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
+ JanusGraphVertex vertex = iterator.next();
Map<GraphPropertyEnum, Object> newProp = getVertexProperties(vertex);
GraphVertex graphVertex = createAndFill(vertex, parseFlag);
@@ -441,7 +440,7 @@ public class TitanDao {
logger.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
}
if (result.size() == 0) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(result);
@@ -449,7 +448,7 @@ public class TitanDao {
if (logger.isDebugEnabled()) {
logger.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -460,13 +459,13 @@ public class TitanDao {
}
}
- public Either<List<GraphVertex>, TitanOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, Map<GraphPropertyEnum, Object> hasNotProps, JsonParseFlagEnum parseFlag) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, Map<GraphPropertyEnum, Object> hasNotProps, JsonParseFlagEnum parseFlag) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
- TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+ JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
if (type != null) {
query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
}
@@ -485,16 +484,16 @@ public class TitanDao {
}
}
}
- Iterable<TitanVertex> vertices = query.vertices();
+ Iterable<JanusGraphVertex> vertices = query.vertices();
if (vertices == null) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
- Iterator<TitanVertex> iterator = vertices.iterator();
+ Iterator<JanusGraphVertex> iterator = vertices.iterator();
List<GraphVertex> result = new ArrayList<>();
while (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
+ JanusGraphVertex vertex = iterator.next();
Map<GraphPropertyEnum, Object> newProp = getVertexProperties(vertex);
GraphVertex graphVertex = createAndFill(vertex, parseFlag);
@@ -505,7 +504,7 @@ public class TitanDao {
logger.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
}
if (result.size() == 0) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(result);
@@ -513,7 +512,7 @@ public class TitanDao {
if (logger.isDebugEnabled()) {
logger.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -524,22 +523,22 @@ public class TitanDao {
}
}
- public Either<Iterator<Vertex>, TitanOperationStatus> getCatalogOrArchiveVerticies(boolean isCatalog) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ public Either<Iterator<Vertex>, JanusGraphOperationStatus> getCatalogOrArchiveVerticies(boolean isCatalog) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
- TitanGraph tGraph = graph.left().value();
+ JanusGraph tGraph = graph.left().value();
String name = isCatalog ? VertexTypeEnum.CATALOG_ROOT.getName() : VertexTypeEnum.ARCHIVE_ROOT.getName();
- Iterable<TitanVertex> vCatalogIter = tGraph.query().has(GraphPropertyEnum.LABEL.getProperty(), name).vertices();
+ Iterable<JanusGraphVertex> vCatalogIter = tGraph.query().has(GraphPropertyEnum.LABEL.getProperty(), name).vertices();
if (vCatalogIter == null) {
logger.debug("Failed to fetch catalog vertex");
- return Either.right(TitanOperationStatus.GENERAL_ERROR);
+ return Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
}
- TitanVertex catalogV = vCatalogIter.iterator().next();
+ JanusGraphVertex catalogV = vCatalogIter.iterator().next();
if (catalogV == null) {
logger.debug("Failed to fetch catalog vertex");
- return Either.right(TitanOperationStatus.GENERAL_ERROR);
+ return Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
}
String edgeLabel = isCatalog ? EdgeLabelEnum.CATALOG_ELEMENT.name() : EdgeLabelEnum.ARCHIVE_ELEMENT.name();
Iterator<Vertex> vertices = catalogV.vertices(Direction.OUT, edgeLabel);
@@ -549,7 +548,7 @@ public class TitanDao {
if (logger.isDebugEnabled()) {
logger.debug("Failed get by criteria: ", e);
}
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -560,7 +559,7 @@ public class TitanDao {
}
}
- private void buildMultipleNegateQueryFromList(Map.Entry<GraphPropertyEnum, Object> entry, TitanGraphQuery query) {
+ private void buildMultipleNegateQueryFromList(Map.Entry<GraphPropertyEnum, Object> entry, JanusGraphQuery query) {
List<Object> negateList = (List<Object>) entry.getValue();
for (Object listItem : negateList) {
query.hasNot(entry.getKey().getProperty(), listItem);
@@ -574,8 +573,8 @@ public class TitanDao {
* @param parseFlag
* @return
*/
- public Either<GraphVertex, TitanOperationStatus> getChildVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
- Either<List<GraphVertex>, TitanOperationStatus> childrenVertecies = getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
+ public Either<GraphVertex, JanusGraphOperationStatus> getChildVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ Either<List<GraphVertex>, JanusGraphOperationStatus> childrenVertecies = getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
if (childrenVertecies.isRight()) {
return Either.right(childrenVertecies.right().value());
}
@@ -589,32 +588,32 @@ public class TitanDao {
* @param parseFlag
* @return
*/
- public Either<Vertex, TitanOperationStatus> getChildVertex(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
- Either<List<Vertex>, TitanOperationStatus> childrenVertecies = getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
+ public Either<Vertex, JanusGraphOperationStatus> getChildVertex(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ Either<List<Vertex>, JanusGraphOperationStatus> childrenVertecies = getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
if (childrenVertecies.isRight()) {
return Either.right(childrenVertecies.right().value());
}
return Either.left(childrenVertecies.left().value().get(0));
}
- public Either<GraphVertex, TitanOperationStatus> getParentVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
- Either<List<GraphVertex>, TitanOperationStatus> childrenVertecies = getParentVertecies(parentVertex, edgeLabel, parseFlag);
+ public Either<GraphVertex, JanusGraphOperationStatus> getParentVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ Either<List<GraphVertex>, JanusGraphOperationStatus> childrenVertecies = getParentVertecies(parentVertex, edgeLabel, parseFlag);
if (childrenVertecies.isRight()) {
return Either.right(childrenVertecies.right().value());
}
if (isEmpty(childrenVertecies.left().value())){
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(childrenVertecies.left().value().get(0));
}
- public Either<Vertex, TitanOperationStatus> getParentVertex(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
- Either<List<Vertex>, TitanOperationStatus> childrenVertecies = getParentVertecies(parentVertex, edgeLabel, parseFlag);
+ public Either<Vertex, JanusGraphOperationStatus> getParentVertex(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ Either<List<Vertex>, JanusGraphOperationStatus> childrenVertecies = getParentVertecies(parentVertex, edgeLabel, parseFlag);
if (childrenVertecies.isRight() ) {
return Either.right(childrenVertecies.right().value());
}
if (isEmpty(childrenVertecies.left().value())){
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(childrenVertecies.left().value().get(0));
}
@@ -626,22 +625,22 @@ public class TitanDao {
* @param parseFlag
* @return
*/
- public Either<List<GraphVertex>, TitanOperationStatus> getChildrenVertecies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ public Either<List<GraphVertex>, JanusGraphOperationStatus> getChildrenVertecies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.OUT);
}
- public Either<List<GraphVertex>, TitanOperationStatus> getParentVertecies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ public Either<List<GraphVertex>, JanusGraphOperationStatus> getParentVertecies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.IN);
}
- public Either<List<Vertex>, TitanOperationStatus> getParentVertecies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ public Either<List<Vertex>, JanusGraphOperationStatus> getParentVertecies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.IN);
}
- private Either<List<Vertex>, TitanOperationStatus> getAdjacentVerticies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
+ private Either<List<Vertex>, JanusGraphOperationStatus> getAdjacentVerticies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
List<Vertex> list = new ArrayList<>();
try {
- Either<TitanGraph, TitanOperationStatus> graphRes = titanClient.getGraph();
+ Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
if (graphRes.isRight()) {
logger.error("Failed to retrieve graph. status is {}", graphRes);
return Either.right(graphRes.right().value());
@@ -650,11 +649,11 @@ public class TitanDao {
if (edgesCreatorIterator != null) {
while (edgesCreatorIterator.hasNext()) {
Edge edge = edgesCreatorIterator.next();
- TitanVertex vertex;
+ JanusGraphVertex vertex;
if (direction == Direction.IN) {
- vertex = (TitanVertex) edge.outVertex();
+ vertex = (JanusGraphVertex) edge.outVertex();
} else {
- vertex = (TitanVertex) edge.inVertex();
+ vertex = (JanusGraphVertex) edge.inVertex();
}
// GraphVertex graphVertex = createAndFill(vertex, parseFlag);
@@ -662,11 +661,11 @@ public class TitanDao {
}
}
if (list.isEmpty()) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
} catch (Exception e) {
logger.error("Failed to perform graph operation ", e);
- Either.right(TitanGraphClient.handleTitanException(e));
+ Either.right(JanusGraphClient.handleJanusGraphException(e));
}
return Either.left(list);
@@ -679,19 +678,19 @@ public class TitanDao {
* @param parseFlag
* @return
*/
- public Either<List<Vertex>, TitanOperationStatus> getChildrenVertecies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ public Either<List<Vertex>, JanusGraphOperationStatus> getChildrenVertecies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.OUT);
}
- private Either<List<GraphVertex>, TitanOperationStatus> getAdjacentVerticies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
+ private Either<List<GraphVertex>, JanusGraphOperationStatus> getAdjacentVerticies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
List<GraphVertex> list = new ArrayList<>();
- Either<List<Vertex>, TitanOperationStatus> adjacentVerticies = getAdjacentVerticies(parentVertex.getVertex(), edgeLabel, parseFlag, direction);
+ Either<List<Vertex>, JanusGraphOperationStatus> adjacentVerticies = getAdjacentVerticies(parentVertex.getVertex(), edgeLabel, parseFlag, direction);
if (adjacentVerticies.isRight()) {
return Either.right(adjacentVerticies.right().value());
}
adjacentVerticies.left().value().stream().forEach(vertex -> {
- list.add(createAndFill((TitanVertex) vertex, parseFlag));
+ list.add(createAndFill((JanusGraphVertex) vertex, parseFlag));
});
return Either.left(list);
@@ -703,15 +702,15 @@ public class TitanDao {
* @param vertex
* @param label
* @param properties
- * @return found edge or TitanOperationStatus
+ * @return found edge or JanusGraphOperationStatus
*/
- public Either<Edge, TitanOperationStatus> getBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+ public Either<Edge, JanusGraphOperationStatus> getBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
- Either<Edge, TitanOperationStatus> result = null;
+ Either<Edge, JanusGraphOperationStatus> result = null;
Edge matchingEdge = null;
String notFoundMsg = "No edges in graph for criteria";
try {
- TitanVertexQuery<?> query = vertex.getVertex().query().labels(label.name());
+ JanusGraphVertexQuery<?> query = vertex.getVertex().query().labels(label.name());
if (properties != null && !properties.isEmpty()) {
for (Map.Entry<GraphPropertyEnum, Object> entry : properties.entrySet()) {
@@ -719,17 +718,17 @@ public class TitanDao {
}
}
- Iterable<TitanEdge> edges = query.edges();
+ Iterable<JanusGraphEdge> edges = query.edges();
if (edges == null) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, notFoundMsg);
- result = Either.right(TitanOperationStatus.NOT_FOUND);
+ result = Either.right(JanusGraphOperationStatus.NOT_FOUND);
} else {
- Iterator<TitanEdge> eIter = edges.iterator();
+ Iterator<JanusGraphEdge> eIter = edges.iterator();
if (eIter.hasNext()) {
matchingEdge = eIter.next();
} else {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, notFoundMsg);
- result = Either.right(TitanOperationStatus.NOT_FOUND);
+ result = Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
}
if (result == null) {
@@ -737,13 +736,13 @@ public class TitanDao {
}
} catch (Exception e) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during getting edge by criteria for component with id {}. {}", vertex.getUniqueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
return result;
}
- public Either<Edge, TitanOperationStatus> getEdgeByChildrenVertexProperties(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
- Either<Edge, TitanOperationStatus> result = null;
+ public Either<Edge, JanusGraphOperationStatus> getEdgeByChildrenVertexProperties(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+ Either<Edge, JanusGraphOperationStatus> result = null;
Edge matchingEdge = null;
String notFoundMsg = "No edges in graph for criteria";
try {
@@ -761,11 +760,11 @@ public class TitanDao {
if (result == null) {
//no match
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, notFoundMsg);
- result = Either.right(TitanOperationStatus.NOT_FOUND);
+ result = Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
} catch (Exception e) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during getting edge by criteria for component with id {}. {}", vertex.getUniqueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
return result;
}
@@ -778,8 +777,8 @@ public class TitanDao {
* @param properties
* @return
*/
- public Either<Edge, TitanOperationStatus> deleteBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
- Either<Edge, TitanOperationStatus> result = null;
+ public Either<Edge, JanusGraphOperationStatus> deleteBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+ Either<Edge, JanusGraphOperationStatus> result = null;
try {
result = getBelongingEdgeByCriteria(vertex, label, properties);
if (result.isLeft()) {
@@ -792,7 +791,7 @@ public class TitanDao {
}
} catch (Exception e) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge by criteria for the component with id {}. {}", vertex == null ? "NULL" : vertex.getUniqueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
return result;
}
@@ -807,19 +806,19 @@ public class TitanDao {
* @return
*/
- public Either<Edge, TitanOperationStatus> deleteEdge(GraphVertex fromVertex, GraphVertex toVertex, EdgeLabelEnum label) {
+ public Either<Edge, JanusGraphOperationStatus> deleteEdge(GraphVertex fromVertex, GraphVertex toVertex, EdgeLabelEnum label) {
return deleteEdge(fromVertex.getVertex(), toVertex.getVertex(), label, fromVertex.getUniqueId(), toVertex.getUniqueId(), false);
}
- public Either<Edge, TitanOperationStatus> deleteAllEdges(GraphVertex fromVertex, GraphVertex toVertex, EdgeLabelEnum label) {
+ public Either<Edge, JanusGraphOperationStatus> deleteAllEdges(GraphVertex fromVertex, GraphVertex toVertex, EdgeLabelEnum label) {
return deleteEdge(fromVertex.getVertex(), toVertex.getVertex(), label, fromVertex.getUniqueId(), toVertex.getUniqueId(), true);
}
- public Either<Edge, TitanOperationStatus> deleteEdge(TitanVertex fromVertex, TitanVertex toVertex, EdgeLabelEnum label, String uniqueIdFrom, String uniqueIdTo, boolean deleteAll) {
- Either<Edge, TitanOperationStatus> result = null;
+ public Either<Edge, JanusGraphOperationStatus> deleteEdge(JanusGraphVertex fromVertex, JanusGraphVertex toVertex, EdgeLabelEnum label, String uniqueIdFrom, String uniqueIdTo, boolean deleteAll) {
+ Either<Edge, JanusGraphOperationStatus> result = null;
try {
- Iterable<TitanEdge> edges = fromVertex.query().labels(label.name()).edges();
- Iterator<TitanEdge> eIter = edges.iterator();
+ Iterable<JanusGraphEdge> edges = fromVertex.query().labels(label.name()).edges();
+ Iterator<JanusGraphEdge> eIter = edges.iterator();
while (eIter.hasNext()) {
Edge edge = eIter.next();
String currVertexUniqueId = edge.inVertex().value(GraphPropertyEnum.UNIQUE_ID.getProperty());
@@ -834,16 +833,16 @@ public class TitanDao {
}
if (result == null) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete an edge with the label {} between vertices {} and {}. ", label.name(), uniqueIdFrom, uniqueIdTo);
- result = Either.right(TitanOperationStatus.NOT_FOUND);
+ result = Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
} catch (Exception e) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge with the label {} between vertices {} and {}. {}", label.name(), uniqueIdFrom, uniqueIdTo, e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
return result;
}
- public TitanOperationStatus deleteEdgeByDirection(GraphVertex fromVertex, Direction direction, EdgeLabelEnum label) {
+ public JanusGraphOperationStatus deleteEdgeByDirection(GraphVertex fromVertex, Direction direction, EdgeLabelEnum label) {
try {
Iterator<Edge> edges = fromVertex.getVertex().edges(direction, label.name());
@@ -853,9 +852,9 @@ public class TitanDao {
}
} catch (Exception e) {
logger.debug("Failed to remove from vertex {} edges {} by direction {} ", fromVertex.getUniqueId(), label, direction, e);
- return TitanGraphClient.handleTitanException(e);
+ return JanusGraphClient.handleJanusGraphException(e);
}
- return TitanOperationStatus.OK;
+ return JanusGraphOperationStatus.OK;
}
/**
@@ -864,7 +863,7 @@ public class TitanDao {
* @param graphVertex
* @return
*/
- public Either<GraphVertex, TitanOperationStatus> updateVertex(GraphVertex graphVertex) {
+ public Either<GraphVertex, JanusGraphOperationStatus> updateVertex(GraphVertex graphVertex) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to update metadata of vertex with uniqueId {}. ", graphVertex.getUniqueId());
try {
graphVertex.updateMetadataJsonWithCurrentMetadataProperties();
@@ -872,7 +871,7 @@ public class TitanDao {
} catch (Exception e) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update metadata of vertex with uniqueId {}. ", graphVertex.getUniqueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
return Either.left(graphVertex);
}
@@ -883,12 +882,12 @@ public class TitanDao {
* @param verticesToGet
* @return
*/
- public Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesByUniqueIdAndParseFlag(Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGet) {
+ public Either<Map<String, GraphVertex>, JanusGraphOperationStatus> getVerticesByUniqueIdAndParseFlag(Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGet) {
- Either<Map<String, GraphVertex>, TitanOperationStatus> result = null;
+ Either<Map<String, GraphVertex>, JanusGraphOperationStatus> result = null;
Map<String, GraphVertex> vertices = new HashMap<>();
- TitanOperationStatus titatStatus;
- Either<GraphVertex, TitanOperationStatus> getVertexRes = null;
+ JanusGraphOperationStatus titatStatus;
+ Either<GraphVertex, JanusGraphOperationStatus> getVertexRes = null;
for (Map.Entry<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> entry : verticesToGet.entrySet()) {
if (entry.getValue().getKey() == GraphPropertyEnum.UNIQUE_ID) {
getVertexRes = getVertexById(entry.getKey(), entry.getValue().getValue());
@@ -896,7 +895,7 @@ public class TitanDao {
getVertexRes = getVertexByPropertyAndLabel(entry.getValue().getKey(), entry.getKey(), VertexTypeEnum.USER, entry.getValue().getValue());
}
if (getVertexRes == null) {
- titatStatus = TitanOperationStatus.ILLEGAL_ARGUMENT;
+ titatStatus = JanusGraphOperationStatus.ILLEGAL_ARGUMENT;
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Invalid vertex type label {} has been received. ", entry.getValue().getKey(), titatStatus);
return Either.right(titatStatus);
}
@@ -924,16 +923,16 @@ public class TitanDao {
* @param edgeToCopy
* @return
*/
- public TitanOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Edge edgeToCopy) {
+ public JanusGraphOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Edge edgeToCopy) {
return createEdge(from, to, label, getEdgeProperties(edgeToCopy));
}
- public TitanOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, Edge prevEdge, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
+ public JanusGraphOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, Edge prevEdge, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to replace edge with label {} to {} between vertices {} and {}", prevLabel, newLabel, fromVertex!=null ? fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()) : "NULL",
toVertex!=null ? toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()) : "NULL");
- TitanOperationStatus result = createEdge(fromVertex, toVertex, newLabel, prevEdge);
- if (result == TitanOperationStatus.OK) {
+ JanusGraphOperationStatus result = createEdge(fromVertex, toVertex, newLabel, prevEdge);
+ if (result == JanusGraphOperationStatus.OK) {
prevEdge.remove();
}
return result;
@@ -948,14 +947,14 @@ public class TitanDao {
* @param newLabel
* @return
*/
- public TitanOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
+ public JanusGraphOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
- TitanOperationStatus result = null;
+ JanusGraphOperationStatus result = null;
Iterator<Edge> prevEdgeIter = toVertex.edges(Direction.IN, prevLabel.name());
if (prevEdgeIter == null || !prevEdgeIter.hasNext()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to replace edge with label {} to {} between vertices {} and {}", prevLabel, newLabel, fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
- result = TitanOperationStatus.NOT_FOUND;
+ result = JanusGraphOperationStatus.NOT_FOUND;
}
if (result == null) {
result = replaceEdgeLabel(fromVertex, toVertex, prevEdgeIter.next(), prevLabel, newLabel);
@@ -971,7 +970,7 @@ public class TitanDao {
* @param properties
* @return
*/
- public TitanOperationStatus updateVertexMetadataPropertiesWithJson(Vertex vertex, Map<GraphPropertyEnum, Object> properties) {
+ public JanusGraphOperationStatus updateVertexMetadataPropertiesWithJson(Vertex vertex, Map<GraphPropertyEnum, Object> properties) {
try {
if (!MapUtils.isEmpty(properties)) {
String jsonMetadataStr = (String) vertex.property(GraphPropertyEnum.METADATA.getProperty()).value();
@@ -984,12 +983,12 @@ public class TitanDao {
}
} catch (Exception e) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occurred during update vertex metadata properties with json{}. {}", vertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), e.getMessage());
- return TitanGraphClient.handleTitanException(e);
+ return JanusGraphClient.handleJanusGraphException(e);
}
- return TitanOperationStatus.OK;
+ return JanusGraphOperationStatus.OK;
}
- public TitanOperationStatus disassociateAndDeleteLast(GraphVertex vertex, Direction direction, EdgeLabelEnum label) {
+ public JanusGraphOperationStatus disassociateAndDeleteLast(GraphVertex vertex, Direction direction, EdgeLabelEnum label) {
try {
Iterator<Edge> edges = vertex.getVertex().edges(direction, label.name());
@@ -1015,13 +1014,13 @@ public class TitanDao {
}
} catch (Exception e) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge with the label {} direction {} from vertex {}. {}", label.name(), direction, vertex.getUniqueId(), e);
- return TitanGraphClient.handleTitanException(e);
+ return JanusGraphClient.handleJanusGraphException(e);
}
- return TitanOperationStatus.OK;
+ return JanusGraphOperationStatus.OK;
}
- public Object getProperty(TitanVertex vertex, String key) {
- PropertyKey propertyKey = titanClient.getGraph().left().value().getPropertyKey(key);
+ public Object getProperty(JanusGraphVertex vertex, String key) {
+ PropertyKey propertyKey = janusGraphClient.getGraph().left().value().getPropertyKey(key);
return vertex.valueOrNull(propertyKey);
}
@@ -1050,26 +1049,26 @@ public class TitanDao {
* @param direction
* @return
*/
- public TitanOperationStatus moveEdge(GraphVertex vertexA, GraphVertex vertexB, EdgeLabelEnum label, Direction direction) {
- TitanOperationStatus result = deleteEdgeByDirection(vertexA, direction, label);
- if (result != TitanOperationStatus.OK) {
+ public JanusGraphOperationStatus moveEdge(GraphVertex vertexA, GraphVertex vertexB, EdgeLabelEnum label, Direction direction) {
+ JanusGraphOperationStatus result = deleteEdgeByDirection(vertexA, direction, label);
+ if (result != JanusGraphOperationStatus.OK) {
logger.error("Failed to diassociate {} from element {}. error {} ", label, vertexA.getUniqueId(), result);
return result;
}
- TitanOperationStatus createRelation;
+ JanusGraphOperationStatus createRelation;
if (direction == Direction.IN) {
createRelation = createEdge(vertexB, vertexA, label, null);
} else {
createRelation = createEdge(vertexA, vertexB, label, null);
}
- if (createRelation != TitanOperationStatus.OK) {
+ if (createRelation != JanusGraphOperationStatus.OK) {
return createRelation;
}
- return TitanOperationStatus.OK;
+ return JanusGraphOperationStatus.OK;
}
- public Either<Edge, TitanOperationStatus> getBelongingEdgeByCriteria(String parentId, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
- Either<GraphVertex, TitanOperationStatus> getVertexRes = getVertexById(parentId, JsonParseFlagEnum.NoParse);
+ public Either<Edge, JanusGraphOperationStatus> getBelongingEdgeByCriteria(String parentId, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+ Either<GraphVertex, JanusGraphOperationStatus> getVertexRes = getVertexById(parentId, JsonParseFlagEnum.NoParse);
if (getVertexRes.isRight()) {
return Either.right(getVertexRes.right().value());
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractTitanVertexHeal.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractJanusGraphVertexHeal.java
index e01ddab989..f60a063a0a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractTitanVertexHeal.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractJanusGraphVertexHeal.java
@@ -17,6 +17,6 @@ package org.openecomp.sdc.be.dao.jsongraph.heal;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-public abstract class AbstractTitanVertexHeal implements Heal<GraphNode> {
+public abstract class AbstractJanusGraphVertexHeal implements Heal<GraphNode> {
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanUtils.java
deleted file mode 100644
index 163ef807fb..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanUtils.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.openecomp.sdc.be.dao.titan;
-
-import com.thinkaurelius.titan.graphdb.query.TitanPredicate;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import static com.thinkaurelius.titan.core.attribute.Contain.NOT_IN;
-import static java.util.Collections.emptyMap;
-import static org.apache.commons.collections.CollectionUtils.isEmpty;
-
-public class TitanUtils {
-
- private TitanUtils() {
- }
-
- public static <T> Map<String, Entry<TitanPredicate, Object>> buildNotInPredicate(String propKey, Collection<T> notInCollection) {
- if (isEmpty(notInCollection)) {
- return emptyMap();
- }
- Map<String, Entry<TitanPredicate, Object>> predicateCriteria = new HashMap<>();
- predicateCriteria.put(propKey, new HashMap.SimpleEntry<>(NOT_IN, notInCollection));
- return predicateCriteria;
- }
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java
index b7ca47600a..c6c609b189 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java
@@ -26,7 +26,7 @@ public interface AuditingTypesConstants {
String REPO_KEYSPACE = "sdcrepository";
String AUDIT_KEYSPACE = "sdcaudit";
String COMPONENT_KEYSPACE = "sdccomponent";
- String TITAN_KEYSPACE = "titan";
+ String janusGraph_KEYSPACE = "janusgraph";
String USER_ADMIN_EVENT_TYPE = "useradminevent";
String USER_ACCESS_EVENT_TYPE = "useraccessevent";