summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2023-05-05 16:10:13 +0000
committerGerrit Code Review <gerrit@onap.org>2023-05-05 16:10:13 +0000
commit1b54aea09dcc3a278a55d7e7754fd2bc095ba789 (patch)
tree40bbc11a559595b834cca677b4321c280475fece
parent5472e50a387830d6dd85410c19a3b0e687ddf05a (diff)
parent5c921c62ef5fd97ae86efe28e932619546966907 (diff)
Merge "Add participant properties capability to acm/participants"
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java3
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java11
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java2
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java6
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java43
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerTest.java42
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java2
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java6
9 files changed, 110 insertions, 9 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java
index 611336058..39bbdd173 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java
@@ -20,6 +20,8 @@
package org.onap.policy.clamp.models.acm.concepts;
+import java.util.LinkedHashMap;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
@@ -41,6 +43,8 @@ public class AcElementDeployAck {
private String useState;
+ private Map<String, Object> statusProperties = new LinkedHashMap<>();
+
// Result: Success/Fail.
private Boolean result;
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 edc9e1c5f..208766ebb 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
@@ -64,6 +64,8 @@ public class AutomationCompositionElement {
// which can be deserialized into an instance of the type of the property.
private Map<String, Object> properties = new LinkedHashMap<>();
+ private Map<String, Object> statusProperties = new LinkedHashMap<>();
+
/**
* Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
*
@@ -75,6 +77,7 @@ public class AutomationCompositionElement {
this.participantId = otherElement.participantId;
this.description = otherElement.description;
this.properties = PfUtils.mapMap(otherElement.properties, UnaryOperator.identity());
+ this.statusProperties = PfUtils.mapMap(otherElement.statusProperties, UnaryOperator.identity());
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/persistence/concepts/JpaAutomationCompositionElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java
index 4ba336edf..9956a471b 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
@@ -107,6 +107,12 @@ public class JpaAutomationCompositionElement extends Validated
@Convert(converter = StringToMapConverter.class)
private Map<String, Object> properties;
+ @Lob
+ @NotNull
+ @Valid
+ @Convert(converter = StringToMapConverter.class)
+ private Map<String, Object> statusProperties;
+
/**
* The Default Constructor creates a {@link JpaAutomationCompositionElement} object with a null key.
*/
@@ -156,6 +162,9 @@ public class JpaAutomationCompositionElement extends Validated
this.participantId = copyConcept.participantId;
this.description = copyConcept.description;
this.properties = (copyConcept.properties != null ? new LinkedHashMap<>(copyConcept.properties) : null);
+ this.statusProperties =
+ (copyConcept.statusProperties != null ? new LinkedHashMap<>(copyConcept.statusProperties)
+ : null);
this.deployState = copyConcept.deployState;
this.lockState = copyConcept.lockState;
this.operationalState = copyConcept.operationalState;
@@ -180,6 +189,7 @@ public class JpaAutomationCompositionElement extends Validated
element.setParticipantId(UUID.fromString(participantId));
element.setDescription(description);
element.setProperties(PfUtils.mapMap(properties, UnaryOperator.identity()));
+ element.setStatusProperties(PfUtils.mapMap(statusProperties, UnaryOperator.identity()));
element.setDeployState(deployState);
element.setLockState(lockState);
element.setOperationalState(operationalState);
@@ -194,6 +204,7 @@ public class JpaAutomationCompositionElement extends Validated
this.participantId = element.getParticipantId().toString();
this.description = element.getDescription();
this.properties = PfUtils.mapMap(element.getProperties(), UnaryOperator.identity());
+ this.statusProperties = PfUtils.mapMap(element.getStatusProperties(), UnaryOperator.identity());
this.deployState = element.getDeployState();
this.lockState = element.getLockState();
this.operationalState = element.getOperationalState();
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java
index 95a169960..b74b94932 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java
@@ -50,7 +50,7 @@ class AutomationCompositionDeployAckTest {
// verify with all values
orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(CommonTestData.getParticipantId());
- var acElementResult = new AcElementDeployAck(DeployState.DEPLOYED, LockState.LOCKED, "", "",
+ var acElementResult = new AcElementDeployAck(DeployState.DEPLOYED, LockState.LOCKED, "", "", Map.of(),
true, "AutomationCompositionElement result");
final var automationCompositionResultMap = Map.of(UUID.randomUUID(), acElementResult);
orig.setAutomationCompositionResultMap(automationCompositionResultMap);
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
index c99241f27..a61a6678a 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
@@ -69,4 +69,10 @@ public interface AutomationCompositionElementListener {
// default Operational State
return "";
}
+
+ public default Map<String, Object> getStatusProperties(UUID automationCompositionId,
+ UUID automationCompositionElementId) throws PfModelException {
+ // default StatusProperties
+ return Map.of();
+ }
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
index 1eaf63dcc..f918ed12c 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
@@ -21,6 +21,7 @@
package org.onap.policy.clamp.acm.participant.intermediary.handler;
+import com.att.aft.dme2.internal.apache.commons.lang.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -96,6 +97,7 @@ public class AutomationCompositionHandler {
* @param automationCompositionId the automationComposition Id
* @param id the automationComposition UUID
* @param deployState the DeployState state
+ * @param lockState the LockState state
*/
public void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState deployState,
LockState lockState) {
@@ -113,6 +115,7 @@ public class AutomationCompositionHandler {
element.setLockState(lockState);
element.setUseState(getUseState(automationCompositionId, id));
element.setOperationalState(getOperationalState(automationCompositionId, id));
+ element.setStatusProperties(getStatusProperties(automationCompositionId, id));
}
var checkOpt = automationComposition.getElements().values().stream()
.filter(acElement -> !deployState.equals(acElement.getDeployState())).findAny();
@@ -137,9 +140,10 @@ public class AutomationCompositionHandler {
acElement.setLockState(lockState);
acElement.setUseState(getUseState(automationCompositionId, id));
acElement.setOperationalState(getOperationalState(automationCompositionId, id));
+ acElement.setStatusProperties(getStatusProperties(automationCompositionId, id));
automationCompositionStateChangeAck.getAutomationCompositionResultMap().put(acElement.getId(),
- new AcElementDeployAck(deployState, lockState,
- acElement.getOperationalState(), acElement.getUseState(), true,
+ new AcElementDeployAck(deployState, lockState, acElement.getOperationalState(),
+ acElement.getUseState(), acElement.getStatusProperties(), true,
"Automation composition element {} state changed to {}\", id, newState)"));
LOGGER.debug("Automation composition element {} state changed to {}", id, deployState);
automationCompositionStateChangeAck
@@ -470,14 +474,18 @@ public class AutomationCompositionHandler {
* @return the UseState of the Automation Composition Element
*/
public String getUseState(UUID instanceId, UUID acElementId) {
+ var result = new StringBuilder();
for (var acElementListener : listeners) {
try {
- return acElementListener.getUseState(instanceId, acElementId);
+ var state = acElementListener.getUseState(instanceId, acElementId);
+ if (!StringUtils.isBlank(state)) {
+ result.append(state);
+ }
} catch (PfModelException e) {
LOGGER.error("Automation composition element get Use State failed {}", acElementId);
}
}
- return null;
+ return result.toString();
}
/**
@@ -488,13 +496,36 @@ public class AutomationCompositionHandler {
* @return the OperationalState of the Automation Composition Element
*/
public String getOperationalState(UUID instanceId, UUID acElementId) {
+ var result = new StringBuilder();
for (var acElementListener : listeners) {
try {
- return acElementListener.getOperationalState(instanceId, acElementId);
+ var state = acElementListener.getOperationalState(instanceId, acElementId);
+ if (!StringUtils.isBlank(state)) {
+ result.append(state);
+ }
} catch (PfModelException e) {
LOGGER.error("Automation composition element get Use State failed {}", acElementId);
}
}
- return null;
+ return result.toString();
+ }
+
+ /**
+ * Get StatusProperties.
+ *
+ * @param instanceId the instance Id
+ * @param acElementId the Automation Composition Element Id
+ * @return the Status Properties Map
+ */
+ public Map<String, Object> getStatusProperties(UUID instanceId, UUID acElementId) {
+ Map<String, Object> result = new HashMap<>();
+ for (var acElementListener : listeners) {
+ try {
+ result.putAll(acElementListener.getStatusProperties(instanceId, acElementId));
+ } catch (PfModelException e) {
+ LOGGER.error("Automation composition element get Status Properties failed {}", acElementId);
+ }
+ }
+ return result;
}
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerTest.java
new file mode 100644
index 000000000..6255b886c
--- /dev/null
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 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.
+ * 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.acm.participant.intermediary.api.impl;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.DummyAcElementListener;
+import org.onap.policy.models.base.PfModelException;
+
+class AutomationCompositionElementListenerTest {
+
+ @Test
+ void defaultTest() throws PfModelException {
+ var listener = new DummyAcElementListener();
+ assertThat(listener.getStatusProperties(UUID.randomUUID(), UUID.randomUUID())).isNotNull().isEmpty();
+ assertThat(listener.getOperationalState(UUID.randomUUID(), UUID.randomUUID())).isNotNull().isEmpty();
+ assertThat(listener.getUseState(UUID.randomUUID(), UUID.randomUUID())).isNotNull().isEmpty();
+ assertThatCode(() -> listener.lock(UUID.randomUUID(), UUID.randomUUID())).doesNotThrowAnyException();
+ assertThatCode(() -> listener.unlock(UUID.randomUUID(), UUID.randomUUID())).doesNotThrowAnyException();
+ }
+}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
index 85beb76c4..0eb4ecbd9 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
@@ -166,9 +166,11 @@ public class SupervisionAcHandler {
if (DeployState.DEPLOYED.equals(element.getDeployState())) {
element.setOperationalState(acElementAck.getValue().getOperationalState());
element.setUseState(acElementAck.getValue().getUseState());
+ element.setStatusProperties(acElementAck.getValue().getStatusProperties());
} else {
element.setOperationalState(null);
element.setUseState(null);
+ element.setStatusProperties(Map.of());
}
updated = true;
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java
index c44fa1d21..c61984b01 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java
@@ -64,7 +64,8 @@ class SupervisionAcHandlerTest {
var automationCompositionAckMessage =
new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
for (var elementEntry : automationComposition.getElements().entrySet()) {
- var acElementDeployAck = new AcElementDeployAck(DeployState.DEPLOYED, LockState.UNLOCKED, "", "", true, "");
+ var acElementDeployAck =
+ new AcElementDeployAck(DeployState.DEPLOYED, LockState.UNLOCKED, "", "", Map.of(), true, "");
automationCompositionAckMessage.getAutomationCompositionResultMap().put(elementEntry.getKey(),
acElementDeployAck);
}
@@ -86,7 +87,8 @@ class SupervisionAcHandlerTest {
var automationCompositionAckMessage =
new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY_ACK);
for (var elementEntry : automationComposition.getElements().entrySet()) {
- var acElementDeployAck = new AcElementDeployAck(DeployState.DEPLOYED, LockState.LOCKED, "", "", true, "");
+ var acElementDeployAck =
+ new AcElementDeployAck(DeployState.DEPLOYED, LockState.LOCKED, "", "", Map.of(), true, "");
automationCompositionAckMessage
.setAutomationCompositionResultMap(Map.of(elementEntry.getKey(), acElementDeployAck));
}