From 9b982666d6ddb6c964a1e539fea97231b5053f5b Mon Sep 17 00:00:00 2001 From: Sirisha_Manchikanti Date: Mon, 20 Sep 2021 16:08:25 +0100 Subject: 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 Change-Id: Ic9205aafe269ccc6dae0b3463fc6df5c47129e5d --- .../models/controlloop/concepts/ControlLoopElement.java | 5 +++-- .../concepts/ControlLoopElementDefinition.java | 3 ++- .../models/controlloop/concepts/Participant.java | 4 ++++ .../controlloop/persistence/concepts/JpaParticipant.java | 15 +++++++++++++++ .../persistence/concepts/JpaParticipantTest.java | 1 + .../messages/dmaap/participant/ControlLoopUpdateTest.java | 8 ++++++-- .../messages/dmaap/participant/ParticipantStatusTest.java | 7 ++++++- .../messages/dmaap/participant/ParticipantUpdateTest.java | 7 ++++++- models/src/test/resources/providers/TestParticipant.json | 6 +++++- 9 files changed, 48 insertions(+), 8 deletions(-) (limited to 'models') diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java index 67bcb5348..c7d85e4b6 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java @@ -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 commonPropertiesMap = new LinkedHashMap<>(); + private Map 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()); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java index b9f4d6904..ae50b40ce 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java @@ -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 commonPropertiesMap = new LinkedHashMap<>(); + private Map commonPropertiesMap = new LinkedHashMap<>(); /** * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java index 3130b6c2f..198cf1a16 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java @@ -44,6 +44,9 @@ public class Participant extends ToscaEntity implements Comparable @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 this.definition = new ToscaConceptIdentifier(otherParticipant.definition); this.participantState = otherParticipant.participantState; this.healthStatus = otherParticipant.healthStatus; + this.participantType = otherParticipant.participantType; } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java index 4d49683bf..c8c26a8de 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java @@ -70,6 +70,11 @@ public class JpaParticipant extends PfConcept implements PfAuthorative keyList = getKey().getKeys(); keyList.add(definition); + keyList.add(participantType); return keyList; } @@ -176,6 +185,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative commonPropertiesMap = Map.of("Prop1", "PropValue"); - clElement.setCommonPropertiesMap(commonPropertiesMap); + ToscaProperty property = new ToscaProperty(); + property.setName("test"); + property.setType("testType"); + Map propertiesMap = Map.of("Prop1", property); + clElement.setPropertiesMap(propertiesMap); ParticipantUpdates participantUpdates = new ParticipantUpdates(); participantUpdates.setParticipantId(id); diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java index f34777a70..b2bce05cc 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java @@ -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 commonPropertiesMap = Map.of("Prop1", "PropValue"); + + ToscaProperty property = new ToscaProperty(); + property.setName("test"); + property.setType("testType"); + Map commonPropertiesMap = Map.of("Prop1", property); clDefinition.setCommonPropertiesMap(commonPropertiesMap); return clDefinition; } diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java index 6fe8604cf..d7023d0c1 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java @@ -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 commonPropertiesMap = Map.of("Prop1", "PropValue"); + + ToscaProperty property = new ToscaProperty(); + property.setName("test"); + property.setType("testType"); + Map commonPropertiesMap = Map.of("Prop1", property); clDefinition.setCommonPropertiesMap(commonPropertiesMap); return clDefinition; } diff --git a/models/src/test/resources/providers/TestParticipant.json b/models/src/test/resources/providers/TestParticipant.json index c6965ce62..4722ead9b 100644 --- a/models/src/test/resources/providers/TestParticipant.json +++ b/models/src/test/resources/providers/TestParticipant.json @@ -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" + } } -- cgit 1.2.3-korg