From d034de615965ca8214396e30c85191a5aa4aa37b Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 9 May 2019 15:54:41 +0000 Subject: 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 --- .../onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'models-tosca/src/main/java/org') 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); } -- cgit 1.2.3-korg