From 951196b4e0d4c64403f186693c2d1c53e25df3b1 Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Tue, 3 Jan 2023 10:48:36 +0000 Subject: Refactor Post compositions to create and update ACM definitions Issue-ID: POLICY-4492 Change-Id: Ica3885c7e2a048500a86abc194624ac22efd6bc2 Signed-off-by: FrancescoFioraEst --- .../models/acm/persistence/provider/AcDefinitionProvider.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'models/src/main') 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"); -- cgit 1.2.3-korg