diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-05-10 17:11:04 +0100 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-05-16 08:19:07 +0100 |
commit | 722523f568a682f1e48f6998c24c945802fec782 (patch) | |
tree | ffe6e47aa4c339023772a15d816af8b509b8142e /participant/participant-intermediary/src/main/java/org | |
parent | b4b9a1f3c81a1c64271e38d879a84f6b134d3a54 (diff) |
Add participant capability to send message with status and properties
Add participant capability to send message with status and properties
to ACM-R when those values need to be change.
Issue-ID: POLICY-4679
Change-Id: Idca5796c199b235e1f829097316c50688a351e80
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src/main/java/org')
5 files changed, 170 insertions, 175 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java index a61a6678a..23390699a 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java @@ -57,22 +57,4 @@ public interface AutomationCompositionElementListener { throws PfModelException { // default Unlock Operation } - - public default String getUseState(UUID automationCompositionId, UUID automationCompositionElementId) - throws PfModelException { - // default Use State - return ""; - } - - public default String getOperationalState(UUID automationCompositionId, UUID automationCompositionElementId) - throws PfModelException { - // default Operational State - return ""; - } - - public default Map<String, Object> getStatusProperties(UUID automationCompositionId, - UUID automationCompositionElementId) throws PfModelException { - // default StatusProperties - return Map.of(); - } } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java index 998a63269..509b6ed6e 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java @@ -21,6 +21,7 @@ package org.onap.policy.clamp.acm.participant.intermediary.api; +import java.util.Map; import java.util.UUID; import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.concepts.LockState; @@ -41,9 +42,24 @@ public interface ParticipantIntermediaryApi { /** * Update the state of a automation composition element. * + * @param automationCompositionId the ID of the automation composition to update the state on * @param id the ID of the automation composition element to update the state on - * @param newState the state of the automation composition element + * @param deployState the Deploy State of the automation composition element + * @param lockState the Lock State of the automation composition element + * @param message the message */ - void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState newState, - LockState lockState); + void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState deployState, + LockState lockState, String message); + + /** + * Send Automation Composition Element update Info to AC-runtime. + * + * @param automationCompositionId the ID of the automation composition to update the states + * @param id the ID of the automation composition element to update the states + * @param useState the use State + * @param operationalState the operational State + * @param statusProperties the status Properties Map + */ + void sendAcElementInfo(UUID automationCompositionId, UUID id, String useState, String operationalState, + Map<String, Object> statusProperties); } 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 d729a097f..20f222ab3 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 @@ -21,6 +21,7 @@ package org.onap.policy.clamp.acm.participant.intermediary.api.impl; +import java.util.Map; import java.util.UUID; import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; @@ -55,8 +56,15 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp @Override public void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState newState, - LockState lockState) { + LockState lockState, String message) { automationCompositionHandler.updateAutomationCompositionElementState(automationCompositionId, id, newState, - lockState); + lockState, message); + } + + @Override + public void sendAcElementInfo(UUID automationCompositionId, UUID elementId, String useState, + String operationalState, Map<String, Object> statusProperties) { + automationCompositionHandler.sendAcElementInfo(automationCompositionId, elementId, useState, operationalState, + statusProperties); } } 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 f918ed12c..e35582058 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 @@ -21,7 +21,6 @@ package org.onap.policy.clamp.acm.participant.intermediary.handler; -import com.att.aft.dme2.internal.apache.commons.lang.StringUtils; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; @@ -37,14 +36,19 @@ import org.onap.policy.clamp.models.acm.concepts.AcElementDeployAck; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementInfo; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo; 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.ParticipantDeploy; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType; import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeploy; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeployAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.LockOrder; import org.onap.policy.clamp.models.acm.persistence.provider.AcInstanceStateResolver; @@ -65,16 +69,12 @@ public class AutomationCompositionHandler { private final UUID participantId; private final ParticipantMessagePublisher publisher; private final AcInstanceStateResolver acInstanceStateResolver; + private final List<ParticipantSupportedElementType> supportedAcElementTypes; + private final List<AutomationCompositionElementListener> listeners = new ArrayList<>(); @Getter private final Map<UUID, AutomationComposition> automationCompositionMap = new LinkedHashMap<>(); - @Getter - private final Map<UUID, AutomationCompositionElement> elementsOnThisParticipant = new LinkedHashMap<>(); - - @Getter - private final List<AutomationCompositionElementListener> listeners = new ArrayList<>(); - /** * Constructor, set the participant ID and messageSender. * @@ -85,6 +85,7 @@ public class AutomationCompositionHandler { this.participantId = parameters.getIntermediaryParameters().getParticipantId(); this.publisher = publisher; this.acInstanceStateResolver = new AcInstanceStateResolver(); + this.supportedAcElementTypes = parameters.getIntermediaryParameters().getParticipantSupportedElementTypes(); } public void registerAutomationCompositionElementListener(AutomationCompositionElementListener listener) { @@ -100,57 +101,63 @@ public class AutomationCompositionHandler { * @param lockState the LockState state */ public void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState deployState, - LockState lockState) { + LockState lockState, String message) { - if (id == null) { - LOGGER.warn("Cannot update Automation composition element state, id is null"); + if (automationCompositionId == null || id == null) { + LOGGER.error("Cannot update Automation composition element state, id is null"); return; } - // Update states of AutomationCompositionElement in automationCompositionMap - for (var automationComposition : automationCompositionMap.values()) { - var element = automationComposition.getElements().get(id); - if (element != null) { - element.setDeployState(deployState); - element.setLockState(lockState); - element.setUseState(getUseState(automationCompositionId, id)); - element.setOperationalState(getOperationalState(automationCompositionId, id)); - element.setStatusProperties(getStatusProperties(automationCompositionId, id)); - } + if ((deployState != null && lockState != null) || (deployState == null && lockState == null)) { + LOGGER.error("state error {} and {} cannot be handled", deployState, lockState); + return; + } + + var automationComposition = automationCompositionMap.get(automationCompositionId); + if (automationComposition == null) { + LOGGER.error("Cannot update Automation composition element state, Automation composition id {} not present", + automationComposition); + return; + } + + var element = automationComposition.getElements().get(id); + if (element == null) { + var msg = "Cannot update Automation composition element state, AC Element id {} not present"; + LOGGER.error(msg, automationComposition); + return; + } + + if (deployState != null) { + element.setDeployState(deployState); var checkOpt = automationComposition.getElements().values().stream() .filter(acElement -> !deployState.equals(acElement.getDeployState())).findAny(); if (checkOpt.isEmpty()) { automationComposition.setDeployState(deployState); } - checkOpt = automationComposition.getElements().values().stream() + element.setLockState( + DeployState.DEPLOYED.equals(element.getDeployState()) ? LockState.LOCKED : LockState.NONE); + } + if (lockState != null) { + element.setLockState(lockState); + var checkOpt = automationComposition.getElements().values().stream() .filter(acElement -> !lockState.equals(acElement.getLockState())).findAny(); if (checkOpt.isEmpty()) { automationComposition.setLockState(lockState); } } - // Update states of AutomationCompositionElement in elementsOnThisParticipant - var acElement = elementsOnThisParticipant.get(id); - if (acElement != null) { - var automationCompositionStateChangeAck = - new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); - automationCompositionStateChangeAck.setParticipantId(participantId); - automationCompositionStateChangeAck.setAutomationCompositionId(automationCompositionId); - acElement.setDeployState(deployState); - acElement.setLockState(lockState); - acElement.setUseState(getUseState(automationCompositionId, id)); - acElement.setOperationalState(getOperationalState(automationCompositionId, id)); - acElement.setStatusProperties(getStatusProperties(automationCompositionId, id)); - automationCompositionStateChangeAck.getAutomationCompositionResultMap().put(acElement.getId(), - new AcElementDeployAck(deployState, lockState, acElement.getOperationalState(), - acElement.getUseState(), acElement.getStatusProperties(), true, - "Automation composition element {} state changed to {}\", id, newState)")); - LOGGER.debug("Automation composition element {} state changed to {}", id, deployState); - automationCompositionStateChangeAck - .setMessage("AutomationCompositionElement state changed to {} " + deployState); - automationCompositionStateChangeAck.setResult(true); - publisher.sendAutomationCompositionAck(automationCompositionStateChangeAck); - } + var automationCompositionStateChangeAck = + new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); + automationCompositionStateChangeAck.setParticipantId(participantId); + automationCompositionStateChangeAck.setMessage(message); + automationCompositionStateChangeAck.setAutomationCompositionId(automationCompositionId); + automationCompositionStateChangeAck.getAutomationCompositionResultMap().put(element.getId(), + new AcElementDeployAck(element.getDeployState(), element.getLockState(), element.getOperationalState(), + element.getUseState(), element.getStatusProperties(), true, + "Automation composition element {} state changed to {}\", id, newState)")); + LOGGER.debug("Automation composition element {} state changed to {}", id, deployState); + automationCompositionStateChangeAck.setResult(true); + publisher.sendAutomationCompositionAck(automationCompositionStateChangeAck); } /** @@ -346,7 +353,6 @@ public class AutomationCompositionHandler { acElement.setDefinition(element.getDefinition()); acElement.setDeployState(DeployState.DEPLOYING); acElement.setLockState(LockState.NONE); - elementsOnThisParticipant.put(element.getId(), acElement); acElementList.add(acElement); } return acElementList; @@ -378,8 +384,6 @@ public class AutomationCompositionHandler { .filter(element -> !DeployState.UNDEPLOYED.equals(element.getDeployState())).findAny().isEmpty(); if (isAllUninitialised) { automationCompositionMap.remove(automationComposition.getInstanceId()); - automationComposition.getElements().values() - .forEach(element -> elementsOnThisParticipant.remove(element.getId())); } } @@ -420,8 +424,8 @@ public class AutomationCompositionHandler { for (var acElementListener : listeners) { try { acElementListener.lock(instanceId, acElement.getId()); - updateAutomationCompositionElementState(instanceId, acElement.getId(), DeployState.DEPLOYED, - LockState.LOCKED); + updateAutomationCompositionElementState(instanceId, acElement.getId(), null, LockState.LOCKED, + "Locked"); } catch (PfModelException e) { LOGGER.error("Automation composition element lock failed {}", instanceId); } @@ -439,8 +443,8 @@ public class AutomationCompositionHandler { for (var acElementListener : listeners) { try { acElementListener.unlock(instanceId, acElement.getId()); - updateAutomationCompositionElementState(instanceId, acElement.getId(), DeployState.DEPLOYED, - LockState.UNLOCKED); + updateAutomationCompositionElementState(instanceId, acElement.getId(), null, LockState.UNLOCKED, + "Unlocked"); } catch (PfModelException e) { LOGGER.error("Automation composition element unlock failed {}", instanceId); } @@ -455,77 +459,112 @@ public class AutomationCompositionHandler { if (acElementNodeTemplate != null) { int startPhase = ParticipantUtils.findStartPhase(acElementNodeTemplate.getProperties()); if (startPhaseMsg.equals(startPhase)) { - for (var acElementListener : listeners) { - try { - acElementListener.undeploy(instanceId, acElement.getId()); - } catch (PfModelException e) { - LOGGER.error("Automation composition element update failed {}", instanceId); - } - } + undeployInstanceElements(instanceId, acElement.getId()); } } } + /** - * Get UseState. - * - * @param instanceId the instance Id - * @param acElementId the Automation Composition Element Id - * @return the UseState of the Automation Composition Element + * Undeploy Instance Elements On Participant. */ - public String getUseState(UUID instanceId, UUID acElementId) { - var result = new StringBuilder(); + public void undeployInstances() { + automationCompositionMap.values().forEach(this::undeployInstance); + } + + private void undeployInstance(AutomationComposition automationComposition) { + automationComposition.getElements().values().forEach(element -> { + if (element.getParticipantId().equals(participantId)) { + undeployInstanceElements(automationComposition.getInstanceId(), element.getId()); + } + }); + } + + private void undeployInstanceElements(UUID instanceId, UUID elementId) { for (var acElementListener : listeners) { try { - var state = acElementListener.getUseState(instanceId, acElementId); - if (!StringUtils.isBlank(state)) { - result.append(state); - } + acElementListener.undeploy(instanceId, elementId); } catch (PfModelException e) { - LOGGER.error("Automation composition element get Use State failed {}", acElementId); + LOGGER.error("Automation composition element update failed {}", instanceId); } } - return result.toString(); } /** - * Get OperationalState. + * Send Ac Element Info. * - * @param instanceId the instance Id - * @param acElementId the Automation Composition Element Id - * @return the OperationalState of the Automation Composition Element + * @param automationCompositionId the automationComposition Id + * @param elementId the automationComposition Element id + * @param useState the use State + * @param operationalState the operational State + * @param statusProperties the status Properties Map */ - public String getOperationalState(UUID instanceId, UUID acElementId) { - var result = new StringBuilder(); - for (var acElementListener : listeners) { - try { - var state = acElementListener.getOperationalState(instanceId, acElementId); - if (!StringUtils.isBlank(state)) { - result.append(state); - } - } catch (PfModelException e) { - LOGGER.error("Automation composition element get Use State failed {}", acElementId); - } + public void sendAcElementInfo(UUID automationCompositionId, UUID elementId, String useState, + String operationalState, Map<String, Object> statusProperties) { + + if (automationCompositionId == null || elementId == null) { + LOGGER.error("Cannot update Automation composition element state, id is null"); + return; } - return result.toString(); + + var automationComposition = automationCompositionMap.get(automationCompositionId); + if (automationComposition == null) { + LOGGER.error("Cannot update Automation composition element state, Automation composition id {} not present", + automationComposition); + return; + } + + var element = automationComposition.getElements().get(elementId); + if (element == null) { + var msg = "Cannot update Automation composition element state, AC Element id {} not present"; + LOGGER.error(msg, automationComposition); + return; + } + element.setOperationalState(operationalState); + element.setUseState(useState); + element.setStatusProperties(statusProperties); + + var statusMsg = new ParticipantStatus(); + statusMsg.setParticipantId(participantId); + statusMsg.setState(ParticipantState.ON_LINE); + statusMsg.setParticipantSupportedElementType(new ArrayList<>(supportedAcElementTypes)); + var acInfo = new AutomationCompositionInfo(); + acInfo.setAutomationCompositionId(automationCompositionId); + acInfo.setDeployState(automationComposition.getDeployState()); + acInfo.setLockState(automationComposition.getLockState()); + acInfo.setElements(List.of(getAutomationCompositionElementInfo(element))); + statusMsg.setAutomationCompositionInfoList(List.of(acInfo)); + publisher.sendParticipantStatus(statusMsg); } /** - * Get StatusProperties. + * get AutomationComposition Info List. * - * @param instanceId the instance Id - * @param acElementId the Automation Composition Element Id - * @return the Status Properties Map + * @return list of AutomationCompositionInfo */ - public Map<String, Object> getStatusProperties(UUID instanceId, UUID acElementId) { - Map<String, Object> result = new HashMap<>(); - for (var acElementListener : listeners) { - try { - result.putAll(acElementListener.getStatusProperties(instanceId, acElementId)); - } catch (PfModelException e) { - LOGGER.error("Automation composition element get Status Properties failed {}", acElementId); + public List<AutomationCompositionInfo> getAutomationCompositionInfoList() { + List<AutomationCompositionInfo> automationCompositionInfoList = new ArrayList<>(); + for (var entry : automationCompositionMap.entrySet()) { + var acInfo = new AutomationCompositionInfo(); + acInfo.setAutomationCompositionId(entry.getKey()); + acInfo.setDeployState(entry.getValue().getDeployState()); + acInfo.setLockState(entry.getValue().getLockState()); + for (var element : entry.getValue().getElements().values()) { + acInfo.getElements().add(getAutomationCompositionElementInfo(element)); } + automationCompositionInfoList.add(acInfo); } - return result; + return automationCompositionInfoList; + } + + private AutomationCompositionElementInfo getAutomationCompositionElementInfo(AutomationCompositionElement element) { + var elementInfo = new AutomationCompositionElementInfo(); + elementInfo.setAutomationCompositionElementId(element.getId()); + elementInfo.setDeployState(element.getDeployState()); + elementInfo.setLockState(element.getLockState()); + elementInfo.setOperationalState(element.getOperationalState()); + elementInfo.setUseState(element.getUseState()); + elementInfo.setStatusProperties(element.getStatusProperties()); + return elementInfo; } } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java index 9e2484c7d..44a988a27 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java @@ -31,10 +31,7 @@ import java.util.UUID; import lombok.Getter; import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher; import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; -import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementInfo; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo; import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; import org.onap.policy.clamp.models.acm.concepts.ParticipantState; import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType; @@ -50,7 +47,6 @@ import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRe import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatusReq; -import org.onap.policy.models.base.PfModelException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -77,6 +73,7 @@ public class ParticipantHandler { * * @param parameters the parameters of the participant * @param publisher the publisher for sending responses to messages + * @param automationCompositionHandler the publisher for sending responses to messages */ public ParticipantHandler(ParticipantParameters parameters, ParticipantMessagePublisher publisher, AutomationCompositionHandler automationCompositionHandler) { @@ -173,32 +170,7 @@ public class ParticipantHandler { var participantDeregister = new ParticipantDeregister(); participantDeregister.setParticipantId(participantId); publisher.sendParticipantDeregister(participantDeregister); - undeployInstancesOnParticipant(); - } - - private void undeployInstancesOnParticipant() { - automationCompositionHandler.getAutomationCompositionMap().values().forEach(ac -> - undeployInstanceOnParticipant(ac) - ); - } - - private void undeployInstanceOnParticipant(AutomationComposition automationComposition) { - automationComposition.getElements().values().forEach(element -> { - if (element.getParticipantId().equals(participantId)) { - undeployInstanceElementsOnParticipant(automationComposition.getInstanceId(), element.getId()); - } - }); - } - - private void undeployInstanceElementsOnParticipant(UUID instanceId, UUID elementId) { - var acElementListeners = automationCompositionHandler.getListeners(); - for (var acElementListener : acElementListeners) { - try { - acElementListener.undeploy(instanceId, elementId); - } catch (PfModelException e) { - LOGGER.debug("Automation composition element update failed {}", instanceId); - } - } + automationCompositionHandler.undeployInstances(); } /** @@ -242,7 +214,7 @@ public class ParticipantHandler { /** * Method to send ParticipantPrimeAck message to automation composition runtime. */ - public void sendParticipantPrimeAck(UUID messageId, UUID compositionId) { + private void sendParticipantPrimeAck(UUID messageId, UUID compositionId) { var participantPrimeAck = new ParticipantPrimeAck(); participantPrimeAck.setResponseTo(messageId); participantPrimeAck.setCompositionId(compositionId); @@ -267,7 +239,7 @@ public class ParticipantHandler { var heartbeat = new ParticipantStatus(); heartbeat.setParticipantId(participantId); heartbeat.setState(ParticipantState.ON_LINE); - heartbeat.setAutomationCompositionInfoList(getAutomationCompositionInfoList()); + heartbeat.setAutomationCompositionInfoList(automationCompositionHandler.getAutomationCompositionInfoList()); heartbeat.setParticipantSupportedElementType(new ArrayList<>(this.supportedAcElementTypes)); if (responseToParticipantStatusReq) { @@ -283,26 +255,4 @@ public class ParticipantHandler { return heartbeat; } - - private List<AutomationCompositionInfo> getAutomationCompositionInfoList() { - List<AutomationCompositionInfo> automationCompositionInfoList = new ArrayList<>(); - for (var entry : automationCompositionHandler.getAutomationCompositionMap().entrySet()) { - var acInfo = new AutomationCompositionInfo(); - acInfo.setAutomationCompositionId(entry.getKey()); - acInfo.setDeployState(entry.getValue().getDeployState()); - acInfo.setLockState(entry.getValue().getLockState()); - for (var element : entry.getValue().getElements().values()) { - var elementInfo = new AutomationCompositionElementInfo(); - elementInfo.setAutomationCompositionElementId(element.getId()); - elementInfo.setDeployState(element.getDeployState()); - elementInfo.setLockState(element.getLockState()); - elementInfo.setOperationalState( - automationCompositionHandler.getOperationalState(entry.getKey(), element.getId())); - elementInfo.setUseState(automationCompositionHandler.getUseState(entry.getKey(), element.getId())); - acInfo.getElements().add(elementInfo); - } - automationCompositionInfoList.add(acInfo); - } - return automationCompositionInfoList; - } } |