diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-07-07 13:50:59 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2023-07-07 13:05:12 +0000 |
commit | b28ae291bc1b4a7426d4c6e5098c0a20f3948796 (patch) | |
tree | 7e3f325e60f976101b5a028fd3650c22945f296a /models/src/main | |
parent | fdd9179e8713e68916a16ea949b1125a358b560e (diff) |
Add restart support in composition and in instance
Add restart support in Automation Composition Definition
and in Automation Composition Instance.
Issue-ID: POLICY-4766
Change-Id: I8d169caf7fe74b6d2fcd40c106e4a1646a89a915
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models/src/main')
9 files changed, 58 insertions, 2 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java index 54c9b6190..b92b03fba 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java @@ -42,6 +42,8 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut @NonNull private UUID compositionId; + private Boolean restarting; + @NonNull private DeployState deployState = DeployState.UNDEPLOYED; @@ -61,6 +63,7 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut super(otherAutomationComposition); this.instanceId = otherAutomationComposition.instanceId; this.compositionId = otherAutomationComposition.compositionId; + this.restarting = otherAutomationComposition.restarting; this.deployState = otherAutomationComposition.deployState; this.lockState = otherAutomationComposition.lockState; this.elements = PfUtils.mapMap(otherAutomationComposition.elements, AutomationCompositionElement::new); diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java index eb8a919d6..548bc4549 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java @@ -41,6 +41,8 @@ public class AutomationCompositionDefinition { @NonNull private ToscaServiceTemplate serviceTemplate; + private Boolean restarting; + @NonNull private AcTypeState state; @@ -58,6 +60,7 @@ public class AutomationCompositionDefinition { public AutomationCompositionDefinition(final AutomationCompositionDefinition otherAcmDefinition) { this.compositionId = otherAcmDefinition.compositionId; this.serviceTemplate = new ToscaServiceTemplate(otherAcmDefinition.serviceTemplate); + this.restarting = otherAcmDefinition.restarting; this.state = otherAcmDefinition.state; this.elementStateMap = PfUtils.mapMap(otherAcmDefinition.elementStateMap, NodeTemplateState::new); this.stateChangeResult = otherAcmDefinition.stateChangeResult; 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 ea54076ba..95ee55f8d 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 @@ -48,6 +48,8 @@ public class AutomationCompositionElement { @NonNull private UUID participantId = UUID.randomUUID(); + private Boolean restarting; + @NonNull private DeployState deployState = DeployState.UNDEPLOYED; @@ -77,6 +79,7 @@ public class AutomationCompositionElement { this.description = otherElement.description; this.properties = PfUtils.mapMap(otherElement.properties, UnaryOperator.identity()); this.outProperties = PfUtils.mapMap(otherElement.outProperties, UnaryOperator.identity()); + this.restarting = otherElement.restarting; this.deployState = otherElement.deployState; this.lockState = otherElement.lockState; this.operationalState = otherElement.operationalState; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/NodeTemplateState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/NodeTemplateState.java index 62e92087e..add4f1078 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/NodeTemplateState.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/NodeTemplateState.java @@ -38,6 +38,8 @@ public class NodeTemplateState { private ToscaConceptIdentifier nodeTemplateId; + private Boolean restarting; + private AcTypeState state; private String message; @@ -51,6 +53,7 @@ public class NodeTemplateState { this.nodeTemplateStateId = copyConstructor.nodeTemplateStateId; this.participantId = copyConstructor.participantId; this.nodeTemplateId = new ToscaConceptIdentifier(copyConstructor.nodeTemplateId); + this.restarting = copyConstructor.restarting; this.state = copyConstructor.state; this.message = copyConstructor.message; } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java index 3a448f262..7f2a1e5ae 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java @@ -81,6 +81,9 @@ public class JpaAutomationComposition extends Validated private String compositionId; @Column + private Boolean restarting; + + @Column @NotNull private DeployState deployState; @@ -140,6 +143,7 @@ public class JpaAutomationComposition extends Validated this.name = copyConcept.name; this.version = copyConcept.version; this.compositionId = copyConcept.compositionId; + this.restarting = copyConcept.restarting; this.deployState = copyConcept.deployState; this.lockState = copyConcept.lockState; this.description = copyConcept.description; @@ -164,6 +168,7 @@ public class JpaAutomationComposition extends Validated automationComposition.setName(name); automationComposition.setVersion(version); automationComposition.setCompositionId(UUID.fromString(compositionId)); + automationComposition.setRestarting(restarting); automationComposition.setDeployState(deployState); automationComposition.setLockState(lockState); automationComposition.setDescription(description); @@ -182,6 +187,7 @@ public class JpaAutomationComposition extends Validated this.name = automationComposition.getName(); this.version = automationComposition.getVersion(); this.compositionId = automationComposition.getCompositionId().toString(); + this.restarting = automationComposition.getRestarting(); this.deployState = automationComposition.getDeployState(); this.lockState = automationComposition.getLockState(); this.description = automationComposition.getDescription(); @@ -224,6 +230,11 @@ public class JpaAutomationComposition extends Validated return result; } + result = ObjectUtils.compare(restarting, other.restarting); + if (result != 0) { + return result; + } + result = ObjectUtils.compare(deployState, other.deployState); if (result != 0) { return result; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java index 50949d751..f82152ddc 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java @@ -74,6 +74,9 @@ public class JpaAutomationCompositionDefinition extends Validated private String version; @Column + private Boolean restarting; + + @Column @NotNull private AcTypeState state; @@ -94,6 +97,7 @@ public class JpaAutomationCompositionDefinition extends Validated public AutomationCompositionDefinition toAuthorative() { var acmDefinition = new AutomationCompositionDefinition(); acmDefinition.setCompositionId(UUID.fromString(this.compositionId)); + acmDefinition.setRestarting(this.restarting); acmDefinition.setState(this.state); acmDefinition.setStateChangeResult(this.stateChangeResult); acmDefinition.setServiceTemplate(this.serviceTemplate.toAuthorative()); @@ -107,6 +111,7 @@ public class JpaAutomationCompositionDefinition extends Validated @Override public void fromAuthorative(final AutomationCompositionDefinition copyConcept) { this.compositionId = copyConcept.getCompositionId().toString(); + this.restarting = copyConcept.getRestarting(); this.state = copyConcept.getState(); this.stateChangeResult = copyConcept.getStateChangeResult(); this.serviceTemplate = new DocToscaServiceTemplate(copyConcept.getServiceTemplate()); 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 60a911b21..8c679146e 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 @@ -81,10 +81,14 @@ public class JpaAutomationCompositionElement extends Validated }) private PfConceptKey definition; + @Column @NotNull private String participantId; @Column + private Boolean restarting; + + @Column @NotNull private DeployState deployState; @@ -168,6 +172,7 @@ public class JpaAutomationCompositionElement extends Validated this.outProperties = (copyConcept.outProperties != null ? new LinkedHashMap<>(copyConcept.outProperties) : null); + this.restarting = copyConcept.restarting; this.deployState = copyConcept.deployState; this.lockState = copyConcept.lockState; this.operationalState = copyConcept.operationalState; @@ -194,6 +199,7 @@ public class JpaAutomationCompositionElement extends Validated element.setDescription(description); element.setProperties(PfUtils.mapMap(properties, UnaryOperator.identity())); element.setOutProperties(PfUtils.mapMap(outProperties, UnaryOperator.identity())); + element.setRestarting(restarting); element.setDeployState(deployState); element.setLockState(lockState); element.setOperationalState(operationalState); @@ -210,6 +216,7 @@ public class JpaAutomationCompositionElement extends Validated this.description = element.getDescription(); this.properties = PfUtils.mapMap(element.getProperties(), UnaryOperator.identity()); this.outProperties = PfUtils.mapMap(element.getOutProperties(), UnaryOperator.identity()); + this.restarting = element.getRestarting(); this.deployState = element.getDeployState(); this.lockState = element.getLockState(); this.operationalState = element.getOperationalState(); @@ -246,6 +253,11 @@ public class JpaAutomationCompositionElement extends Validated return result; } + result = ObjectUtils.compare(restarting, other.restarting); + if (result != 0) { + return result; + } + result = ObjectUtils.compare(deployState, other.deployState); if (result != 0) { return result; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaNodeTemplateState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaNodeTemplateState.java index 8ee1075f6..809e13911 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaNodeTemplateState.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaNodeTemplateState.java @@ -67,6 +67,9 @@ public class JpaNodeTemplateState extends Validated implements PfAuthorative<Nod private PfConceptKey nodeTemplateId; @Column + private Boolean restarting; + + @Column @NotNull private AcTypeState state; @@ -98,6 +101,7 @@ public class JpaNodeTemplateState extends Validated implements PfAuthorative<Nod this.participantId = copyConcept.getParticipantId().toString(); } this.nodeTemplateId = copyConcept.getNodeTemplateId().asConceptKey(); + this.restarting = copyConcept.getRestarting(); this.state = copyConcept.getState(); this.message = copyConcept.getMessage(); } @@ -110,6 +114,7 @@ public class JpaNodeTemplateState extends Validated implements PfAuthorative<Nod nodeTemplateState.setParticipantId(UUID.fromString(this.participantId)); } nodeTemplateState.setNodeTemplateId(new ToscaConceptIdentifier(this.nodeTemplateId)); + nodeTemplateState.setRestarting(this.restarting); nodeTemplateState.setState(this.state); nodeTemplateState.setMessage(this.message); return nodeTemplateState; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java index 597606e17..7e8b353ad 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java @@ -24,13 +24,13 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.UUID; +import java.util.stream.Collectors; import javax.ws.rs.core.Response.Status; import lombok.NonNull; import lombok.RequiredArgsConstructor; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; -import org.onap.policy.clamp.models.acm.concepts.DeployState; -import org.onap.policy.clamp.models.acm.concepts.LockState; import org.onap.policy.clamp.models.acm.concepts.NodeTemplateState; import org.onap.policy.clamp.models.acm.concepts.Participant; import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant; @@ -182,4 +182,15 @@ public class ParticipantProvider { return ProviderUtils.asEntityList(nodeTemplateStateRepository .findByParticipantId(participantId.toString())); } + + /** + * Get a list of compositionId associated with a participantId from ac definitions. + * @param participantId the participant id associated with the automation composition elements + * @return the list of compositionId + */ + public Set<UUID> getCompositionIds(@NonNull final UUID participantId) { + return nodeTemplateStateRepository.findByParticipantId(participantId.toString()).stream() + .map(nodeTemplateState -> UUID.fromString(nodeTemplateState.getCompositionId())) + .collect(Collectors.toSet()); + } } |