From adec59e9340b85a014a789c742c5905241b250b6 Mon Sep 17 00:00:00 2001 From: dilanua Date: Tue, 10 May 2016 15:26:20 +0530 Subject: [PATCH] Adding inter-mediate postgre-sql and oracle support to dashboard analytics feature --- .../dao/impl/GadgetDataServiceDAOImpl.java | 1 + .../main/resources/dbscripts/cdm/oracle.sql | 55 +++++++++++++++++++ .../resources/dbscripts/cdm/postgresql.sql | 55 +++++++++++++++++++ 3 files changed, 111 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GadgetDataServiceDAOImpl.java index d13bf8c1d7a..f6db11bc51b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GadgetDataServiceDAOImpl.java @@ -56,6 +56,7 @@ public class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO { return deviceCountByGroupEntry; } + @Override public DeviceCountByGroupEntry getDeviceCount(FilterSet filterSet) throws InvalidParameterValueException, SQLException { diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql index 3f6d81226bf..c4a2fd0267c 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -848,3 +848,58 @@ WHEN (NEW.ID IS NULL) END; / +-- DASHBOARD RELATED VIEWS -- + +CREATE VIEW DEVICES_VIEW_1 AS +SELECT +DEVICE_INFO.DEVICE_ID, +DEVICE_INFO.PLATFORM, +DEVICE_INFO.OWNERSHIP, +DEVICE_INFO.CONNECTIVITY_STATUS, +NVL(DEVICE_WITH_POLICY_INFO.POLICY_ID, -1) AS POLICY_ID, +NVL(DEVICE_WITH_POLICY_INFO.IS_COMPLIANT, -1) AS IS_COMPLIANT, +DEVICE_INFO.TENANT_ID +FROM +(SELECT +DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE_TYPE.NAME AS PLATFORM, +DM_ENROLMENT.OWNERSHIP, +DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, +DM_DEVICE.TENANT_ID +FROM DM_DEVICE, DM_DEVICE_TYPE, DM_ENROLMENT +WHERE DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID) DEVICE_INFO +LEFT JOIN +(SELECT +DEVICE_ID, +POLICY_ID, +STATUS AS IS_COMPLIANT +FROM DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO +ON DEVICE_INFO.DEVICE_ID = DEVICE_WITH_POLICY_INFO.DEVICE_ID +ORDER BY DEVICE_INFO.DEVICE_ID; + +CREATE VIEW DEVICES_VIEW_2 AS +SELECT +DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE_DETAIL.DEVICE_MODEL, +DM_DEVICE_DETAIL.VENDOR, +DM_DEVICE_DETAIL.OS_VERSION, +DM_ENROLMENT.OWNERSHIP, +DM_ENROLMENT.OWNER, +DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, +DM_POLICY_COMPLIANCE_STATUS.POLICY_ID, +DM_DEVICE_TYPE.NAME AS PLATFORM, +DM_POLICY_COMPLIANCE_FEATURES.FEATURE_CODE, +DM_POLICY_COMPLIANCE_FEATURES.STATUS AS IS_COMPLAINT, +DM_DEVICE.TENANT_ID +FROM +DM_POLICY_COMPLIANCE_FEATURES, DM_POLICY_COMPLIANCE_STATUS, DM_ENROLMENT, DM_DEVICE, DM_DEVICE_TYPE, DM_DEVICE_DETAIL +WHERE +DM_POLICY_COMPLIANCE_FEATURES.COMPLIANCE_STATUS_ID = DM_POLICY_COMPLIANCE_STATUS.ID AND +DM_POLICY_COMPLIANCE_STATUS.ENROLMENT_ID = DM_ENROLMENT.ID AND +DM_POLICY_COMPLIANCE_STATUS.DEVICE_ID = DM_DEVICE.ID AND +DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND +DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID +ORDER BY TENANT_ID, DEVICE_ID; + +-- END OF DASHBOARD RELATED VIEWS -- + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 3f5b7965b89..7e8c8a3e0c0 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -429,3 +429,58 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( ON UPDATE NO ACTION ); +-- DASHBOARD RELATED VIEWS -- + +CREATE VIEW DEVICES_VIEW_1 AS +SELECT +DEVICE_INFO.DEVICE_ID, +DEVICE_INFO.PLATFORM, +DEVICE_INFO.OWNERSHIP, +DEVICE_INFO.CONNECTIVITY_STATUS, +COALESCE(DEVICE_WITH_POLICY_INFO.POLICY_ID, -1) AS POLICY_ID, +COALESCE(DEVICE_WITH_POLICY_INFO.IS_COMPLIANT, -1) AS IS_COMPLIANT, +DEVICE_INFO.TENANT_ID +FROM +(SELECT +DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE_TYPE.NAME AS PLATFORM, +DM_ENROLMENT.OWNERSHIP, +DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, +DM_DEVICE.TENANT_ID +FROM DM_DEVICE, DM_DEVICE_TYPE, DM_ENROLMENT +WHERE DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID) DEVICE_INFO +LEFT JOIN +(SELECT +DEVICE_ID, +POLICY_ID, +STATUS AS IS_COMPLIANT +FROM DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO +ON DEVICE_INFO.DEVICE_ID = DEVICE_WITH_POLICY_INFO.DEVICE_ID +ORDER BY DEVICE_INFO.DEVICE_ID; + +CREATE VIEW DEVICES_VIEW_2 AS +SELECT +DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE_DETAIL.DEVICE_MODEL, +DM_DEVICE_DETAIL.VENDOR, +DM_DEVICE_DETAIL.OS_VERSION, +DM_ENROLMENT.OWNERSHIP, +DM_ENROLMENT.OWNER, +DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, +DM_POLICY_COMPLIANCE_STATUS.POLICY_ID, +DM_DEVICE_TYPE.NAME AS PLATFORM, +DM_POLICY_COMPLIANCE_FEATURES.FEATURE_CODE, +DM_POLICY_COMPLIANCE_FEATURES.STATUS AS IS_COMPLAINT, +DM_DEVICE.TENANT_ID +FROM +DM_POLICY_COMPLIANCE_FEATURES, DM_POLICY_COMPLIANCE_STATUS, DM_ENROLMENT, DM_DEVICE, DM_DEVICE_TYPE, DM_DEVICE_DETAIL +WHERE +DM_POLICY_COMPLIANCE_FEATURES.COMPLIANCE_STATUS_ID = DM_POLICY_COMPLIANCE_STATUS.ID AND +DM_POLICY_COMPLIANCE_STATUS.ENROLMENT_ID = DM_ENROLMENT.ID AND +DM_POLICY_COMPLIANCE_STATUS.DEVICE_ID = DM_DEVICE.ID AND +DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND +DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID +ORDER BY TENANT_ID, DEVICE_ID; + +-- END OF DASHBOARD RELATED VIEWS -- +