From e66b2e5e4202e0f19e1460d5856d04c9c4e2c065 Mon Sep 17 00:00:00 2001 From: "saul.gill" Date: Mon, 30 Jan 2023 15:44:58 +0000 Subject: Added deployState to Automation Composition Added deployState and lockState Issue-ID: POLICY-4506 Change-Id: If7fa2cc1f3c729de5dc261e2b527b03c0009e99c Signed-off-by: saul.gill --- .../models/acm/concepts/AutomationComposition.java | 10 ++++++- .../acm/concepts/AutomationCompositionElement.java | 8 +++++ .../concepts/JpaAutomationComposition.java | 35 ++++++++++++++++++++-- .../concepts/JpaAutomationCompositionElement.java | 34 +++++++++++++++++++-- 4 files changed, 81 insertions(+), 6 deletions(-) (limited to 'models/src/main/java/org') 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 83c51eadb..18a62ae94 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 @@ -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. @@ -49,6 +49,12 @@ public class AutomationComposition extends ToscaEntity implements Comparable elements; @NonNull @@ -65,6 +71,8 @@ public class AutomationComposition extends ToscaEntity implements Comparable()); + AutomationCompositionState.UNINITIALISED, new ArrayList<>(), DeployState.UNDEPLOYED, LockState.LOCKED); } /** @@ -117,12 +127,15 @@ public class JpaAutomationComposition extends Validated */ public JpaAutomationComposition(@NonNull final String instanceId, @NonNull final PfConceptKey key, @NonNull final String compositionId, @NonNull final AutomationCompositionState state, - @NonNull final List elements) { + @NonNull final List elements, + @NonNull final DeployState deployState, @NonNull final LockState lockState) { this.instanceId = instanceId; this.name = key.getName(); this.version = key.getVersion(); this.compositionId = compositionId; this.state = state; + this.deployState = deployState; + this.lockState = lockState; this.elements = elements; } @@ -138,6 +151,8 @@ public class JpaAutomationComposition extends Validated this.compositionId = copyConcept.compositionId; this.state = copyConcept.state; this.orderedState = copyConcept.orderedState; + this.deployState = copyConcept.deployState; + this.lockState = copyConcept.lockState; this.description = copyConcept.description; this.elements = PfUtils.mapList(copyConcept.elements, JpaAutomationCompositionElement::new); this.primed = copyConcept.primed; @@ -162,6 +177,8 @@ public class JpaAutomationComposition extends Validated automationComposition.setCompositionId(UUID.fromString(compositionId)); automationComposition.setState(state); automationComposition.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); + automationComposition.setDeployState(deployState); + automationComposition.setLockState(lockState); automationComposition.setDescription(description); automationComposition.setPrimed(primed); automationComposition.setElements(new LinkedHashMap<>(this.elements.size())); @@ -180,6 +197,8 @@ public class JpaAutomationComposition extends Validated this.compositionId = automationComposition.getCompositionId().toString(); this.state = automationComposition.getState(); this.orderedState = automationComposition.getOrderedState(); + this.deployState = automationComposition.getDeployState(); + this.lockState = automationComposition.getLockState(); this.description = automationComposition.getDescription(); this.primed = automationComposition.getPrimed(); @@ -231,6 +250,16 @@ public class JpaAutomationComposition extends Validated return result; } + result = ObjectUtils.compare(deployState, other.deployState); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(lockState, other.lockState); + if (result != 0) { + return result; + } + result = ObjectUtils.compare(description, other.description); if (result != 0) { return result; 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 743bb7fd3..4020243bb 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 @@ -42,6 +42,8 @@ import org.apache.commons.lang3.ObjectUtils; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.DeployState; +import org.onap.policy.clamp.models.acm.concepts.LockState; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.common.parameters.annotations.Valid; import org.onap.policy.models.base.PfAuthorative; @@ -90,6 +92,14 @@ public class JpaAutomationCompositionElement extends Validated @NotNull private AutomationCompositionOrderedState orderedState; + @Column + @NotNull + private DeployState deployState; + + @Column + @NotNull + private LockState lockState; + @Column private String description; @@ -113,7 +123,8 @@ 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(), AutomationCompositionState.UNINITIALISED); + this(elementId, instanceId, new PfConceptKey(), + AutomationCompositionState.UNINITIALISED, DeployState.UNDEPLOYED, LockState.LOCKED); } /** @@ -126,11 +137,14 @@ public class JpaAutomationCompositionElement extends Validated */ public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId, @NonNull final PfConceptKey definition, - @NonNull final AutomationCompositionState state) { + @NonNull final AutomationCompositionState state, + @NonNull final DeployState deployState, @NonNull final LockState lockState) { this.elementId = elementId; this.instanceId = instanceId; this.definition = definition; this.state = state; + this.deployState = deployState; + this.lockState = lockState; } /** @@ -147,6 +161,8 @@ public class JpaAutomationCompositionElement extends Validated this.orderedState = copyConcept.orderedState; this.description = copyConcept.description; this.properties = (copyConcept.properties != null ? new LinkedHashMap<>(copyConcept.properties) : null); + this.deployState = copyConcept.deployState; + this.lockState = copyConcept.lockState; } /** @@ -169,6 +185,8 @@ public class JpaAutomationCompositionElement extends Validated element.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); element.setDescription(description); element.setProperties(PfUtils.mapMap(properties, UnaryOperator.identity())); + element.setDeployState(deployState); + element.setLockState(lockState); return element; } @@ -181,6 +199,8 @@ public class JpaAutomationCompositionElement extends Validated this.orderedState = element.getOrderedState(); this.description = element.getDescription(); properties = PfUtils.mapMap(element.getProperties(), UnaryOperator.identity()); + this.deployState = element.getDeployState(); + this.lockState = element.getLockState(); } @Override @@ -222,6 +242,16 @@ public class JpaAutomationCompositionElement extends Validated return result; } + result = ObjectUtils.compare(deployState, other.deployState); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(lockState, other.lockState); + if (result != 0) { + return result; + } + return ObjectUtils.compare(description, other.description); } } -- cgit 1.2.3-korg