|
|
@ -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());
|
|
|
|