From 45939832e234215b7bb05e5c5222315f3eb3f914 Mon Sep 17 00:00:00 2001 From: shamalka Date: Mon, 16 Mar 2020 20:17:07 +0530 Subject: [PATCH] Fix App NOT installed report API query --- .../scenes/AppNotInstalledDevices/index.js | 4 +- .../core/dao/impl/AbstractDeviceDAOImpl.java | 50 +++++++++---------- .../mgt/core/dao/impl/ApplicationDAOImpl.java | 4 +- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Reports/scenes/AppNotInstalledDevices/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Reports/scenes/AppNotInstalledDevices/index.js index 6dac86271d..a23f4df8f0 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Reports/scenes/AppNotInstalledDevices/index.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Reports/scenes/AppNotInstalledDevices/index.js @@ -23,7 +23,7 @@ import { Link } from 'react-router-dom'; import { withConfigContext } from '../../../../../../components/ConfigContext'; import AppListDropDown from './components/AppListDropDown'; -import ReportDevicesTable from '../../components/DevicesTable'; +import DevicesTable from './../../components/DevicesTable'; import AppVersionDropDown from './components/AppVersionDropDown'; // eslint-disable-next-line no-unused-vars @@ -121,7 +121,7 @@ class AppNotInstalledDevicesReport extends React.Component {
- +
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 7b691ca0b8..8994dff865 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -45,7 +45,6 @@ import org.wso2.carbon.device.mgt.common.EnrolmentInfo.Status; import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.configuration.mgt.DevicePropertyInfo; import org.wso2.carbon.device.mgt.common.device.details.DeviceData; -import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistory; import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; @@ -54,7 +53,6 @@ import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.geo.GeoCluster; import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; -import org.wso2.carbon.device.mgt.core.report.mgt.Constants; import java.sql.Connection; import java.sql.PreparedStatement; @@ -1919,24 +1917,24 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { boolean isVersionProvided = false; String sql = "SELECT " + - "d.ID AS DEVICE_ID, " + - "d.DESCRIPTION,d.NAME AS DEVICE_NAME, " + - "t.NAME AS DEVICE_TYPE, " + - "d.DEVICE_IDENTIFICATION, " + - "e.OWNER, " + - "e.OWNERSHIP, " + - "e.STATUS, " + - "e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, " + - "e.ID AS ENROLMENT_ID " + - "FROM DM_DEVICE AS d " + - "INNER JOIN DM_ENROLMENT AS e ON d.ID = e.DEVICE_ID " + - "INNER JOIN DM_DEVICE_TYPE AS t ON d.DEVICE_TYPE_ID = t.ID " + - "WHERE t.NAME = ? AND e.TENANT_ID = ? AND d.ID " + - "NOT IN (SELECT m.DEVICE_ID " + - "FROM DM_DEVICE_APPLICATION_MAPPING AS m " + - "INNER JOIN DM_APPLICATION AS a ON m.APPLICATION_ID=a.ID " + - "WHERE a.APP_IDENTIFIER = ?"; + "d.ID AS DEVICE_ID, " + + "d.DESCRIPTION, " + + "d.NAME AS DEVICE_NAME, " + + "t.NAME AS DEVICE_TYPE, " + + "d.DEVICE_IDENTIFICATION, " + + "e.OWNER, " + + "e.OWNERSHIP, " + + "e.STATUS, " + + "e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, " + + "e.ID AS ENROLMENT_ID " + + "FROM DM_DEVICE AS d " + + "INNER JOIN DM_ENROLMENT AS e ON d.ID = e.DEVICE_ID " + + "INNER JOIN DM_DEVICE_TYPE AS t ON d.DEVICE_TYPE_ID = t.ID " + + "WHERE " + + "t.NAME = ? AND e.TENANT_ID = ? AND d.ID " + + "NOT IN " + + "(SELECT a.DEVICE_ID FROM DM_APPLICATION AS a WHERE a.APP_IDENTIFIER = ?"; if (!StringUtils.isBlank(version)) { sql = sql + " AND a.VERSION = ? "; @@ -1985,14 +1983,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { String sql = "SELECT " + "COUNT(d.ID) AS DEVICE_COUNT " + "FROM DM_DEVICE AS d " + - "INNER JOIN DM_ENROLMENT AS e ON d.ID = e.DEVICE_ID " + - "INNER JOIN DM_DEVICE_TYPE AS t ON d.DEVICE_TYPE_ID = t.ID " + - "WHERE t.NAME = ? AND e.TENANT_ID = ? AND d.ID " + + "INNER JOIN DM_ENROLMENT AS e ON d.ID = e.DEVICE_ID " + + "INNER JOIN DM_DEVICE_TYPE AS t ON d.DEVICE_TYPE_ID = t.ID " + + "WHERE " + + "t.NAME = ? AND e.TENANT_ID = ? AND d.ID " + "NOT IN " + - "(SELECT m.DEVICE_ID " + - "FROM DM_DEVICE_APPLICATION_MAPPING AS m " + - "INNER JOIN DM_APPLICATION AS a ON m.APPLICATION_ID=a.ID " + - "WHERE a.APP_IDENTIFIER = ?"; + "(SELECT a.DEVICE_ID FROM DM_APPLICATION AS a WHERE a.APP_IDENTIFIER = ?"; if (!StringUtils.isBlank(version)) { sql = sql + " AND a.VERSION = ? "; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationDAOImpl.java index 9c3af9e0b9..894062df51 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationDAOImpl.java @@ -29,9 +29,7 @@ import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.sql.Connection; import java.sql.PreparedStatement; @@ -322,7 +320,7 @@ public class ApplicationDAOImpl implements ApplicationDAO { @Override public List getAppVersions(int tenantId, String packageName) throws DeviceManagementDAOException { - String sql = "SELECT " + + String sql = "SELECT DISTINCT " + "VERSION " + "FROM DM_APPLICATION " + "WHERE TENANT_ID=? " +