aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java/org
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2021-07-14 21:33:45 +0100
committerMichael Morris <michael.morris@est.tech>2021-07-23 17:05:23 +0000
commitb4b33231cead2ace0dbf18d3c5df89930101dc8c (patch)
treea46ad2d47f06c189ba7af270ed0ca7c51e888121 /catalog-model/src/main/java/org
parentcba52c9e6c67ae2ee723c76f0c9ed165b657df63 (diff)
Fix upgrade for different vendor release
Change-Id: Id5769b45c4b41fd40b7bac25407c046b8fe787e7 Issue-ID: SDC-3644 Signed-off-by: André Schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-model/src/main/java/org')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java31
1 files changed, 15 insertions, 16 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
index 25bac1642c..ec5721b95a 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
@@ -523,27 +523,26 @@ public class ToscaOperationFacade {
return predicateCriteria;
}
- public Optional<GraphVertex> isNodeAssociatedToModel(final String model, Resource resource) {
- return getNodeModelVertices(resource, model);
+ public boolean isNodeAssociatedToModel(final String model, final Resource resource) {
+ final List<GraphVertex> modelElementVertices = getResourceModelElementVertices(resource);
+ if (model == null) {
+ return modelElementVertices.isEmpty();
+ }
+ return modelElementVertices.stream().anyMatch(graphVertex -> graphVertex.getMetadataProperty(GraphPropertyEnum.NAME).equals(model));
}
- public Optional<GraphVertex> getNodeModelVertices(final Resource resource, final String model) {
- final Either<GraphVertex, JanusGraphOperationStatus> vertex = janusGraphDao
- .getVertexById(resource.getUniqueId(), JsonParseFlagEnum.NoParse);
+ public List<GraphVertex> getResourceModelElementVertices(final Resource resource) {
+ final Either<GraphVertex, JanusGraphOperationStatus> vertex =
+ janusGraphDao.getVertexById(resource.getUniqueId(), JsonParseFlagEnum.NoParse);
if (vertex.isRight() || Objects.isNull(vertex.left().value())) {
- return Optional.empty();
+ return Collections.emptyList();
}
- return getElementModelVertex(model, vertex.left().value());
- }
-
- private Optional<GraphVertex> getElementModelVertex(final String model, final GraphVertex vertex) {
- final Either<List<GraphVertex>, JanusGraphOperationStatus> nodeModelVertices = janusGraphDao
- .getParentVertices(vertex, EdgeLabelEnum.MODEL_ELEMENT, JsonParseFlagEnum.NoParse);
- if (nodeModelVertices.isRight() || Objects.isNull(nodeModelVertices.left().value())) {
- return Optional.empty();
+ final Either<List<GraphVertex>, JanusGraphOperationStatus> nodeModelVertices =
+ janusGraphDao.getParentVertices(vertex.left().value(), EdgeLabelEnum.MODEL_ELEMENT, JsonParseFlagEnum.NoParse);
+ if (nodeModelVertices.isRight() || nodeModelVertices.left().value() == null) {
+ return Collections.emptyList();
}
- return nodeModelVertices.left().value().stream().filter(graphVertex -> graphVertex.getMetadataProperty(GraphPropertyEnum.NAME).equals(model))
- .findFirst();
+ return nodeModelVertices.left().value();
}
private boolean isValidForVendorRelease(final GraphVertex resource, final String vendorRelease) {