|
|
@ -878,7 +878,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
|
|
|
|
public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
|
|
|
|
List<Integer> deviceIds, int tenantId, String status)
|
|
|
|
List<Integer> deviceIds, int tenantId, List<String> status)
|
|
|
|
throws DeviceManagementDAOException {
|
|
|
|
throws DeviceManagementDAOException {
|
|
|
|
Connection conn;
|
|
|
|
Connection conn;
|
|
|
|
|
|
|
|
|
|
|
@ -894,18 +894,18 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|
|
|
+ "DM_DEVICE.DESCRIPTION AS DESCRIPTION, "
|
|
|
|
+ "DM_DEVICE.DESCRIPTION AS DESCRIPTION, "
|
|
|
|
+ "DM_DEVICE.DEVICE_TYPE_ID, "
|
|
|
|
+ "DM_DEVICE.DEVICE_TYPE_ID, "
|
|
|
|
+ "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, "
|
|
|
|
+ "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, "
|
|
|
|
+ "DM_ENROLMENT.ID AS ENROLMENT_ID, "
|
|
|
|
+ "e.ID AS ENROLMENT_ID, "
|
|
|
|
+ "DM_ENROLMENT.OWNER, "
|
|
|
|
+ "e.OWNER, "
|
|
|
|
+ "DM_ENROLMENT.OWNERSHIP, "
|
|
|
|
+ "e.OWNERSHIP, "
|
|
|
|
+ "DM_ENROLMENT.DATE_OF_ENROLMENT, "
|
|
|
|
+ "e.DATE_OF_ENROLMENT, "
|
|
|
|
+ "DM_ENROLMENT.DATE_OF_LAST_UPDATE, "
|
|
|
|
+ "e.DATE_OF_LAST_UPDATE, "
|
|
|
|
+ "DM_ENROLMENT.STATUS, "
|
|
|
|
+ "e.STATUS, "
|
|
|
|
+ "DM_ENROLMENT.IS_TRANSFERRED, "
|
|
|
|
+ "e.IS_TRANSFERRED, "
|
|
|
|
+ "device_types.NAME AS DEVICE_TYPE "
|
|
|
|
+ "device_types.NAME AS DEVICE_TYPE "
|
|
|
|
+ "FROM DM_DEVICE "
|
|
|
|
+ "FROM DM_DEVICE "
|
|
|
|
+ "INNER JOIN DM_ENROLMENT ON "
|
|
|
|
+ "INNER JOIN DM_ENROLMENT e ON "
|
|
|
|
+ "DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID AND "
|
|
|
|
+ "DM_DEVICE.ID = e.DEVICE_ID AND "
|
|
|
|
+ "DM_DEVICE.TENANT_ID = DM_ENROLMENT.TENANT_ID "
|
|
|
|
+ "DM_DEVICE.TENANT_ID = e.TENANT_ID "
|
|
|
|
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
|
|
|
|
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
|
|
|
|
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "
|
|
|
|
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "
|
|
|
|
+ "WHERE DM_DEVICE.ID IN (",
|
|
|
|
+ "WHERE DM_DEVICE.ID IN (",
|
|
|
@ -914,8 +914,13 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|
|
|
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()) {
|
|
|
|
|
|
|
|
// query = query + " AND DM_ENROLMENT.STATUS=?";
|
|
|
|
|
|
|
|
// isStatusProvided = true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
if (status != null && !status.isEmpty()) {
|
|
|
|
if (status != null && !status.isEmpty()) {
|
|
|
|
query = query + " AND DM_ENROLMENT.STATUS=?";
|
|
|
|
query += buildStatusQuery(status);
|
|
|
|
isStatusProvided = true;
|
|
|
|
isStatusProvided = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -929,7 +934,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|
|
|
|
|
|
|
|
|
|
|
ps.setInt(index++, tenantId);
|
|
|
|
ps.setInt(index++, tenantId);
|
|
|
|
if (isStatusProvided) {
|
|
|
|
if (isStatusProvided) {
|
|
|
|
ps.setString(index++, status);
|
|
|
|
for (String deviceStatus : status) {
|
|
|
|
|
|
|
|
ps.setString(index++, deviceStatus);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ps.setInt(index++, offsetValue);
|
|
|
|
ps.setInt(index++, offsetValue);
|
|
|
|
ps.setInt(index, limitValue);
|
|
|
|
ps.setInt(index, limitValue);
|
|
|
@ -951,7 +958,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, String status)
|
|
|
|
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
|
|
|
|
throws DeviceManagementDAOException {
|
|
|
|
throws DeviceManagementDAOException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = this.getConnection();
|
|
|
|
Connection conn = this.getConnection();
|
|
|
@ -967,8 +974,12 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|
|
|
deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
|
|
|
|
deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
|
|
|
|
String query = joiner.toString();
|
|
|
|
String query = joiner.toString();
|
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isBlank(status)) {
|
|
|
|
// if (!StringUtils.isBlank(status)) {
|
|
|
|
query = query + " AND e.STATUS = ?";
|
|
|
|
// query = query + " AND e.STATUS = ?";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (status != null && !status.isEmpty()) {
|
|
|
|
|
|
|
|
query += buildStatusQuery(status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
|
|
|
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
|
|
@ -977,8 +988,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ps.setInt(index++, tenantId);
|
|
|
|
ps.setInt(index++, tenantId);
|
|
|
|
if (!StringUtils.isBlank(status)) {
|
|
|
|
if (status != null && !status.isEmpty()) {
|
|
|
|
ps.setString(index, status);
|
|
|
|
for (String deviceStatus : status) {
|
|
|
|
|
|
|
|
ps.setString(index++, deviceStatus);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try (ResultSet rs = ps.executeQuery()) {
|
|
|
|
try (ResultSet rs = ps.executeQuery()) {
|
|
|
|