diff options
Diffstat (limited to 'participant/participant-intermediary/src/main')
4 files changed, 54 insertions, 6 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java index 891d67e2d..0cb4963ec 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java @@ -34,6 +34,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; /** * This interface is used by participant implementations to use the participant intermediary. @@ -57,6 +58,14 @@ public interface ParticipantIntermediaryApi { List<Participant> getParticipants(String name, String version); /** + * Get common properties of a controlloopelement. + * + * @param clElementDef the control loop element definition + * @return the common properties + */ + Map<String, ToscaProperty> getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef); + + /** * Update the state of a participant. * * @param definition the definition of the participant to update the state on diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java index aa1febadd..43ac3464c 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java @@ -40,6 +40,7 @@ import org.onap.policy.clamp.controlloop.participant.intermediary.api.Participan import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ControlLoopHandler; import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; import org.springframework.stereotype.Component; /** @@ -77,6 +78,11 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp } @Override + public Map<String, ToscaProperty> getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef) { + return participantHandler.getClElementDefinitionCommonProperties(clElementDef); + } + + @Override public Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state) { return participantHandler.updateParticipantState(definition, state); } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java index 30a06ba22..5cb79a37f 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java @@ -22,6 +22,7 @@ package org.onap.policy.clamp.controlloop.participant.intermediary.handler; import java.util.ArrayList; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -47,6 +48,7 @@ import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.Par import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -265,7 +267,8 @@ public class ControlLoopHandler { private ToscaNodeTemplate getClElementNodeTemplate(List<ControlLoopElementDefinition> clElementDefinitions, ToscaConceptIdentifier clElementDefId) { for (var clElementDefinition : clElementDefinitions) { - if (clElementDefinition.getClElementDefinitionId().equals(clElementDefId)) { + if (clElementDefId.getName().contains( + clElementDefinition.getClElementDefinitionId().getName())) { return clElementDefinition.getControlLoopElementToscaNodeTemplate(); } } @@ -364,4 +367,21 @@ public class ControlLoopHandler { controlLoops.setControlLoopList(new ArrayList<>(controlLoopMap.values())); return controlLoops; } + + /** + * Get properties of a controlloopelement. + * + * @param id the control loop element id + * @return the instance properties + */ + public Map<String, ToscaProperty> getClElementInstanceProperties(UUID id) { + Map<String, ToscaProperty> propertiesMap = new HashMap<>(); + for (var controlLoop : controlLoopMap.values()) { + var element = controlLoop.getElements().get(id); + if (element != null) { + propertiesMap.putAll(element.getPropertiesMap()); + } + } + return propertiesMap; + } } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java index 69f8febb8..ea7d84501 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java @@ -24,6 +24,7 @@ package org.onap.policy.clamp.controlloop.participant.intermediary.handler; import java.time.Instant; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -60,6 +61,7 @@ import org.onap.policy.clamp.controlloop.participant.intermediary.comm.Participa import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -206,6 +208,22 @@ public class ParticipantHandler { } /** + * Get common properties of a controlloopelement. + * + * @param clElementDef the control loop element definition + * @return the common properties + */ + public Map<String, ToscaProperty> getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef) { + Map<String, ToscaProperty> commonPropertiesMap = new HashMap<>(); + clElementDefsOnThisParticipant.stream().forEach(definition -> { + if (definition.getClElementDefinitionId().equals(clElementDef)) { + commonPropertiesMap.putAll(definition.getCommonPropertiesMap()); + } + }); + return commonPropertiesMap; + } + + /** * Check if a participant message applies to this participant handler. * * @param participantMsg the message to check @@ -284,15 +302,10 @@ public class ParticipantHandler { LOGGER.debug("ParticipantUpdate message received for participantId {}", participantUpdateMsg.getParticipantId()); - if (!participantUpdateMsg.appliesTo(participantType, participantId)) { - return; - } - if (!participantUpdateMsg.getParticipantDefinitionUpdates().isEmpty()) { // This message is to commission the controlloop for (ParticipantDefinition participantDefinition : participantUpdateMsg.getParticipantDefinitionUpdates()) { if (participantDefinition.getParticipantType().equals(participantType)) { - clElementDefsOnThisParticipant.clear(); clElementDefsOnThisParticipant.addAll(participantDefinition.getControlLoopElementDefinitionList()); break; } |