summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-04-10 17:01:22 +0000
committerliamfallon <liam.fallon@est.tech>2019-04-10 17:01:22 +0000
commit52567cb059f90bb3114c4d4db3c758dd98b7b18b (patch)
tree8495dfe705a48b17e3993a3dad84c3729d3c8166
parent0f268c6715615c578222d77a806c81e6e7fdaadd (diff)
Add policy ID and version to metadata
Adds the policy-id and policy-version of the policy to the policy metadata, duplicating the policy key in therre. Issue-ID: POLICY-1095 Change-Id: I49603766141f5dee47573edc9f05d2ee2cf9da52 Signed-off-by: liamfallon <liam.fallon@est.tech>
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java
index 3bc472243..7655eb96a 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java
@@ -69,6 +69,10 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
public class JpaToscaPolicy extends JpaToscaEntityType<ToscaPolicy> implements PfAuthorative<ToscaPolicy> {
private static final long serialVersionUID = 3265174757061982805L;
+ // Tags for metadata
+ private static final String METADATA_POLICY_ID_TAG = "policy-id";
+ private static final String METADATA_POLICY_VERSION_TAG = "policy-version";
+
// @formatter:off
@Column
@AttributeOverrides({
@@ -184,6 +188,15 @@ public class JpaToscaPolicy extends JpaToscaEntityType<ToscaPolicy> implements P
properties.put(propertyEntry.getKey(), propertyEntry.getValue().toString());
}
}
+
+ // Add the property metadata if it doesn't exist already
+ if (toscaPolicy.getMetadata() == null) {
+ toscaPolicy.setMetadata(new LinkedHashMap<>());
+ }
+
+ // Add the policy name and version fields to the metadata
+ toscaPolicy.getMetadata().put(METADATA_POLICY_ID_TAG, getKey().getName());
+ toscaPolicy.getMetadata().put(METADATA_POLICY_VERSION_TAG, Integer.toString(getKey().getMajorVersion()));
}
@Override