summaryrefslogtreecommitdiffstats
path: root/models-tosca
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-05-09 15:54:41 +0000
committerliamfallon <liam.fallon@est.tech>2019-05-09 15:54:41 +0000
commitd034de615965ca8214396e30c85191a5aa4aa37b (patch)
treee19b0a396010b94a28f76ea86f06739c1ed479aa /models-tosca
parent4a1ec1aea71bf58d371a034045defd11d9e77ce3 (diff)
Store policy type version in policy before DB write
The policy type version must be updated on a policy before it is stored to the database, otherwise the database value is incorrect. Issue-ID: POLICY-1738 Change-Id: I0a7f2da3837497dd999141f40466d6507c26159b Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca')
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
index 81a41aa05..761a47c9a 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
@@ -195,7 +195,6 @@ public class SimpleToscaProvider {
for (JpaToscaPolicy policy : serviceTemplate.getTopologyTemplate().getPolicies().getAll(null)) {
verifyPolicyTypeForPolicy(dao, policy);
-
dao.create(policy);
}
@@ -226,6 +225,7 @@ public class SimpleToscaProvider {
ToscaUtils.assertPoliciesExist(serviceTemplate);
for (JpaToscaPolicy policy : serviceTemplate.getTopologyTemplate().getPolicies().getAll(null)) {
+ verifyPolicyTypeForPolicy(dao, policy);
dao.update(policy);
}
@@ -288,6 +288,7 @@ public class SimpleToscaProvider {
if (PfKey.NULL_KEY_VERSION.equals(policyTypeKey.getVersion())) {
policyType = getLatestPolicyTypeVersion(dao, policyTypeKey.getName());
+ policy.getType().setVersion(policyType.getKey().getVersion());
} else {
policyType = dao.get(JpaToscaPolicyType.class, policyTypeKey);
}