aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java
diff options
context:
space:
mode:
authorniamhcore <niamh.core@est.tech>2021-10-21 15:19:04 +0100
committerniamhcore <niamh.core@est.tech>2021-10-29 09:20:39 +0100
commita1c6e6ac56f9e53f08b329ce7f5069514c62fc77 (patch)
tree124ea9506d021c70d430e213015b9e9522f0f184 /cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java
parentd5bc2ef86b68ba6e8fdc8cf808e9cc0065ce2ae2 (diff)
Add get cm handles by modules names - persistence layer
- Add sql query to anchor repository - Add sql query to yang resource repository Issue-ID: CPS-644 Signed-off-by: niamhcore <niamh.core@est.tech> Change-Id: I85ab1fcb343e6be77628695153d8d9f303dc3112
Diffstat (limited to 'cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java')
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java16
1 files changed, 16 insertions, 0 deletions
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 030555545..6d4cb3c71 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
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Pantheon.tech
+ * Modifications Copyright (C) 2021 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +28,8 @@ import org.onap.cps.spi.entities.DataspaceEntity;
import org.onap.cps.spi.entities.SchemaSetEntity;
import org.onap.cps.spi.exceptions.AnchorNotFoundException;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
public interface AnchorRepository extends JpaRepository<AnchorEntity, Integer> {
@@ -41,4 +44,17 @@ public interface AnchorRepository extends JpaRepository<AnchorEntity, Integer> {
Collection<AnchorEntity> findAllByDataspace(@NotNull DataspaceEntity dataspaceEntity);
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"
+ + "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);
} \ No newline at end of file