summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/functions')
-rw-r--r--ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt56
-rw-r--r--ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt30
2 files changed, 86 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt
index e1806438b..6806ad665 100644
--- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt
+++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt
@@ -40,4 +40,60 @@ interface ResourceConfigSnapshotRepository : JpaRepository<ResourceConfigSnapsho
resourceType: String,
status: ResourceConfigSnapshot.Status
)
+
+ /**
+ * Finds all ResourceConfigSnapshot for a given resourceId and status as search criterias,
+ * ordering the resulting list in reverse chronological order.
+ *
+ * @param resourceId a resource identifier, e.g. CLLI1234555
+ * @param status RUNNING or CANDIDATE
+ *
+ * @return A list of entries are found returns a list of ConfigSnapshot.
+ * If no entries are found, this method returns an empty list.
+ */
+ fun findByResourceIdAndStatusOrderByCreatedDateDesc(
+ resourceId: String,
+ status: ResourceConfigSnapshot.Status
+ ): List<ResourceConfigSnapshot>?
+
+ /**
+ * Finds all ResourceConfigSnapshot for a given resourceId,
+ * ordering the resulting list in reverse chronological order.
+ *
+ * @param resourceId a resource identifier, e.g. CLLI1234555
+ *
+ * @return A list of entries are found returns a list of ConfigSnapshot.
+ * If no entries are found, this method returns an empty list.
+ */
+ fun findByResourceIdOrderByCreatedDateDesc(
+ resourceId: String
+ ): List<ResourceConfigSnapshot>?
+
+ /**
+ * Finds all ResourceConfigSnapshot for a given resourceType and status as search criterias,
+ * ordering the resulting list in reverse chronological order.
+ *
+ * @param resourceType a resource type name, e.g full_config
+ * @param status RUNNING or CANDIDATE
+ *
+ * @return A list of entries are found returns a list of ConfigSnapshot.
+ * If no entries are found, this method returns an empty list.
+ */
+ fun findByResourceTypeAndStatusOrderByCreatedDateDesc(
+ resourceType: String,
+ status: ResourceConfigSnapshot.Status
+ ): List<ResourceConfigSnapshot>?
+
+ /**
+ * Finds all ResourceConfigSnapshot for a given resourceType,
+ * ordering the resulting list in reverse chronological order.
+ *
+ * @param resourceType a resource type name, e.g full_config
+ *
+ * @return A list of entries are found returns a list of ConfigSnapshot.
+ * If no entries are found, this method returns an empty list.
+ */
+ fun findByResourceTypeOrderByCreatedDateDesc(
+ resourceType: String
+ ): List<ResourceConfigSnapshot>?
}
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt
index 9260b79e8..2383f2c64 100644
--- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt
+++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt
@@ -36,6 +36,36 @@ open class ResourceConfigSnapshotService(private val resourceConfigSnapshotRepos
private val log = LoggerFactory.getLogger(ResourceConfigSnapshotService::class.toString())
+ suspend fun findAllByResourceIdForStatus(
+ resourceId: String,
+ status: ResourceConfigSnapshot.Status
+ ): List<ResourceConfigSnapshot>? =
+ withContext(Dispatchers.IO) {
+ resourceConfigSnapshotRepository.findByResourceIdAndStatusOrderByCreatedDateDesc(resourceId, status)
+ }
+
+ suspend fun findAllByResourceId(
+ resourceId: String
+ ): List<ResourceConfigSnapshot>? =
+ withContext(Dispatchers.IO) {
+ resourceConfigSnapshotRepository.findByResourceIdOrderByCreatedDateDesc(resourceId)
+ }
+
+ suspend fun findAllByResourceTypeForStatus(
+ resourceType: String,
+ status: ResourceConfigSnapshot.Status
+ ): List<ResourceConfigSnapshot>? =
+ withContext(Dispatchers.IO) {
+ resourceConfigSnapshotRepository.findByResourceTypeAndStatusOrderByCreatedDateDesc(resourceType, status)
+ }
+
+ suspend fun findAllByResourceType(
+ resourceType: String
+ ): List<ResourceConfigSnapshot>? =
+ withContext(Dispatchers.IO) {
+ resourceConfigSnapshotRepository.findByResourceTypeOrderByCreatedDateDesc(resourceType)
+ }
+
suspend fun findByResourceIdAndResourceTypeAndStatus(
resourceId: String,
resourceType: String,