diff options
Diffstat (limited to 'catalog-dao/src')
3 files changed, 15 insertions, 9 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java index 76fddc070b..8614f4beb4 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java @@ -587,16 +587,21 @@ public class JanusGraphDao { } private boolean vertexValidForModel(final JanusGraphVertex vertex, final String model) { - final Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> modelVertices = getParentVerticies(vertex, GraphEdgeLabels.MODEL_ELEMENT); + final String vertexLabel = (String)vertex.property(GraphPropertyEnum.LABEL.getProperty()).value(); + final VertexTypeEnum vertexType = VertexTypeEnum.getByName(vertexLabel); + final GraphEdgeLabels edgeLabel = vertexType.equals(VertexTypeEnum.TOPOLOGY_TEMPLATE) ? GraphEdgeLabels.MODEL : GraphEdgeLabels.MODEL_ELEMENT; + final Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> modelVertices = getParentVerticies(vertex, edgeLabel); - if (modelVertices.isLeft()) { - for (ImmutablePair<JanusGraphVertex, Edge> vertexPair : modelVertices.left().value()) { - if (model.equals((String)vertexPair.getLeft().property("name").value())) { - return true; - } - } + return modelVertices.isLeft() && modelVertices.left().value().stream().anyMatch(vertexPair -> modelVertexMatchesModel(vertexPair.getLeft(), model)); + } + + private boolean modelVertexMatchesModel(final JanusGraphVertex modelVertex, final String model) { + if (model.equals((String)modelVertex.property("name").value())) { + return true; } - return false; + final Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> derivedModels = + getParentVerticies(modelVertex, GraphEdgeLabels.DERIVED_FROM); + return derivedModels.isLeft() && derivedModels.left().value().stream().anyMatch(derivedModel ->modelVertexMatchesModel(derivedModel.left, model)); } private Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> getParentVerticies( diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java index 7dbcc87eb4..4ed16a42ec 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java @@ -71,6 +71,7 @@ public enum GraphEdgeLabels { PARAMETER_VALUE("PARAMETER_VALUE"), PARAMETER_IMPL("PARAMETER_IMPL"), MODEL_ELEMENT("MODEL_ELEMENT"), + MODEL("MODEL"), // VF additions CALCULATED_REQUIREMENT("CALCULATED_REQUIREMENT"), CALCULATED_CAPABILITY("CALCULATED_CAPABILITY"), diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabelsTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabelsTest.java index bfa940929a..37f1707e41 100644 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabelsTest.java +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabelsTest.java @@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; public class GraphEdgeLabelsTest { @Test public void testGetAllProperties() throws Exception { - assertEquals(56, GraphEdgeLabels.getAllProperties().size()); + assertEquals(57, GraphEdgeLabels.getAllProperties().size()); } @Test |