From f2f153a2b4849f37d3ec9216b119307f47c70a10 Mon Sep 17 00:00:00 2001 From: dilanua Date: Sun, 1 May 2016 09:51:09 +0530 Subject: [PATCH] Adding temporary development code bits for dashboard analytics feature --- .../dashboard/dao/GadgetDataServiceDAOImpl.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAOImpl.java index fabd43ec8e..e8f2e19a94 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAOImpl.java @@ -485,7 +485,6 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO { PreparedStatement stmt = null; ResultSet rs = null; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - Map filteredDeviceWithDetails = new HashMap<>(); List> filteredDevicesWithDetails = new ArrayList<>(); int totalRecordsCount = 0; try { @@ -499,7 +498,7 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO { } } sql = "SELECT DEVICE_ID, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM DEVICES_VIEW_2 " + - "WHERE TENANT_ID = ? AND FEATURE_CODE = ? " + advancedSqlFiltering + "ORDER BY DEVICE_ID ASC LIMIT ?, ?"; + "WHERE TENANT_ID = ? AND FEATURE_CODE = ? " + advancedSqlFiltering + "ORDER BY DEVICE_ID ASC LIMIT ?, ?"; stmt = con.prepareStatement(sql); // [2] appending filter column values, if exist stmt.setInt(1, tenantId); @@ -523,7 +522,9 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO { // executing query rs = stmt.executeQuery(); // fetching query results + Map filteredDeviceWithDetails; while (rs.next()) { + filteredDeviceWithDetails = new HashMap<>(); filteredDeviceWithDetails.put("device-id", rs.getInt("DEVICE_ID")); filteredDeviceWithDetails.put("platform", rs.getString("PLATFORM")); filteredDeviceWithDetails.put("ownership", rs.getString("OWNERSHIP")); @@ -612,13 +613,12 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO { PreparedStatement stmt = null; ResultSet rs = null; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - Map filteredDeviceWithDetails = new HashMap<>(); List> filteredDevicesWithDetails = new ArrayList<>(); try { con = this.getConnection(); String sql; sql = "SELECT DEVICE_ID, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM DEVICES_VIEW_2 " + - "WHERE TENANT_ID = ? AND FEATURE_CODE = ?"; + "WHERE TENANT_ID = ? AND FEATURE_CODE = ?"; // appending filters to support advanced filtering options // [1] appending filter columns, if exist if (filters != null && filters.size() > 0) { @@ -644,7 +644,9 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO { // executing query rs = stmt.executeQuery(); // fetching query results + Map filteredDeviceWithDetails; while (rs.next()) { + filteredDeviceWithDetails = new HashMap<>(); filteredDeviceWithDetails.put("device-id", rs.getInt("DEVICE_ID")); filteredDeviceWithDetails.put("platform", rs.getString("PLATFORM")); filteredDeviceWithDetails.put("ownership", rs.getString("OWNERSHIP"));