diff options
Diffstat (limited to 'vid-app-common/src/main/java/org')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt | 18 |
1 files changed, 15 insertions, 3 deletions
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<T> } + + fun listServicesByServiceModelId(modelUuid: UUID): List<ServiceInfo> = + dataAccessService.getList(ServiceInfo::class.java, filterByServiceModelId(modelUuid), orderByCreatedDateAndStatus(), null) as List<ServiceInfo>; } |