diff options
author | Liam Fallon <liam.fallon@est.tech> | 2021-09-23 14:45:33 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-09-23 14:45:33 +0000 |
commit | 6bcadaa32d556a623fb1908f08c8611786d615d6 (patch) | |
tree | 38609e9e8a5ff444c11a9ce888fb57410344aaf6 /models | |
parent | 4143155d835d2fcb291143e6863147dedfe367f4 (diff) | |
parent | 9b982666d6ddb6c964a1e539fea97231b5053f5b (diff) |
Merge "Add participantType to participant class"
Diffstat (limited to 'models')
9 files changed, 48 insertions, 8 deletions
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<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()); } } 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<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. 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<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; } } 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<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); } } diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java index e2eb5154f..087292354 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java @@ -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; } diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java index 1b155a12a..ce56d582a 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java @@ -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); 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<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; } 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<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; } 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" + } } |