mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fixed EMM-1518
This commit is contained in:
parent
28c28475d4
commit
624bf7c7b4
@ -421,9 +421,18 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String sql = "SELECT COUNT(d1.ID) AS DEVICE_COUNT FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, d.DEVICE_IDENTIFICATION, " +
|
String sql = "SELECT COUNT(d1.ID) AS DEVICE_COUNT FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, d.DEVICE_IDENTIFICATION, " +
|
||||||
"t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_DETAIL dt WHERE DEVICE_TYPE_ID = t.ID " +
|
"t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t";
|
||||||
"AND d.TENANT_ID = ? AND dt.DEVICE_ID = d.ID";
|
|
||||||
|
|
||||||
|
//Add query for last updated timestamp
|
||||||
|
if (since != null) {
|
||||||
|
sql = sql + " , DM_DEVICE_DETAIL dt";
|
||||||
|
isSinceProvided = true;
|
||||||
|
}
|
||||||
|
sql = sql + " WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
||||||
|
//Add query for last updated timestamp
|
||||||
|
if (isSinceProvided) {
|
||||||
|
sql = sql + " AND dt.DEVICE_ID = d.ID AND dt.UPDATE_TIMESTAMP > ?";
|
||||||
|
}
|
||||||
if (deviceType != null && !deviceType.isEmpty()) {
|
if (deviceType != null && !deviceType.isEmpty()) {
|
||||||
sql = sql + " AND t.NAME = ?";
|
sql = sql + " AND t.NAME = ?";
|
||||||
isDeviceTypeProvided = true;
|
isDeviceTypeProvided = true;
|
||||||
@ -434,12 +443,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
isDeviceNameProvided = true;
|
isDeviceNameProvided = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add query for last updated timestamp
|
|
||||||
if (since != null) {
|
|
||||||
sql = sql + " AND dt.UPDATE_TIMESTAMP > ?";
|
|
||||||
isSinceProvided = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sql = sql + ") d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?";
|
sql = sql + ") d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?";
|
||||||
|
|
||||||
if (ownership != null && !ownership.isEmpty()) {
|
if (ownership != null && !ownership.isEmpty()) {
|
||||||
@ -460,15 +463,16 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
stmt.setInt(1, tenantId);
|
stmt.setInt(1, tenantId);
|
||||||
int paramIdx = 2;
|
int paramIdx = 2;
|
||||||
|
if (isSinceProvided) {
|
||||||
|
stmt.setLong(paramIdx++, since.getTime());
|
||||||
|
}
|
||||||
if (isDeviceTypeProvided) {
|
if (isDeviceTypeProvided) {
|
||||||
stmt.setString(paramIdx++, request.getDeviceType());
|
stmt.setString(paramIdx++, request.getDeviceType());
|
||||||
}
|
}
|
||||||
if (isDeviceNameProvided) {
|
if (isDeviceNameProvided) {
|
||||||
stmt.setString(paramIdx++, request.getDeviceName() + "%");
|
stmt.setString(paramIdx++, request.getDeviceName() + "%");
|
||||||
}
|
}
|
||||||
if (isSinceProvided) {
|
|
||||||
stmt.setLong(paramIdx++, since.getTime());
|
|
||||||
}
|
|
||||||
stmt.setInt(paramIdx++, tenantId);
|
stmt.setInt(paramIdx++, tenantId);
|
||||||
if (isOwnershipProvided) {
|
if (isOwnershipProvided) {
|
||||||
stmt.setString(paramIdx++, request.getOwnership());
|
stmt.setString(paramIdx++, request.getOwnership());
|
||||||
|
|||||||
@ -31,7 +31,6 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* This class holds the generic implementation of DeviceDAO which can be used to support ANSI db syntax.
|
* This class holds the generic implementation of DeviceDAO which can be used to support ANSI db syntax.
|
||||||
*/
|
*/
|
||||||
public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||||
@ -61,8 +60,20 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
|
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
|
||||||
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, " +
|
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, " +
|
||||||
"d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE " +
|
"d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE " +
|
||||||
"FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_DETAIL dt " +
|
"FROM DM_DEVICE d, DM_DEVICE_TYPE t ";
|
||||||
"WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? AND dt.DEVICE_ID = d.ID";
|
|
||||||
|
//Add the query to filter active devices on timestamp
|
||||||
|
if (since != null) {
|
||||||
|
sql = sql + ", DM_DEVICE_DETAIL dt";
|
||||||
|
isSinceProvided = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sql = sql + " WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
||||||
|
|
||||||
|
//Add query for last updated timestamp
|
||||||
|
if (isSinceProvided) {
|
||||||
|
sql = sql + " AND dt.DEVICE_ID = d.ID AND dt.UPDATE_TIMESTAMP > ?";
|
||||||
|
}
|
||||||
|
|
||||||
//Add the query for device-type
|
//Add the query for device-type
|
||||||
if (deviceType != null && !deviceType.isEmpty()) {
|
if (deviceType != null && !deviceType.isEmpty()) {
|
||||||
@ -75,12 +86,6 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
isDeviceNameProvided = true;
|
isDeviceNameProvided = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add query for last updated timestamp
|
|
||||||
if (since != null) {
|
|
||||||
sql = sql + " AND dt.UPDATE_TIMESTAMP > ?";
|
|
||||||
isSinceProvided = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sql = sql + ") d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?";
|
sql = sql + ") d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?";
|
||||||
|
|
||||||
//Add the query for ownership
|
//Add the query for ownership
|
||||||
@ -104,15 +109,16 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
stmt.setInt(1, tenantId);
|
stmt.setInt(1, tenantId);
|
||||||
int paramIdx = 2;
|
int paramIdx = 2;
|
||||||
|
if (isSinceProvided) {
|
||||||
|
stmt.setLong(paramIdx++, since.getTime());
|
||||||
|
}
|
||||||
if (isDeviceTypeProvided) {
|
if (isDeviceTypeProvided) {
|
||||||
stmt.setString(paramIdx++, request.getDeviceType());
|
stmt.setString(paramIdx++, request.getDeviceType());
|
||||||
}
|
}
|
||||||
if (isDeviceNameProvided) {
|
if (isDeviceNameProvided) {
|
||||||
stmt.setString(paramIdx++, request.getDeviceName() + "%");
|
stmt.setString(paramIdx++, request.getDeviceName() + "%");
|
||||||
}
|
}
|
||||||
if (isSinceProvided) {
|
|
||||||
stmt.setLong(paramIdx++, since.getTime());
|
|
||||||
}
|
|
||||||
stmt.setInt(paramIdx++, tenantId);
|
stmt.setInt(paramIdx++, tenantId);
|
||||||
if (isOwnershipProvided) {
|
if (isOwnershipProvided) {
|
||||||
stmt.setString(paramIdx++, request.getOwnership());
|
stmt.setString(paramIdx++, request.getOwnership());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user