summaryrefslogtreecommitdiffstats
path: root/participant
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2022-11-24 10:41:40 +0000
committerFrancescoFioraEst <francesco.fiora@est.tech>2022-11-24 14:52:18 +0000
commit933f1325044e6233ca0da1eecf223bc5bbb06b36 (patch)
tree77ab10ee6fa109b53294e328ead2df12aee78a73 /participant
parenta2e99e7df02837d8270228c330bed4915043b996 (diff)
Link the AutomationComposition with AutomationCompositionDefinition
In AutomationComposition replace the link to ToscaNodeTemplate whit a link to AutomationCompositionDefinition using compositionId. Issue-ID: POLICY-4464 Change-Id: I66878f04ef93fb0754d0066e78bd074ce082f891 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant')
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java20
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java19
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java4
-rw-r--r--participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json10
4 files changed, 24 insertions, 29 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
index e4d921af7..cf7a93fb4 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
@@ -60,14 +60,14 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
* @param automationCompositionHandler AutomationCompositionHandler
*/
public ParticipantIntermediaryApiImpl(ParticipantHandler participantHandler,
- AutomationCompositionHandler automationCompositionHandler) {
+ AutomationCompositionHandler automationCompositionHandler) {
this.participantHandler = participantHandler;
this.automationCompositionHandler = automationCompositionHandler;
}
@Override
public void registerAutomationCompositionElementListener(
- AutomationCompositionElementListener automationCompositionElementListener) {
+ AutomationCompositionElementListener automationCompositionElementListener) {
automationCompositionHandler.registerAutomationCompositionElementListener(automationCompositionElementListener);
}
@@ -93,11 +93,11 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
@Override
public Map<UUID, AutomationCompositionElement> getAutomationCompositionElements(String name, String version) {
- List<AutomationComposition> automationCompositions =
- automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList();
+ var automationCompositions =
+ automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList();
- for (AutomationComposition automationComposition : automationCompositions) {
- if (name.equals(automationComposition.getDefinition().getName())) {
+ for (var automationComposition : automationCompositions) {
+ if (name.equals(automationComposition.getName())) {
return automationComposition.getElements();
}
}
@@ -107,7 +107,7 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
@Override
public AutomationCompositionElement getAutomationCompositionElement(UUID id) {
List<AutomationComposition> automationCompositions =
- automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList();
+ automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList();
for (AutomationComposition automationComposition : automationCompositions) {
AutomationCompositionElement acElement = automationComposition.getElements().get(id);
@@ -120,9 +120,9 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
@Override
public AutomationCompositionElement updateAutomationCompositionElementState(
- ToscaConceptIdentifier automationCompositionId, UUID id, AutomationCompositionOrderedState currentState,
- AutomationCompositionState newState, ParticipantMessageType messageType) {
+ ToscaConceptIdentifier automationCompositionId, UUID id, AutomationCompositionOrderedState currentState,
+ AutomationCompositionState newState, ParticipantMessageType messageType) {
return automationCompositionHandler.updateAutomationCompositionElementState(automationCompositionId, id,
- currentState, newState);
+ currentState, newState);
}
}
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 4c74e50fe..451215515 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
@@ -202,7 +202,7 @@ public class AutomationCompositionHandler {
break;
default:
LOGGER.debug("StateChange message has no state, state is null {}",
- automationComposition.getDefinition());
+ automationComposition.getKey());
break;
}
}
@@ -255,11 +255,11 @@ public class AutomationCompositionHandler {
return;
}
+ automationComposition = new AutomationComposition();
+ automationComposition.setName(updateMsg.getAutomationCompositionId().getName());
+ automationComposition.setVersion(updateMsg.getAutomationCompositionId().getVersion());
var acElements = storeElementsOnThisParticipant(updateMsg.getParticipantUpdatesList());
-
var acElementMap = prepareAcElementMap(acElements);
- automationComposition = new AutomationComposition();
- automationComposition.setDefinition(updateMsg.getAutomationCompositionId());
automationComposition.setElements(acElementMap);
automationCompositionMap.put(updateMsg.getAutomationCompositionId(), automationComposition);
@@ -347,7 +347,7 @@ public class AutomationCompositionHandler {
.filter(element -> !AutomationCompositionState.UNINITIALISED.equals(element.getState())).findAny()
.isEmpty();
if (isAllUninitialised) {
- automationCompositionMap.remove(automationComposition.getDefinition());
+ automationCompositionMap.remove(automationComposition.getKey().asIdentifier());
automationComposition.getElements().values()
.forEach(element -> elementsOnThisParticipant.remove(element.getId()));
}
@@ -400,7 +400,7 @@ public class AutomationCompositionHandler {
automationCompositionAck.setParticipantType(participantType);
automationCompositionAck.setMessage("Automation composition is already in state " + orderedState);
automationCompositionAck.setResult(false);
- automationCompositionAck.setAutomationCompositionId(automationComposition.getDefinition());
+ automationCompositionAck.setAutomationCompositionId(automationComposition.getKey().asIdentifier());
publisher.sendAutomationCompositionAck(automationCompositionAck);
return;
}
@@ -419,11 +419,12 @@ public class AutomationCompositionHandler {
if (startPhaseMsg.equals(startPhase)) {
for (var acElementListener : listeners) {
try {
- acElementListener.automationCompositionElementStateChange(automationComposition.getDefinition(),
- acElement.getId(), acElement.getState(), orderedState);
+ acElementListener.automationCompositionElementStateChange(
+ automationComposition.getKey().asIdentifier(), acElement.getId(), acElement.getState(),
+ orderedState);
} catch (PfModelException e) {
LOGGER.debug("Automation composition element update failed {}",
- automationComposition.getDefinition());
+ automationComposition.getKey().asIdentifier());
}
}
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
index 0d631ad04..440958e33 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
@@ -43,8 +43,8 @@ class ParticipantIntermediaryApiImplTest {
private static final String ID_NAME = "org.onap.PM_CDS_Blueprint";
private static final String ID_VERSION = "1.0.1";
- private static final String ID_NAME_E = "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition";
- private static final String ID_VERSION_E = "1.0.0";
+ private static final String ID_NAME_E = "PMSHInstance1";
+ private static final String ID_VERSION_E = "1.0.1";
private static final String ID_NAME_TYPE = "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant";
private static final String ID_VERSION_TYPE = "2.3.4";
diff --git a/participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json b/participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json
index 4e0f08981..10ed6d187 100644
--- a/participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json
+++ b/participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json
@@ -1,10 +1,7 @@
{
"automationCompositionList": [
{
- "definition": {
- "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition",
- "version": "1.0.0"
- },
+ "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40",
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"elements": {
@@ -70,10 +67,7 @@
"description": "PMSH automation composition instance 0"
},
{
- "definition": {
- "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition",
- "version": "1.0.0"
- },
+ "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40",
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"elements": {