summaryrefslogtreecommitdiffstats
path: root/catalog-dao
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-dao')
-rw-r--r--catalog-dao/pom.xml14
-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
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/HealingPipelineDaoTest.java36
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtilsTest.java (renamed from catalog-dao/src/test/java/org/openecomp/sdc/be/dao/titan/TitanUtilsTest.java)10
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertexTest.java6
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDaoMockTest.java (renamed from catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/TitanDaoMockTest.java)184
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDaoTest.java (renamed from catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/TitanDaoTest.java)52
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JanusGraphGenericDaoTest.java (renamed from catalog-dao/src/test/java/org/openecomp/sdc/be/resources/TitanGenericDaoTest.java)295
-rw-r--r--catalog-dao/src/test/resources/application-context-test.xml2
-rw-r--r--catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml6
31 files changed, 1009 insertions, 1009 deletions
diff --git a/catalog-dao/pom.xml b/catalog-dao/pom.xml
index ee2da543c8..3e04560aa6 100644
--- a/catalog-dao/pom.xml
+++ b/catalog-dao/pom.xml
@@ -230,11 +230,10 @@ Modifications copyright (c) 2018 Nokia
<scope>test</scope>
</dependency>
- <!-- TITAN -->
<dependency>
- <groupId>com.thinkaurelius.titan</groupId>
- <artifactId>titan-core</artifactId>
- <version>${titan.version}</version>
+ <groupId>org.janusgraph</groupId>
+ <artifactId>janusgraph-core</artifactId>
+ <version>${janusgraph.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@@ -257,9 +256,9 @@ Modifications copyright (c) 2018 Nokia
</dependency>
<dependency>
- <groupId>org.onap.sdc.sdc-titan-cassandra</groupId>
- <artifactId>sdc-titan-cassandra</artifactId>
- <version>${sdc.titan.version}</version>
+ <groupId>org.janusgraph</groupId>
+ <artifactId>janusgraph-cassandra</artifactId>
+ <version>${janusgraph.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@@ -275,7 +274,6 @@ Modifications copyright (c) 2018 Nokia
<version>${lang3.version}</version>
<scope>provided</scope>
</dependency>
- <!-- TITAN END -->
<!-- CASSANDRA -->
<dependency>
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";
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/HealingPipelineDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/HealingPipelineDaoTest.java
index 83b68920b9..c0d9e4644c 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/HealingPipelineDaoTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/HealingPipelineDaoTest.java
@@ -17,10 +17,10 @@
package org.openecomp.sdc.be.dao.cassandra;
import com.google.common.collect.ImmutableListMultimap;
-import com.thinkaurelius.titan.core.TitanVertex;
-import com.thinkaurelius.titan.graphdb.relations.StandardVertexProperty;
-import com.thinkaurelius.titan.graphdb.types.system.EmptyVertex;
-import com.thinkaurelius.titan.graphdb.types.system.ImplicitKey;
+import org.janusgraph.core.JanusGraphVertex;
+import org.janusgraph.graphdb.relations.StandardVertexProperty;
+import org.janusgraph.graphdb.types.system.EmptyVertex;
+import org.janusgraph.graphdb.types.system.ImplicitKey;
import java.util.HashMap;
import org.junit.Test;
import org.mockito.Mockito;
@@ -85,7 +85,7 @@ public class HealingPipelineDaoTest {
}
@Test
- public void testPipelineFilter3AttributesTitanVertex() {
+ public void testPipelineFilter3AttributesJanusGraphVertex() {
// init data
HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
healingPipelineDao.setHealVersion(7);
@@ -95,16 +95,16 @@ public class HealingPipelineDaoTest {
assertEquals(2,
healingPipelineDao.getHealersForVertex(GraphEdgeLabels.CAPABILITY.getProperty(), HealVersionBuilder.build(5)).size());
- TitanVertex titanVertex = Mockito.mock(TitanVertex.class);
+ JanusGraphVertex janusGraphVertex = Mockito.mock(JanusGraphVertex.class);
final int version = 5;
StandardVertexProperty vertexProperty = new StandardVertexProperty(1, ImplicitKey.ID, new EmptyVertex(), version, (byte) 1);
- Mockito.when(titanVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty())).thenReturn(vertexProperty);
+ Mockito.when(janusGraphVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty())).thenReturn(vertexProperty);
// perform test
- Optional optional = healingPipelineDao.performGraphReadHealing(titanVertex, GraphEdgeLabels.CAPABILITY);
+ Optional optional = healingPipelineDao.performGraphReadHealing(janusGraphVertex, GraphEdgeLabels.CAPABILITY);
assertTrue(optional.isPresent());
- final TitanVertex changedVertex = (TitanVertex) optional.get();
+ final JanusGraphVertex changedVertex = (JanusGraphVertex) optional.get();
//validate result
assertNotNull(changedVertex);
@@ -112,7 +112,7 @@ public class HealingPipelineDaoTest {
}
@Test
- public void testPipelineFilterGenericTitanDao() {
+ public void testPipelineFilterGenericJanusGraphDao() {
// init data
HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
healingPipelineDao.setHealVersion(7);
@@ -140,7 +140,7 @@ public class HealingPipelineDaoTest {
}
@Test
- public void testPipelineFilterTitanGraph1Attributes() {
+ public void testPipelineFilterJanusGraph1Attributes() {
// init data
HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
healingPipelineDao.setHealVersion(7);
@@ -217,9 +217,9 @@ public class HealingPipelineDaoTest {
.put(GraphEdgeLabels.ATTRIBUTE.getProperty(), new GraphNodeHealTestMock(4))
.put(GraphEdgeLabels.ATTRIBUTE.getProperty(), new GraphNodeHealTestMock(5))
.put(GraphEdgeLabels.ATTRIBUTE.getProperty(), new GraphNodeHealTestMock(6))
- .put(GraphEdgeLabels.CAPABILITY.getProperty(), new TitanVertexHealTestMock(4))
- .put(GraphEdgeLabels.CAPABILITY.getProperty(), new TitanVertexHealTestMock(5))
- .put(GraphEdgeLabels.CAPABILITY.getProperty(), new TitanVertexHealTestMock(6)).build();
+ .put(GraphEdgeLabels.CAPABILITY.getProperty(), new JanusGraphVertexHealTestMock(4))
+ .put(GraphEdgeLabels.CAPABILITY.getProperty(), new JanusGraphVertexHealTestMock(5))
+ .put(GraphEdgeLabels.CAPABILITY.getProperty(), new JanusGraphVertexHealTestMock(6)).build();
}
public GraphEdge createGraphEdge(GraphEdgeLabels graphEdgeLabels){
@@ -247,7 +247,7 @@ public class HealingPipelineDaoTest {
}
- private class GraphNodeHealTestMock extends AbstractTitanVertexHeal {
+ private class GraphNodeHealTestMock extends AbstractJanusGraphVertexHeal {
private HealVersion healVersion;
public GraphNodeHealTestMock(int i) {
@@ -266,10 +266,10 @@ public class HealingPipelineDaoTest {
}
- private class TitanVertexHealTestMock implements Heal<TitanVertex> {
+ private class JanusGraphVertexHealTestMock implements Heal<JanusGraphVertex> {
private HealVersion healVersion;
- public TitanVertexHealTestMock(int i) {
+ public JanusGraphVertexHealTestMock(int i) {
healVersion = HealVersionBuilder.build(i);
}
@@ -279,7 +279,7 @@ public class HealingPipelineDaoTest {
}
@Override
- public void healData(TitanVertex parentV) {
+ public void healData(JanusGraphVertex parentV) {
}
}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/titan/TitanUtilsTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtilsTest.java
index 641eec5773..b3fd59e8b6 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/titan/TitanUtilsTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtilsTest.java
@@ -1,21 +1,21 @@
-package org.openecomp.sdc.be.dao.titan;
+package org.openecomp.sdc.be.dao.janusgraph;
-import com.thinkaurelius.titan.graphdb.query.TitanPredicate;
+import org.janusgraph.graphdb.query.JanusGraphPredicate;
import org.apache.tinkerpop.gremlin.structure.T;
import org.junit.Test;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
-public class TitanUtilsTest {
+public class JanusGraphUtilsTest {
@Test
public void testBuildNotInPredicate() throws Exception {
String propKey = "";
Collection<T> notInCollection = null;
- Map<String, Entry<TitanPredicate, Object>> result;
+ Map<String, Entry<JanusGraphPredicate, Object>> result;
// default test
- result = TitanUtils.buildNotInPredicate(propKey, notInCollection);
+ result = JanusGraphUtils.buildNotInPredicate(propKey, notInCollection);
}
} \ No newline at end of file
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertexTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertexTest.java
index b336bc65e9..8ce20191fd 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertexTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertexTest.java
@@ -1,6 +1,6 @@
package org.openecomp.sdc.be.dao.jsongraph;
-import com.thinkaurelius.titan.core.TitanVertex;
+import org.janusgraph.core.JanusGraphVertex;
import org.junit.Test;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -70,7 +70,7 @@ public class GraphVertexTest {
@Test
public void testGetVertex() throws Exception {
GraphVertex testSubject;
- TitanVertex result;
+ JanusGraphVertex result;
// default test
testSubject = createTestSubject();
@@ -81,7 +81,7 @@ public class GraphVertexTest {
@Test
public void testSetVertex() throws Exception {
GraphVertex testSubject;
- TitanVertex vertex = null;
+ JanusGraphVertex vertex = null;
// default test
testSubject = createTestSubject();
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/TitanDaoMockTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDaoMockTest.java
index 5703e53c9c..72a9d54336 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/TitanDaoMockTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDaoMockTest.java
@@ -1,7 +1,7 @@
package org.openecomp.sdc.be.dao.jsongraph;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanVertex;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphVertex;
import fj.data.Either;
import mockit.Deencapsulation;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -15,12 +15,12 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+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.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import java.util.HashMap;
@@ -28,13 +28,13 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-public class TitanDaoMockTest {
+public class JanusGraphDaoMockTest {
@InjectMocks
- TitanDao testSubject;
+ JanusGraphDao testSubject;
@Mock
- TitanGraphClient titanClient;
+ JanusGraphClient janusGraphClient;
@Before
public void setUp() throws Exception {
@@ -43,7 +43,7 @@ public class TitanDaoMockTest {
@Test
public void testCommit() throws Exception {
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
// default test
result = testSubject.commit();
@@ -51,7 +51,7 @@ public class TitanDaoMockTest {
@Test
public void testRollback() throws Exception {
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
// default test
result = testSubject.rollback();
@@ -60,7 +60,7 @@ public class TitanDaoMockTest {
@Test
public void testGetGraph() throws Exception {
- Either<TitanGraph, TitanOperationStatus> result;
+ Either<JanusGraph, JanusGraphOperationStatus> result;
// default test
@@ -72,14 +72,14 @@ public class TitanDaoMockTest {
GraphVertex graphVertex = new GraphVertex();
graphVertex.setLabel(VertexTypeEnum.ADDITIONAL_INFORMATION);
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
- TitanGraph tg = Mockito.mock(TitanGraph.class);
- Either<TitanGraph, TitanOperationStatus> value = Either.left(tg);
+ JanusGraph tg = Mockito.mock(JanusGraph.class);
+ Either<JanusGraph, JanusGraphOperationStatus> value = Either.left(tg);
// default test
- TitanVertex value2 = Mockito.mock(TitanVertex.class);
+ JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
Mockito.when(tg.addVertex()).thenReturn(value2);
- Mockito.when(titanClient.getGraph()).thenReturn(value);
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
result = testSubject.createVertex(graphVertex);
}
@@ -88,11 +88,11 @@ public class TitanDaoMockTest {
GraphVertex graphVertex = new GraphVertex();
graphVertex.setLabel(VertexTypeEnum.ADDITIONAL_INFORMATION);
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
- Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
+ Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
// default test
- Mockito.when(titanClient.getGraph()).thenReturn(value);
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
result = testSubject.createVertex(graphVertex);
}
@@ -101,35 +101,35 @@ public class TitanDaoMockTest {
GraphVertex graphVertex = new GraphVertex();
graphVertex.setLabel(VertexTypeEnum.ADDITIONAL_INFORMATION);
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
- TitanGraph tg = Mockito.mock(TitanGraph.class);
- Either<TitanGraph, TitanOperationStatus> value = Either.left(tg);
+ JanusGraph tg = Mockito.mock(JanusGraph.class);
+ Either<JanusGraph, JanusGraphOperationStatus> value = Either.left(tg);
// default test
Mockito.when(tg.addVertex()).thenThrow(RuntimeException.class);
- Mockito.when(titanClient.getGraph()).thenReturn(value);
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
result = testSubject.createVertex(graphVertex);
}
@Test
public void testGetVertexByPropertyAndLabel() throws Exception {
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
// default test
- Mockito.when(titanClient.getGraph()).thenReturn(Either.right(TitanOperationStatus.GENERAL_ERROR));
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(Either.right(JanusGraphOperationStatus.GENERAL_ERROR));
result = testSubject.getVertexByPropertyAndLabel(GraphPropertyEnum.COMPONENT_TYPE, "mock",
VertexTypeEnum.ADDITIONAL_INFORMATION);
}
@Test
public void testGetFirstFoundVertex() throws Exception {
- Iterable<TitanVertex> vertices = Mockito.mock(Iterable.class);
- Either<GraphVertex, TitanOperationStatus> result;
+ Iterable<JanusGraphVertex> vertices = Mockito.mock(Iterable.class);
+ Either<GraphVertex, JanusGraphOperationStatus> result;
- Iterator<TitanVertex> value = Mockito.mock(Iterator.class);
+ Iterator<JanusGraphVertex> value = Mockito.mock(Iterator.class);
Mockito.when(vertices.iterator()).thenReturn(value);
Mockito.when(value.hasNext()).thenReturn(true);
- TitanVertex value2 = Mockito.mock(TitanVertex.class);
+ JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
Mockito.when(value.next()).thenReturn(value2);
// default test
@@ -138,13 +138,13 @@ public class TitanDaoMockTest {
@Test
public void testGetFirstFoundVertexNotFound() throws Exception {
- Iterable<TitanVertex> vertices = Mockito.mock(Iterable.class);
- Either<GraphVertex, TitanOperationStatus> result;
+ Iterable<JanusGraphVertex> vertices = Mockito.mock(Iterable.class);
+ Either<GraphVertex, JanusGraphOperationStatus> result;
- Iterator<TitanVertex> value = Mockito.mock(Iterator.class);
+ Iterator<JanusGraphVertex> value = Mockito.mock(Iterator.class);
Mockito.when(vertices.iterator()).thenReturn(value);
Mockito.when(value.hasNext()).thenReturn(false);
- TitanVertex value2 = Mockito.mock(TitanVertex.class);
+ JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
Mockito.when(value.next()).thenReturn(value2);
// default test
@@ -155,14 +155,14 @@ public class TitanDaoMockTest {
public void testGetVertexById_1Exception() throws Exception {
String id = "mock";
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
- TitanGraph tg = Mockito.mock(TitanGraph.class);
- Either<TitanGraph, TitanOperationStatus> value = Either.left(tg);
+ JanusGraph tg = Mockito.mock(JanusGraph.class);
+ Either<JanusGraph, JanusGraphOperationStatus> value = Either.left(tg);
// default test
- TitanVertex value2 = Mockito.mock(TitanVertex.class);
+ JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
Mockito.when(tg.addVertex()).thenReturn(value2);
- Mockito.when(titanClient.getGraph()).thenReturn(value);
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
// test 1
result = testSubject.getVertexById(id, JsonParseFlagEnum.NoParse);
@@ -173,13 +173,13 @@ public class TitanDaoMockTest {
public void testGetVertexById_1GraphClosed() throws Exception {
String id = "mock";
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
Object b;
- Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
+ Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
// default test
- TitanVertex value2 = Mockito.mock(TitanVertex.class);
- Mockito.when(titanClient.getGraph()).thenReturn(value);
+ JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
// test 1
result = testSubject.getVertexById(id, JsonParseFlagEnum.NoParse);
@@ -199,7 +199,7 @@ public class TitanDaoMockTest {
@Test
public void testCreateAndFill() throws Exception {
- TitanVertex vertex = Mockito.mock(TitanVertex.class);
+ JanusGraphVertex vertex = Mockito.mock(JanusGraphVertex.class);
JsonParseFlagEnum parseFlag = null;
GraphVertex result;
@@ -212,7 +212,7 @@ public class TitanDaoMockTest {
public void testParseVertexProperties() throws Exception {
GraphVertex graphVertex = new GraphVertex();
- TitanVertex vertex = Mockito.mock(TitanVertex.class);
+ JanusGraphVertex vertex = Mockito.mock(JanusGraphVertex.class);
graphVertex.setVertex(vertex);
JsonParseFlagEnum parseFlag = null;
@@ -228,11 +228,11 @@ public class TitanDaoMockTest {
GraphVertex from = Mockito.mock(GraphVertex.class);
GraphVertex to = Mockito.mock(GraphVertex.class);
- TitanVertex value = Mockito.mock(TitanVertex.class);
+ JanusGraphVertex value = Mockito.mock(JanusGraphVertex.class);
Mockito.when(from.getVertex()).thenReturn(value);
Mockito.when(to.getVertex()).thenReturn(value);
Map<EdgePropertyEnum, Object> properties = new HashMap<>();
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
// default test
@@ -257,13 +257,13 @@ public class TitanDaoMockTest {
@Test
public void testGetByCriteria() throws Exception {
Map<GraphPropertyEnum, Object> props = new HashMap<>();
- Either<List<GraphVertex>, TitanOperationStatus> result;
+ Either<List<GraphVertex>, JanusGraphOperationStatus> result;
- TitanGraph tg = Mockito.mock(TitanGraph.class);
- Either<TitanGraph, TitanOperationStatus> value = Either.left(tg);
- TitanVertex value2 = Mockito.mock(TitanVertex.class);
+ JanusGraph tg = Mockito.mock(JanusGraph.class);
+ Either<JanusGraph, JanusGraphOperationStatus> value = Either.left(tg);
+ JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
Mockito.when(tg.addVertex()).thenReturn(value2);
- Mockito.when(titanClient.getGraph()).thenReturn(value);
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
// default test
result = testSubject.getByCriteria(VertexTypeEnum.ADDITIONAL_INFORMATION, props);
@@ -273,11 +273,11 @@ public class TitanDaoMockTest {
public void testGetByCriteria_1() throws Exception {
Map<GraphPropertyEnum, Object> props = new HashMap<>();
- Either<List<GraphVertex>, TitanOperationStatus> result;
+ Either<List<GraphVertex>, JanusGraphOperationStatus> result;
- Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
- TitanVertex value2 = Mockito.mock(TitanVertex.class);
- Mockito.when(titanClient.getGraph()).thenReturn(value);
+ Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
+ JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
// default test
result = testSubject.getByCriteria(VertexTypeEnum.ADDITIONAL_INFORMATION, props, JsonParseFlagEnum.NoParse);
@@ -285,12 +285,12 @@ public class TitanDaoMockTest {
@Test
public void testGetCatalogVerticies() throws Exception {
- Either<Iterator<Vertex>, TitanOperationStatus> result;
+ Either<Iterator<Vertex>, JanusGraphOperationStatus> result;
- Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
+ Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
// default test
- TitanVertex value2 = Mockito.mock(TitanVertex.class);
- Mockito.when(titanClient.getGraph()).thenReturn(value);
+ JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
// default test
result = testSubject.getCatalogOrArchiveVerticies(true);
@@ -302,11 +302,11 @@ public class TitanDaoMockTest {
GraphVertex parentVertex = new GraphVertex();
EdgeLabelEnum edgeLabel = null;
JsonParseFlagEnum parseFlag = null;
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
- Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
- TitanVertex value2 = Mockito.mock(TitanVertex.class);
- Mockito.when(titanClient.getGraph()).thenReturn(value);
+ Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
+ JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
// default test
result = testSubject.getChildVertex(parentVertex, EdgeLabelEnum.ADDITIONAL_INFORMATION, JsonParseFlagEnum.NoParse);
@@ -318,11 +318,11 @@ public class TitanDaoMockTest {
Vertex parentVertex = null;
EdgeLabelEnum edgeLabel = null;
JsonParseFlagEnum parseFlag = null;
- Either<Vertex, TitanOperationStatus> result;
+ Either<Vertex, JanusGraphOperationStatus> result;
- Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
- TitanVertex value2 = Mockito.mock(TitanVertex.class);
- Mockito.when(titanClient.getGraph()).thenReturn(value);
+ Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
+ JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
// default test
result = testSubject.getChildVertex(parentVertex, edgeLabel, parseFlag);
@@ -335,7 +335,7 @@ public class TitanDaoMockTest {
Vertex parentVertex = null;
EdgeLabelEnum edgeLabel = null;
JsonParseFlagEnum parseFlag = null;
- Either<Vertex, TitanOperationStatus> result;
+ Either<Vertex, JanusGraphOperationStatus> result;
// default test
@@ -348,7 +348,7 @@ public class TitanDaoMockTest {
Vertex parentVertex = null;
EdgeLabelEnum edgeLabel = null;
JsonParseFlagEnum parseFlag = null;
- Either<List<Vertex>, TitanOperationStatus> result;
+ Either<List<Vertex>, JanusGraphOperationStatus> result;
// default test
@@ -362,11 +362,11 @@ public class TitanDaoMockTest {
EdgeLabelEnum edgeLabel = null;
JsonParseFlagEnum parseFlag = null;
Direction direction = null;
- Either<List<Vertex>, TitanOperationStatus> result;
+ Either<List<Vertex>, JanusGraphOperationStatus> result;
- Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
- TitanVertex value2 = Mockito.mock(TitanVertex.class);
- Mockito.when(titanClient.getGraph()).thenReturn(value);
+ Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
+ JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
// default test
result = Deencapsulation.invoke(testSubject, "getAdjacentVerticies",
new Object[] { Vertex.class, EdgeLabelEnum.class, JsonParseFlagEnum.class, Direction.class });
@@ -378,7 +378,7 @@ public class TitanDaoMockTest {
Vertex parentVertex = null;
EdgeLabelEnum edgeLabel = null;
JsonParseFlagEnum parseFlag = null;
- Either<List<Vertex>, TitanOperationStatus> result;
+ Either<List<Vertex>, JanusGraphOperationStatus> result;
// default test
@@ -392,7 +392,7 @@ public class TitanDaoMockTest {
GraphVertex vertex = null;
EdgeLabelEnum label = null;
Map<GraphPropertyEnum, Object> properties = null;
- Either<Edge, TitanOperationStatus> result;
+ Either<Edge, JanusGraphOperationStatus> result;
// default test
@@ -404,11 +404,11 @@ public class TitanDaoMockTest {
GraphVertex fromVertex = new GraphVertex();
GraphVertex toVertex = new GraphVertex();
- Either<Edge, TitanOperationStatus> result;
+ Either<Edge, JanusGraphOperationStatus> result;
- Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
- TitanVertex value2 = Mockito.mock(TitanVertex.class);
- Mockito.when(titanClient.getGraph()).thenReturn(value);
+ Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
+ JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+ Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
// default test
result = testSubject.deleteEdge(fromVertex, toVertex, EdgeLabelEnum.ADDITIONAL_INFORMATION);
@@ -417,7 +417,7 @@ public class TitanDaoMockTest {
@Test
public void testDeleteEdgeByDirection() throws Exception {
GraphVertex fromVertex = new GraphVertex();
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
// default test
result = testSubject.deleteEdgeByDirection(fromVertex, Direction.BOTH, EdgeLabelEnum.ADDITIONAL_INFORMATION);
@@ -426,9 +426,9 @@ public class TitanDaoMockTest {
@Test
public void testDeleteEdgeByDirectionMock() throws Exception {
GraphVertex fromVertex = Mockito.mock(GraphVertex.class);
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
- TitanVertex value = Mockito.mock(TitanVertex.class);;
+ JanusGraphVertex value = Mockito.mock(JanusGraphVertex.class);;
Mockito.when(fromVertex.getVertex()).thenReturn(value);
Iterator<Edge> value2 = Mockito.mock(Iterator.class);;
Mockito.when(value.edges(Mockito.any(), Mockito.any())).thenReturn(value2);
@@ -443,7 +443,7 @@ public class TitanDaoMockTest {
public void testUpdateVertex() throws Exception {
GraphVertex graphVertex = new GraphVertex();
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
// default test
@@ -454,7 +454,7 @@ public class TitanDaoMockTest {
public void testGetVerticesByUniqueIdAndParseFlag() throws Exception {
Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGet = new HashMap<>();
- Either<Map<String, GraphVertex>, TitanOperationStatus> result;
+ Either<Map<String, GraphVertex>, JanusGraphOperationStatus> result;
// default test
result = testSubject.getVerticesByUniqueIdAndParseFlag(verticesToGet);
@@ -475,7 +475,7 @@ public class TitanDaoMockTest {
Vertex to = null;
EdgeLabelEnum label = null;
Edge edgeToCopy = null;
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
// default test
@@ -491,7 +491,7 @@ public class TitanDaoMockTest {
Edge prevEdge = null;
EdgeLabelEnum prevLabel = null;
EdgeLabelEnum newLabel = null;
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
// default test
@@ -504,7 +504,7 @@ public class TitanDaoMockTest {
Vertex vertex = Mockito.mock(Vertex.class);;
Map<GraphPropertyEnum, Object> properties = new HashMap<>();
properties.put(GraphPropertyEnum.COMPONENT_TYPE, "mock");
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
// default test
@@ -516,9 +516,9 @@ public class TitanDaoMockTest {
public void testDisassociateAndDeleteLast() throws Exception {
GraphVertex vertex = Mockito.mock(GraphVertex.class);
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
- TitanVertex value = Mockito.mock(TitanVertex.class);
+ JanusGraphVertex value = Mockito.mock(JanusGraphVertex.class);
Iterator<Edge> mockiter = Mockito.mock(Iterator.class);
Edge nextmock = Mockito.mock(Edge.class);
Mockito.when(vertex.getVertex()).thenReturn(value);
@@ -540,9 +540,9 @@ public class TitanDaoMockTest {
public void testDisassociateAndDeleteLastOut() throws Exception {
GraphVertex vertex = Mockito.mock(GraphVertex.class);
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
- TitanVertex value = Mockito.mock(TitanVertex.class);
+ JanusGraphVertex value = Mockito.mock(JanusGraphVertex.class);
Iterator<Edge> mockiter = Mockito.mock(Iterator.class);
Edge nextmock = Mockito.mock(Edge.class);
Mockito.when(vertex.getVertex()).thenReturn(value);
@@ -564,7 +564,7 @@ public class TitanDaoMockTest {
public void testDisassociateAndDeleteLastException() throws Exception {
GraphVertex vertex = Mockito.mock(GraphVertex.class);
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
Mockito.when(vertex.getVertex()).thenThrow(RuntimeException.class);
@@ -577,7 +577,7 @@ public class TitanDaoMockTest {
GraphVertex vertexA = new GraphVertex();
GraphVertex vertexB = new GraphVertex();
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
// default test
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/TitanDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDaoTest.java
index 2c4b868ff2..9019de9d24 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/TitanDaoTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDaoTest.java
@@ -1,6 +1,6 @@
package org.openecomp.sdc.be.dao.jsongraph;
-import com.thinkaurelius.titan.core.TitanGraph;
+import org.janusgraph.core.JanusGraph;
import fj.data.Either;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Element;
@@ -10,13 +10,13 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
-import org.openecomp.sdc.be.dao.DAOTitanStrategy;
+import org.openecomp.sdc.be.dao.DAOJanusGraphStrategy;
+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.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.utils.DAOConfDependentTest;
import org.slf4j.Logger;
@@ -26,25 +26,25 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-public class TitanDaoTest extends DAOConfDependentTest{
+public class JanusGraphDaoTest extends DAOConfDependentTest{
- private static Logger logger = LoggerFactory.getLogger(TitanDaoTest.class);
- private TitanDao dao = new TitanDao(new TitanGraphClient(new DAOTitanStrategy()));
+ private static Logger logger = LoggerFactory.getLogger(JanusGraphDaoTest.class);
+ private JanusGraphDao dao = new JanusGraphDao(new JanusGraphClient(new DAOJanusGraphStrategy()));
@Before
public void init(){
- dao.titanClient.createGraph();
+ dao.janusGraphClient.createGraph();
}
@After
public void end(){
- dao.titanClient.cleanupGraph();
+ dao.janusGraphClient.cleanupGraph();
}
@Test
public void testCreateVertex() throws Exception {
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
// default test
GraphVertex graphVertex = new GraphVertex(VertexTypeEnum.REQUIREMENTS);
@@ -56,7 +56,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
@Test
public void testGetVertexByLabel() throws Exception {
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
// default test
result = dao.getVertexByLabel(VertexTypeEnum.ADDITIONAL_INFORMATION);
@@ -64,7 +64,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
@Test
public void testCommit() throws Exception {
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
// default test
@@ -75,7 +75,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
@Test
public void testRollback() throws Exception {
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
// default test
@@ -85,7 +85,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
@Test
public void testGetGraph() throws Exception {
- Either<TitanGraph, TitanOperationStatus> result;
+ Either<JanusGraph, JanusGraphOperationStatus> result;
// default test
@@ -98,7 +98,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
GraphPropertyEnum name = null;
Object value = null;
VertexTypeEnum label = null;
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
// default test
@@ -114,7 +114,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
Object value = null;
VertexTypeEnum label = null;
JsonParseFlagEnum parseFlag = null;
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
// default test
@@ -126,7 +126,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
public void testGetVertexById() throws Exception {
String id = "";
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
// default test
@@ -138,7 +138,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
String id = "";
JsonParseFlagEnum parseFlag = null;
- Either<GraphVertex, TitanOperationStatus> result;
+ Either<GraphVertex, JanusGraphOperationStatus> result;
// test 1
@@ -181,7 +181,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
VertexTypeEnum type = null;
Map<GraphPropertyEnum, Object> props = null;
- Either<List<GraphVertex>, TitanOperationStatus> result;
+ Either<List<GraphVertex>, JanusGraphOperationStatus> result;
// default test
@@ -194,7 +194,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
VertexTypeEnum type = null;
Map<GraphPropertyEnum, Object> props = null;
JsonParseFlagEnum parseFlag = null;
- Either<List<GraphVertex>, TitanOperationStatus> result;
+ Either<List<GraphVertex>, JanusGraphOperationStatus> result;
// default test
@@ -209,7 +209,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
Map<GraphPropertyEnum, Object> props = null;
Map<GraphPropertyEnum, Object> hasNotProps = null;
JsonParseFlagEnum parseFlag = null;
- Either<List<GraphVertex>, TitanOperationStatus> result;
+ Either<List<GraphVertex>, JanusGraphOperationStatus> result;
// default test
@@ -219,7 +219,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
@Test
public void testGetCatalogVerticies() throws Exception {
- Either<Iterator<Vertex>, TitanOperationStatus> result;
+ Either<Iterator<Vertex>, JanusGraphOperationStatus> result;
// default test
@@ -232,7 +232,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
Vertex parentVertex = null;
EdgeLabelEnum edgeLabel = null;
JsonParseFlagEnum parseFlag = null;
- Either<List<Vertex>, TitanOperationStatus> result;
+ Either<List<Vertex>, JanusGraphOperationStatus> result;
// default test
@@ -245,7 +245,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
Vertex parentVertex = null;
EdgeLabelEnum edgeLabel = null;
JsonParseFlagEnum parseFlag = null;
- Either<List<Vertex>, TitanOperationStatus> result;
+ Either<List<Vertex>, JanusGraphOperationStatus> result;
// default test
@@ -257,7 +257,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
Vertex vertex = null;
Map<GraphPropertyEnum, Object> properties = null;
- TitanOperationStatus result;
+ JanusGraphOperationStatus result;
// default test
@@ -303,7 +303,7 @@ public class TitanDaoTest extends DAOConfDependentTest{
String parentId = "";
EdgeLabelEnum label = null;
Map<GraphPropertyEnum, Object> properties = null;
- Either<Edge, TitanOperationStatus> result;
+ Either<Edge, JanusGraphOperationStatus> result;
// default test
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/TitanGenericDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JanusGraphGenericDaoTest.java
index e8c6b3cdd1..09ab6a1745 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/TitanGenericDaoTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JanusGraphGenericDaoTest.java
@@ -21,13 +21,13 @@
package org.openecomp.sdc.be.resources;
import com.google.gson.Gson;
-import com.thinkaurelius.titan.core.PropertyKey;
-import com.thinkaurelius.titan.core.TitanEdge;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanVertex;
-import com.thinkaurelius.titan.core.attribute.Text;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
+import org.janusgraph.core.PropertyKey;
+import org.janusgraph.core.JanusGraphEdge;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphVertex;
+import org.janusgraph.core.attribute.Text;
+import org.janusgraph.core.schema.JanusGraphManagement;
import fj.data.Either;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -38,10 +38,10 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -72,12 +72,12 @@ import static org.junit.Assert.assertTrue;
@ContextConfiguration("classpath:application-context-test.xml")
@TestExecutionListeners(listeners = { DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class })
-public class TitanGenericDaoTest {
- private static Logger log = LoggerFactory.getLogger(TitanGenericDaoTest.class.getName());
+public class JanusGraphGenericDaoTest {
+ private static Logger log = LoggerFactory.getLogger(JanusGraphGenericDaoTest.class.getName());
private static ConfigurationManager configurationManager;
- @Resource(name = "titan-generic-dao")
- private TitanGenericDao titanDao;
+ @Resource(name = "janusgraph-generic-dao")
+ private JanusGraphGenericDao janusGraphDao;
@BeforeClass
public static void setupBeforeClass() {
@@ -86,27 +86,26 @@ public class TitanGenericDaoTest {
ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
appConfigDir);
configurationManager = new ConfigurationManager(configurationSource);
- configurationManager.getConfiguration()
- .setTitanCfgFile("../catalog-be/src/main/resources/config/titan.properties");
- configurationManager.getConfiguration().setTitanInMemoryGraph(true);
+ configurationManager.getConfiguration().setJanusGraphCfgFile("../catalog-be/src/main/resources/config/janusgraph.properties");
+ configurationManager.getConfiguration().setJanusGraphInMemoryGraph(true);
}
// @Test
public void testcheckEdgeProps() {
- TitanGraph graph = titanDao.getGraph().left().value();
- TitanVertex v1 = graph.addVertex();
+ JanusGraph graph = janusGraphDao.getGraph().left().value();
+ JanusGraphVertex v1 = graph.addVertex();
v1.property("prop1", 123);
- TitanVertex v2 = graph.addVertex();
+ JanusGraphVertex v2 = graph.addVertex();
v2.property("prop1", 456);
- TitanEdge addEdge = v1.addEdge("label11", v2);
+ JanusGraphEdge addEdge = v1.addEdge("label11", v2);
addEdge.property("edgeProp", "my prop edge");
graph.tx().commit();
- Either<TitanVertex, TitanOperationStatus> v11 = titanDao.getVertexByProperty("prop1", 123);
+ Either<JanusGraphVertex, JanusGraphOperationStatus> v11 = janusGraphDao.getVertexByProperty("prop1", 123);
Iterator<Edge> edges = v11.left().value().edges(Direction.OUT, "label11");
Edge edge = edges.next();
// String value = (String)edge.value("edgeProp");
- String value = (String) titanDao.getProperty(edge, "edgeProp");
+ String value = (String) janusGraphDao.getProperty(edge, "edgeProp");
log.debug(value);
}
@@ -118,34 +117,34 @@ public class TitanGenericDaoTest {
UserData userData = new UserData("Myname123", "Mylastname", id, "email123", "Tester",
UserStatusEnum.ACTIVE.name(), null);
- Either<UserData, TitanOperationStatus> newNode = titanDao.createNode(userData, UserData.class);
+ Either<UserData, JanusGraphOperationStatus> newNode = janusGraphDao.createNode(userData, UserData.class);
assertTrue(newNode.isLeft());
log.debug("{}", newNode.left().value());
- titanDao.commit();
+ janusGraphDao.commit();
ImmutablePair<String, Object> keyValueId = userData.getKeyValueId();
- Either<UserData, TitanOperationStatus> node = titanDao.getNode(keyValueId.getKey(), keyValueId.getValue(),
+ Either<UserData, JanusGraphOperationStatus> node = janusGraphDao.getNode(keyValueId.getKey(), keyValueId.getValue(),
UserData.class);
- titanDao.commit();
+ janusGraphDao.commit();
assertTrue(node.isLeft());
log.debug("{}", node.left().value());
userData.setRole("Designer");
- node = titanDao.updateNode(userData, UserData.class);
+ node = janusGraphDao.updateNode(userData, UserData.class);
assertTrue(node.isLeft());
log.debug("{}", node.left().value());
assertEquals(null, "Designer", node.left().value().getRole());
- titanDao.commit();
+ janusGraphDao.commit();
- node = titanDao.deleteNode(userData, UserData.class);
+ node = janusGraphDao.deleteNode(userData, UserData.class);
assertTrue(node.isLeft());
log.debug("{}", node.left().value());
- titanDao.commit();
+ janusGraphDao.commit();
- node = titanDao.getNode(keyValueId.getKey(), keyValueId.getValue(), UserData.class);
+ node = janusGraphDao.getNode(keyValueId.getKey(), keyValueId.getValue(), UserData.class);
assertTrue(node.isRight());
log.debug("{}", node.right().value());
@@ -159,29 +158,29 @@ public class TitanGenericDaoTest {
UserData userData1 = new UserData("Myname123", "Mylastname", id, "email123", "Tester",
UserStatusEnum.ACTIVE.name(), null);
- Either<UserData, TitanOperationStatus> node1 = titanDao.createNode(userData1, UserData.class);
+ Either<UserData, JanusGraphOperationStatus> node1 = janusGraphDao.createNode(userData1, UserData.class);
assertTrue(node1.isLeft());
log.debug("{}", node1.left().value());
id = "userIddfkoer45abc";
UserData userData2 = new UserData("Mynadyhme123", "Mylasghtname", id, "emaighdl123", "Designer",
UserStatusEnum.ACTIVE.name(), null);
- Either<UserData, TitanOperationStatus> node2 = titanDao.createNode(userData2, UserData.class);
+ Either<UserData, JanusGraphOperationStatus> node2 = janusGraphDao.createNode(userData2, UserData.class);
assertTrue(node2.isLeft());
log.debug("{}", node2.left().value());
- titanDao.commit();
+ janusGraphDao.commit();
ImmutablePair<String, Object> keyValueId1 = userData1.getKeyValueId();
// get first node
- Either<UserData, TitanOperationStatus> node = titanDao.getNode(keyValueId1.getKey(), keyValueId1.getValue(),
+ Either<UserData, JanusGraphOperationStatus> node = janusGraphDao.getNode(keyValueId1.getKey(), keyValueId1.getValue(),
UserData.class);
assertTrue(node.isLeft());
log.debug("{}", node.left().value());
- titanDao.commit();
+ janusGraphDao.commit();
// get all must be 2 + 1 default user = 3
- Either<List<UserData>, TitanOperationStatus> all = titanDao.getAll(NodeTypeEnum.User, UserData.class);
+ Either<List<UserData>, JanusGraphOperationStatus> all = janusGraphDao.getAll(NodeTypeEnum.User, UserData.class);
assertTrue(all.isLeft());
assertTrue(all.left().value().size() > 0);
@@ -192,7 +191,7 @@ public class TitanGenericDaoTest {
props.put(keyValueId1.getKey(), keyValueId1.getValue());
// get by criteria. must be 1
- Either<List<UserData>, TitanOperationStatus> byCriteria = titanDao.getByCriteria(NodeTypeEnum.User, props,
+ Either<List<UserData>, JanusGraphOperationStatus> byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.User, props,
UserData.class);
assertTrue(byCriteria.isLeft());
assertEquals(1, byCriteria.left().value().size());
@@ -200,9 +199,9 @@ public class TitanGenericDaoTest {
log.debug("{}", byCriteria.left().value());
// delete all nodes
- node = titanDao.deleteNode(userData1, UserData.class);
+ node = janusGraphDao.deleteNode(userData1, UserData.class);
assertTrue(node.isLeft());
- node = titanDao.deleteNode(userData2, UserData.class);
+ node = janusGraphDao.deleteNode(userData2, UserData.class);
assertTrue(node.isLeft());
}
@@ -211,7 +210,7 @@ public class TitanGenericDaoTest {
String id = "userId12345abc";
UserData userData = new UserData("Myname123", "Mylastname", id, "email123", UserRoleEnum.ADMIN.name(),
UserStatusEnum.ACTIVE.name(), null);
- titanDao.createNode(userData, UserData.class);
+ janusGraphDao.createNode(userData, UserData.class);
ResourceMetadataData resourceData = new ResourceMetadataData();
resourceData.getMetadataDataDefinition().setName("resourceForLock");
resourceData.getMetadataDataDefinition().setVersion("0.1");
@@ -219,37 +218,37 @@ public class TitanGenericDaoTest {
resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "."
+ resourceData.getMetadataDataDefinition().getVersion());
- titanDao.createNode(resourceData, ResourceMetadataData.class);
- titanDao.createRelation(userData, resourceData, GraphEdgeLabels.LAST_MODIFIER, null);
- titanDao.commit();
+ janusGraphDao.createNode(resourceData, ResourceMetadataData.class);
+ janusGraphDao.createRelation(userData, resourceData, GraphEdgeLabels.LAST_MODIFIER, null);
+ janusGraphDao.commit();
- Either<List<Edge>, TitanOperationStatus> eitherEdges = titanDao.getEdgesForNode(userData, Direction.OUT);
+ Either<List<Edge>, JanusGraphOperationStatus> eitherEdges = janusGraphDao.getEdgesForNode(userData, Direction.OUT);
assertTrue(eitherEdges.isLeft());
assertEquals(1, eitherEdges.left().value().size());
- eitherEdges = titanDao.getEdgesForNode(userData, Direction.IN);
+ eitherEdges = janusGraphDao.getEdgesForNode(userData, Direction.IN);
assertTrue(eitherEdges.isLeft());
assertEquals(0, eitherEdges.left().value().size());
- eitherEdges = titanDao.getEdgesForNode(resourceData, Direction.OUT);
+ eitherEdges = janusGraphDao.getEdgesForNode(resourceData, Direction.OUT);
assertTrue(eitherEdges.isLeft());
assertEquals(0, eitherEdges.left().value().size());
- eitherEdges = titanDao.getEdgesForNode(resourceData, Direction.IN);
+ eitherEdges = janusGraphDao.getEdgesForNode(resourceData, Direction.IN);
assertTrue(eitherEdges.isLeft());
assertEquals(1, eitherEdges.left().value().size());
- eitherEdges = titanDao.getEdgesForNode(resourceData, Direction.BOTH);
+ eitherEdges = janusGraphDao.getEdgesForNode(resourceData, Direction.BOTH);
assertTrue(eitherEdges.isLeft());
assertEquals(1, eitherEdges.left().value().size());
- eitherEdges = titanDao.getEdgesForNode(userData, Direction.BOTH);
+ eitherEdges = janusGraphDao.getEdgesForNode(userData, Direction.BOTH);
assertTrue(eitherEdges.isLeft());
assertEquals(1, eitherEdges.left().value().size());
- titanDao.deleteNode(userData, UserData.class);
- titanDao.deleteNode(resourceData, ResourceMetadataData.class);
- titanDao.commit();
+ janusGraphDao.deleteNode(userData, UserData.class);
+ janusGraphDao.deleteNode(resourceData, ResourceMetadataData.class);
+ janusGraphDao.commit();
}
@Test
@@ -263,37 +262,37 @@ public class TitanGenericDaoTest {
resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "."
+ resourceData.getMetadataDataDefinition().getVersion());
- Either<ResourceMetadataData, TitanOperationStatus> resource1 = titanDao.createNode(resourceData,
+ Either<ResourceMetadataData, JanusGraphOperationStatus> resource1 = janusGraphDao.createNode(resourceData,
ResourceMetadataData.class);
assertTrue(resource1.isLeft());
- titanDao.commit();
+ janusGraphDao.commit();
String lockId = "lock_" + resourceData.getLabel() + "_" + resource1.left().value().getUniqueId();
- Either<GraphNodeLock, TitanOperationStatus> nodeLock = titanDao
+ Either<GraphNodeLock, JanusGraphOperationStatus> nodeLock = janusGraphDao
.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
assertTrue(nodeLock.isRight());
- assertEquals(TitanOperationStatus.NOT_FOUND, nodeLock.right().value());
+ assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value());
- TitanOperationStatus status = titanDao.lockElement(resourceData);
- assertEquals(TitanOperationStatus.OK, status);
+ JanusGraphOperationStatus status = janusGraphDao.lockElement(resourceData);
+ assertEquals(JanusGraphOperationStatus.OK, status);
- nodeLock = titanDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
+ nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
assertTrue(nodeLock.isLeft());
assertEquals(lockId, nodeLock.left().value().getUniqueId());
- titanDao.commit();
+ janusGraphDao.commit();
- status = titanDao.lockElement(resourceData);
- assertEquals(TitanOperationStatus.ALREADY_LOCKED, status);
+ status = janusGraphDao.lockElement(resourceData);
+ assertEquals(JanusGraphOperationStatus.ALREADY_LOCKED, status);
- status = titanDao.releaseElement(resourceData);
- assertEquals(TitanOperationStatus.OK, status);
+ status = janusGraphDao.releaseElement(resourceData);
+ assertEquals(JanusGraphOperationStatus.OK, status);
- nodeLock = titanDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
+ nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
assertTrue(nodeLock.isRight());
- assertEquals(TitanOperationStatus.NOT_FOUND, nodeLock.right().value());
- titanDao.deleteNode(resourceData, ResourceMetadataData.class);
- titanDao.commit();
+ assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value());
+ janusGraphDao.deleteNode(resourceData, ResourceMetadataData.class);
+ janusGraphDao.commit();
}
@@ -308,37 +307,37 @@ public class TitanGenericDaoTest {
resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "."
+ resourceData.getMetadataDataDefinition().getVersion());
- Either<ResourceMetadataData, TitanOperationStatus> resource1 = titanDao.createNode(resourceData,
+ Either<ResourceMetadataData, JanusGraphOperationStatus> resource1 = janusGraphDao.createNode(resourceData,
ResourceMetadataData.class);
assertTrue(resource1.isLeft());
- titanDao.commit();
+ janusGraphDao.commit();
String lockId = "lock_" + resourceData.getLabel() + "_" + resource1.left().value().getUniqueId();
- Either<GraphNodeLock, TitanOperationStatus> nodeLock = titanDao
+ Either<GraphNodeLock, JanusGraphOperationStatus> nodeLock = janusGraphDao
.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
assertTrue(nodeLock.isRight());
- assertEquals(TitanOperationStatus.NOT_FOUND, nodeLock.right().value());
+ assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value());
// lock
- TitanOperationStatus status = titanDao.lockElement(resourceData);
- assertEquals(TitanOperationStatus.OK, status);
+ JanusGraphOperationStatus status = janusGraphDao.lockElement(resourceData);
+ assertEquals(JanusGraphOperationStatus.OK, status);
- nodeLock = titanDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
+ nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
assertTrue(nodeLock.isLeft());
assertEquals(lockId, nodeLock.left().value().getUniqueId());
long time1 = nodeLock.left().value().getTime();
- titanDao.commit();
+ janusGraphDao.commit();
// timeout
- configurationManager.getConfiguration().setTitanLockTimeout(2L);
+ configurationManager.getConfiguration().setJanusGraphLockTimeout(2L);
Thread.sleep(5001);
// relock
- status = titanDao.lockElement(resourceData);
- assertEquals(TitanOperationStatus.OK, status);
+ status = janusGraphDao.lockElement(resourceData);
+ assertEquals(JanusGraphOperationStatus.OK, status);
- nodeLock = titanDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
+ nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
assertTrue(nodeLock.isLeft());
assertEquals(lockId, nodeLock.left().value().getUniqueId());
@@ -346,15 +345,15 @@ public class TitanGenericDaoTest {
assertTrue(time2 > time1);
- status = titanDao.releaseElement(resourceData);
- assertEquals(TitanOperationStatus.OK, status);
+ status = janusGraphDao.releaseElement(resourceData);
+ assertEquals(JanusGraphOperationStatus.OK, status);
- nodeLock = titanDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
+ nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
assertTrue(nodeLock.isRight());
- assertEquals(TitanOperationStatus.NOT_FOUND, nodeLock.right().value());
+ assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value());
- titanDao.deleteNode(resourceData, ResourceMetadataData.class);
- titanDao.commit();
+ janusGraphDao.deleteNode(resourceData, ResourceMetadataData.class);
+ janusGraphDao.commit();
}
@@ -369,7 +368,7 @@ public class TitanGenericDaoTest {
resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "."
+ resourceData.getMetadataDataDefinition().getVersion());
- Either<ResourceMetadataData, TitanOperationStatus> resource1 = titanDao.createNode(resourceData,
+ Either<ResourceMetadataData, JanusGraphOperationStatus> resource1 = janusGraphDao.createNode(resourceData,
ResourceMetadataData.class);
assertTrue(resource1.isLeft());
@@ -382,9 +381,9 @@ public class TitanGenericDaoTest {
resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "."
+ resourceData.getMetadataDataDefinition().getVersion());
- Either<ResourceMetadataData, TitanOperationStatus> resource2 = titanDao.createNode(resourceData,
+ Either<ResourceMetadataData, JanusGraphOperationStatus> resource2 = janusGraphDao.createNode(resourceData,
ResourceMetadataData.class);
- titanDao.commit();
+ janusGraphDao.commit();
Map<String, Object> props = new HashMap<>();
@@ -393,26 +392,26 @@ public class TitanGenericDaoTest {
props.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), false);
// get by criteria. must be 1
- Either<List<ResourceMetadataData>, TitanOperationStatus> byCriteria = titanDao
+ Either<List<ResourceMetadataData>, JanusGraphOperationStatus> byCriteria = janusGraphDao
.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
assertTrue(byCriteria.isLeft());
- titanDao.deleteNode(resource1.left().value(), ResourceMetadataData.class);
+ janusGraphDao.deleteNode(resource1.left().value(), ResourceMetadataData.class);
- titanDao.deleteNode(resource2.left().value(), ResourceMetadataData.class);
- titanDao.commit();
+ janusGraphDao.deleteNode(resource2.left().value(), ResourceMetadataData.class);
+ janusGraphDao.commit();
}
// @Test
public void testStringSearch() {
- TitanGraph graph;
+ JanusGraph graph;
BaseConfiguration conf = new BaseConfiguration();
conf.setProperty("storage.backend", "inmemory");
- graph = TitanFactory.open(conf);
+ graph = JanusGraphFactory.open(conf);
- // TitanManagement graphMgt = graph.getManagementSystem();
- TitanManagement graphMgt = graph.openManagement();
+ // JanusGraphManagement graphMgt = graph.getManagementSystem();
+ JanusGraphManagement graphMgt = graph.openManagement();
PropertyKey propKey = graphMgt.makePropertyKey("string1").dataType(String.class).make();
graphMgt.buildIndex("string1", Vertex.class).addKey(propKey).unique().buildCompositeIndex();
@@ -423,49 +422,49 @@ public class TitanGenericDaoTest {
log.debug("**** predicat index search non case");
- Iterable<TitanVertex> vertices = graph.query().has("string1", Text.REGEX, "my new string 1").vertices();
- Iterator<TitanVertex> iter = vertices.iterator();
+ Iterable<JanusGraphVertex> vertices = graph.query().has("string1", Text.REGEX, "my new string 1").vertices();
+ Iterator<JanusGraphVertex> iter = vertices.iterator();
while (iter.hasNext()) {
Vertex ver = iter.next();
// System.out.println(com.tinkerpop.blueprints.util.ElementHelper.getProperties(ver));
- log.debug("{}", titanDao.getProperties(ver));
+ log.debug("{}", janusGraphDao.getProperties(ver));
}
}
@Test
- public void testDuplicateResultDueToTitanBug() {
+ public void testDuplicateResultDueToJanusGraphBug() {
ResourceMetadataData resourceData1 = new ResourceMetadataData();
resourceData1.getMetadataDataDefinition().setUniqueId("A");
((ResourceMetadataDataDefinition) resourceData1.getMetadataDataDefinition()).setAbstract(true);
resourceData1.getMetadataDataDefinition().setName("aaaa");
- Either<ResourceMetadataData, TitanOperationStatus> newNode1 = titanDao.createNode(resourceData1,
+ Either<ResourceMetadataData, JanusGraphOperationStatus> newNode1 = janusGraphDao.createNode(resourceData1,
ResourceMetadataData.class);
assertTrue(newNode1.isLeft());
log.debug("{}", newNode1.left().value());
- // titanDao.commit();
+ // janusGraphDao.commit();
Map<String, Object> props = new HashMap<>();
props.put(GraphPropertiesDictionary.IS_ABSTRACT.getProperty(), true);
- Either<List<ResourceMetadataData>, TitanOperationStatus> byCriteria = titanDao
+ Either<List<ResourceMetadataData>, JanusGraphOperationStatus> byCriteria = janusGraphDao
.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
assertTrue(byCriteria.isLeft());
assertEquals("check one result returned", 1, byCriteria.left().value().size());
- // titanDao.commit();
+ // janusGraphDao.commit();
ResourceMetadataData resourceToUpdate = new ResourceMetadataData();
((ResourceMetadataDataDefinition) resourceToUpdate.getMetadataDataDefinition()).setAbstract(false);
resourceToUpdate.getMetadataDataDefinition().setUniqueId("A");
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceToUpdate,
+ Either<ResourceMetadataData, JanusGraphOperationStatus> updateNode = janusGraphDao.updateNode(resourceToUpdate,
ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- // titanDao.commit();
+ // janusGraphDao.commit();
- byCriteria = titanDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
+ byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
assertTrue(byCriteria.isRight());
- assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+ assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
byCriteria.right().value());
AdditionalInfoParameterData infoParameterData = new AdditionalInfoParameterData();
@@ -474,11 +473,11 @@ public class TitanGenericDaoTest {
idToKey.put("key1", "value1");
infoParameterData.setIdToKey(idToKey);
- Either<AdditionalInfoParameterData, TitanOperationStatus> newNode2 = titanDao.createNode(infoParameterData,
+ Either<AdditionalInfoParameterData, JanusGraphOperationStatus> newNode2 = janusGraphDao.createNode(infoParameterData,
AdditionalInfoParameterData.class);
assertTrue(newNode2.isLeft());
log.debug("{}", newNode2.left().value());
- // titanDao.commit();
+ // janusGraphDao.commit();
Map<String, String> idToKey2 = new HashMap<>();
idToKey2.put("key1", "value2");
@@ -490,24 +489,24 @@ public class TitanGenericDaoTest {
// props2.put(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty(),
// idToKey2);
- Either<List<AdditionalInfoParameterData>, TitanOperationStatus> byCriteria2 = titanDao
+ Either<List<AdditionalInfoParameterData>, JanusGraphOperationStatus> byCriteria2 = janusGraphDao
.getByCriteria(NodeTypeEnum.AdditionalInfoParameters, props2, AdditionalInfoParameterData.class);
assertTrue(byCriteria2.isRight());
- assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+ assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
byCriteria2.right().value());
infoParameterData.setIdToKey(idToKey2);
- Either<AdditionalInfoParameterData, TitanOperationStatus> updateNode2 = titanDao.updateNode(infoParameterData,
+ Either<AdditionalInfoParameterData, JanusGraphOperationStatus> updateNode2 = janusGraphDao.updateNode(infoParameterData,
AdditionalInfoParameterData.class);
assertTrue(updateNode2.isLeft());
- // titanDao.commit();
+ // janusGraphDao.commit();
props2.put(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty(), idToKey);
- byCriteria2 = titanDao.getByCriteria(NodeTypeEnum.AdditionalInfoParameters, props2,
+ byCriteria2 = janusGraphDao.getByCriteria(NodeTypeEnum.AdditionalInfoParameters, props2,
AdditionalInfoParameterData.class);
assertTrue(byCriteria2.isRight());
- assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+ assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
byCriteria2.right().value());
ComponentInstanceData resourceInstanceData = new ComponentInstanceData();
@@ -515,33 +514,33 @@ public class TitanGenericDaoTest {
resourceInstanceData.getComponentInstDataDefinition().setPosX("22");
resourceInstanceData.getComponentInstDataDefinition().setName("myresource_1");
- Either<ComponentInstanceData, TitanOperationStatus> newNode3 = titanDao.createNode(resourceInstanceData,
+ Either<ComponentInstanceData, JanusGraphOperationStatus> newNode3 = janusGraphDao.createNode(resourceInstanceData,
ComponentInstanceData.class);
assertTrue(newNode3.isLeft());
log.debug("{}", newNode3.left().value());
- // titanDao.commit();
+ // janusGraphDao.commit();
resourceInstanceData.getComponentInstDataDefinition().setPosX("50");
- Either<ComponentInstanceData, TitanOperationStatus> updateNode3 = titanDao.updateNode(resourceInstanceData,
+ Either<ComponentInstanceData, JanusGraphOperationStatus> updateNode3 = janusGraphDao.updateNode(resourceInstanceData,
ComponentInstanceData.class);
assertTrue(updateNode3.isLeft());
- // titanDao.commit();
+ // janusGraphDao.commit();
resourceInstanceData.getComponentInstDataDefinition().setName("myresource_2");
- updateNode3 = titanDao.updateNode(resourceInstanceData, ComponentInstanceData.class);
+ updateNode3 = janusGraphDao.updateNode(resourceInstanceData, ComponentInstanceData.class);
assertTrue(updateNode3.isLeft());
- // titanDao.commit();
+ // janusGraphDao.commit();
Map<String, Object> props3 = new HashMap<>();
props3.put("positionX", "22");
- Either<List<ComponentInstanceData>, TitanOperationStatus> byCriteria3 = titanDao
+ Either<List<ComponentInstanceData>, JanusGraphOperationStatus> byCriteria3 = janusGraphDao
.getByCriteria(NodeTypeEnum.ResourceInstance, props3, ComponentInstanceData.class);
assertTrue(byCriteria3.isRight());
- assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+ assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
byCriteria3.right().value());
props3.put("positionX", "50");
- byCriteria3 = titanDao.getByCriteria(NodeTypeEnum.ResourceInstance, props3, ComponentInstanceData.class);
+ byCriteria3 = janusGraphDao.getByCriteria(NodeTypeEnum.ResourceInstance, props3, ComponentInstanceData.class);
assertTrue(byCriteria3.isLeft());
/////////////////////////// check integer ////////////////////////
@@ -550,33 +549,33 @@ public class TitanGenericDaoTest {
artifactData.getArtifactDataDefinition().setUniqueId("ad234");
artifactData.getArtifactDataDefinition().setTimeout(100);
- Either<ArtifactData, TitanOperationStatus> newNode4 = titanDao.createNode(artifactData, ArtifactData.class);
+ Either<ArtifactData, JanusGraphOperationStatus> newNode4 = janusGraphDao.createNode(artifactData, ArtifactData.class);
assertTrue(newNode4.isLeft());
log.debug("{}", newNode4.left().value());
- // titanDao.commit();
+ // janusGraphDao.commit();
artifactData.getArtifactDataDefinition().setTimeout(50);
- Either<ArtifactData, TitanOperationStatus> updateNode4 = titanDao.updateNode(artifactData, ArtifactData.class);
+ Either<ArtifactData, JanusGraphOperationStatus> updateNode4 = janusGraphDao.updateNode(artifactData, ArtifactData.class);
assertTrue(updateNode4.isLeft());
- // titanDao.commit();
+ // janusGraphDao.commit();
Map<String, Object> props4 = new HashMap<>();
props4.put("timeout", 100);
- Either<List<ArtifactData>, TitanOperationStatus> byCriteria4 = titanDao.getByCriteria(NodeTypeEnum.ArtifactRef,
+ Either<List<ArtifactData>, JanusGraphOperationStatus> byCriteria4 = janusGraphDao.getByCriteria(NodeTypeEnum.ArtifactRef,
props4, ArtifactData.class);
assertTrue(byCriteria4.isRight());
- assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+ assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
byCriteria4.right().value());
props4.put("timeout", 50);
- byCriteria4 = titanDao.getByCriteria(NodeTypeEnum.ArtifactRef, props4, ArtifactData.class);
+ byCriteria4 = janusGraphDao.getByCriteria(NodeTypeEnum.ArtifactRef, props4, ArtifactData.class);
assertTrue(byCriteria4.isLeft());
- titanDao.rollback();
+ janusGraphDao.rollback();
}
@Test
- public void testDuplicateResultUSeHasNotQueryDueToTitanBug() {
+ public void testDuplicateResultUSeHasNotQueryDueToJanusGraphBug() {
String name = "bbbb";
@@ -585,46 +584,46 @@ public class TitanGenericDaoTest {
((ResourceMetadataDataDefinition) resourceData1.getMetadataDataDefinition()).setAbstract(true);
resourceData1.getMetadataDataDefinition().setName(name);
- Either<ResourceMetadataData, TitanOperationStatus> newNode1 = titanDao.createNode(resourceData1,
+ Either<ResourceMetadataData, JanusGraphOperationStatus> newNode1 = janusGraphDao.createNode(resourceData1,
ResourceMetadataData.class);
assertTrue(newNode1.isLeft());
log.debug("{}", newNode1.left().value());
- // titanDao.commit();
+ // janusGraphDao.commit();
Map<String, Object> props = new HashMap<>();
props.put(GraphPropertiesDictionary.IS_ABSTRACT.getProperty(), true);
- Either<List<ResourceMetadataData>, TitanOperationStatus> byCriteria = titanDao
+ Either<List<ResourceMetadataData>, JanusGraphOperationStatus> byCriteria = janusGraphDao
.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
assertTrue(byCriteria.isLeft());
assertEquals("check one result returned", 1, byCriteria.left().value().size());
- // titanDao.commit();
+ // janusGraphDao.commit();
ResourceMetadataData resourceToUpdate = new ResourceMetadataData();
((ResourceMetadataDataDefinition) resourceToUpdate.getMetadataDataDefinition()).setAbstract(false);
resourceToUpdate.getMetadataDataDefinition().setUniqueId("A");
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceToUpdate,
+ Either<ResourceMetadataData, JanusGraphOperationStatus> updateNode = janusGraphDao.updateNode(resourceToUpdate,
ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- // titanDao.commit();
+ // janusGraphDao.commit();
// no result where isAbstract = true
- byCriteria = titanDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
+ byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
assertTrue(byCriteria.isRight());
- assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+ assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
byCriteria.right().value());
// one result where isAbstract != true
- byCriteria = titanDao.getByCriteria(NodeTypeEnum.Resource, null, props, ResourceMetadataData.class);
+ byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, null, props, ResourceMetadataData.class);
assertTrue(byCriteria.isLeft());
assertEquals("check one result returned", 1, byCriteria.left().value().size());
props.put(GraphPropertiesDictionary.IS_ABSTRACT.getProperty(), false);
- byCriteria = titanDao.getByCriteria(NodeTypeEnum.Resource, null, props, ResourceMetadataData.class);
+ byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, null, props, ResourceMetadataData.class);
assertTrue(byCriteria.isRight());
- assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+ assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
byCriteria.right().value());
- titanDao.rollback();
+ janusGraphDao.rollback();
}
diff --git a/catalog-dao/src/test/resources/application-context-test.xml b/catalog-dao/src/test/resources/application-context-test.xml
index 24980dfecd..c07512f92c 100644
--- a/catalog-dao/src/test/resources/application-context-test.xml
+++ b/catalog-dao/src/test/resources/application-context-test.xml
@@ -13,7 +13,7 @@
org.openecomp.sdc.be.dao.impl,
org.openecomp.sdc.be.dao.es,
org.openecomp.sdc.be.dao.neo4j,
- org.openecomp.sdc.be.dao.titan,
+ org.openecomp.sdc.be.dao.janusgraph,
org.openecomp.sdc.be.resources.impl
">
diff --git a/catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml b/catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml
index 67c0ec7b20..92cf2a3242 100644
--- a/catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml
+++ b/catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml
@@ -25,9 +25,9 @@ beSslPort: 8443
version: 1.0
released: 2012-11-30
-titanCfgFile: src/main/resources/config/titan.properties
-titanInMemoryGraph: true
-titanLockTimeout: 30
+janusGraphCfgFile: src/main/resources/config/janusgraph.properties
+janusGraphInMemoryGraph: true
+janusGraphLockTimeout: 30
# Protocols
protocols: