summaryrefslogtreecommitdiffstats
path: root/common-be
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2021-02-02 19:18:22 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-02-25 12:20:17 +0000
commit0aa493c70aebd63244beeddf0ef22147196c5489 (patch)
tree6557463275234f84d05d40c89c1bcfc7134298fc /common-be
parent70f93dfdd2b3a7c682b341223b6f63af43feb280 (diff)
Improve import and export VFC TOSCA attributes
Improve the import and export VFC TOSCA attributes, addressing the following concerns: - brings the import and export logic very close to the properties logic, as they are very similar structures - fix import/export default values for complex types and list of simple or complex types - fix export of unnecessary/empty attribute entries - creation of attributes during the initialization (base types) - inheritance of parent attributes Change-Id: Ic733e3455fc256595b5c2b1f48e19a13be27b5cc Issue-ID: SDC-3466 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'common-be')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java21
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java1
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java5
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java2
4 files changed, 14 insertions, 15 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 d159da853a..d90f6bece5 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
@@ -19,10 +19,12 @@
*/
package org.openecomp.sdc.be.datatypes.elements;
+import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
+import org.apache.commons.collections.CollectionUtils;
import org.onap.sdc.tosca.datatypes.model.EntrySchema;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
@@ -32,7 +34,7 @@ import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
@NoArgsConstructor
public class AttributeDataDefinition extends ToscaDataDefinition {
- private List<GetOutputValueDataDefinition> getOutputValues;
+ private transient List<GetOutputValueDataDefinition> getOutputValues;
private String outputId;
private String value;
private String outputPath;
@@ -51,11 +53,15 @@ public class AttributeDataDefinition extends ToscaDataDefinition {
this.setValue(attributeDataDefinition.getValue());
this.setStatus(attributeDataDefinition.getStatus());
this.setEntry_schema(attributeDataDefinition.getEntry_schema());
- this.setSchema(attributeDataDefinition.getSchema());
this.setOutputPath(attributeDataDefinition.getOutputPath());
this.setInstanceUniqueId(attributeDataDefinition.getInstanceUniqueId());
this.setAttributeId(attributeDataDefinition.getAttributeId());
this.setParentUniqueId(attributeDataDefinition.getParentUniqueId());
+ this.setOutputId(attributeDataDefinition.getOutputId());
+ if (CollectionUtils.isNotEmpty(attributeDataDefinition.getGetOutputValues())) {
+ this.getOutputValues = new ArrayList<>(attributeDataDefinition.getGetOutputValues());
+ }
+
}
public String getUniqueId() {
@@ -89,11 +95,6 @@ public class AttributeDataDefinition extends ToscaDataDefinition {
return (String) getToscaPresentationValue(JsonPresentationFields.TYPE);
}
- @Override
- public void setType(final String type) {
- setToscaPresentationValue(JsonPresentationFields.TYPE, type);
- }
-
public String getDescription() {
return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
}
@@ -119,15 +120,15 @@ public class AttributeDataDefinition extends ToscaDataDefinition {
}
public EntrySchema getEntry_schema() {
- return (EntrySchema) getToscaPresentationValue(JsonPresentationFields.SCHEMA);
+ return (EntrySchema) getToscaPresentationValue(JsonPresentationFields.ENTRY_SCHEMA);
}
public void setEntry_schema(final EntrySchema entrySchema) {
- setToscaPresentationValue(JsonPresentationFields.SCHEMA, entrySchema);
+ setToscaPresentationValue(JsonPresentationFields.ENTRY_SCHEMA, entrySchema);
}
public SchemaDefinition getSchema() {
- return (SchemaDefinition) getToscaPresentationValue(JsonPresentationFields.SCHEMA);
+ return null;
}
public String getParentUniqueId() {
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 34382df716..2ec5b286b8 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
@@ -119,6 +119,7 @@ public enum JsonPresentationFields {
PROPERTIES("properties", null),
PROPERTY("property", null),
SCHEMA("schema", null),
+ ENTRY_SCHEMA("entry_schema", null),
VALUE("value", null),
PARENT_UNIQUE_ID("parentUniqueId", 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 4ca44423af..518e5eb8cf 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
@@ -23,15 +23,13 @@ package org.openecomp.sdc.be.datatypes.tosca;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import fj.data.Either;
-import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
-import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
public abstract class ToscaDataDefinition {
@@ -138,5 +136,4 @@ public abstract class ToscaDataDefinition {
return false;
}
- public void setSchema(final SchemaDefinition schemaDef){};
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java b/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
index ee8c7db4f2..7535fbd5b6 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
@@ -46,7 +46,7 @@ public class TypeUtils {
DERIVED_FROM("derived_from"), IS_PASSWORD("is_password"),
// Properties
PROPERTIES("properties"), TYPE("type"), STATUS("status"),
- ENTRY_SCHEMA("entry_schema"), REQUIRED("required"), DESCRIPTION("description"),
+ KEY_SCHEMA("key_schema"), ENTRY_SCHEMA("entry_schema"), REQUIRED("required"), DESCRIPTION("description"),
DEFAULT_VALUE("default"), VALUE("value"), CONSTRAINTS("constraints"),
DEFAULT("default"),
// Group Types