From c3bc22519adf587aec5459827df784f2378decf1 Mon Sep 17 00:00:00 2001 From: dilanua Date: Sat, 23 Apr 2016 22:51:58 +0530 Subject: [PATCH] Adding temporary development code bits for dashboard analytics feature --- .../analytics/dashboard/GadgetDataService.java | 4 ++++ .../dashboard/dao/GadgetDataServiceDAOImpl.java | 2 +- .../dashboard/internal/GadgetDataServiceImpl.java | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/GadgetDataService.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/GadgetDataService.java index b9a434721c8..14956fd05d6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/GadgetDataService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/GadgetDataService.java @@ -42,4 +42,8 @@ public interface GadgetDataService { @SuppressWarnings("unused") int getUnmonitoredDeviceCount(); + + @SuppressWarnings("unused") + Map getNonCompliantDeviceCountsByFeatures(); + } 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 7f0cede95bd..6e311e6917a 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 @@ -89,7 +89,7 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO { Map filteredNonCompliantDeviceCountsByFeatures = new HashMap<>(); try { con = this.getConnection(); - String sql = "SELECT FEATURE_CODE, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_1 " + + String sql = "SELECT FEATURE_CODE, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_2 " + "WHERE TENANT_ID = ? GROUP BY FEATURE_CODE"; stmt = con.prepareStatement(sql); stmt.setInt(1, tenantId); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/internal/GadgetDataServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/internal/GadgetDataServiceImpl.java index ab91e9a81a4..5a87209688e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/internal/GadgetDataServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/internal/GadgetDataServiceImpl.java @@ -131,4 +131,19 @@ class GadgetDataServiceImpl implements GadgetDataService { return unmonitoredDeviceCount; } + @Override + public Map getNonCompliantDeviceCountsByFeatures() { + Map nonCompliantDeviceCountsByFeatures = null; + try { + GadgetDataServiceDAOFactory.openConnection(); + nonCompliantDeviceCountsByFeatures = + GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getNonCompliantDeviceCountsByFeatures(); + } catch (GadgetDataServiceDAOException | SQLException e) { + return null; + } finally { + GadgetDataServiceDAOFactory.closeConnection(); + } + return nonCompliantDeviceCountsByFeatures; + } + }