aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy10
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy3
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java51
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java15
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java11
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java11
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java12
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNsInstRepository.java7
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java23
10 files changed, 87 insertions, 60 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy
index e5c9514fa5..05996d3671 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy
@@ -25,11 +25,9 @@ import groovy.json.JsonSlurper
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aaiclient.client.aai.AAIObjectType
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
-import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -39,7 +37,6 @@ import org.onap.so.db.request.beans.ResourceOperationStatus
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-
public class DoActivateTnNssi extends AbstractServiceTaskProcessor {
String Prefix = "TNACT_"
@@ -114,13 +111,14 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor {
void validateSDNCResponse(DelegateExecution execution, String response) {
- tnNssmfUtils.validateSDNCResponse(execution, response, method)
+ String actionType = execution.getVariable("actionType")
+ tnNssmfUtils.validateSDNCResponse(execution, response, actionType)
}
void updateAAIOrchStatus(DelegateExecution execution) {
logger.debug("Start updateAAIOrchStatus")
- String tnNssiId = execution.getVariable("tnNssiId")
+ String tnNssiId = execution.getVariable("sliceServiceInstanceId")
String orchStatus = execution.getVariable("orchestrationStatus")
try {
@@ -144,7 +142,7 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor {
String status,
String progress,
String statusDescription) {
- String serviceId = execution.getVariable("serviceInstanceID")
+ String serviceId = execution.getVariable("sliceServiceInstanceId")
String jobId = execution.getVariable("jobId")
String nsiId = execution.getVariable("nsiId")
String operType = execution.getVariable("actionType")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
index fbb2b00854..c817eaad61 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
@@ -126,7 +126,7 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor {
public void updateAAIOrchStatus(DelegateExecution execution) {
logger.debug("Start updateAAIOrchStatus")
- String tnNssiId = execution.getVariable("serviceInstanceID")
+ String tnNssiId = execution.getVariable("sliceServiceInstanceId")
String orchStatus = execution.getVariable("orchestrationStatus")
try {
@@ -150,7 +150,7 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor {
String status,
String progress,
String statusDescription) {
- String serviceId = execution.getVariable("serviceInstanceID")
+ String serviceId = execution.getVariable("sliceServiceInstanceId")
String jobId = execution.getVariable("jobId")
String nsiId = execution.getVariable("nsiId")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
index 92953fd60b..869b55b5d2 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
@@ -98,6 +98,7 @@ class TnNssmfUtils {
def callbackURL = execution.getVariable("sdncCallbackUrl")
def requestId = execution.getVariable("msoRequestId")
def serviceId = execution.getVariable("sliceServiceInstanceId")
+ def subServiceType = execution.getVariable("subscriptionServiceType")
def vnfType = execution.getVariable("serviceType")
def vnfName = execution.getVariable("sliceServiceInstanceName")
def tenantId = execution.getVariable("sliceServiceInstanceId")
@@ -143,7 +144,7 @@ class TnNssmfUtils {
</request-information>
<service-information>
<service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
- <subscription-service-type>${MsoUtils.xmlEscape(serviceId)}</subscription-service-type>
+ <subscription-service-type>${MsoUtils.xmlEscape(subServiceType)}</subscription-service-type>
${serviceEcompModelInformation}
<service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
<global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java
index e94b3de81e..a785a5199b 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java
@@ -19,9 +19,9 @@
*/
package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
-import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.JOB_ID_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_INSTANCE_ID_PARAM_NAME;
+import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.OCC_ID_PARAM_NAME;
import java.time.LocalDateTime;
import java.util.Optional;
@@ -31,7 +31,6 @@ import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
-import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider;
@@ -109,21 +108,8 @@ public abstract class AbstractNetworkServiceTask {
public void updateNsLcmOpOccStatusToCompleted(final DelegateExecution execution) {
logger.info("Executing updateNsLcmOpOccStatusToCompleted ...");
- final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME);
- final Optional<NsLcmOpOcc> optional = databaseServiceProvider.getNsLcmOpOcc(occId);
-
- if (optional.isEmpty()) {
- final String message = "Unable to find record for NSLcmOpOcc in database using id: " + occId;
- logger.error(message);
- abortOperation(execution, message);
- }
-
- final NsLcmOpOcc nsLcmOpOcc = optional.get();
- final OperationStateEnum operationStateCompleted = OperationStateEnum.COMPLETED;
- logger.info("Setting operation state to {} for id: {}", operationStateCompleted, occId);
- nsLcmOpOcc.setOperationState(operationStateCompleted);
- databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc);
+ updateNsLcmOpOccOperationState(execution, OperationStateEnum.COMPLETED);
logger.info("Finished executing updateNsLcmOpOccStatusToCompleted ...");
@@ -131,20 +117,8 @@ public abstract class AbstractNetworkServiceTask {
public void updateNsLcmOpOccStatusToFailed(final DelegateExecution execution) {
logger.info("Executing updateNsLcmOpOccStatusToFailed ...");
- final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME);
-
- final Optional<NsLcmOpOcc> optional = databaseServiceProvider.getNsLcmOpOcc(occId);
- if (optional.isPresent()) {
- final NsLcmOpOcc nsLcmOpOcc = optional.get();
- final OperationStateEnum operationStateFailed = OperationStateEnum.FAILED;
- logger.info("Setting operation state to {} for id: {}", operationStateFailed, occId);
- nsLcmOpOcc.setOperationState(operationStateFailed);
-
- databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc);
- } else {
- logger.error("Unable to find record for NSLcmOpOcc in database using id: {}", occId);
- }
+ updateNsLcmOpOccOperationState(execution, OperationStateEnum.FAILED);
logger.info("Finished executing updateNsLcmOpOccStatusToFailed ...");
@@ -154,6 +128,19 @@ public abstract class AbstractNetworkServiceTask {
abortOperation(execution, message, new InlineResponse400().detail(message));
}
+ private void updateNsLcmOpOccOperationState(final DelegateExecution execution,
+ final OperationStateEnum operationState) {
+ final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME);
+
+ final boolean isSuccessful = databaseServiceProvider.updateNsLcmOpOccOperationState(occId, operationState);
+ if (!isSuccessful) {
+ final String message =
+ "Unable to update NsLcmOpOcc " + occId + " operationState to" + operationState + " in database";
+ logger.error(message);
+ abortOperation(execution, message);
+ }
+ }
+
protected void abortOperation(final DelegateExecution execution, final String message,
final InlineResponse400 problemDetails) {
logger.error(message);
@@ -175,10 +162,10 @@ public abstract class AbstractNetworkServiceTask {
}
protected void updateNsInstanceStatus(final DelegateExecution execution, final State nsStatus) {
- final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution);
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+
logger.info("Updating NfvoNsInst Status to {} and saving to DB", nsStatus);
- nfvoNsInst.setStatus(nsStatus);
- databaseServiceProvider.saveNfvoNsInst(nfvoNsInst);
+ databaseServiceProvider.updateNsInstState(nsInstId, nsStatus);
}
protected NfvoNsInst getNfvoNsInst(final DelegateExecution execution) {
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java
index 600792acc0..0d4cbbe24f 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java
@@ -195,7 +195,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask {
}
public void updateNfInstanceStatusToFailed(final DelegateExecution execution) {
- logger.info("Executing updateNfInstanceStatusToActive");
+ logger.info("Executing updateNfInstanceStatusToFailed");
updateNfInstanceStatus(execution, State.FAILED);
final CreateInstantiateRequest request =
@@ -203,22 +203,19 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask {
addJobStatus(execution, ERROR, "Failed to create and instantiate VNF: " + request.getVnfName()
+ " will set status to " + State.FAILED);
- logger.info("Finished executing updateNfInstanceStatusToInstantiated ...");
+ logger.info("Finished executing updateNfInstanceStatusToFailed ...");
}
private void updateNfInstanceStatus(final DelegateExecution execution, final State vnfStatus) {
final String nfInstId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME);
- final Optional<NfvoNfInst> optional = databaseServiceProvider.getNfvoNfInst(nfInstId);
- if (optional.isEmpty()) {
- final String message = "Unable to find NfvoNfInst record in database using nfInstId: " + nfInstId;
+ final boolean isSuccessful = databaseServiceProvider.updateNfInstState(nfInstId, vnfStatus);
+ if (!isSuccessful) {
+ final String message =
+ "Unable to update NfvoNfInst " + nfInstId + " status to" + vnfStatus + " in database";
logger.error(message);
abortOperation(execution, message);
}
-
- final NfvoNfInst nfvoNfInst = optional.get();
- nfvoNfInst.setStatus(vnfStatus);
- databaseServiceProvider.saveNfvoNfInst(nfvoNfInst);
}
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java
index 049a6f38b0..f3e7eea212 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java
@@ -31,7 +31,6 @@ import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse;
import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider;
import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterServiceProvider;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum;
-import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider;
import org.slf4j.Logger;
@@ -170,16 +169,12 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask {
private void updateNfInstanceStatus(final DelegateExecution execution, final State vnfStatus) {
final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME);
- final Optional<NfvoNfInst> optional = databaseServiceProvider.getNfvoNfInst(vnfId);
- if (optional.isEmpty()) {
- final String message = "Unable to find NfvoNfInst record in database using vnfId: " + vnfId;
+ final boolean isSuccessful = databaseServiceProvider.updateNfInstState(vnfId, vnfStatus);
+ if (!isSuccessful) {
+ final String message = "Unable to update NfvoNfInst " + vnfId + " status to" + vnfStatus + " in database";
logger.error(message);
abortOperation(execution, message);
}
-
- final NfvoNfInst nfvoNfInst = optional.get();
- nfvoNfInst.setStatus(vnfStatus);
- databaseServiceProvider.saveNfvoNfInst(nfvoNfInst);
}
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java
index 696c7be5dd..d52dcd6192 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java
@@ -19,9 +19,13 @@
*/
package org.onap.so.etsi.nfvo.ns.lcm.database.repository;
+import java.util.Optional;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
-import java.util.Optional;
+import org.springframework.data.repository.query.Param;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -30,4 +34,9 @@ import java.util.Optional;
public interface NSLcmOpOccRepository extends CrudRepository<NsLcmOpOcc, String> {
Optional<NsLcmOpOcc> findById(final String id);
+
+ @Modifying(clearAutomatically = true)
+ @Query("UPDATE NsLcmOpOcc SET operationState = (:operationState) WHERE id = (:id)")
+ int updateNsLcmOpOccOperationState(@Param("id") final String id,
+ @Param("operationState") final OperationStateEnum operationState);
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java
index de14d43de4..5560ea7af3 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java
@@ -22,7 +22,11 @@ package org.onap.so.etsi.nfvo.ns.lcm.database.repository;
import java.util.List;
import java.util.Optional;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.repository.query.Param;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -35,4 +39,12 @@ public interface NfvoNfInstRepository extends CrudRepository<NfvoNfInst, String>
List<NfvoNfInst> findByNsInstNsInstId(final String nsInstId);
List<NfvoNfInst> findByNsInstNsInstIdAndName(final String nsInstId, final String name);
+
+ @Modifying(clearAutomatically = true)
+ @Query("UPDATE NfvoNfInst SET status = (:state) WHERE nfInstId = (:nfInstId)")
+ int updateNfInstState(@Param("nfInstId") final String nfInstId, @Param("state") final State state);
+
+ @Modifying(clearAutomatically = true)
+ @Query("DELETE FROM NfvoNfInst WHERE nfInstId = (:nfInstId)")
+ void deleteNfvoNfInstUsingNfInstId(@Param("nfInstId") final String nfInstId);
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNsInstRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNsInstRepository.java
index beeeacf8cf..2a6abda558 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNsInstRepository.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNsInstRepository.java
@@ -21,7 +21,11 @@ package org.onap.so.etsi.nfvo.ns.lcm.database.repository;
import java.util.Optional;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.repository.query.Param;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -35,5 +39,8 @@ public interface NfvoNsInstRepository extends CrudRepository<NfvoNsInst, String>
boolean existsNfvoNsInstByName(final String name);
+ @Modifying(clearAutomatically = true)
+ @Query("UPDATE NfvoNsInst SET status = (:state) WHERE nsInstId = (:nsInstId)")
+ int updateNsInstState(@Param("nsInstId") final String nsInstId, @Param("state") final State state);
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java
index 1487b630c7..58ca76eec9 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java
@@ -25,6 +25,8 @@ import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NSLcmOpOccRepository;
import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoJobRepository;
import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoNfInstRepository;
@@ -105,6 +107,12 @@ public class DatabaseServiceProvider {
return nfvoNsInstRepository.save(nfvoNsInst) != null;
}
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public boolean updateNsInstState(final String nsInstId, final State state) {
+ logger.info("Updating NfvoNsInst: {} State to {}", nsInstId, state);
+ return nfvoNsInstRepository.updateNsInstState(nsInstId, state) > 0;
+ }
+
public Optional<NfvoNsInst> getNfvoNsInst(final String nsInstId) {
logger.info("Querying database for NfvoNsInst using nsInstId: {}", nsInstId);
return nfvoNsInstRepository.findById(nsInstId);
@@ -120,6 +128,12 @@ public class DatabaseServiceProvider {
return nfvoNfInstRepository.save(nfvoNfInst) != null;
}
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public boolean updateNfInstState(final String nfInstId, final State state) {
+ logger.info("Updating NfvoNfInst: {} State to {}", nfInstId, state);
+ return nfvoNfInstRepository.updateNfInstState(nfInstId, state) > 0;
+ }
+
public List<NfvoNfInst> getNfvoNfInstByNsInstId(final String nsInstId) {
logger.info("Querying database for NfvoNfInst using nsInstId: {}", nsInstId);
return nfvoNfInstRepository.findByNsInstNsInstId(nsInstId);
@@ -140,9 +154,10 @@ public class DatabaseServiceProvider {
return nfvoNfInstRepository.findByNfInstId(nfInstId).isPresent();
}
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
public void deleteNfvoNfInst(final String nfInstId) {
logger.info("Deleting NfvoNfInst with nfInstId: {} from database", nfInstId);
- nfvoNfInstRepository.deleteById(nfInstId);
+ nfvoNfInstRepository.deleteNfvoNfInstUsingNfInstId(nfInstId);
}
public boolean addNSLcmOpOcc(final NsLcmOpOcc nsLcmOpOcc) {
@@ -150,6 +165,12 @@ public class DatabaseServiceProvider {
return nsLcmOpOccRepository.save(nsLcmOpOcc) != null;
}
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public boolean updateNsLcmOpOccOperationState(final String id, final OperationStateEnum operationState) {
+ logger.info("Updating NsLcmOpOcc: {} operationState to {}", id, operationState);
+ return nsLcmOpOccRepository.updateNsLcmOpOccOperationState(id, operationState) > 0;
+ }
+
public Optional<NsLcmOpOcc> getNsLcmOpOcc(final String id) {
logger.info("Querying database for NsLcmOpOcc using id: {}", id);
return nsLcmOpOccRepository.findById(id);