From a80da69b9e95a6cbdbe50251c37c9dcc50650e4c Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Mon, 23 May 2022 08:26:40 +0100 Subject: Maintain VFC instance attribute outputs on instance version change Issue-ID: SDC-4025 Signed-off-by: JvD_Ericsson Change-Id: Ia44a6ac73d9a52042caaacf0c5f790e1e2fc73f1 --- .../elements/AttributeDataDefinition.java | 22 ++++++++++++ .../sdc/be/utils/AttributeDefinitionUtils.java | 42 ++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 common-be/src/main/java/org/openecomp/sdc/be/utils/AttributeDefinitionUtils.java (limited to 'common-be/src') diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java index ee78821b23..7e99418221 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java @@ -140,4 +140,26 @@ public class AttributeDataDefinition extends ToscaDataDefinition { public String getParentUniqueId() { return getOwnerId(); } + + public boolean isGetOutputAttribute() { + return this.getGetOutputValues() != null && !this.getGetOutputValues().isEmpty(); + } + + public boolean typeEquals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + AttributeDataDefinition other = (AttributeDataDefinition) obj; + if (this.getType() == null) { + return other.getType() == null; + } + return false; + } + } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/utils/AttributeDefinitionUtils.java b/common-be/src/main/java/org/openecomp/sdc/be/utils/AttributeDefinitionUtils.java new file mode 100644 index 0000000000..00836e787b --- /dev/null +++ b/common-be/src/main/java/org/openecomp/sdc/be/utils/AttributeDefinitionUtils.java @@ -0,0 +1,42 @@ +/* + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.sdc.be.utils; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class AttributeDefinitionUtils { + + public static List getAttributesMappedToOutputs(List attributes) { + if (attributes == null) { + return Collections.emptyList(); + } + return filterGetOutputAttributes(attributes); + } + + private static List filterGetOutputAttributes(List attributeDefinitions) { + return attributeDefinitions.stream().filter(AttributeDataDefinition::isGetOutputAttribute).collect(Collectors.toList()); + } +} -- cgit 1.2.3-korg