diff options
author | Sirisha_Manchikanti <sirisha.manchikanti@est.tech> | 2021-09-10 15:38:07 +0100 |
---|---|---|
committer | Liam Fallon <liam.fallon@est.tech> | 2021-09-14 20:22:17 +0000 |
commit | b741e69ad9a60a128d1994a6fcf65f0b6aeee7ee (patch) | |
tree | 14fbc25e98d3fd8843712527c691c3f96b96b38d /models/src | |
parent | 16f9b97bda8300b354b7d156c084f9869191415f (diff) |
Add Priming flag per controlloop
This commit adds a Priming flag per controlloop which indicates
whether a controlLoop is primed or deprimed. There is a rest
end-point added to depict in GUI
Issue-ID: POLICY-3577
Signed-off-by: Sirisha_Manchikanti <sirisha.manchikanti@est.tech>
Change-Id: Ie81a41505ab1eafda9515733e0b895421803ea8a
Diffstat (limited to 'models/src')
5 files changed, 92 insertions, 0 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java index f2397602b..4d3d37236 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java @@ -52,6 +52,9 @@ public class ControlLoop extends ToscaEntity implements Comparable<ControlLoop> private Map<UUID, ControlLoopElement> elements; + @NonNull + private Boolean primed = false; + @Override public String getType() { return definition.getName(); @@ -73,6 +76,7 @@ public class ControlLoop extends ToscaEntity implements Comparable<ControlLoop> this.state = otherControlLoop.state; this.orderedState = otherControlLoop.orderedState; this.elements = PfUtils.mapMap(otherControlLoop.elements, ControlLoopElement::new); + this.primed = otherControlLoop.primed; } @Override diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java index 2a2cde2ae..756c4f1bf 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java @@ -91,6 +91,9 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo @Column private String description; + @Column + private Boolean primed; + // @formatter:off @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @NotNull @@ -141,6 +144,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo this.orderedState = copyConcept.orderedState; this.description = copyConcept.description; this.elements = PfUtils.mapMap(copyConcept.elements, JpaControlLoopElement::new, new LinkedHashMap<>(0)); + this.primed = copyConcept.primed; } /** @@ -163,6 +167,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo controlLoop.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); controlLoop.setDescription(description); controlLoop.setElements(PfUtils.mapMap(elements, JpaControlLoopElement::toAuthorative, new LinkedHashMap<>(0))); + controlLoop.setPrimed(primed); return controlLoop; } @@ -177,6 +182,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo this.state = controlLoop.getState(); this.orderedState = controlLoop.getOrderedState(); this.description = controlLoop.getDescription(); + this.primed = controlLoop.getPrimed(); this.elements = new LinkedHashMap<>(controlLoop.getElements().size()); for (Entry<UUID, ControlLoopElement> elementEntry : controlLoop.getElements().entrySet()) { @@ -249,6 +255,10 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo return result; } + result = ObjectUtils.compare(primed, other.primed); + if (result != 0) { + return result; + } return PfUtils.compareObjects(elements, other.elements); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimed.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimed.java new file mode 100644 index 000000000..d6e670060 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimed.java @@ -0,0 +1,32 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; + +import lombok.Data; + +@Data +public class ControlLoopPrimed { + + private String name; + + private String version; + + private boolean primed; +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java new file mode 100644 index 000000000..993c6e592 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java @@ -0,0 +1,41 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; + +import java.util.ArrayList; +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; +import org.onap.policy.clamp.controlloop.models.messages.rest.GenericNameVersion; +import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; + + +/** + * Response to provide all primed controlLoops. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ControlLoopPrimedResponse extends SimpleResponse { + + private List<ControlLoopPrimed> primedControlLoopsList = new ArrayList<>(); +} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java index ff6cc7619..d705c49b5 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java @@ -240,6 +240,11 @@ class JpaControlLoopTest { testJpaControlLoop.setDescription(null); assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); + testJpaControlLoop.setPrimed(true); + assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); + testJpaControlLoop.setPrimed(false); + assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); + assertEquals(testJpaControlLoop, new JpaControlLoop(testJpaControlLoop)); } |