diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-06-05 14:32:37 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2024-06-06 13:29:49 +0000 |
commit | f010d3432b500258121a190ecf94d757c881390e (patch) | |
tree | d66a043185e31ee2897fd52ec2b8c76893220e98 /models/src/main/java | |
parent | a48f784beca5e7aa189217c52cfa83452cf8fc47 (diff) |
Remove Map in ACM-R for timeout Deploy/Undeploy
Issue-ID: POLICY-5040
Change-Id: I6aa5e93fc63cc865648096512487994fb2f48a54
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models/src/main/java')
3 files changed, 35 insertions, 4 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 0cf1f99ec..eb5b6dc9b 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-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,10 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut @NonNull private LockState lockState = LockState.NONE; + private String lastMsg; + + private Integer phase; + private Map<UUID, AutomationCompositionElement> elements; private StateChangeResult stateChangeResult; @@ -69,6 +73,8 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut this.restarting = otherAutomationComposition.restarting; this.deployState = otherAutomationComposition.deployState; this.lockState = otherAutomationComposition.lockState; + this.lastMsg = otherAutomationComposition.lastMsg; + this.phase = otherAutomationComposition.phase; this.elements = PfUtils.mapMap(otherAutomationComposition.elements, AutomationCompositionElement::new); this.stateChangeResult = otherAutomationComposition.stateChangeResult; } 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 5e27fde53..0bf6a9e1a 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 @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import jakarta.persistence.InheritanceType; import jakarta.persistence.JoinColumn; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -44,6 +45,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; 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.StateChangeResult; +import org.onap.policy.clamp.models.acm.utils.TimestampHelper; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.common.parameters.annotations.Valid; import org.onap.policy.models.base.PfAuthorative; @@ -98,6 +100,13 @@ public class JpaAutomationComposition extends Validated private StateChangeResult stateChangeResult; @Column + @NotNull + private Timestamp lastMsg; + + @Column + private Integer phase; + + @Column private String description; @NotNull @@ -149,6 +158,8 @@ public class JpaAutomationComposition extends Validated this.restarting = copyConcept.restarting; this.deployState = copyConcept.deployState; this.lockState = copyConcept.lockState; + this.lastMsg = copyConcept.lastMsg; + this.phase = copyConcept.phase; this.description = copyConcept.description; this.stateChangeResult = copyConcept.stateChangeResult; this.elements = PfUtils.mapList(copyConcept.elements, JpaAutomationCompositionElement::new); @@ -177,6 +188,8 @@ public class JpaAutomationComposition extends Validated automationComposition.setRestarting(restarting); automationComposition.setDeployState(deployState); automationComposition.setLockState(lockState); + automationComposition.setLastMsg(lastMsg.toString()); + automationComposition.setPhase(phase); automationComposition.setDescription(description); automationComposition.setStateChangeResult(stateChangeResult); automationComposition.setElements(new LinkedHashMap<>(this.elements.size())); @@ -199,6 +212,8 @@ public class JpaAutomationComposition extends Validated this.restarting = automationComposition.getRestarting(); this.deployState = automationComposition.getDeployState(); this.lockState = automationComposition.getLockState(); + this.lastMsg = TimestampHelper.toTimestamp(automationComposition.getLastMsg()); + this.phase = automationComposition.getPhase(); this.description = automationComposition.getDescription(); this.stateChangeResult = automationComposition.getStateChangeResult(); this.elements = new ArrayList<>(automationComposition.getElements().size()); @@ -229,6 +244,16 @@ public class JpaAutomationComposition extends Validated return result; } + result = lastMsg.compareTo(other.lastMsg); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(phase, other.phase); + if (result != 0) { + return result; + } + result = ObjectUtils.compare(version, other.version); if (result != 0) { return result; 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 0293bd3c5..5f523ad27 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 @@ -29,7 +29,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Queue; import java.util.UUID; import java.util.function.Function; import java.util.function.UnaryOperator; @@ -71,7 +70,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class AcmUtils { public static final String ENTRY = "entry "; - private static StringToMapConverter MAP_CONVERTER = new StringToMapConverter(); + private static final StringToMapConverter MAP_CONVERTER = new StringToMapConverter(); /** * Get the Policy information in the service template for the deploy message to participants. @@ -379,6 +378,7 @@ public final class AcmUtils { final DeployState deployState, final LockState lockState) { automationComposition.setDeployState(deployState); automationComposition.setLockState(lockState); + automationComposition.setLastMsg(TimestampHelper.now()); if (MapUtils.isEmpty(automationComposition.getElements())) { return; |