aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary/src/main
diff options
context:
space:
mode:
authorSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-09-20 16:08:25 +0100
committerSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-09-22 14:07:56 +0100
commit9b982666d6ddb6c964a1e539fea97231b5053f5b (patch)
treed3e5d8959002f73c420946e7553bb4fb0aae02b7 /participant/participant-intermediary/src/main
parentb428105b44d0504b05a0b93894bef97e5ab7e8b4 (diff)
Add participantType to participant class
Add participantType to participant class, cascade common and instance properties from runtime to participants Issue-ID: POLICY-3576 Signed-off-by: Sirisha_Manchikanti <sirisha.manchikanti@est.tech> Change-Id: Ic9205aafe269ccc6dae0b3463fc6df5c47129e5d
Diffstat (limited to 'participant/participant-intermediary/src/main')
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java9
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java6
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java22
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java23
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;
}