summaryrefslogtreecommitdiffstats
path: root/common-be
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2022-03-23 15:39:45 +0000
committerandre.schmid <andre.schmid@est.tech>2022-03-28 16:52:47 +0100
commit32f75a4854fc1bcf3bfbd8037f2d1682cbbd9fc5 (patch)
tree3c40200e9cdd8a4f3f93a0137ce5c02180890143 /common-be
parent7fc7a76be1e90b9d75f7f6f11181a150cb1d1386 (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> (cherry picked from commit 88fdc6dd75f1119ffa8e54dbfd721b6ed722b779)
Diffstat (limited to 'common-be')
-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() {