summaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-intermediary/src/main')
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java22
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java67
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java11
3 files changed, 94 insertions, 6 deletions
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 da6bccb41..c99241f27 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
@@ -47,4 +47,26 @@ public interface AutomationCompositionElementListener {
*/
public void deploy(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
throws PfModelException;
+
+ public default void lock(UUID automationCompositionId, UUID automationCompositionElementId)
+ throws PfModelException {
+ // default Lock Operation
+ }
+
+ public default void unlock(UUID automationCompositionId, UUID automationCompositionElementId)
+ throws PfModelException {
+ // default Unlock Operation
+ }
+
+ public default String getUseState(UUID automationCompositionId, UUID automationCompositionElementId)
+ throws PfModelException {
+ // default Use State
+ return "";
+ }
+
+ public default String getOperationalState(UUID automationCompositionId, UUID automationCompositionElementId)
+ throws PfModelException {
+ // default Operational State
+ return "";
+ }
}
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 d76700171..1eaf63dcc 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
@@ -111,6 +111,8 @@ public class AutomationCompositionHandler {
if (element != null) {
element.setDeployState(deployState);
element.setLockState(lockState);
+ element.setUseState(getUseState(automationCompositionId, id));
+ element.setOperationalState(getOperationalState(automationCompositionId, id));
}
var checkOpt = automationComposition.getElements().values().stream()
.filter(acElement -> !deployState.equals(acElement.getDeployState())).findAny();
@@ -133,8 +135,11 @@ public class AutomationCompositionHandler {
automationCompositionStateChangeAck.setAutomationCompositionId(automationCompositionId);
acElement.setDeployState(deployState);
acElement.setLockState(lockState);
+ acElement.setUseState(getUseState(automationCompositionId, id));
+ acElement.setOperationalState(getOperationalState(automationCompositionId, id));
automationCompositionStateChangeAck.getAutomationCompositionResultMap().put(acElement.getId(),
- new AcElementDeployAck(deployState, lockState, true,
+ new AcElementDeployAck(deployState, lockState,
+ acElement.getOperationalState(), acElement.getUseState(), true,
"Automation composition element {} state changed to {}\", id, newState)"));
LOGGER.debug("Automation composition element {} state changed to {}", id, deployState);
automationCompositionStateChangeAck
@@ -408,8 +413,15 @@ public class AutomationCompositionHandler {
if (acElementNodeTemplate != null) {
int startPhase = ParticipantUtils.findStartPhase(acElementNodeTemplate.getProperties());
if (startPhaseMsg.equals(startPhase)) {
- updateAutomationCompositionElementState(instanceId, acElement.getId(), DeployState.DEPLOYED,
- LockState.LOCKED);
+ for (var acElementListener : listeners) {
+ try {
+ acElementListener.lock(instanceId, acElement.getId());
+ updateAutomationCompositionElementState(instanceId, acElement.getId(), DeployState.DEPLOYED,
+ LockState.LOCKED);
+ } catch (PfModelException e) {
+ LOGGER.error("Automation composition element lock failed {}", instanceId);
+ }
+ }
}
}
}
@@ -420,8 +432,15 @@ public class AutomationCompositionHandler {
if (acElementNodeTemplate != null) {
int startPhase = ParticipantUtils.findStartPhase(acElementNodeTemplate.getProperties());
if (startPhaseMsg.equals(startPhase)) {
- updateAutomationCompositionElementState(instanceId, acElement.getId(), DeployState.DEPLOYED,
- LockState.UNLOCKED);
+ for (var acElementListener : listeners) {
+ try {
+ acElementListener.unlock(instanceId, acElement.getId());
+ updateAutomationCompositionElementState(instanceId, acElement.getId(), DeployState.DEPLOYED,
+ LockState.UNLOCKED);
+ } catch (PfModelException e) {
+ LOGGER.error("Automation composition element unlock failed {}", instanceId);
+ }
+ }
}
}
}
@@ -436,10 +455,46 @@ public class AutomationCompositionHandler {
try {
acElementListener.undeploy(instanceId, acElement.getId());
} catch (PfModelException e) {
- LOGGER.debug("Automation composition element update failed {}", instanceId);
+ LOGGER.error("Automation composition element update failed {}", instanceId);
}
}
}
}
}
+
+ /**
+ * Get UseState.
+ *
+ * @param instanceId the instance Id
+ * @param acElementId the Automation Composition Element Id
+ * @return the UseState of the Automation Composition Element
+ */
+ public String getUseState(UUID instanceId, UUID acElementId) {
+ for (var acElementListener : listeners) {
+ try {
+ return acElementListener.getUseState(instanceId, acElementId);
+ } catch (PfModelException e) {
+ LOGGER.error("Automation composition element get Use State failed {}", acElementId);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get OperationalState.
+ *
+ * @param instanceId the instance Id
+ * @param acElementId the Automation Composition Element Id
+ * @return the OperationalState of the Automation Composition Element
+ */
+ public String getOperationalState(UUID instanceId, UUID acElementId) {
+ for (var acElementListener : listeners) {
+ try {
+ return acElementListener.getOperationalState(instanceId, acElementId);
+ } catch (PfModelException e) {
+ LOGGER.error("Automation composition element get Use State failed {}", acElementId);
+ }
+ }
+ return null;
+ }
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
index 5565e0bd0..9e2484c7d 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
@@ -33,6 +33,7 @@ import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessag
import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementInfo;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
@@ -290,6 +291,16 @@ public class ParticipantHandler {
acInfo.setAutomationCompositionId(entry.getKey());
acInfo.setDeployState(entry.getValue().getDeployState());
acInfo.setLockState(entry.getValue().getLockState());
+ for (var element : entry.getValue().getElements().values()) {
+ var elementInfo = new AutomationCompositionElementInfo();
+ elementInfo.setAutomationCompositionElementId(element.getId());
+ elementInfo.setDeployState(element.getDeployState());
+ elementInfo.setLockState(element.getLockState());
+ elementInfo.setOperationalState(
+ automationCompositionHandler.getOperationalState(entry.getKey(), element.getId()));
+ elementInfo.setUseState(automationCompositionHandler.getUseState(entry.getKey(), element.getId()));
+ acInfo.getElements().add(elementInfo);
+ }
automationCompositionInfoList.add(acInfo);
}
return automationCompositionInfoList;