aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java
diff options
context:
space:
mode:
authorSara Weiss <sara.weiss@intl.att.com>2019-12-01 14:46:47 +0200
committerEylon Malin <eylon.malin@intl.att.com>2019-12-01 13:04:42 +0000
commitc4c9b3b399036c71f80abe3cb2ba53e8eb8fefd4 (patch)
tree58ba6bda1cbed90ee13df14bad3f4554b558d4aa /vid-app-common/src/main/java
parent434c95a0731b5135a1067f76dfaac9a30878d6cb (diff)
Add filter for serviceInfo by service model id
Issue-ID: VID-724 Change-Id: Icdb35b4fa95acb0d40f2921f3d3de0a037858e08 Signed-off-by: Sara Weiss <sara.weiss@intl.att.com>
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>;
}