From c4c9b3b399036c71f80abe3cb2ba53e8eb8fefd4 Mon Sep 17 00:00:00 2001 From: Sara Weiss Date: Sun, 1 Dec 2019 14:46:47 +0200 Subject: Add filter for serviceInfo by service model id Issue-ID: VID-724 Change-Id: Icdb35b4fa95acb0d40f2921f3d3de0a037858e08 Signed-off-by: Sara Weiss --- .../org/onap/vid/dal/AsyncInstantiationRepository.kt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'vid-app-common/src/main') diff --git a/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt b/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt index 79c7297a3..43d501656 100644 --- a/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt +++ b/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt @@ -86,13 +86,22 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService: private fun filterByCreationDateAndNotDeleted(): String { val minus3Months = LocalDateTime.now().minusMonths(3) val filterDate = Timestamp.valueOf(minus3Months) + return filterServicesByNotHiddenAndNotDeleted() + + " and created >= '" + filterDate + "' " + } + + private fun filterByServiceModelId(serviceModelUuid: UUID): String { + return filterServicesByNotHiddenAndNotDeleted() + + " and SERVICE_MODEL_ID = '$serviceModelUuid'" + } + + private fun filterServicesByNotHiddenAndNotDeleted(): String { return " WHERE" + " hidden = false" + - " and deleted_at is null" + // don't fetch deleted - - " and created >= '" + filterDate + "' " + " and deleted_at is null" // don't fetch deleted } + private fun orderByCreatedDateAndStatus(): String { return " createdBulkDate DESC ,\n" + " (CASE jobStatus\n" + @@ -144,4 +153,7 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService: .joinToString(" $conditionType ") return dataAccessService.getList(className, " WHERE $condition", orderBy, null) as List } + + fun listServicesByServiceModelId(modelUuid: UUID): List = + dataAccessService.getList(ServiceInfo::class.java, filterByServiceModelId(modelUuid), orderByCreatedDateAndStatus(), null) as List; } -- cgit 1.2.3-korg