diff options
author | sourabh_sourabh <sourabh.sourabh@est.tech> | 2023-08-15 12:15:33 +0100 |
---|---|---|
committer | sourabh_sourabh <sourabh.sourabh@est.tech> | 2023-08-18 12:43:48 +0100 |
commit | 17aab0023e514cfe99b70ea161b271c9e42c5667 (patch) | |
tree | ef37ad266262058ea027308eac48aba150714196 /cps-ri/src/main | |
parent | a92d488934c016f0f2645382f7fcdec0ad446f2e (diff) |
CPS-Core : Expose a java interface to update schema set
- Exposed an interface to update anchor by schema set name.
- New interface is implemented into RI model.
- New native query is exposed to update id with given schema set name.
- A new integration test is written to test new interface into cps core.
Issue-ID: CPS-1800
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
Change-Id: Ibf44712e11b53cb6673b04b9e3fd864321c90839
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
Diffstat (limited to 'cps-ri/src/main')
-rwxr-xr-x | cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java | 12 | ||||
-rwxr-xr-x | cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java index 6f9f5a482c..847a4a32fe 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java @@ -171,6 +171,18 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic anchorRepository.deleteAllByDataspaceAndNameIn(dataspaceEntity, anchorNames); } + @Transactional + @Override + public void updateAnchorSchemaSet(final String dataspaceName, + final String anchorName, + final String schemaSetName) { + final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName); + final AnchorEntity anchorEntity = anchorRepository.getByDataspaceAndName(dataspaceEntity, anchorName); + final SchemaSetEntity schemaSetEntity = schemaSetRepository + .getByDataspaceAndName(dataspaceEntity, schemaSetName); + anchorRepository.updateAnchorSchemaSetId(schemaSetEntity.getId(), anchorEntity.getId()); + } + private AnchorEntity getAnchorEntity(final String dataspaceName, final String anchorName) { final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName); return anchorRepository.getByDataspaceAndName(dataspaceEntity, anchorName); diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java index 5bb5857810..b8503a7fea 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java @@ -99,4 +99,8 @@ public interface AnchorRepository extends JpaRepository<AnchorEntity, Long> { deleteAllByDataspaceIdAndNameIn(dataspaceEntity.getId(), anchorNames.toArray(new String[0])); } + @Modifying + @Query(value = "UPDATE anchor SET schema_set_id =:schemaSetId WHERE id = :anchorId ", nativeQuery = true) + void updateAnchorSchemaSetId(@Param("schemaSetId") int schemaSetId, @Param("anchorId") long anchorId); + } |