summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/main/java/org
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2021-11-09 10:57:21 +0000
committerGerrit Code Review <gerrit@onap.org>2021-11-09 10:57:21 +0000
commit7a9e0f81770f2aa2793e241cee3a3c6c9bb40d9d (patch)
treed657b7f8d6c9b2f842d0ce5fece438cecea777de /cps-ri/src/main/java/org
parent8109cfb8e6134ce9de12a3e3b3101aa5dd65fe00 (diff)
parent6804157f3ee5b1268e53ae86e4767ee267d48eec (diff)
Merge "Fix for get anchor identifiers by module names"
Diffstat (limited to 'cps-ri/src/main/java/org')
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java5
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java17
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 9f33b2fa50..b1bd03c255 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
@@ -97,8 +97,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