aboutsummaryrefslogtreecommitdiffstats
path: root/models-tosca/src/main/java/org
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-09-08 17:04:49 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-09-09 16:02:19 +0000
commit1a87ab847d70db032edc260096121c7016ee50d7 (patch)
tree71f1814ccbb4c7adf8b4748a8b25780d7e875dc9 /models-tosca/src/main/java/org
parent79cee88a95874d81ae92fbe34eef73c3eb9469b7 (diff)
Add metadata to properties
Properties should support metadata - adding it in. Added junit tests for the new metadata field. Issue-ID: POLICY-2060 Change-Id: I2e1933ca4260fe5989f36a098108893a366f657a Signed-off-by: Pamela Dragosh <pdragosh@research.att.com> Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-tosca/src/main/java/org')
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java3
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java23
2 files changed, 26 insertions, 0 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java
index 00005f2f8..fd8a86a0d 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java
@@ -26,6 +26,7 @@ package org.onap.policy.models.tosca.authorative.concepts;
import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
+import java.util.Map;
import lombok.Data;
/**
@@ -60,4 +61,6 @@ public class ToscaProperty {
@ApiModelProperty(name = "entry_schema")
@SerializedName("entry_schema")
private ToscaEntrySchema entrySchema;
+
+ private Map<String, String> metadata;
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java
index 93da035a5..0e8201f0f 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java
@@ -24,7 +24,10 @@
package org.onap.policy.models.tosca.simple.concepts;
import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId;
@@ -87,6 +90,9 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative<ToscaPr
@Column
private JpaToscaEntrySchema entrySchema;
+ @ElementCollection
+ private Map<String, String> metadata;
+
/**
* The Default Constructor creates a {@link JpaToscaProperty} object with a null key.
*/
@@ -130,6 +136,7 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative<ToscaPr
// Constraints are immutable
this.constraints = (copyConcept.constraints != null ? new ArrayList<>(copyConcept.constraints) : null);
this.entrySchema = (copyConcept.entrySchema != null ? new JpaToscaEntrySchema(copyConcept.entrySchema) : null);
+ this.metadata = (copyConcept.metadata != null ? new LinkedHashMap<>(copyConcept.metadata) : null);
}
/**
@@ -169,6 +176,10 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative<ToscaPr
toscaProperty.setEntrySchema(entrySchema.toAuthorative());
}
+ if (metadata != null) {
+ toscaProperty.setMetadata(new LinkedHashMap<>(metadata));
+ }
+
return toscaProperty;
}
@@ -199,6 +210,12 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative<ToscaPr
if (toscaProperty.getEntrySchema() != null) {
entrySchema = new JpaToscaEntrySchema(toscaProperty.getEntrySchema());
}
+
+ // Add the property metadata if it doesn't exist already
+ if (toscaProperty.getMetadata() != null) {
+ metadata = new LinkedHashMap<>(toscaProperty.getMetadata());
+ }
+
}
@Override
@@ -231,6 +248,12 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative<ToscaPr
if (entrySchema != null) {
entrySchema.clean();
}
+
+ if (metadata != null) {
+ for (Entry<String, String> metadataEntry : metadata.entrySet()) {
+ metadataEntry.setValue(metadataEntry.getValue().trim());
+ }
+ }
}
@Override