improve getAllTemplatesServiceModelIds query 72/99972/2
authorEylon Malin <eylon.malin@intl.att.com>
Thu, 2 Jan 2020 08:13:06 +0000 (10:13 +0200)
committerEylon Malin <eylon.malin@intl.att.com>
Thu, 2 Jan 2020 09:47:34 +0000 (11:47 +0200)
Issue-ID: VID-739
Change-Id: I0b5520e0d22942a84ca5d6fc54821455ef67f644
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt

index b638a03..b23a464 100644 (file)
@@ -163,11 +163,10 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService:
             dataAccessService.getList(ServiceInfo::class.java, filterInstantiatedServiceByServiceModelId(serviceModelId), orderByCreatedDateAndStatus(), null) as List<ServiceInfo>;
 
     fun getAllTemplatesServiceModelIds(): Set<String> {
-        val allTemplatesInfo =
-                dataAccessService.getList(ServiceInfo::class.java, filterByInstantiateActionStatus(), null, null) as List<ServiceInfo>
-
-        return allTemplatesInfo
-                .map { it.serviceModelId }
-                .toHashSet()
+        val allTemplatesServiceModelID: List<String> =
+            dataAccessService.executeQuery(
+                "select distinct serviceModelId from ServiceInfo ${filterByInstantiateActionStatus()}",
+                null) as List<String>
+        return allTemplatesServiceModelID.toHashSet()
     }
 }