From 053d14b317104d60226ac9d120228f2b47a80b54 Mon Sep 17 00:00:00 2001 From: dilanua Date: Thu, 28 Apr 2016 06:28:13 +0530 Subject: [PATCH] Adding temporary development code bits for dashboard analytics feature --- .../dashboard/GadgetDataService.java | 11 +++ .../internal/GadgetDataServiceImpl.java | 78 ++++++++++++++----- 2 files changed, 71 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/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 7be30840776..eebdbd314f5 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 @@ -52,10 +52,21 @@ public interface GadgetDataService { @SuppressWarnings("unused") int getDeviceCount(Map filters); + @SuppressWarnings("unused") + int getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode, Map filters); + @SuppressWarnings("unused") Map getDeviceCountsByPlatforms(Map filters); + @SuppressWarnings("unused") + Map getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode, + Map filters); + @SuppressWarnings("unused") Map getDeviceCountsByOwnershipTypes(Map filters); + @SuppressWarnings("unused") + Map getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode, + Map filters); + } 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 eb7ed4847d4..11b88d2004e 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 @@ -42,8 +42,7 @@ class GadgetDataServiceImpl implements GadgetDataService { int totalDeviceCount; try { GadgetDataServiceDAOFactory.openConnection(); - totalDeviceCount = GadgetDataServiceDAOFactory. - getGadgetDataServiceDAO().getTotalDeviceCount(); + totalDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getTotalDeviceCount(); } catch (GadgetDataServiceDAOException | SQLException e) { totalDeviceCount = -1; return totalDeviceCount; @@ -58,8 +57,7 @@ class GadgetDataServiceImpl implements GadgetDataService { int activeDeviceCount; try { GadgetDataServiceDAOFactory.openConnection(); - activeDeviceCount = GadgetDataServiceDAOFactory. - getGadgetDataServiceDAO().getActiveDeviceCount(); + activeDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getActiveDeviceCount(); } catch (GadgetDataServiceDAOException | SQLException e) { activeDeviceCount = -1; return activeDeviceCount; @@ -74,8 +72,7 @@ class GadgetDataServiceImpl implements GadgetDataService { int inactiveDeviceCount; try { GadgetDataServiceDAOFactory.openConnection(); - inactiveDeviceCount = GadgetDataServiceDAOFactory. - getGadgetDataServiceDAO().getInactiveDeviceCount(); + inactiveDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getInactiveDeviceCount(); } catch (GadgetDataServiceDAOException | SQLException e) { inactiveDeviceCount = -1; return inactiveDeviceCount; @@ -90,8 +87,7 @@ class GadgetDataServiceImpl implements GadgetDataService { int removedDeviceCount; try { GadgetDataServiceDAOFactory.openConnection(); - removedDeviceCount = GadgetDataServiceDAOFactory. - getGadgetDataServiceDAO().getRemovedDeviceCount(); + removedDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getRemovedDeviceCount(); } catch (GadgetDataServiceDAOException | SQLException e) { removedDeviceCount = -1; return removedDeviceCount; @@ -106,8 +102,7 @@ class GadgetDataServiceImpl implements GadgetDataService { int nonCompliantDeviceCount; try { GadgetDataServiceDAOFactory.openConnection(); - nonCompliantDeviceCount = GadgetDataServiceDAOFactory. - getGadgetDataServiceDAO().getNonCompliantDeviceCount(); + nonCompliantDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getNonCompliantDeviceCount(); } catch (GadgetDataServiceDAOException | SQLException e) { nonCompliantDeviceCount = -1; return nonCompliantDeviceCount; @@ -122,8 +117,7 @@ class GadgetDataServiceImpl implements GadgetDataService { int unmonitoredDeviceCount; try { GadgetDataServiceDAOFactory.openConnection(); - unmonitoredDeviceCount = GadgetDataServiceDAOFactory. - getGadgetDataServiceDAO().getUnmonitoredDeviceCount(); + unmonitoredDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getUnmonitoredDeviceCount(); } catch (GadgetDataServiceDAOException | SQLException e) { unmonitoredDeviceCount = -1; return unmonitoredDeviceCount; @@ -153,8 +147,7 @@ class GadgetDataServiceImpl implements GadgetDataService { int deviceCount; try { GadgetDataServiceDAOFactory.openConnection(); - deviceCount = GadgetDataServiceDAOFactory. - getGadgetDataServiceDAO().getDeviceCount(filters); + deviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getDeviceCount(filters); } catch (GadgetDataServiceDAOException | SQLException e) { deviceCount = -1; return deviceCount; @@ -164,13 +157,29 @@ class GadgetDataServiceImpl implements GadgetDataService { return deviceCount; } + @Override + public int getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode, Map filters) { + int featureNonCompliantDeviceCount; + try { + GadgetDataServiceDAOFactory.openConnection(); + featureNonCompliantDeviceCount = GadgetDataServiceDAOFactory. + getGadgetDataServiceDAO().getFeatureNonCompliantDeviceCount(nonCompliantFeatureCode, filters); + } catch (GadgetDataServiceDAOException | SQLException e) { + featureNonCompliantDeviceCount = -1; + return featureNonCompliantDeviceCount; + } finally { + GadgetDataServiceDAOFactory.closeConnection(); + } + return featureNonCompliantDeviceCount; + } + @Override public Map getDeviceCountsByPlatforms(Map filters) { Map deviceCountsByPlatforms = null; try { GadgetDataServiceDAOFactory.openConnection(); - deviceCountsByPlatforms = GadgetDataServiceDAOFactory. - getGadgetDataServiceDAO().getDeviceCountsByPlatforms(filters); + deviceCountsByPlatforms = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). + getDeviceCountsByPlatforms(filters); } catch (GadgetDataServiceDAOException | SQLException e) { return null; } finally { @@ -179,13 +188,29 @@ class GadgetDataServiceImpl implements GadgetDataService { return deviceCountsByPlatforms; } + @Override + public Map getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode, + Map filters) { + Map featureNonCompliantDeviceCountsByPlatforms = null; + try { + GadgetDataServiceDAOFactory.openConnection(); + featureNonCompliantDeviceCountsByPlatforms = GadgetDataServiceDAOFactory. + getGadgetDataServiceDAO().getFeatureNonCompliantDeviceCountsByPlatforms(nonCompliantFeatureCode, filters); + } catch (GadgetDataServiceDAOException | SQLException e) { + return null; + } finally { + GadgetDataServiceDAOFactory.closeConnection(); + } + return featureNonCompliantDeviceCountsByPlatforms; + } + @Override public Map getDeviceCountsByOwnershipTypes(Map filters) { Map deviceCountsByOwnershipTypes = null; try { GadgetDataServiceDAOFactory.openConnection(); - deviceCountsByOwnershipTypes = GadgetDataServiceDAOFactory. - getGadgetDataServiceDAO().getDeviceCountsByOwnershipTypes(filters); + deviceCountsByOwnershipTypes = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). + getDeviceCountsByOwnershipTypes(filters); } catch (GadgetDataServiceDAOException | SQLException e) { return null; } finally { @@ -194,4 +219,21 @@ class GadgetDataServiceImpl implements GadgetDataService { return deviceCountsByOwnershipTypes; } + @Override + public Map getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode, + Map filters) { + Map featureNonCompliantDeviceCountsByOwnershipTypes = null; + try { + GadgetDataServiceDAOFactory.openConnection(); + featureNonCompliantDeviceCountsByOwnershipTypes = + GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). + getFeatureNonCompliantDeviceCountsByOwnershipTypes(nonCompliantFeatureCode, filters); + } catch (GadgetDataServiceDAOException | SQLException e) { + return null; + } finally { + GadgetDataServiceDAOFactory.closeConnection(); + } + return featureNonCompliantDeviceCountsByOwnershipTypes; + } + }