diff options
Diffstat (limited to 'catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph')
-rw-r--r-- | catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java | 8 | ||||
-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 |
4 files changed, 180 insertions, 181 deletions
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> { } |