summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/swagger/api/impl/DcaeServicesGroupByApiServiceImpl.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main/java/io/swagger/api/impl/DcaeServicesGroupByApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServicesGroupByApiServiceImpl.java
index f879bff..fff2bd4 100644
--- a/src/main/java/io/swagger/api/impl/DcaeServicesGroupByApiServiceImpl.java
+++ b/src/main/java/io/swagger/api/impl/DcaeServicesGroupByApiServiceImpl.java
@@ -27,6 +27,7 @@ import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
import io.swagger.model.DCAEServiceGroupByResults;
import io.swagger.model.DCAEServiceGroupByResultsPropertyValues;
import org.skife.jdbi.v2.Handle;
+import org.skife.jdbi.v2.Query;
import javax.ws.rs.core.Link;
import javax.ws.rs.core.Response;
@@ -149,14 +150,18 @@ public class DcaeServicesGroupByApiServiceImpl extends DcaeServicesGroupbyApiSer
String queryString = createQuery(columnName);
try (Handle jdbiHandle = inventoryDataAccessManager.getHandle()) {
-
- // NOTE: This is hardcoded because service status is only used internally.
- return jdbiHandle.createQuery(queryString)
- .bind(SERVICE_STATUS_PLACE_HOLDER, DCAEServiceObject.DCAEServiceStatus.RUNNING)
- .list();
+ return executeQuery(queryString, jdbiHandle);
}
}
+ List<Map<String, Object>> executeQuery(String queryString, Handle jdbiHandle) {
+ // NOTE: This is hardcoded because service status is only used internally.
+ final Query<Map<String, Object>> query = jdbiHandle.createQuery(queryString);
+ final Query<Map<String, Object>> bind = query
+ .bind(SERVICE_STATUS_PLACE_HOLDER, DCAEServiceObject.DCAEServiceStatus.RUNNING);
+ return bind.list();
+ }
+
static String createQuery(String columnName) {
StringBuilder sb = new StringBuilder();
sb.append(String.format("select %s, count(1) as num ", columnName));