summaryrefslogtreecommitdiffstats
path: root/common-be/src/main
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2022-05-23 08:26:40 +0100
committerMichael Morris <michael.morris@est.tech>2022-06-03 12:20:16 +0000
commita80da69b9e95a6cbdbe50251c37c9dcc50650e4c (patch)
treef21a6acc25dab04f42b2891e5d1ec2b099c36dd6 /common-be/src/main
parentff317808f308af03321de0f0b0849cd9f6f8ccad (diff)
Maintain VFC instance attribute outputs on instance version change
Issue-ID: SDC-4025 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: Ia44a6ac73d9a52042caaacf0c5f790e1e2fc73f1
Diffstat (limited to 'common-be/src/main')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java22
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/utils/AttributeDefinitionUtils.java42
2 files changed, 64 insertions, 0 deletions
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<AttributeDataDefinition> getAttributesMappedToOutputs(List<AttributeDataDefinition> attributes) {
+ if (attributes == null) {
+ return Collections.emptyList();
+ }
+ return filterGetOutputAttributes(attributes);
+ }
+
+ private static <T extends AttributeDataDefinition> List<AttributeDataDefinition> filterGetOutputAttributes(List<T> attributeDefinitions) {
+ return attributeDefinitions.stream().filter(AttributeDataDefinition::isGetOutputAttribute).collect(Collectors.toList());
+ }
+}