summaryrefslogtreecommitdiffstats
path: root/common-be/src/main/java/org
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2022-03-23 15:39:45 +0000
committerMichael Morris <michael.morris@est.tech>2022-03-28 15:28:02 +0000
commit88fdc6dd75f1119ffa8e54dbfd721b6ed722b779 (patch)
tree2dd23aa9e31bc833ea2d3351b676963072f43d7d /common-be/src/main/java/org
parentb34392d78130702e86e36b89f848118ac08e7e44 (diff)
Fix Service/VF set value to list/map properties
In the Service Property Assignment page, setting a value to a property of type list<complex> or map<complex> was having the type replaced by the schema type and the value incorrectly set. Add test cases to cover the problem. Include small refactors. Issue-ID: SDC-3926 Change-Id: I1257dbb02e18b103118672ec52d663707d53229c Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'common-be/src/main/java/org')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java6
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/SchemaDefinition.java26
2 files changed, 28 insertions, 4 deletions
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 969d986c4d..c885dbcc46 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
@@ -84,14 +84,16 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
super(pr);
}
- public PropertyDataDefinition(PropertyDataDefinition propertyDataDefinition) {
+ public PropertyDataDefinition(final PropertyDataDefinition propertyDataDefinition) {
super();
this.setUniqueId(propertyDataDefinition.getUniqueId());
this.setRequired(propertyDataDefinition.isRequired());
this.setDefaultValue(propertyDataDefinition.getDefaultValue());
this.setDefinition(propertyDataDefinition.getDefinition());
this.setDescription(propertyDataDefinition.getDescription());
- this.setSchema(propertyDataDefinition.getSchema());
+ if (propertyDataDefinition.getSchema() != null) {
+ this.setSchema(new SchemaDefinition(propertyDataDefinition.getSchema()));
+ }
this.setPassword(propertyDataDefinition.isPassword());
this.setType(propertyDataDefinition.getType());
this.setName(propertyDataDefinition.getName());
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/SchemaDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/SchemaDefinition.java
index 1e4fc58ffe..17e21f0cc7 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/SchemaDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/SchemaDefinition.java
@@ -20,10 +20,14 @@
package org.openecomp.sdc.be.datatypes.elements;
-import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
/**
* Schema allows to create new types that can be used along TOSCA definitions.
@@ -45,7 +49,25 @@ public class SchemaDefinition extends ToscaDataDefinition {
this.setDerivedFrom(derivedFrom);
this.setConstraints(constraints);
this.setProperties(properties);
+ }
+ public SchemaDefinition(final SchemaDefinition schemaDefinition) {
+ if (schemaDefinition == null) {
+ return;
+ }
+ this.derivedFrom = schemaDefinition.getDerivedFrom();
+ if (CollectionUtils.isNotEmpty(schemaDefinition.getConstraints())) {
+ this.constraints = new ArrayList<>(schemaDefinition.getConstraints());
+ }
+ if (schemaDefinition.getProperty() != null) {
+ this.property = new PropertyDataDefinition(schemaDefinition.getProperty());
+ }
+ if (MapUtils.isNotEmpty(schemaDefinition.getProperties())) {
+ this.properties = new HashMap<>();
+ for (final Entry<String, PropertyDataDefinition> propertyEntry : schemaDefinition.getProperties().entrySet()) {
+ this.properties.put(propertyEntry.getKey(), new PropertyDataDefinition(propertyEntry.getValue()));
+ }
+ }
}
public String getDerivedFrom() {