From 0dbffafcc772e363fa6318c982a4b298ddab88cb Mon Sep 17 00:00:00 2001 From: Alexey Sandler Date: Wed, 1 Jan 2020 14:23:00 +0200 Subject: Add DB query for all model-service-ids which have a template Issue-ID: VID-739 Change-Id: Ib401f1fd312afb9652793854d49c8c7e5e115149 Signed-off-by: Alexey Sandler --- .../org/onap/vid/dal/AsyncInstantiationRepository.kt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'vid-app-common/src/main/java') 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 e26247281..b638a03e3 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 @@ -90,12 +90,16 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService: " and created >= '" + filterDate + "' " } - private fun filterInstantiatedServiceByServiceModelId(serviceModelUuid: UUID): String { + private fun filterByInstantiateActionStatus(): String{ return filterServicesByNotHiddenAndNotDeleted() + - " and SERVICE_MODEL_ID = '$serviceModelUuid'" + " and ACTION = 'INSTANTIATE'" } + private fun filterInstantiatedServiceByServiceModelId(serviceModelUuid: UUID): String { + return filterByInstantiateActionStatus() + + " and SERVICE_MODEL_ID = '$serviceModelUuid'" + } + private fun filterServicesByNotHiddenAndNotDeleted(): String { return " WHERE" + " hidden = false" + @@ -157,4 +161,13 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService: fun listInstantiatedServicesByServiceModelId(serviceModelId: UUID): List = dataAccessService.getList(ServiceInfo::class.java, filterInstantiatedServiceByServiceModelId(serviceModelId), orderByCreatedDateAndStatus(), null) as List; + + fun getAllTemplatesServiceModelIds(): Set { + val allTemplatesInfo = + dataAccessService.getList(ServiceInfo::class.java, filterByInstantiateActionStatus(), null, null) as List + + return allTemplatesInfo + .map { it.serviceModelId } + .toHashSet() + } } -- cgit 1.2.3-korg