From 46964ab900060a560b9b41f7d34ab0e26ac7fd61 Mon Sep 17 00:00:00 2001 From: "saul.gill" Date: Fri, 13 Jan 2023 17:24:23 +0000 Subject: Add supported ac elements to participants Added new supported elements table Added supported element names and versions to participant application.yaml files Issue-ID: POLICY-4512 Change-Id: I97d7f571f2906846514ac0804b4827f0601177d7 Signed-off-by: saul.gill --- .../supervision/SupervisionParticipantHandler.java | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'runtime-acm/src/main/java') diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java index 2c9e84ba7..6f0f5cc7b 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java @@ -21,11 +21,17 @@ package org.onap.policy.clamp.acm.runtime.supervision; import io.micrometer.core.annotation.Timed; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import lombok.AllArgsConstructor; +import org.apache.commons.collections4.MapUtils; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher; import org.onap.policy.clamp.models.acm.concepts.Participant; 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.messages.dmaap.participant.ParticipantDeregister; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; @@ -98,11 +104,14 @@ public class SupervisionParticipantHandler { var participantOpt = participantProvider.findParticipant(participantMessage.getParticipantId()); if (participantOpt.isEmpty()) { + ParticipantRegister registerMessage = (ParticipantRegister) participantMessage; var participant = new Participant(); - participant.setName(participantMessage.getParticipantId().getName()); - participant.setVersion(participantMessage.getParticipantId().getVersion()); - participant.setDefinition(participantMessage.getParticipantId()); - participant.setParticipantType(participantMessage.getParticipantType()); + participant.setName(registerMessage.getParticipantId().getName()); + participant.setVersion(registerMessage.getParticipantId().getVersion()); + participant.setDefinition(registerMessage.getParticipantId()); + participant.setParticipantType(registerMessage.getParticipantType()); + participant.setParticipantSupportedElementTypes(listToMap(registerMessage + .getParticipantSupportedElementType())); participant.setParticipantState(ParticipantState.ON_LINE); participantProvider.saveParticipant(participant); @@ -113,4 +122,10 @@ public class SupervisionParticipantHandler { participantProvider.updateParticipant(participant); } } + + private Map listToMap(List elementList) { + Map map = new HashMap<>(); + MapUtils.populateMap(map, elementList, ParticipantSupportedElementType::getId); + return map; + } } -- cgit 1.2.3-korg