summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-12-01 14:18:41 +0000
committerGerrit Code Review <gerrit@onap.org>2019-12-01 14:18:41 +0000
commitd8a9536b717d0ff48f25deee301f033eceb6e100 (patch)
tree5ab9a6faa3bb284ead0cf74655351e6f8c360c47 /vid-app-common/src/main/java
parentb167cf459a0064310235c3f48918378202e4a41f (diff)
parentc4c9b3b399036c71f80abe3cb2ba53e8eb8fefd4 (diff)
Merge "Add filter for serviceInfo by service model id"
Diffstat (limited to 'vid-app-common/src/main/java')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt18
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>;
}