summaryrefslogtreecommitdiffstats
path: root/runtime-acm/src/main
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2022-12-07 16:22:45 +0000
committerFrancesco Fiora <francesco.fiora@est.tech>2022-12-08 10:08:43 +0000
commita50038a6ed673819b45e9af35eb203e6e24dec99 (patch)
tree7cd5cf908e5367f03d938bef91fe0778bf0ec436 /runtime-acm/src/main
parenta0ccd552fa1c6ddbef3a1e8d455ce256395ee97a (diff)
Add instanceId support in AutomationCompositionProvider
As part of the endpoint refactoring of InstantiationController, AutomationCompositionProvider have to support instanceId in CRUD operations. InstanceId will be temporary add as normal field and it will became primary key in next Jira task. Issue-ID: POLICY-4478 Change-Id: I0f7a1ab7683671403831cffdfe6db37eea569c74 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src/main')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java18
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java2
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java2
3 files changed, 14 insertions, 8 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
index 29b337edd..03a2f4e25 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
@@ -43,6 +43,7 @@ import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -80,9 +81,10 @@ public class AutomationCompositionInstantiationProvider {
if (!validationResult.isValid()) {
throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
}
- automationComposition = automationCompositionProvider.saveAutomationComposition(automationComposition);
+ automationComposition = automationCompositionProvider.createAutomationComposition(automationComposition);
var response = new InstantiationResponse();
+ response.setInstanceId(automationComposition.getInstanceId());
response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier());
return response;
@@ -99,9 +101,10 @@ public class AutomationCompositionInstantiationProvider {
if (!validationResult.isValid()) {
throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
}
- automationCompositionProvider.saveAutomationComposition(automationComposition);
+ automationCompositionProvider.updateAutomationComposition(automationComposition);
var response = new InstantiationResponse();
+ response.setInstanceId(automationComposition.getInstanceId());
response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier());
return response;
@@ -134,7 +137,8 @@ public class AutomationCompositionInstantiationProvider {
* @return the result of the deletion
*/
public InstantiationResponse deleteAutomationComposition(String name, String version) {
- var automationCompositionOpt = automationCompositionProvider.findAutomationComposition(name, version);
+ var automationCompositionOpt =
+ automationCompositionProvider.findAutomationComposition(new ToscaConceptIdentifier(name, version));
if (automationCompositionOpt.isEmpty()) {
throw new PfModelRuntimeException(Response.Status.NOT_FOUND, "Automation composition not found");
}
@@ -144,8 +148,10 @@ public class AutomationCompositionInstantiationProvider {
"Automation composition state is still " + automationComposition.getState());
}
var response = new InstantiationResponse();
- response.setAffectedAutomationComposition(
- automationCompositionProvider.deleteAutomationComposition(name, version).getKey().asIdentifier());
+ automationComposition =
+ automationCompositionProvider.deleteAutomationComposition(automationComposition.getInstanceId());
+ response.setInstanceId(automationComposition.getInstanceId());
+ response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier());
return response;
}
@@ -199,7 +205,7 @@ public class AutomationCompositionInstantiationProvider {
automationComposition.setCascadedOrderedState(command.getOrderedState());
supervisionHandler.triggerAutomationCompositionSupervision(automationComposition);
- automationCompositionProvider.saveAutomationComposition(automationComposition);
+ automationCompositionProvider.updateAutomationComposition(automationComposition);
var response = new InstantiationResponse();
response.setAffectedAutomationComposition(command.getAutomationCompositionIdentifier());
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
index b5d7645da..de67360f8 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
@@ -235,7 +235,7 @@ public class SupervisionHandler {
automationCompositionAckMessage.getAutomationCompositionResultMap().entrySet());
updated |= setPrimed(automationComposition.get());
if (updated) {
- automationCompositionProvider.saveAutomationComposition(automationComposition.get());
+ automationCompositionProvider.updateAutomationComposition(automationComposition.get());
}
} else {
LOGGER.warn("AutomationComposition not found in database {}",
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
index e2f8b6777..129569b6b 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
@@ -242,7 +242,7 @@ public class SupervisionScanner {
automationComposition.getState(), automationComposition.getOrderedState());
automationComposition.setState(automationComposition.getOrderedState().asState());
- automationCompositionProvider.saveAutomationComposition(automationComposition);
+ automationCompositionProvider.updateAutomationComposition(automationComposition);
// Clear missed report counter on automation composition
clearFaultAndCounter(automationComposition);