Merge branch 'master' into 'master'

Fix uninstall device list retrieving issue

See merge request entgra/carbon-device-mgt!382
feature/appm-store/pbac
Saad Sahibjan 5 years ago
commit 66db919702

@ -597,21 +597,33 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
boolean isStatusProvided = false; boolean isStatusProvided = false;
StringJoiner joiner = new StringJoiner(",", StringJoiner joiner = new StringJoiner(",",
"SELECT " + "SELECT "
"f.ID AS DEVICE_ID, f.NAME AS DEVICE_NAME, f.DESCRIPTION AS DESCRIPTION, " + + "DM_DEVICE.ID AS DEVICE_ID, "
"f.DEVICE_TYPE_ID, f.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + + "DM_DEVICE.NAME AS DEVICE_NAME, "
"e.ID AS ENROLMENT_ID, e.OWNER, e.OWNERSHIP, e.DATE_OF_ENROLMENT, " + + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, "
"e.DATE_OF_LAST_UPDATE, e.STATUS, t.NAME AS DEVICE_TYPE " + + "DM_DEVICE.DEVICE_TYPE_ID, "
"FROM DM_ENROLMENT AS e,DM_DEVICE AS f, DM_DEVICE_TYPE t "+ + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, "
"WHERE " + + "DM_ENROLMENT.ID AS ENROLMENT_ID, "
"e.DEVICE_ID=f.ID AND " + + "DM_ENROLMENT.OWNER, "
"e.DEVICE_ID IN (", ") AND e.TENANT_ID=?"); + "DM_ENROLMENT.OWNERSHIP, "
+ "DM_ENROLMENT.DATE_OF_ENROLMENT, "
+ "DM_ENROLMENT.DATE_OF_LAST_UPDATE, "
+ "DM_ENROLMENT.STATUS, "
+ "device_types.NAME AS DEVICE_TYPE "
+ "FROM DM_DEVICE "
+ "INNER JOIN DM_ENROLMENT ON "
+ "DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID AND "
+ "DM_DEVICE.TENANT_ID = DM_ENROLMENT.TENANT_ID "
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "
+ "WHERE DM_DEVICE.ID IN (",
") AND DM_DEVICE.TENANT_ID = ?");
deviceIds.stream().map(ignored -> "?").forEach(joiner::add); deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
query = query + " AND e.STATUS=?"; query = query + " AND DM_ENROLMENT.STATUS=?";
isStatusProvided = true; isStatusProvided = true;
} }

@ -600,21 +600,33 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
boolean isStatusProvided = false; boolean isStatusProvided = false;
StringJoiner joiner = new StringJoiner(",", StringJoiner joiner = new StringJoiner(",",
"SELECT " + "SELECT "
"f.ID AS DEVICE_ID, f.NAME AS DEVICE_NAME, f.DESCRIPTION AS DESCRIPTION, " + + "DM_DEVICE.ID AS DEVICE_ID, "
"f.DEVICE_TYPE_ID, f.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + + "DM_DEVICE.NAME AS DEVICE_NAME, "
"e.ID AS ENROLMENT_ID, e.OWNER, e.OWNERSHIP, e.DATE_OF_ENROLMENT, " + + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, "
"e.DATE_OF_LAST_UPDATE, e.STATUS, t.NAME AS DEVICE_TYPE " + + "DM_DEVICE.DEVICE_TYPE_ID, "
"FROM DM_ENROLMENT AS e,DM_DEVICE AS f, DM_DEVICE_TYPE t " + + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, "
"WHERE " + + "DM_ENROLMENT.ID AS ENROLMENT_ID, "
"e.DEVICE_ID=f.ID AND " + + "DM_ENROLMENT.OWNER, "
"e.DEVICE_ID IN (", ") AND e.TENANT_ID=?"); + "DM_ENROLMENT.OWNERSHIP, "
+ "DM_ENROLMENT.DATE_OF_ENROLMENT, "
+ "DM_ENROLMENT.DATE_OF_LAST_UPDATE, "
+ "DM_ENROLMENT.STATUS, "
+ "device_types.NAME AS DEVICE_TYPE "
+ "FROM DM_DEVICE "
+ "INNER JOIN DM_ENROLMENT ON "
+ "DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID AND "
+ "DM_DEVICE.TENANT_ID = DM_ENROLMENT.TENANT_ID "
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "
+ "WHERE DM_DEVICE.ID IN (",
") AND DM_DEVICE.TENANT_ID = ?");
deviceIds.stream().map(ignored -> "?").forEach(joiner::add); deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
query = query + " AND e.STATUS=?"; query = query + " AND DM_ENROLMENT.STATUS=?";
isStatusProvided = true; isStatusProvided = true;
} }

@ -580,21 +580,33 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
boolean isStatusProvided = false; boolean isStatusProvided = false;
StringJoiner joiner = new StringJoiner(",", StringJoiner joiner = new StringJoiner(",",
"SELECT " + "SELECT "
"f.ID AS DEVICE_ID, f.NAME AS DEVICE_NAME, f.DESCRIPTION AS DESCRIPTION, " + + "DM_DEVICE.ID AS DEVICE_ID, "
"f.DEVICE_TYPE_ID, f.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + + "DM_DEVICE.NAME AS DEVICE_NAME, "
"e.ID AS ENROLMENT_ID, e.OWNER, e.OWNERSHIP, e.DATE_OF_ENROLMENT, " + + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, "
"e.DATE_OF_LAST_UPDATE, e.STATUS, t.NAME AS DEVICE_TYPE " + + "DM_DEVICE.DEVICE_TYPE_ID, "
"FROM DM_ENROLMENT AS e,DM_DEVICE AS f, DM_DEVICE_TYPE t "+ + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, "
"WHERE " + + "DM_ENROLMENT.ID AS ENROLMENT_ID, "
"e.DEVICE_ID=f.ID AND " + + "DM_ENROLMENT.OWNER, "
"e.DEVICE_ID IN (", ") AND e.TENANT_ID=?"); + "DM_ENROLMENT.OWNERSHIP, "
+ "DM_ENROLMENT.DATE_OF_ENROLMENT, "
+ "DM_ENROLMENT.DATE_OF_LAST_UPDATE, "
+ "DM_ENROLMENT.STATUS, "
+ "device_types.NAME AS DEVICE_TYPE "
+ "FROM DM_DEVICE "
+ "INNER JOIN DM_ENROLMENT ON "
+ "DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID AND "
+ "DM_DEVICE.TENANT_ID = DM_ENROLMENT.TENANT_ID "
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "
+ "WHERE DM_DEVICE.ID IN (",
") AND DM_DEVICE.TENANT_ID = ?");
deviceIds.stream().map(ignored -> "?").forEach(joiner::add); deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
query = query + " AND e.STATUS=?"; query = query + " AND DM_ENROLMENT.STATUS=?";
isStatusProvided = true; isStatusProvided = true;
} }

@ -535,21 +535,33 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
boolean isStatusProvided = false; boolean isStatusProvided = false;
StringJoiner joiner = new StringJoiner(",", StringJoiner joiner = new StringJoiner(",",
"SELECT " + "SELECT "
"f.ID AS DEVICE_ID, f.NAME AS DEVICE_NAME, f.DESCRIPTION AS DESCRIPTION, " + + "DM_DEVICE.ID AS DEVICE_ID, "
"f.DEVICE_TYPE_ID, f.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + + "DM_DEVICE.NAME AS DEVICE_NAME, "
"e.ID AS ENROLMENT_ID, e.OWNER, e.OWNERSHIP, e.DATE_OF_ENROLMENT, " + + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, "
"e.DATE_OF_LAST_UPDATE, e.STATUS, t.NAME AS DEVICE_TYPE " + + "DM_DEVICE.DEVICE_TYPE_ID, "
"FROM DM_ENROLMENT AS e,DM_DEVICE AS f, DM_DEVICE_TYPE t "+ + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, "
"WHERE " + + "DM_ENROLMENT.ID AS ENROLMENT_ID, "
"e.DEVICE_ID=f.ID AND " + + "DM_ENROLMENT.OWNER, "
"e.DEVICE_ID IN (", ") AND e.TENANT_ID=?"); + "DM_ENROLMENT.OWNERSHIP, "
+ "DM_ENROLMENT.DATE_OF_ENROLMENT, "
+ "DM_ENROLMENT.DATE_OF_LAST_UPDATE, "
+ "DM_ENROLMENT.STATUS, "
+ "device_types.NAME AS DEVICE_TYPE "
+ "FROM DM_DEVICE "
+ "INNER JOIN DM_ENROLMENT ON "
+ "DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID AND "
+ "DM_DEVICE.TENANT_ID = DM_ENROLMENT.TENANT_ID "
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "
+ "WHERE DM_DEVICE.ID IN (",
") AND DM_DEVICE.TENANT_ID = ?");
deviceIds.stream().map(ignored -> "?").forEach(joiner::add); deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
query = query + " AND e.STATUS=?"; query = query + " AND DM_ENROLMENT.STATUS=?";
isStatusProvided = true; isStatusProvided = true;
} }

Loading…
Cancel
Save