From a85118152983dbc53ce1d0e14712bc66c4177f65 Mon Sep 17 00:00:00 2001 From: "saul.gill" Date: Wed, 15 Feb 2023 12:39:43 +0000 Subject: Add undeploy on deregister (acm-side) State of Ac Elements associated with participant changed on deregister Issue-ID: POLICY-4499 Change-Id: I54265c13deebd77d654fb843a33f7267d4276b76 Signed-off-by: saul.gill --- .../acm/persistence/provider/ParticipantProvider.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'models/src/main') diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java index 65b72c436..25d72cb06 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java @@ -29,6 +29,8 @@ import javax.ws.rs.core.Response.Status; import lombok.NonNull; import lombok.RequiredArgsConstructor; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.DeployState; +import org.onap.policy.clamp.models.acm.concepts.LockState; import org.onap.policy.clamp.models.acm.concepts.NodeTemplateState; import org.onap.policy.clamp.models.acm.concepts.Participant; import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant; @@ -180,4 +182,19 @@ public class ParticipantProvider { return ProviderUtils.asEntityList(nodeTemplateStateRepository .findByParticipantId(participantId.toString())); } + + /** + * Reset the Deploy and Lock states of all the ac elements associated with a participant. + * + * @param participantId the participant id associated with the automation composition elements + */ + public void resetParticipantAcElementState(@NonNull final UUID participantId) { + var participantAcElementList = automationCompositionElementRepository + .findByParticipantId(participantId.toString()); + participantAcElementList.forEach(e -> { + e.setDeployState(DeployState.UNDEPLOYED); + e.setLockState(LockState.NONE); + }); + automationCompositionElementRepository.saveAll(participantAcElementList); + } } -- cgit