summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-01-03 10:48:36 +0000
committerFrancesco Fiora <francesco.fiora@est.tech>2023-01-04 09:54:47 +0000
commit951196b4e0d4c64403f186693c2d1c53e25df3b1 (patch)
treebdfbd91c858902522be7866081496e2f5e878db4 /models
parentc6fb86de3dae6f26aec9813cd5ef4cc8d9268359 (diff)
Refactor Post compositions to create and update ACM definitions
Issue-ID: POLICY-4492 Change-Id: Ica3885c7e2a048500a86abc194624ac22efd6bc2 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java
index 12a05946e..054271512 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java
@@ -20,6 +20,7 @@
package org.onap.policy.clamp.models.acm.persistence.provider;
+import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@@ -52,7 +53,12 @@ public class AcDefinitionProvider {
public AutomationCompositionDefinition createAutomationCompositionDefinition(
final ToscaServiceTemplate serviceTemplate) {
var acmDefinition = new AutomationCompositionDefinition();
- acmDefinition.setCompositionId(UUID.randomUUID());
+ var compositionId = UUID.randomUUID();
+ acmDefinition.setCompositionId(compositionId);
+ if (serviceTemplate.getMetadata() == null) {
+ serviceTemplate.setMetadata(new HashMap<>());
+ }
+ serviceTemplate.getMetadata().put("compositionId", compositionId);
acmDefinition.setServiceTemplate(serviceTemplate);
var jpaAcmDefinition = ProviderUtils.getJpaAndValidate(acmDefinition, JpaAutomationCompositionDefinition::new,
"AutomationCompositionDefinition");