diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-04-27 15:22:50 +0100 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-05-03 16:48:44 +0100 |
commit | 5c921c62ef5fd97ae86efe28e932619546966907 (patch) | |
tree | a8fa5a2ad5c52f41e12e43750aee7ff026e245bf /participant/participant-intermediary/src/main/java/org | |
parent | b619e00e3dbb4c7e2d5a484be8cae4db29afe149 (diff) |
Add participant properties capability to acm/participants
Add statusProperties support in acm acm/participants.
Issue-ID: POLICY-4652
Change-Id: I6dd37c9be58fce36def022364abe46c791e98a77
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src/main/java/org')
2 files changed, 43 insertions, 6 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 c99241f27..a61a6678a 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 @@ -69,4 +69,10 @@ public interface AutomationCompositionElementListener { // 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/handler/AutomationCompositionHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java index 1eaf63dcc..f918ed12c 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,6 +21,7 @@ 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; @@ -96,6 +97,7 @@ public class AutomationCompositionHandler { * @param automationCompositionId the automationComposition Id * @param id the automationComposition UUID * @param deployState the DeployState state + * @param lockState the LockState state */ public void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState deployState, LockState lockState) { @@ -113,6 +115,7 @@ public class AutomationCompositionHandler { element.setLockState(lockState); element.setUseState(getUseState(automationCompositionId, id)); element.setOperationalState(getOperationalState(automationCompositionId, id)); + element.setStatusProperties(getStatusProperties(automationCompositionId, id)); } var checkOpt = automationComposition.getElements().values().stream() .filter(acElement -> !deployState.equals(acElement.getDeployState())).findAny(); @@ -137,9 +140,10 @@ public class AutomationCompositionHandler { 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(), true, + 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 @@ -470,14 +474,18 @@ public class AutomationCompositionHandler { * @return the UseState of the Automation Composition Element */ public String getUseState(UUID instanceId, UUID acElementId) { + var result = new StringBuilder(); for (var acElementListener : listeners) { try { - return acElementListener.getUseState(instanceId, acElementId); + var state = acElementListener.getUseState(instanceId, acElementId); + if (!StringUtils.isBlank(state)) { + result.append(state); + } } catch (PfModelException e) { LOGGER.error("Automation composition element get Use State failed {}", acElementId); } } - return null; + return result.toString(); } /** @@ -488,13 +496,36 @@ public class AutomationCompositionHandler { * @return the OperationalState of the Automation Composition Element */ public String getOperationalState(UUID instanceId, UUID acElementId) { + var result = new StringBuilder(); for (var acElementListener : listeners) { try { - return acElementListener.getOperationalState(instanceId, acElementId); + 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); } } - return null; + return result.toString(); + } + + /** + * Get StatusProperties. + * + * @param instanceId the instance Id + * @param acElementId the Automation Composition Element Id + * @return the Status Properties Map + */ + 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); + } + } + return result; } } |