From ceaf83e0f29c10e4521321abcd6dd17080d2db60 Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Mon, 11 Sep 2023 10:56:37 +0100 Subject: Support setting interfaces on instances Issue-ID: SDC-4620 Signed-off-by: JvD_Ericsson Change-Id: I4f78eb5e017e79120d61870ecc3b7268f83b4206 --- .../operations/NodeTemplateOperation.java | 74 +++++++++++++--------- .../operations/ToscaOperationFacade.java | 60 +++++++++--------- 2 files changed, 76 insertions(+), 58 deletions(-) (limited to 'catalog-model') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java index f75c7a6b06..0b296757cf 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.openecomp.sdc.be.model.jsonjanusgraph.operations; import fj.data.Either; @@ -134,7 +135,8 @@ public class NodeTemplateOperation extends BaseOperation { static final String HEAT_VF_ENV_NAME = "VfHeatEnv"; static final String HEAT_ENV_SUFFIX = "env"; private static final String FAILED_TO_FETCH_CONTAINER_VERTEX_ERROR = "Failed to fetch container vertex {} error {}"; - private static final String FAILED_TO_UPDATE_TOPOLOGY_TEMPLATE_WITH_NEW_COMPONENT_INSTANCE = "Failed to update topology template {} with new component instance {}. "; + private static final String FAILED_TO_UPDATE_TOPOLOGY_TEMPLATE_WITH_NEW_COMPONENT_INSTANCE = + "Failed to update topology template {} with new component instance {}. "; private static final String ARTIFACT_PLACEHOLDER_TYPE = "type"; private static final String ARTIFACT_PLACEHOLDER_DISPLAY_NAME = "displayName"; private static final Object ARTIFACT_PLACEHOLDER_DESCRIPTION = "description"; @@ -669,31 +671,35 @@ public class NodeTemplateOperation extends BaseOperation { if (composition != null) { Map relations = composition.getRelations(); if (MapUtils.isNotEmpty(relations)) { - Either>, StorageOperationStatus> capResult = fetchContainerCalculatedCapability( - containerV, EdgeLabelEnum.CALCULATED_CAPABILITIES); + Either>, StorageOperationStatus> capResult = + fetchContainerCalculatedCapability( + containerV, EdgeLabelEnum.CALCULATED_CAPABILITIES); if (capResult.isRight()) { return capResult.right().value(); } Map calculatedCapabilty = capResult.left().value().getRight(); - Either>, StorageOperationStatus> capFullResult = fetchContainerCalculatedCapability( - containerV, EdgeLabelEnum.FULLFILLED_CAPABILITIES); + Either>, StorageOperationStatus> capFullResult = + fetchContainerCalculatedCapability( + containerV, EdgeLabelEnum.FULLFILLED_CAPABILITIES); if (capFullResult.isRight()) { return capFullResult.right().value(); } Map fullFilledCapabilty = capFullResult.left().value().getRight(); - Either>, StorageOperationStatus> reqResult = fetchContainerCalculatedRequirement( - containerV, EdgeLabelEnum.CALCULATED_REQUIREMENTS); + Either>, StorageOperationStatus> reqResult = + fetchContainerCalculatedRequirement( + containerV, EdgeLabelEnum.CALCULATED_REQUIREMENTS); if (reqResult.isRight()) { return reqResult.right().value(); } Map calculatedRequirement = reqResult.left().value().getRight(); - Either>, StorageOperationStatus> reqFullResult = fetchContainerCalculatedRequirement( - containerV, EdgeLabelEnum.FULLFILLED_REQUIREMENTS); + Either>, StorageOperationStatus> reqFullResult = + fetchContainerCalculatedRequirement( + containerV, EdgeLabelEnum.FULLFILLED_REQUIREMENTS); if (reqResult.isRight()) { return reqResult.right().value(); } @@ -1588,26 +1594,30 @@ public class NodeTemplateOperation extends BaseOperation { return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(error)); } GraphVertex containerV = containerVEither.left().value(); - Either>, StorageOperationStatus> capResult = fetchContainerCalculatedCapability( - containerV, EdgeLabelEnum.CALCULATED_CAPABILITIES); + Either>, StorageOperationStatus> capResult = + fetchContainerCalculatedCapability( + containerV, EdgeLabelEnum.CALCULATED_CAPABILITIES); if (capResult.isRight()) { return Either.right(capResult.right().value()); } Map calculatedCapabilty = capResult.left().value().getRight(); - Either>, StorageOperationStatus> capFullResult = fetchContainerCalculatedCapability( - containerV, EdgeLabelEnum.FULLFILLED_CAPABILITIES); + Either>, StorageOperationStatus> capFullResult = + fetchContainerCalculatedCapability( + containerV, EdgeLabelEnum.FULLFILLED_CAPABILITIES); if (capResult.isRight()) { return Either.right(capResult.right().value()); } Map fullFilledCapabilty = capFullResult.left().value().getRight(); - Either>, StorageOperationStatus> reqResult = fetchContainerCalculatedRequirement( - containerV, EdgeLabelEnum.CALCULATED_REQUIREMENTS); + Either>, StorageOperationStatus> reqResult = + fetchContainerCalculatedRequirement( + containerV, EdgeLabelEnum.CALCULATED_REQUIREMENTS); if (reqResult.isRight()) { return Either.right(reqResult.right().value()); } Map calculatedRequirement = reqResult.left().value().getRight(); - Either>, StorageOperationStatus> reqFullResult = fetchContainerCalculatedRequirement( - containerV, EdgeLabelEnum.FULLFILLED_REQUIREMENTS); + Either>, StorageOperationStatus> reqFullResult = + fetchContainerCalculatedRequirement( + containerV, EdgeLabelEnum.FULLFILLED_REQUIREMENTS); if (reqResult.isRight()) { return Either.right(reqResult.right().value()); } @@ -1823,26 +1833,30 @@ public class NodeTemplateOperation extends BaseOperation { } Map relations = compositionDataDefinition.getRelations(); List relationPairList = requirementDef.getRelationships(); - Either>, StorageOperationStatus> capResult = fetchContainerCalculatedCapability( - containerV, EdgeLabelEnum.CALCULATED_CAPABILITIES); + Either>, StorageOperationStatus> capResult = + fetchContainerCalculatedCapability( + containerV, EdgeLabelEnum.CALCULATED_CAPABILITIES); if (capResult.isRight()) { return Either.right(capResult.right().value()); } Map calculatedCapability = capResult.left().value().getRight(); - Either>, StorageOperationStatus> capFullResult = fetchContainerCalculatedCapability( - containerV, EdgeLabelEnum.FULLFILLED_CAPABILITIES); + Either>, StorageOperationStatus> capFullResult = + fetchContainerCalculatedCapability( + containerV, EdgeLabelEnum.FULLFILLED_CAPABILITIES); if (capResult.isRight()) { return Either.right(capResult.right().value()); } Map fulfilledCapability = capFullResult.left().value().getRight(); - Either>, StorageOperationStatus> reqResult = fetchContainerCalculatedRequirement( - containerV, EdgeLabelEnum.CALCULATED_REQUIREMENTS); + Either>, StorageOperationStatus> reqResult = + fetchContainerCalculatedRequirement( + containerV, EdgeLabelEnum.CALCULATED_REQUIREMENTS); if (reqResult.isRight()) { return Either.right(reqResult.right().value()); } Map calculatedRequirement = reqResult.left().value().getRight(); - Either>, StorageOperationStatus> reqFullResult = fetchContainerCalculatedRequirement( - containerV, EdgeLabelEnum.FULLFILLED_REQUIREMENTS); + Either>, StorageOperationStatus> reqFullResult = + fetchContainerCalculatedRequirement( + containerV, EdgeLabelEnum.FULLFILLED_REQUIREMENTS); if (reqResult.isRight()) { return Either.right(reqResult.right().value()); } @@ -2237,8 +2251,9 @@ public class NodeTemplateOperation extends BaseOperation { private Either>, StorageOperationStatus> fetchContainerCalculatedCapability( GraphVertex containerV, EdgeLabelEnum capLabel) { - Either>, JanusGraphOperationStatus> calculatedCapabiltyEither = getDataAndVertexFromGraph( - containerV, capLabel); + Either>, JanusGraphOperationStatus> calculatedCapabiltyEither = + getDataAndVertexFromGraph( + containerV, capLabel); if (calculatedCapabiltyEither.isRight()) { JanusGraphOperationStatus error = calculatedCapabiltyEither.right().value(); CommonUtility @@ -2251,8 +2266,9 @@ public class NodeTemplateOperation extends BaseOperation { private Either>, StorageOperationStatus> fetchContainerCalculatedRequirement( GraphVertex containerV, EdgeLabelEnum reqLabel) { - Either>, JanusGraphOperationStatus> calculatedRequirementEither = getDataAndVertexFromGraph( - containerV, reqLabel); + Either>, JanusGraphOperationStatus> calculatedRequirementEither = + getDataAndVertexFromGraph( + containerV, reqLabel); if (calculatedRequirementEither.isRight()) { JanusGraphOperationStatus error = calculatedRequirementEither.right().value(); CommonUtility 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 951dc5aaed..b6339e85ec 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 @@ -17,13 +17,39 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.openecomp.sdc.be.model.jsonjanusgraph.operations; +import static java.util.Objects.requireNonNull; +import static org.apache.commons.collections.CollectionUtils.isEmpty; +import static org.apache.commons.collections.CollectionUtils.isNotEmpty; +import static org.janusgraph.core.attribute.Text.REGEX; +import static org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum.TOPOLOGY_TEMPLATE; + import com.vdurmont.semver4j.Semver; import com.vdurmont.semver4j.Semver.SemverType; import fj.data.Either; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.TreeSet; +import java.util.function.BiPredicate; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -113,32 +139,6 @@ import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.util.ValidationUtils; import org.springframework.beans.factory.annotation.Autowired; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.TreeSet; -import java.util.function.BiPredicate; -import java.util.stream.Collectors; - -import static java.util.Objects.requireNonNull; -import static org.apache.commons.collections.CollectionUtils.isEmpty; -import static org.apache.commons.collections.CollectionUtils.isNotEmpty; -import static org.janusgraph.core.attribute.Text.REGEX; -import static org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum.TOPOLOGY_TEMPLATE; - @org.springframework.stereotype.Component("tosca-operation-facade") public class ToscaOperationFacade { @@ -146,9 +146,11 @@ public class ToscaOperationFacade { public static final String PROXY_SUFFIX = "_proxy"; // region - Fields private static final String COULDNT_FETCH_A_COMPONENT_WITH_AND_UNIQUE_ID_ERROR = "Couldn't fetch a component with and UniqueId {}, error: {}"; - private static final String FAILED_TO_FIND_RECENTLY_ADDED_PROPERTY_ON_THE_RESOURCE_STATUS_IS = "Failed to find recently added property {} on the resource {}. Status is {}. "; + private static final String FAILED_TO_FIND_RECENTLY_ADDED_PROPERTY_ON_THE_RESOURCE_STATUS_IS = + "Failed to find recently added property {} on the resource {}. Status is {}. "; private static final String FAILED_TO_GET_UPDATED_RESOURCE_STATUS_IS = "Failed to get updated resource {}. Status is {}. "; - private static final String FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS = "Failed to add the property {} to the resource {}. Status is {}. "; + private static final String FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS = + "Failed to add the property {} to the resource {}. Status is {}. "; private static final String SERVICE = "service"; private static final String VF = "VF"; private static final String NOT_SUPPORTED_COMPONENT_TYPE = "Not supported component type {}"; @@ -2532,7 +2534,7 @@ public class ToscaOperationFacade { } Component component = latestVersionList.size() == 1 ? latestVersionList.get(0) : latestVersionList.stream().max((c1, c2) -> Double.compare(Double.parseDouble(c1.getVersion()), Double.parseDouble(c2.getVersion()))) - .get(); + .get(); return Either.left(component); } -- cgit 1.2.3-korg