From 933f1325044e6233ca0da1eecf223bc5bbb06b36 Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Thu, 24 Nov 2022 10:41:40 +0000 Subject: Link the AutomationComposition with AutomationCompositionDefinition In AutomationComposition replace the link to ToscaNodeTemplate whit a link to AutomationCompositionDefinition using compositionId. Issue-ID: POLICY-4464 Change-Id: I66878f04ef93fb0754d0066e78bd074ce082f891 Signed-off-by: FrancescoFioraEst --- .../api/impl/ParticipantIntermediaryApiImpl.java | 20 ++++++++++---------- .../handler/AutomationCompositionHandler.java | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 19 deletions(-) (limited to 'participant/participant-intermediary/src/main/java') diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java index e4d921af7..cf7a93fb4 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java @@ -60,14 +60,14 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp * @param automationCompositionHandler AutomationCompositionHandler */ public ParticipantIntermediaryApiImpl(ParticipantHandler participantHandler, - AutomationCompositionHandler automationCompositionHandler) { + AutomationCompositionHandler automationCompositionHandler) { this.participantHandler = participantHandler; this.automationCompositionHandler = automationCompositionHandler; } @Override public void registerAutomationCompositionElementListener( - AutomationCompositionElementListener automationCompositionElementListener) { + AutomationCompositionElementListener automationCompositionElementListener) { automationCompositionHandler.registerAutomationCompositionElementListener(automationCompositionElementListener); } @@ -93,11 +93,11 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp @Override public Map getAutomationCompositionElements(String name, String version) { - List automationCompositions = - automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList(); + var automationCompositions = + automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList(); - for (AutomationComposition automationComposition : automationCompositions) { - if (name.equals(automationComposition.getDefinition().getName())) { + for (var automationComposition : automationCompositions) { + if (name.equals(automationComposition.getName())) { return automationComposition.getElements(); } } @@ -107,7 +107,7 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp @Override public AutomationCompositionElement getAutomationCompositionElement(UUID id) { List automationCompositions = - automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList(); + automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList(); for (AutomationComposition automationComposition : automationCompositions) { AutomationCompositionElement acElement = automationComposition.getElements().get(id); @@ -120,9 +120,9 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp @Override public AutomationCompositionElement updateAutomationCompositionElementState( - ToscaConceptIdentifier automationCompositionId, UUID id, AutomationCompositionOrderedState currentState, - AutomationCompositionState newState, ParticipantMessageType messageType) { + ToscaConceptIdentifier automationCompositionId, UUID id, AutomationCompositionOrderedState currentState, + AutomationCompositionState newState, ParticipantMessageType messageType) { return automationCompositionHandler.updateAutomationCompositionElementState(automationCompositionId, id, - currentState, newState); + currentState, newState); } } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java index 4c74e50fe..451215515 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java @@ -202,7 +202,7 @@ public class AutomationCompositionHandler { break; default: LOGGER.debug("StateChange message has no state, state is null {}", - automationComposition.getDefinition()); + automationComposition.getKey()); break; } } @@ -255,11 +255,11 @@ public class AutomationCompositionHandler { return; } + automationComposition = new AutomationComposition(); + automationComposition.setName(updateMsg.getAutomationCompositionId().getName()); + automationComposition.setVersion(updateMsg.getAutomationCompositionId().getVersion()); var acElements = storeElementsOnThisParticipant(updateMsg.getParticipantUpdatesList()); - var acElementMap = prepareAcElementMap(acElements); - automationComposition = new AutomationComposition(); - automationComposition.setDefinition(updateMsg.getAutomationCompositionId()); automationComposition.setElements(acElementMap); automationCompositionMap.put(updateMsg.getAutomationCompositionId(), automationComposition); @@ -347,7 +347,7 @@ public class AutomationCompositionHandler { .filter(element -> !AutomationCompositionState.UNINITIALISED.equals(element.getState())).findAny() .isEmpty(); if (isAllUninitialised) { - automationCompositionMap.remove(automationComposition.getDefinition()); + automationCompositionMap.remove(automationComposition.getKey().asIdentifier()); automationComposition.getElements().values() .forEach(element -> elementsOnThisParticipant.remove(element.getId())); } @@ -400,7 +400,7 @@ public class AutomationCompositionHandler { automationCompositionAck.setParticipantType(participantType); automationCompositionAck.setMessage("Automation composition is already in state " + orderedState); automationCompositionAck.setResult(false); - automationCompositionAck.setAutomationCompositionId(automationComposition.getDefinition()); + automationCompositionAck.setAutomationCompositionId(automationComposition.getKey().asIdentifier()); publisher.sendAutomationCompositionAck(automationCompositionAck); return; } @@ -419,11 +419,12 @@ public class AutomationCompositionHandler { if (startPhaseMsg.equals(startPhase)) { for (var acElementListener : listeners) { try { - acElementListener.automationCompositionElementStateChange(automationComposition.getDefinition(), - acElement.getId(), acElement.getState(), orderedState); + acElementListener.automationCompositionElementStateChange( + automationComposition.getKey().asIdentifier(), acElement.getId(), acElement.getState(), + orderedState); } catch (PfModelException e) { LOGGER.debug("Automation composition element update failed {}", - automationComposition.getDefinition()); + automationComposition.getKey().asIdentifier()); } } } -- cgit 1.2.3-korg