diff options
author | saul.gill <saul.gill@est.tech> | 2023-01-23 17:44:13 +0000 |
---|---|---|
committer | saul.gill <saul.gill@est.tech> | 2023-01-26 09:27:28 +0000 |
commit | 73d0c089fe3e3019e8caa54a60a4c76de5edd72a (patch) | |
tree | 3197ed2af3da4a57abf8226c1cf21e6500a42444 /models/src/main/java/org | |
parent | db615d9fed370c7896a638704d00807c19b6f5d3 (diff) |
Remove participantType and references
Issue-ID: POLICY-4538
Change-Id: Idf3f0308254a318b3e72aa8a234fd7c78f6ffd82
Signed-off-by: saul.gill <saul.gill@est.tech>
Diffstat (limited to 'models/src/main/java/org')
9 files changed, 28 insertions, 127 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java index bea2278a8..b153ef508 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,9 +47,6 @@ public class AutomationCompositionElement { private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); @NonNull - private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); - - @NonNull private UUID participantId = UUID.randomUUID(); @NonNull @@ -74,7 +71,6 @@ public class AutomationCompositionElement { public AutomationCompositionElement(final AutomationCompositionElement otherElement) { this.id = otherElement.id; this.definition = new ToscaConceptIdentifier(otherElement.definition); - this.participantType = new ToscaConceptIdentifier(otherElement.participantType); this.participantId = otherElement.participantId; this.state = otherElement.state; this.orderedState = otherElement.orderedState; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java index 8503516a1..c045c928b 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java @@ -28,7 +28,6 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.NonNull; import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Class to represent details of a running participant instance. @@ -45,9 +44,6 @@ public class Participant { private ParticipantState participantState = ParticipantState.ON_LINE; @NonNull - private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier(); - - @NonNull private Map<UUID, ParticipantSupportedElementType> participantSupportedElementTypes = new HashMap<>(); /** @@ -57,7 +53,6 @@ public class Participant { */ public Participant(Participant otherParticipant) { this.participantState = otherParticipant.participantState; - this.participantType = otherParticipant.participantType; this.participantId = otherParticipant.participantId; this.participantSupportedElementTypes = PfUtils.mapMap(otherParticipant.getParticipantSupportedElementTypes(), ParticipantSupportedElementType::new); diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDefinition.java index aff619873..d3e800cf1 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDefinition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDefinition.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Class to represent a participant definition update instance. @@ -41,7 +40,6 @@ public class ParticipantDefinition { private UUID participantId; - private ToscaConceptIdentifier participantType; // List of AutomationCompositionElementDefinition values for a particular participant private List<AutomationCompositionElementDefinition> automationCompositionElementDefinitionList = new ArrayList<>(); @@ -53,7 +51,6 @@ public class ParticipantDefinition { */ public ParticipantDefinition(final ParticipantDefinition participantDefinition) { this.participantId = participantDefinition.participantId; - this.participantType = participantDefinition.participantType; this.automationCompositionElementDefinitionList = PfUtils.mapList(participantDefinition.automationCompositionElementDefinitionList, AutomationCompositionElementDefinition::new); diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java index 9d26ce406..015a96aad 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,10 @@ package org.onap.policy.clamp.models.acm.concepts; import java.util.Map; -import javax.ws.rs.core.Response; import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.base.PfModelRuntimeException; -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.ToscaServiceTemplate; @@ -40,24 +36,6 @@ public final class ParticipantUtils { "org.onap.policy.clamp.acm.AutomationCompositionElement"; /** - * Finds participantType from a map of properties. - * - * @param properties Map of properties - * @return participantType - */ - public static ToscaConceptIdentifier findParticipantType(Map<String, Object> properties) { - var objParticipantType = properties.get("participantType"); - if (objParticipantType != null) { - try { - return CODER.decode(objParticipantType.toString(), ToscaConceptIdentifier.class); - } catch (CoderException e) { - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e); - } - } - return null; - } - - /** * Get the First StartPhase. * * <p>This depends on the state of the automation composition and also on all start phases defined in the @@ -91,9 +69,9 @@ public final class ParticipantUtils { * @return startPhase */ public static int findStartPhase(Map<String, Object> properties) { - var objParticipantType = properties.get("startPhase"); - if (objParticipantType != null) { - return Integer.valueOf(objParticipantType.toString()); + var objStartPhase = properties.get("startPhase"); + if (objStartPhase != null) { + return Integer.valueOf(objStartPhase.toString()); } return 0; } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java index 8d847f8d4..bdb2be861 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ import lombok.NonNull; import lombok.Setter; import lombok.ToString; import org.onap.policy.clamp.models.acm.concepts.ParticipantState; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Class to represent participant Ack message. @@ -48,11 +47,6 @@ public class ParticipantAckMessage { private ParticipantMessageType messageType; /** - * Participant Type, or {@code null} for messages from participants. - */ - private ToscaConceptIdentifier participantType; - - /** * Participant ID, or {@code null} for messages from participants. */ private UUID participantId; @@ -81,7 +75,6 @@ public class ParticipantAckMessage { this.result = source.result; this.message = source.message; this.messageType = source.messageType; - this.participantType = source.participantType; this.participantId = source.participantId; this.state = source.state; } @@ -89,22 +82,11 @@ public class ParticipantAckMessage { /** * Determines if this message applies to this participant type. * - * @param participantType type of the participant to match against * @param participantId id of the participant to match against * @return {@code true} if this message applies to this participant, {@code false} otherwise */ - public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType, - @NonNull final UUID participantId) { + public boolean appliesTo(@NonNull final UUID participantId) { // Broadcast message to all participants - if (this.participantType == null) { - return true; - } - - if (!participantType.equals(this.participantType)) { - return false; - } - - // Broadcast message to all automation composition elements on this participant if (this.participantId == null) { return true; } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java index 525dab75f..81eda8ce2 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ import lombok.Getter; import lombok.NonNull; import lombok.Setter; import lombok.ToString; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Class to represent the base class for various messages that will be exchanged between the ACM runtime and @@ -48,11 +47,6 @@ public class ParticipantMessage { private Instant timestamp = Instant.now(); /** - * Participant Type, or {@code null} for messages from participants. - */ - private ToscaConceptIdentifier participantType; - - /** * Participant ID, or {@code null} for messages from participants. */ private UUID participantId; @@ -80,7 +74,6 @@ public class ParticipantMessage { */ public ParticipantMessage(final ParticipantMessage source) { this.messageType = source.messageType; - this.participantType = source.participantType; this.participantId = source.participantId; this.automationCompositionId = source.automationCompositionId; this.compositionId = source.compositionId; @@ -89,22 +82,11 @@ public class ParticipantMessage { /** * Determines if this message applies to this participant type. * - * @param participantType type of the participant to match against * @param participantId id of the participant to match against * @return {@code true} if this message applies to this participant, {@code false} otherwise */ - public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType, - @NonNull final UUID participantId) { + public boolean appliesTo(@NonNull final UUID participantId) { // Broadcast message to all participants - if (this.participantType == null) { - return true; - } - - if (!participantType.equals(this.participantType)) { - return false; - } - - // Broadcast message to all automation composition elements on this participant if (this.participantId == null) { return true; } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java index 23fc0a93e..743bb7fd3 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * ================================================================================ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -79,13 +79,6 @@ public class JpaAutomationCompositionElement extends Validated @AttributeOverride(name = "version", column = @Column(name = "definition_version")) private PfConceptKey definition; - @VerifyKey - @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 String participantId; @@ -120,7 +113,7 @@ public class JpaAutomationCompositionElement extends Validated * @param instanceId The id of the automation composition instance */ public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId) { - this(elementId, instanceId, new PfConceptKey(), new PfConceptKey(), AutomationCompositionState.UNINITIALISED); + this(elementId, instanceId, new PfConceptKey(), AutomationCompositionState.UNINITIALISED); } /** @@ -129,16 +122,14 @@ public class JpaAutomationCompositionElement extends Validated * @param elementId The id of the automation composition instance Element * @param instanceId The id of the automation composition instance * @param definition the TOSCA definition of the automation composition element - * @param participantType the TOSCA definition of the participant running the automation composition element * @param state the state of the automation composition */ public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId, - @NonNull final PfConceptKey definition, @NonNull final PfConceptKey participantType, + @NonNull final PfConceptKey definition, @NonNull final AutomationCompositionState state) { this.elementId = elementId; this.instanceId = instanceId; this.definition = definition; - this.participantType = participantType; this.state = state; } @@ -151,7 +142,6 @@ public class JpaAutomationCompositionElement extends Validated this.elementId = copyConcept.elementId; this.instanceId = copyConcept.instanceId; this.definition = new PfConceptKey(copyConcept.definition); - this.participantType = new PfConceptKey(copyConcept.participantType); this.participantId = copyConcept.participantId; this.state = copyConcept.state; this.orderedState = copyConcept.orderedState; @@ -174,7 +164,6 @@ public class JpaAutomationCompositionElement extends Validated element.setId(UUID.fromString(elementId)); element.setDefinition(new ToscaConceptIdentifier(definition)); - element.setParticipantType(new ToscaConceptIdentifier(participantType)); element.setParticipantId(UUID.fromString(participantId)); element.setState(state); element.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); @@ -187,7 +176,6 @@ public class JpaAutomationCompositionElement extends Validated @Override public void fromAuthorative(@NonNull final AutomationCompositionElement element) { this.definition = element.getDefinition().asConceptKey(); - this.participantType = element.getParticipantType().asConceptKey(); this.participantId = element.getParticipantId().toString(); this.state = element.getState(); this.orderedState = element.getOrderedState(); @@ -219,11 +207,6 @@ public class JpaAutomationCompositionElement extends Validated return result; } - result = participantType.compareTo(other.participantType); - if (result != 0) { - return result; - } - result = participantId.compareTo(other.participantId); if (result != 0) { return result; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java index b7e95cfa7..0674873a9 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java @@ -25,7 +25,6 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.UUID; -import javax.persistence.AttributeOverride; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -46,9 +45,7 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantState; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.common.parameters.annotations.Valid; import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.Validated; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Class to represent a participant in the database. @@ -68,11 +65,6 @@ public class JpaParticipant extends Validated @NotNull private String participantId; - @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; @@ -114,7 +106,6 @@ public class JpaParticipant extends Validated public JpaParticipant(@NonNull final JpaParticipant copyConcept) { this.participantState = copyConcept.participantState; this.description = copyConcept.description; - this.participantType = copyConcept.participantType; this.participantId = copyConcept.participantId; this.supportedElements = copyConcept.supportedElements; } @@ -133,7 +124,6 @@ public class JpaParticipant extends Validated var participant = new Participant(); participant.setParticipantState(participantState); - participant.setParticipantType(new ToscaConceptIdentifier(participantType)); participant.setParticipantId(UUID.fromString(participantId)); participant.setParticipantSupportedElementTypes(new LinkedHashMap<>(this.supportedElements.size())); for (var element : this.supportedElements) { @@ -147,7 +137,6 @@ public class JpaParticipant extends Validated @Override public void fromAuthorative(@NonNull final Participant participant) { this.setParticipantState(participant.getParticipantState()); - this.participantType = participant.getParticipantType().asConceptKey(); this.participantId = participant.getParticipantId().toString(); this.supportedElements = new ArrayList<>(participant.getParticipantSupportedElementTypes().size()); @@ -178,11 +167,6 @@ public class JpaParticipant extends Validated return result; } - result = ObjectUtils.compare(participantType, other.participantType); - if (result != 0) { - return result; - } - return ObjectUtils.compare(description, other.description); } } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java index 220a3c132..8bd9039fd 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.function.Function; import java.util.function.UnaryOperator; import java.util.stream.Collectors; @@ -112,13 +113,14 @@ public final class AcmUtils { /** * Prepare ParticipantDefinitionUpdate to set in the message. * - * @param acParticipantType participant type + * @param acParticipantId participant id * @param entryKey key for the entry * @param entryValue value relates to toscaNodeTemplate * @param participantDefinitionUpdates list of participantDefinitionUpdates */ - public static void prepareParticipantDefinitionUpdate(ToscaConceptIdentifier acParticipantType, String entryKey, - ToscaNodeTemplate entryValue, List<ParticipantDefinition> participantDefinitionUpdates) { + public static void prepareParticipantDefinitionUpdate(UUID acParticipantId, String entryKey, + ToscaNodeTemplate entryValue, + List<ParticipantDefinition> participantDefinitionUpdates) { var acDefinition = new AutomationCompositionElementDefinition(); acDefinition.setAcElementDefinitionId(new ToscaConceptIdentifier(entryKey, entryValue.getVersion())); @@ -127,28 +129,30 @@ public final class AcmUtils { List<AutomationCompositionElementDefinition> automationCompositionElementDefinitionList = new ArrayList<>(); if (participantDefinitionUpdates.isEmpty()) { - participantDefinitionUpdates.add(getParticipantDefinition(acDefinition, acParticipantType, + participantDefinitionUpdates.add(getParticipantDefinition(acDefinition, acParticipantId, automationCompositionElementDefinitionList)); } else { var participantExists = false; for (ParticipantDefinition participantDefinitionUpdate : participantDefinitionUpdates) { - if (participantDefinitionUpdate.getParticipantType().equals(acParticipantType)) { - participantDefinitionUpdate.getAutomationCompositionElementDefinitionList().add(acDefinition); - participantExists = true; + if (acParticipantId != null || participantDefinitionUpdate.getParticipantId() != null) { + if (participantDefinitionUpdate.getParticipantId().equals(acParticipantId)) { + participantDefinitionUpdate.getAutomationCompositionElementDefinitionList().add(acDefinition); + participantExists = true; + } } } if (!participantExists) { - participantDefinitionUpdates.add(getParticipantDefinition(acDefinition, acParticipantType, + participantDefinitionUpdates.add(getParticipantDefinition(acDefinition, acParticipantId, automationCompositionElementDefinitionList)); } } } private static ParticipantDefinition getParticipantDefinition(AutomationCompositionElementDefinition acDefinition, - ToscaConceptIdentifier acParticipantType, + UUID acParticipantId, List<AutomationCompositionElementDefinition> automationCompositionElementDefinitionList) { var participantDefinition = new ParticipantDefinition(); - participantDefinition.setParticipantType(acParticipantType); + participantDefinition.setParticipantId(acParticipantId); automationCompositionElementDefinitionList.add(acDefinition); participantDefinition.setAutomationCompositionElementDefinitionList(automationCompositionElementDefinitionList); return participantDefinition; |