|
|
@ -416,11 +416,13 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|
|
|
boolean isOwnershipProvided = false;
|
|
|
|
boolean isOwnershipProvided = false;
|
|
|
|
String status = request.getStatus();
|
|
|
|
String status = request.getStatus();
|
|
|
|
boolean isStatusProvided = false;
|
|
|
|
boolean isStatusProvided = false;
|
|
|
|
|
|
|
|
Date since = request.getSince();
|
|
|
|
|
|
|
|
boolean isSinceProvided = false;
|
|
|
|
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 WHERE DEVICE_TYPE_ID = t.ID " +
|
|
|
|
"t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_DETAIL dt WHERE DEVICE_TYPE_ID = t.ID " +
|
|
|
|
"AND d.TENANT_ID = ?";
|
|
|
|
"AND d.TENANT_ID = ? AND dt.DEVICE_ID = d.ID";
|
|
|
|
|
|
|
|
|
|
|
|
if (deviceType != null && !deviceType.isEmpty()) {
|
|
|
|
if (deviceType != null && !deviceType.isEmpty()) {
|
|
|
|
sql = sql + " AND t.NAME = ?";
|
|
|
|
sql = sql + " AND t.NAME = ?";
|
|
|
@ -432,6 +434,12 @@ 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()) {
|
|
|
@ -458,6 +466,9 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|
|
|
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());
|
|
|
|