aboutsummaryrefslogtreecommitdiffstats
path: root/common-be
diff options
context:
space:
mode:
Diffstat (limited to 'common-be')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java8
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java209
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListCapabilityDataDefinition.java6
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListDataDefinition.java18
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListRequirementDataDefinition.java10
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapAttributesDataDefinition.java45
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java56
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java33
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java41
9 files changed, 110 insertions, 316 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java
index 102c7dde6e..24d801262c 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java
@@ -348,6 +348,14 @@ public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinitio
this.conformanceLevel = conformanceLevel;
}
+ public String getLifecycleState() {
+ return state;
+ }
+
+ public void setLifecycleState(String state) {
+ this.state = state;
+ }
+
@Override
public String toString() {
return "ComponentMetadataDataDefinition [uniqueId=" + uniqueId + ", name=" + name + ", version=" + version
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
deleted file mode 100644
index a753270bbd..0000000000
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.datatypes.elements;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
-import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-
-/**
- * Represents AttributeDataDefinition
- *
- * @author mshitrit
- *
- */
-public class AttributeDataDefinition extends ToscaDataDefinition implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -3046831950009259569L;
-
- private String uniqueId;
- private String name;
- private String type;
- private String description;
-
- private String defaultValue;
- private String value;
-
- private String status;
- private SchemaDefinition schema;
-
- public AttributeDataDefinition() {
- // Used From Attribute Defenition
- }
-
- /**
- * Clone Constructor
- *
- * @param attribute
- */
- public AttributeDataDefinition(AttributeDataDefinition attribute) {
- this.uniqueId = attribute.uniqueId;
- this.name = attribute.name;
- this.type = attribute.type;
- this.description = attribute.description;
- this.defaultValue = attribute.defaultValue;
- this.value = attribute.value;
- this.status = attribute.status;
- this.schema = attribute.schema;
- }
-
- public String getUniqueId() {
- return uniqueId;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getDefaultValue() {
- return defaultValue;
- }
-
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public SchemaDefinition getSchema() {
- return schema;
- }
-
- public void setSchema(SchemaDefinition entrySchema) {
- this.schema = entrySchema;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
- result = prime * result + ((value == null) ? 0 : value.hashCode());
- result = prime * result + ((description == null) ? 0 : description.hashCode());
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
- result = prime * result + ((status == null) ? 0 : status.hashCode());
- result = prime * result + ((schema == null) ? 0 : schema.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- boolean equals = true;
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
-
- AttributeDataDefinition other = (AttributeDataDefinition) obj;
- if (!Objects.equals(defaultValue, other.defaultValue)) {
- equals = false;
- } else if (!Objects.equals(value, other.value)) {
- equals = false;
- } else if (!Objects.equals(description, other.description)) {
- equals = false;
- } else if (!Objects.equals(name, other.name)) {
- equals = false;
- } else if (!Objects.equals(type, other.type)) {
- equals = false;
- } else if (!Objects.equals(uniqueId, other.uniqueId)) {
- equals = false;
- } else if (!Objects.equals(status, other.status)) {
- equals = false;
- } else if (!Objects.equals(schema, other.schema)) {
- equals = false;
- }
- return equals;
- }
-
- @Override
- public String toString() {
- return "AttributeDataDefinition [uniqueId=" + uniqueId + ", name=" + name + ", type=" + type + ", description="
- + description + ", defaultValue=" + defaultValue + ", value=" + value + ", status=" + status
- + ", entrySchema=" + schema + "]";
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- @Override
- public Object getToscaPresentationValue(JsonPresentationFields field) {
- switch (field) {
- case NAME:
- return name;
- case UNIQUE_ID:
- return uniqueId;
- case TYPE:
- return type;
- case DESCRIPTION:
- return description;
- case VALUE:
- return value;
- case DEFAULT_VALUE:
- return defaultValue;
- default:
- return super.getToscaPresentationValue(field);
- }
- }
-}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListCapabilityDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListCapabilityDataDefinition.java
index 3057c72c67..c986c0fe7e 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListCapabilityDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListCapabilityDataDefinition.java
@@ -33,10 +33,4 @@ public class ListCapabilityDataDefinition extends ListDataDefinition<CapabilityD
this.listToscaDataDefinition = listToscaDataDefinition;
}
- public ListCapabilityDataDefinition mergeListItemsByName(ListCapabilityDataDefinition other){
- Map<String, CapabilityDataDefinition> mapByName = listToMapByName();
- Map<String, CapabilityDataDefinition> mapOtherByName = other.listToMapByName();
- mapByName.putAll(mapOtherByName);
- return new ListCapabilityDataDefinition(mapByName.values().stream().collect(Collectors.toList()));
- }
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListDataDefinition.java
index 2eb8dcad2e..c9bf851e17 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListDataDefinition.java
@@ -55,15 +55,17 @@ public class ListDataDefinition<T extends ToscaDataDefinition> extends ToscaData
listToscaDataDefinition.forEach(e -> e.setOwnerIdIfEmpty(ownerId));
}
}
-
-
- public Map<String, T> listToMapByName() {
- Map<String, T> mapByName = new HashMap<>();
- listToscaDataDefinition.forEach(e -> mapByName.put((String)e.getToscaPresentationValue(JsonPresentationFields.NAME), e));
- return mapByName;
- }
-
+ @Override
+ public <S extends ToscaDataDefinition> S mergeFunction(S other, boolean allowDefaultValueOverride){
+ Map<String, T> mapByName = listToMapByName(listToscaDataDefinition);
+ List<T> otherList = ((ListDataDefinition)other).getListToscaDataDefinition();
+ for(T item : otherList){
+ mapByName.merge(item.getName(), item, (thisItem, otherItem) -> thisItem.mergeFunction(otherItem, allowDefaultValueOverride));
+ }
+ ((ListDataDefinition)other).listToscaDataDefinition = mapByName.values().stream().collect(Collectors.toList());
+ return other;
+ }
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListRequirementDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListRequirementDataDefinition.java
index 4c69958e62..fb1248d100 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListRequirementDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListRequirementDataDefinition.java
@@ -6,6 +6,7 @@ import java.util.stream.Collectors;
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonValue;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
public class ListRequirementDataDefinition extends ListDataDefinition<RequirementDataDefinition> {
@@ -33,11 +34,8 @@ public class ListRequirementDataDefinition extends ListDataDefinition<Requiremen
this.listToscaDataDefinition = listToscaDataDefinition;
}
- public ListRequirementDataDefinition mergeListItemsByName(ListRequirementDataDefinition other){
- Map<String, RequirementDataDefinition> mapByName = listToMapByName();
- Map<String, RequirementDataDefinition> mapOtherByName = other.listToMapByName();
- mapByName.putAll(mapOtherByName);
- return new ListRequirementDataDefinition(mapByName.values().stream().collect(Collectors.toList()));
- }
+
+
+
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapAttributesDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapAttributesDataDefinition.java
deleted file mode 100644
index 817fbebd5c..0000000000
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapAttributesDataDefinition.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.openecomp.sdc.be.datatypes.elements;
-
-import java.util.Map;
-
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonValue;
-
-public class MapAttributesDataDefinition extends MapDataDefinition<AttributeDataDefinition>{
-
- private String parentName;
-
- public MapAttributesDataDefinition(MapDataDefinition cdt, String parentName) {
- super(cdt);
- this.parentName = parentName;
- }
-
- @JsonCreator
- public MapAttributesDataDefinition(Map<String, AttributeDataDefinition > mapToscaDataDefinition) {
- super(mapToscaDataDefinition);
- }
- public MapAttributesDataDefinition() {
- super();
-
- }
- @JsonValue
- @Override
- public Map<String, AttributeDataDefinition> getMapToscaDataDefinition() {
- return mapToscaDataDefinition;
- }
-
-
- public void setMapToscaDataDefinition(Map<String, AttributeDataDefinition> mapToscaDataDefinition) {
- this.mapToscaDataDefinition = mapToscaDataDefinition;
- }
-
- public String getParentName() {
- return parentName;
- }
-
- public void setParentName(String parentName) {
- this.parentName = parentName;
- }
-
-
-}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java
index ed94ce0d87..4c798521c5 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.datatypes.elements;
import java.io.Serializable;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -60,12 +61,11 @@ public class PropertyDataDefinition extends ToscaDataDefinition implements Seria
private String value;
private String label;
- private Boolean hidden = Boolean.FALSE;;
+ protected Boolean hidden = Boolean.FALSE;
private Boolean immutable = Boolean.FALSE;
private String inputPath;
-
-
+ private String status;
/**
* The resource id which this property belongs to
@@ -104,9 +104,10 @@ public class PropertyDataDefinition extends ToscaDataDefinition implements Seria
this.setOwnerId(p.getOwnerId());
this.setGetInputValues(p.getInputValues);
this.setInputPath(p.getInputPath());
+ this.setStatus(p.getStatus());
}
-
+
public String getInputPath() {
return inputPath;
}
@@ -115,7 +116,6 @@ public class PropertyDataDefinition extends ToscaDataDefinition implements Seria
this.inputPath = inputPath;
}
-
public String getName() {
return name;
}
@@ -238,6 +238,15 @@ public class PropertyDataDefinition extends ToscaDataDefinition implements Seria
public void setGetInputValues(List<GetInputValueDataDefinition> getInputValues) {
this.getInputValues = getInputValues;
}
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
@Override
public String toString() {
return "PropertyDataDefinition [uniqueId=" + uniqueId + ", type=" + type + ", required=" + required + ", defaultValue=" + defaultValue + ", description=" + description + ", entrySchema=" + schema + ", parentUniqueId=" + parentUniqueId + ", password=" + password + "]";
@@ -256,6 +265,7 @@ public class PropertyDataDefinition extends ToscaDataDefinition implements Seria
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
result = prime * result + ((parentUniqueId == null) ? 0 : parentUniqueId.hashCode());
+ result = prime * result + ((status == null) ? 0 : status.hashCode());
return result;
}
@@ -307,6 +317,11 @@ public class PropertyDataDefinition extends ToscaDataDefinition implements Seria
return false;
} else if (!uniqueId.equals(other.uniqueId))
return false;
+ if (status == null) {
+ if (other.status != null)
+ return false;
+ } else if (!status.equals(other.status))
+ return false;
return true;
}
@@ -332,34 +347,23 @@ public class PropertyDataDefinition extends ToscaDataDefinition implements Seria
}
}
- protected <T extends PropertyDataDefinition> T overrideDataDefinition(T other, boolean allowDefaultValueOverride){
- if(this.getType().equals(other.getType())){
+ private <T extends ToscaDataDefinition> boolean compareSchemaType(T other){
+ return !"list".equals(type) && !"map".equals(type) || this.getSchema().getProperty().getType().equals(((PropertyDataDefinition)other).getSchema().getProperty().getType());
+ }
+
+
+ @Override
+ public <T extends ToscaDataDefinition> T mergeFunction(T other, boolean allowDefaultValueOverride){
+ if(this.getType().equals(other.getType()) && compareSchemaType(other)){
other.setOwnerId(getOwnerId());
if(allowDefaultValueOverride)
- other.setDefaultValue(getDefaultValue());
+ other.setToscaPresentationValue(JsonPresentationFields.DEFAULT_VALUE, getDefaultValue());
return other;
}
return null;
}
-
-
- //return Either.right(propertyName) if an illegal merge was attempted (overriding data type is forbidden)
- public static <T extends PropertyDataDefinition> Either<Map<String, T>, String> mergeProperties(Map<String, T> derivedProps, Map<String, T> importedProps, boolean allowDefaultValueOverride){
- for(T property : importedProps.values()){
- derivedProps.merge(property.getName(), property, (derivedProp, importedProp) -> derivedProp.overrideDataDefinition(importedProp, allowDefaultValueOverride));
- //validate merge success
- if(!derivedProps.containsKey(property.getName()))
- return Either.right(property.getName());
- }
- return Either.left(derivedProps);
- }
-
-
- public static <T extends PropertyDataDefinition> Map<String, T> listToMapByName(List<T> propertiesList) {
- return propertiesList.stream()
- .collect(Collectors.toMap(p -> p.getName(), p -> p));
- }
+
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
index 6004e65949..f5cc2b661b 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
@@ -38,8 +38,8 @@ public enum JsonPresentationFields {
CONTACT_ID ("contactId", null),
PROJECT_CODE ("projectCode", null),
DISTRIBUTION_STATUS ("distributionStatus", GraphPropertyEnum.DISTRIBUTION_STATUS),
- DERIVED_FROM_GENERIC_TYPE("derivedFromGenericType", null),
- DERIVED_FROM_GENERIC_VERSION("derivedFromGenericVersion", null),
+ DERIVED_FROM_GENERIC_TYPE ("derivedFromGenericType", null),
+ DERIVED_FROM_GENERIC_VERSION ("derivedFromGenericVersion", null),
////Artifact
ARTIFACT_TYPE ("artifactType", null),
@@ -68,7 +68,7 @@ public enum JsonPresentationFields {
REQUIRED_ARTIFACTS ("requiredArtifacts", null),
DUPLICATED ("duplicated", null),
HEAT_PARAMETERS ("heatParameters", null),
- GENERATED_FROM_ID ("generatedFromId", null),
+ GENERATED_FROM_ID ("generatedFromId", null),
// end artifacts
@@ -89,10 +89,11 @@ public enum JsonPresentationFields {
COMPONENT_INSTANCES ("componentInstances", null),
RELATIONS ("relations", null),
-
+ //attribute
+ STATUS ("status", null),
//capability
VALID_SOURCE_TYPE ("validSourceTypes", null),
- CREATION_TIME ("creationTime", null),
+ CREATION_TIME ("creationTime", null),
MODIFICATION_TIME ("modificationTime", null),
CAPABILITY_SOURCES ("capabilitySources", null),
MAX_OCCURRENCES ("maxOccurrences", null),
@@ -124,17 +125,17 @@ public enum JsonPresentationFields {
GROUP_UUID ("groupUUID", null),
GROUP_MEMBER ("members", null),
GROUP_ARTIFACTS ("artifacts", null),
- GROUP_ARTIFACTS_UUID (" artifactsUuid", null),
- GROUP_PROPERTIES (" properties", null),
- GROUP_UNIQUE_ID (" groupUid", null),
- POS_X (" posX", null),
- POS_Y (" posY", null),
- PROPERTY_VALUE_COUNTER (" propertyValueCounter", null),
- CUSTOMIZATION_UUID (" customizationUUID", null),
- GROUP_NAME (" groupName", null),
- GROUP_INSTANCE_ARTIFACTS (" groupInstanceArtifacts", null),
- GROUP_INSTANCE_ARTIFACTS_UUID (" groupInstanceArtifactsUuid", null),
- GROUP_INSTANCE_PROPERTIES (" groupInstancesProperties", null),
+ GROUP_ARTIFACTS_UUID ("artifactsUuid", null),
+ GROUP_PROPERTIES ("properties", null),
+ GROUP_UNIQUE_ID ("groupUid", null),
+ POS_X ("posX", null),
+ POS_Y ("posY", null),
+ PROPERTY_VALUE_COUNTER ("propertyValueCounter", null),
+ CUSTOMIZATION_UUID ("customizationUUID", null),
+ GROUP_NAME ("groupName", null),
+ GROUP_INSTANCE_ARTIFACTS ("groupInstanceArtifacts", null),
+ GROUP_INSTANCE_ARTIFACTS_UUID ("groupInstanceArtifactsUuid", null),
+ GROUP_INSTANCE_PROPERTIES ("groupInstancesProperties", null),
;
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
index d0f480b588..bf51ba4e28 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
@@ -1,13 +1,19 @@
package org.openecomp.sdc.be.datatypes.tosca;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonValue;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import fj.data.Either;
+
public abstract class ToscaDataDefinition {
protected Map<String, Object> toscaPresentation;
@@ -47,4 +53,39 @@ public abstract class ToscaDataDefinition {
public String getOwnerId(){
return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_ID);
}
+
+
+ public String getType(){
+ return (String) getToscaPresentationValue(JsonPresentationFields.TYPE);
+ }
+
+ public String getName(){
+ return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
+ }
+
+ //default merge function for merging data maps - implement where needed and use mergeDataMaps method where applicable instead of map1.putAll(map2)
+ public <T extends ToscaDataDefinition> T mergeFunction(T other, boolean allowDefaultValueOverride){
+ other.setOwnerId(getOwnerId());
+ return other;
+ }
+
+ public static <T extends ToscaDataDefinition> Either<Map<String, T>, String> mergeDataMaps(Map<String, T> map1, Map<String, T> map2){
+ return mergeDataMaps(map1, map2, false);
+ }
+
+ //return Either.right(item key) if an illegal merge was attempted (overriding data type is forbidden)
+ public static <T extends ToscaDataDefinition> Either<Map<String, T>, String> mergeDataMaps(Map<String, T> map1, Map<String, T> map2, boolean allowDefaultValueOverride){
+ for(Entry<String, T> entry : map2.entrySet()){
+ map1.merge(entry.getKey(), entry.getValue(), (item1, item2) -> item1.mergeFunction(item2, allowDefaultValueOverride));
+ //validate merge success
+ if(!map1.containsKey(entry.getKey()))
+ return Either.right(entry.getKey());
+ }
+ return Either.left(map1);
+ }
+
+ public static <T extends ToscaDataDefinition> Map<String, T> listToMapByName(List<T> dataList) {
+ return null == dataList? new HashMap<>() : dataList.stream()
+ .collect(Collectors.toMap(p -> p.getName(), p -> p));
+ }
}