From 46117b4e84dc87614a9af9ac10fa3a48cf3b35b3 Mon Sep 17 00:00:00 2001 From: dilanua Date: Thu, 28 Apr 2016 18:10:52 +0530 Subject: [PATCH 1/2] Adding temporary development code bits for dashboard analytics feature --- .../analytics/dashboard/dao/GadgetDataServiceDAOImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 e56e241ec5..fabd43ec8e 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 @@ -411,7 +411,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 { @@ -448,7 +447,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")); @@ -559,7 +560,6 @@ 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(); @@ -589,7 +589,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")); From b8972c90198e11bcdeec1aecddbf1ee271825344 Mon Sep 17 00:00:00 2001 From: dilanua Date: Fri, 29 Apr 2016 05:40:34 +0530 Subject: [PATCH 2/2] Adding temporary development code bits for dashboard analytics feature --- .../dashboard/dao/GadgetDataServiceDAO.java | 32 ++++++++++--------- .../internal/GadgetDataServiceImpl.java | 26 +++++++++++++-- 2 files changed, 40 insertions(+), 18 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/GadgetDataServiceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAO.java index f54701c716..6cbdba08bc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAO.java @@ -33,65 +33,67 @@ public interface GadgetDataServiceDAO { */ int getTotalDeviceCount() throws GadgetDataServiceDAOException; + /** + * Method to get active device count from a particular tenant. + * + * @return active device count. + */ int getActiveDeviceCount() throws GadgetDataServiceDAOException; + /** + * Method to get inactive device count from a particular tenant. + * + * @return inactive device count. + */ int getInactiveDeviceCount() throws GadgetDataServiceDAOException; + /** + * Method to get removed device count from a particular tenant. + * + * @return removed device count. + */ int getRemovedDeviceCount() throws GadgetDataServiceDAOException; /** - * Method to get non-compliant device count. + * Method to get non-compliant device count from a particular tenant. * * @return Non-compliant device count. */ - @SuppressWarnings("unused") int getNonCompliantDeviceCount() throws GadgetDataServiceDAOException; /** - * Method to get unmonitored device count. + * Method to get unmonitored device count from a particular tenant. * * @return Unmonitored device count. */ - @SuppressWarnings("unused") int getUnmonitoredDeviceCount() throws GadgetDataServiceDAOException; - @SuppressWarnings("unused") PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest) throws GadgetDataServiceDAOException; - @SuppressWarnings("unused") int getDeviceCount(Map filters) throws GadgetDataServiceDAOException; - @SuppressWarnings("unused") int getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode, Map filters) throws GadgetDataServiceDAOException; - @SuppressWarnings("unused") Map getDeviceCountsByPlatforms(Map filters) throws GadgetDataServiceDAOException; - @SuppressWarnings("unused") Map getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode, Map filters) throws GadgetDataServiceDAOException; - @SuppressWarnings("unused") Map getDeviceCountsByOwnershipTypes(Map filters) throws GadgetDataServiceDAOException; - @SuppressWarnings("unused") Map getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode, Map filters) throws GadgetDataServiceDAOException; - @SuppressWarnings("unused") PaginationResult getDevicesWithDetails(Map filters, PaginationRequest paginationRequest) throws GadgetDataServiceDAOException; - @SuppressWarnings("unused") PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode, Map filters, PaginationRequest paginationRequest) throws GadgetDataServiceDAOException; - @SuppressWarnings("unused") List> getDevicesWithDetails(Map filters) throws GadgetDataServiceDAOException; - @SuppressWarnings("unused") List> getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode, Map filters) throws GadgetDataServiceDAOException; 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 c0df361d9f..2f31b84f40 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 @@ -270,12 +270,32 @@ class GadgetDataServiceImpl implements GadgetDataService { @Override public List> getDevicesWithDetails(Map filters) { - return null; + List> devicesWithDetails = null; + try { + GadgetDataServiceDAOFactory.openConnection(); + devicesWithDetails = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getDevicesWithDetails(filters); + } catch (GadgetDataServiceDAOException | SQLException e) { + return null; + } finally { + GadgetDataServiceDAOFactory.closeConnection(); + } + return devicesWithDetails; } @Override - public List> getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode, Map filters) { - return null; + public List> getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode, + Map filters) { + List> featureNonCompliantDevicesWithDetails = null; + try { + GadgetDataServiceDAOFactory.openConnection(); + featureNonCompliantDevicesWithDetails = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). + getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, filters); + } catch (GadgetDataServiceDAOException | SQLException e) { + return null; + } finally { + GadgetDataServiceDAOFactory.closeConnection(); + } + return featureNonCompliantDevicesWithDetails; } }