aboutsummaryrefslogtreecommitdiffstats
path: root/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2020-10-20 18:39:21 +0100
committerwaqas.ikram <waqas.ikram@est.tech>2020-10-21 15:59:57 +0100
commiteb00f2d1bbc80fb858f15a565a54fa8336c6650d (patch)
treef6fa694420cd726f887a66c0c6bc1206bec5a730 /so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java
parent623dbe5cf31cec13c3c6eec7b74791682eb3b731 (diff)
Fixing Update status query for NfvoNfInst
Change-Id: Iaa9119532c3005001c5af73f904a9395048ffd11 Issue-ID: SO-2868 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java')
-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
4 files changed, 51 insertions, 2 deletions
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);