Add participantType to participant class 24/124424/1
authorSirisha_Manchikanti <sirisha.manchikanti@est.tech>
Mon, 20 Sep 2021 15:08:25 +0000 (16:08 +0100)
committerSirisha_Manchikanti <sirisha.manchikanti@est.tech>
Wed, 22 Sep 2021 13:07:56 +0000 (14:07 +0100)
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

18 files changed:
models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java
models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java
models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java
models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java
models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java
models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java
models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java
models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java
models/src/test/resources/providers/TestParticipant.json
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScannerTest.java

index 67bcb53..c7d85e4 100644 (file)
@@ -31,6 +31,7 @@ import lombok.ToString;
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfUtils;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 
 /**
@@ -66,7 +67,7 @@ public class ControlLoopElement {
 
     // A map indexed by the property name. Each map entry is the serialized value of the property,
     // which can be deserialized into an instance of the type of the property.
-    private Map<String, String> commonPropertiesMap = new LinkedHashMap<>();
+    private Map<String, ToscaProperty> propertiesMap = new LinkedHashMap<>();
 
     /**
      * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
@@ -83,6 +84,6 @@ public class ControlLoopElement {
         this.toscaServiceTemplateFragment = otherElement.toscaServiceTemplateFragment;
         this.description = otherElement.description;
         this.clElementStatistics = otherElement.clElementStatistics;
-        this.commonPropertiesMap = PfUtils.mapMap(otherElement.commonPropertiesMap, UnaryOperator.identity());
+        this.propertiesMap = PfUtils.mapMap(otherElement.propertiesMap, UnaryOperator.identity());
     }
 }
index b9f4d69..ae50b40 100644 (file)
@@ -30,6 +30,7 @@ import lombok.ToString;
 import org.onap.policy.models.base.PfUtils;
 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;
 
 /**
  * Class to represent a control loop element definition instance.
@@ -47,7 +48,7 @@ public class ControlLoopElementDefinition {
 
     // A map indexed by the property name. Each map entry is the serialized value of the property,
     // which can be deserialized into an instance of the type of the property.
-    private Map<String, String> commonPropertiesMap = new LinkedHashMap<>();
+    private Map<String, ToscaProperty> commonPropertiesMap = new LinkedHashMap<>();
 
     /**
      * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
index 3130b6c..198cf1a 100644 (file)
@@ -44,6 +44,9 @@ public class Participant extends ToscaEntity implements Comparable<Participant>
     @NonNull
     private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN;
 
+    @NonNull
+    private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier();
+
     @Override
     public String getType() {
         return definition.getName();
@@ -69,5 +72,6 @@ public class Participant extends ToscaEntity implements Comparable<Participant>
         this.definition = new ToscaConceptIdentifier(otherParticipant.definition);
         this.participantState = otherParticipant.participantState;
         this.healthStatus = otherParticipant.healthStatus;
+        this.participantType = otherParticipant.participantType;
     }
 }
index 4d49683..c8c26a8 100644 (file)
@@ -70,6 +70,11 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
     private PfConceptKey definition;
     // @formatter:on
 
+    @NotNull
+    @AttributeOverride(name = "name",    column = @Column(name = "participant_type_name"))
+    @AttributeOverride(name = "version", column = @Column(name = "participant_type_version"))
+    private PfConceptKey participantType;
+
     @Column
     @NotNull
     private ParticipantState participantState;
@@ -125,6 +130,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
         this.participantState = copyConcept.participantState;
         this.healthStatus = copyConcept.healthStatus;
         this.description = copyConcept.description;
+        this.participantType = copyConcept.participantType;
     }
 
     /**
@@ -146,6 +152,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
         participant.setParticipantState(participantState);
         participant.setHealthStatus(healthStatus);
         participant.setDescription(description);
+        participant.setParticipantType(new ToscaConceptIdentifier(participantType));
 
         return participant;
     }
@@ -160,6 +167,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
         this.setParticipantState(participant.getParticipantState());
         this.setHealthStatus(participant.getHealthStatus());
         this.setDescription(participant.getDescription());
+        this.participantType = participant.getParticipantType().asConceptKey();
     }
 
     @Override
@@ -167,6 +175,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
         List<PfKey> keyList = getKey().getKeys();
 
         keyList.add(definition);
+        keyList.add(participantType);
 
         return keyList;
     }
@@ -176,6 +185,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
         key.clean();
         definition.clean();
         description = (description == null ? null : description.trim());
+        participantType.clean();
     }
 
     @Override
@@ -211,6 +221,11 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
             return result;
         }
 
+        result = ObjectUtils.compare(participantType, other.participantType);
+        if (result != 0) {
+            return result;
+        }
+
         return ObjectUtils.compare(description, other.description);
     }
 }
index e2eb515..0872923 100644 (file)
@@ -247,6 +247,7 @@ class JpaParticipantTest {
         testParticipant.setName("participant");
         testParticipant.setVersion("0.0.1");
         testParticipant.setDefinition(new ToscaConceptIdentifier("participantDefinitionName", "0.0.1"));
+        testParticipant.setParticipantType(new ToscaConceptIdentifier("participantTypeName", "0.0.1"));
 
         return testParticipant;
     }
index 1b155a1..ce56d58 100644 (file)
@@ -36,6 +36,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
 
 /**
  * Test the copy constructor.
@@ -62,8 +63,11 @@ class ControlLoopUpdateTest {
         clElement.setParticipantId(id);
         clElement.setParticipantType(id);
 
-        Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue");
-        clElement.setCommonPropertiesMap(commonPropertiesMap);
+        ToscaProperty property = new ToscaProperty();
+        property.setName("test");
+        property.setType("testType");
+        Map<String, ToscaProperty> propertiesMap = Map.of("Prop1", property);
+        clElement.setPropertiesMap(propertiesMap);
 
         ParticipantUpdates participantUpdates = new ParticipantUpdates();
         participantUpdates.setParticipantId(id);
index f34777a..b2bce05 100644 (file)
@@ -42,6 +42,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant
 import org.onap.policy.common.utils.coder.CoderException;
 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;
 
 class ParticipantStatusTest {
 
@@ -117,7 +118,11 @@ class ParticipantStatusTest {
         ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
         clDefinition.setClElementDefinitionId(id);
         clDefinition.setControlLoopElementToscaNodeTemplate(toscaNodeTemplate);
-        Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue");
+
+        ToscaProperty property = new ToscaProperty();
+        property.setName("test");
+        property.setType("testType");
+        Map<String, ToscaProperty> commonPropertiesMap = Map.of("Prop1", property);
         clDefinition.setCommonPropertiesMap(commonPropertiesMap);
         return clDefinition;
     }
index 6fe8604..d7023d0 100644 (file)
@@ -35,6 +35,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant
 import org.onap.policy.common.utils.coder.CoderException;
 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.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 
 /**
@@ -89,7 +90,11 @@ class ParticipantUpdateTest {
         ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
         clDefinition.setClElementDefinitionId(id);
         clDefinition.setControlLoopElementToscaNodeTemplate(toscaNodeTemplate);
-        Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue");
+
+        ToscaProperty property = new ToscaProperty();
+        property.setName("test");
+        property.setType("testType");
+        Map<String, ToscaProperty> commonPropertiesMap = Map.of("Prop1", property);
         clDefinition.setCommonPropertiesMap(commonPropertiesMap);
         return clDefinition;
     }
index c6965ce..4722ead 100644 (file)
@@ -7,5 +7,9 @@
   },
   "participantState": "PASSIVE",
   "healthStatus": "HEALTHY",
-  "description": "A dummy PMSH participant1"
+  "description": "A dummy PMSH participant1",
+  "participantType":{
+    "name": "org.onap.domain.pmsh.PolicyControlLoopDefinition",
+    "version": "1.0.0"
+  }
 }
index 891d67e..0cb4963 100644 (file)
@@ -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.
@@ -56,6 +57,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.
      *
index aa1feba..43ac346 100644 (file)
@@ -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;
 
 /**
@@ -76,6 +77,11 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
         return List.of(participantHandler.getParticipant(name, version));
     }
 
+    @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);
index 30a06ba..5cb79a3 100644 (file)
@@ -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;
+    }
 }
index 69f8feb..ea7d845 100644 (file)
@@ -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;
@@ -205,6 +207,22 @@ public class ParticipantHandler {
         return null;
     }
 
+    /**
+     * 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.
      *
@@ -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;
                 }
index 0b7bc9a..472348a 100644 (file)
@@ -40,6 +40,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider
 import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
 import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse;
 import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher;
 import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.provider.PolicyModelsProvider;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType;
@@ -108,23 +109,13 @@ public class CommissioningProvider {
         synchronized (lockit) {
             modelsProvider.createServiceTemplate(serviceTemplate);
             List<Participant> participantList =
-                participantProvider.getParticipants(null,
-                    null);
-
-            if (participantList != null) {
-                for (Participant participant: participantList) {
-                    var participantType = new ToscaConceptIdentifier();
-                    participantType.setName(participant.getType());
-                    participantType.setVersion(participant.getTypeVersion());
-
-                    var participantUpdate = new ParticipantUpdate();
-                    participantUpdate.setParticipantId(participant.getDefinition());
-                    participantUpdate.setParticipantType(participantType);
-
-                    this.supervisionHandler.handleSendCommissionMessage(participantUpdate);
-                }
+                participantProvider.getParticipants(null, null);
+            if (!participantList.isEmpty()) {
+                this.supervisionHandler.handleSendCommissionMessage(
+                    getCommonOrInstancePropertiesFromNodeTypes(true,
+                        serviceTemplate.getName(),
+                        serviceTemplate.getVersion()));
             }
-
         }
 
         var response = new CommissioningResponse();
@@ -159,21 +150,9 @@ public class CommissioningProvider {
             List<Participant> participantList =
                 participantProvider.getParticipants(null,
                     null);
-
-            if (participantList != null) {
-                for (Participant participant : participantList) {
-                    var participantType = new ToscaConceptIdentifier();
-                    participantType.setName(participant.getType());
-                    participantType.setVersion(participant.getTypeVersion());
-
-                    var participantUpdate = new ParticipantUpdate();
-                    participantUpdate.setParticipantId(participant.getDefinition());
-                    participantUpdate.setParticipantType(participantType);
-
-                    this.supervisionHandler.handleSendDeCommissionMessage(participantUpdate);
-                }
+            if (!participantList.isEmpty()) {
+                this.supervisionHandler.handleSendDeCommissionMessage();
             }
-
             modelsProvider.deleteServiceTemplate(name, version);
         }
 
@@ -342,7 +321,7 @@ public class CommissioningProvider {
      * @return the node types with common or instance properties
      * @throws PfModelException on errors getting node type properties
      */
-    private Map<String, ToscaNodeType> getCommonOrInstancePropertiesFromNodeTypes(boolean common, String name,
+    public Map<String, ToscaNodeType> getCommonOrInstancePropertiesFromNodeTypes(boolean common, String name,
             String version) throws PfModelException {
         var serviceTemplates = new ToscaServiceTemplates();
         serviceTemplates.setServiceTemplates(modelsProvider.getServiceTemplateList(name, version));
index c4ca568..1747bbd 100644 (file)
@@ -52,6 +52,7 @@ import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantReg
 import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher;
 import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
@@ -149,8 +150,7 @@ public class SupervisionHandler {
         participantRegisterAckPublisher.send(participantRegisterMessage.getMessageId(),
                 participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType());
 
-        participantUpdatePublisher.send(participantRegisterMessage.getParticipantId(),
-                participantRegisterMessage.getParticipantType(), true);
+        participantUpdatePublisher.send(null, true);
     }
 
     /**
@@ -209,25 +209,19 @@ public class SupervisionHandler {
     /**
      * Send commissioning update message to dmaap.
      *
-     * @param participantUpdateMessage the ParticipantUpdate message to send
      */
-    public void handleSendCommissionMessage(ParticipantUpdate participantUpdateMessage) {
-        LOGGER.debug("Participant update message being sent {}", participantUpdateMessage);
-
-        participantUpdatePublisher.send(participantUpdateMessage.getParticipantId(),
-            participantUpdateMessage.getParticipantType(), true);
+    public void handleSendCommissionMessage(Map<String, ToscaNodeType> commonPropertiesMap) {
+        LOGGER.debug("Participant update message being sent {}");
+        participantUpdatePublisher.send(commonPropertiesMap, true);
     }
 
     /**
      * Send decommissioning update message to dmaap.
      *
-     * @param participantUpdateMessage the ParticipantUpdate message to send
      */
-    public void handleSendDeCommissionMessage(ParticipantUpdate participantUpdateMessage) {
-        LOGGER.debug("Participant update message being sent {}", participantUpdateMessage);
-
-        participantUpdatePublisher.send(participantUpdateMessage.getParticipantId(),
-            participantUpdateMessage.getParticipantType(), false);
+    public void handleSendDeCommissionMessage() {
+        LOGGER.debug("Participant update message being sent");
+        participantUpdatePublisher.send(null, false);
     }
 
     /**
@@ -429,6 +423,7 @@ public class SupervisionHandler {
             participant.setName(participantStatusMessage.getParticipantId().getName());
             participant.setVersion(participantStatusMessage.getParticipantId().getVersion());
             participant.setDefinition(participantStatusMessage.getParticipantId());
+            participant.setParticipantType(participantStatusMessage.getParticipantType());
             participant.setParticipantState(participantStatusMessage.getState());
             participant.setHealthStatus(participantStatusMessage.getHealthStatus());
 
index d13d66c..fde94bc 100644 (file)
@@ -144,7 +144,7 @@ public class SupervisionScanner {
 
                 if (participantUpdateCounter.count(id)) {
                     LOGGER.debug("retry message ParticipantUpdate");
-                    participantUpdatePublisher.send(id.getLeft(), id.getRight(), true);
+                    participantUpdatePublisher.send(null, true);
                 } else {
                     LOGGER.debug("report Participant Update fault");
                     participantUpdateCounter.setFault(id);
index fe46297..0f6cc7c 100644 (file)
@@ -25,6 +25,7 @@ package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import lombok.AllArgsConstructor;
 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
@@ -34,6 +35,7 @@ import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.provider.PolicyModelsProvider;
 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.ToscaNodeType;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,14 +55,9 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
     /**
      * Send ParticipantUpdate to Participant.
      *
-     * @param participantId the participant Id
-     * @param participantType the participant Type
      */
-    public void send(ToscaConceptIdentifier participantId, ToscaConceptIdentifier participantType,
-            boolean commissionFlag) {
+    public void send(Map<String, ToscaNodeType> commonPropertiesMap, boolean commissionFlag) {
         var message = new ParticipantUpdate();
-        message.setParticipantId(participantId);
-        message.setParticipantType(participantType);
         message.setTimestamp(Instant.now());
 
         ToscaServiceTemplate toscaServiceTemplate = null;
@@ -82,7 +79,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
                     var clParticipantType =
                             ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties());
                     prepareParticipantDefinitionUpdate(clParticipantType, toscaInputEntry.getKey(),
-                            toscaInputEntry.getValue(), participantDefinitionUpdates);
+                            toscaInputEntry.getValue(), participantDefinitionUpdates, commonPropertiesMap);
                 }
             }
         }
@@ -99,11 +96,17 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
     }
 
     private void prepareParticipantDefinitionUpdate(ToscaConceptIdentifier clParticipantType, String entryKey,
-            ToscaNodeTemplate entryValue, List<ParticipantDefinition> participantDefinitionUpdates) {
+            ToscaNodeTemplate entryValue, List<ParticipantDefinition> participantDefinitionUpdates,
+            Map<String, ToscaNodeType> commonPropertiesMap) {
 
         var clDefinition = new ControlLoopElementDefinition();
         clDefinition.setClElementDefinitionId(new ToscaConceptIdentifier(entryKey, entryValue.getVersion()));
         clDefinition.setControlLoopElementToscaNodeTemplate(entryValue);
+        ToscaNodeType nodeType = commonPropertiesMap.get(entryValue.getType());
+        if (nodeType != null) {
+            clDefinition.setCommonPropertiesMap(nodeType.getProperties());
+        }
+
         List<ControlLoopElementDefinition> controlLoopElementDefinitionList = new ArrayList<>();
 
         if (participantDefinitionUpdates.isEmpty()) {
index 2ba321d..9b64f90 100644 (file)
@@ -139,6 +139,7 @@ class SupervisionScannerTest {
         participant.setHealthStatus(ParticipantHealthStatus.HEALTHY);
         participant.setParticipantState(ParticipantState.ACTIVE);
         participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0"));
+        participant.setParticipantType(new ToscaConceptIdentifier("ParticipantType1", "1.0.0"));
         var participantProvider = new ParticipantProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
         participantProvider.updateParticipants(List.of(participant));