diff options
author | niamhcore <niamh.core@est.tech> | 2021-11-08 14:27:18 +0000 |
---|---|---|
committer | niamhcore <niamh.core@est.tech> | 2021-11-09 10:29:18 +0000 |
commit | 6804157f3ee5b1268e53ae86e4767ee267d48eec (patch) | |
tree | 1f7e4543257c5ff5d99f5f073dd17270c993ada8 /cps-ri/src/main/java | |
parent | 94a4b4575f4b5bfe53817db831cc7270dc2abae9 (diff) |
Fix for get anchor identifiers by module names
Issue-ID: CPS-762
Signed-off-by: niamhcore <niamh.core@est.tech>
Change-Id: Idf93f89f8427c5906c9f6b018633c8852b111821
Diffstat (limited to 'cps-ri/src/main/java')
-rwxr-xr-x | cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java | 5 | ||||
-rwxr-xr-x | cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java | 17 |
2 files changed, 10 insertions, 12 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 cd3c30b97b..e5df9c5cab 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 @@ -96,8 +96,9 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic @Override public Collection<Anchor> queryAnchors(final String dataspaceName, final Collection<String> inputModuleNames) { validateDataspaceAndModuleNames(dataspaceName, inputModuleNames); - final Collection<AnchorEntity> anchorEntities = - anchorRepository.getAnchorsByDataspaceNameAndModuleNames(dataspaceName, inputModuleNames); + final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName); + final Collection<AnchorEntity> anchorEntities = anchorRepository + .getAnchorsByDataspaceIdAndModuleNames(dataspaceEntity.getId(), inputModuleNames, inputModuleNames.size()); return anchorEntities.stream().map(CpsAdminPersistenceServiceImpl::toAnchor).collect(Collectors.toSet()); } 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 6d4cb3c716..5870fd9e9b 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 @@ -45,16 +45,13 @@ public interface AnchorRepository extends JpaRepository<AnchorEntity, Integer> { Collection<AnchorEntity> findAllBySchemaSet(@NotNull SchemaSetEntity schemaSetEntity); - @Query(value = "SELECT DISTINCT\n" - + "anchor.*\n" - + "FROM\n" - + "yang_resource\n" - + "JOIN schema_set_yang_resources ON " - + "schema_set_yang_resources.yang_resource_id = yang_resource.id\n" + @Query(value = "SELECT anchor.* FROM yang_resource\n" + + "JOIN schema_set_yang_resources ON schema_set_yang_resources.yang_resource_id = yang_resource.id\n" + "JOIN schema_set ON schema_set.id = schema_set_yang_resources.schema_set_id\n" + "JOIN anchor ON anchor.schema_set_id = schema_set.id\n" - + "JOIN dataspace ON dataspace.id = anchor.dataspace_id AND dataspace.name = :dataspaceName\n" - + "WHERE yang_resource.module_Name IN (:moduleNames)", nativeQuery = true) - Collection<AnchorEntity> getAnchorsByDataspaceNameAndModuleNames(@Param("dataspaceName") String dataspaceName, - @Param("moduleNames") Collection<String> moduleNames); + + "WHERE schema_set.dataspace_id = :dataspaceId AND module_name IN (:moduleNames)\n" + + "GROUP BY anchor.id, anchor.name, anchor.dataspace_id, anchor.schema_set_id\n" + + "HAVING COUNT(DISTINCT module_name) = :sizeOfModuleNames", nativeQuery = true) + Collection<AnchorEntity> getAnchorsByDataspaceIdAndModuleNames(@Param("dataspaceId") int dataspaceId, + @Param("moduleNames") Collection<String> moduleNames, @Param("sizeOfModuleNames") int sizeOfModuleNames); }
\ No newline at end of file |