|
|
@ -42,8 +42,7 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
int deviceId = -1;
|
|
|
|
int deviceId = -1;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "INSERT INTO DM_DEVICE(DESCRIPTION, NAME, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, TENANT_ID) " +
|
|
|
|
"INSERT INTO DM_DEVICE(DESCRIPTION, NAME, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, TENANT_ID) " +
|
|
|
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?)";
|
|
|
|
"VALUES (?, ?, ?, ?, ?)";
|
|
|
|
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
|
|
|
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
|
|
|
stmt.setString(1, device.getDescription());
|
|
|
|
stmt.setString(1, device.getDescription());
|
|
|
@ -74,8 +73,7 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
int deviceId = -1;
|
|
|
|
int deviceId = -1;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "UPDATE DM_DEVICE SET DESCRIPTION = ?, NAME = ? WHERE DEVICE_IDENTIFICATION = ? AND " +
|
|
|
|
"UPDATE DM_DEVICE SET DESCRIPTION = ?, NAME = ? WHERE DEVICE_IDENTIFICATION = ? AND " +
|
|
|
|
|
|
|
|
"DEVICE_TYPE_ID = ? AND TENANT_ID = ?";
|
|
|
|
"DEVICE_TYPE_ID = ? AND TENANT_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
|
|
|
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
|
|
|
stmt.setString(1, device.getDescription());
|
|
|
|
stmt.setString(1, device.getDescription());
|
|
|
@ -111,10 +109,9 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
Device device = null;
|
|
|
|
Device device = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
|
|
|
|
"SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, d1.DEVICE_IDENTIFICATION, " +
|
|
|
|
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
|
|
|
|
"e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " +
|
|
|
|
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " +
|
|
|
|
"FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " +
|
|
|
|
|
|
|
|
"t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " +
|
|
|
|
"t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " +
|
|
|
|
"t.NAME = ? AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " +
|
|
|
|
"t.NAME = ? AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " +
|
|
|
|
"AND TENANT_ID = ?";
|
|
|
|
"AND TENANT_ID = ?";
|
|
|
@ -144,12 +141,12 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
List<Device> devices = null;
|
|
|
|
List<Device> devices = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
|
|
|
|
"SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, d1.DEVICE_IDENTIFICATION, " +
|
|
|
|
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
|
|
|
|
"e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " +
|
|
|
|
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID AS DEVICE_ID, " +
|
|
|
|
"FROM DM_ENROLMENT e, (SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME," +
|
|
|
|
"d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " +
|
|
|
|
"d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t " +
|
|
|
|
"DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?) d1 " +
|
|
|
|
"WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?";
|
|
|
|
"WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
@ -176,12 +173,12 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
List<Device> devices = null;
|
|
|
|
List<Device> devices = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
|
|
|
|
"SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, d1.DEVICE_IDENTIFICATION, " +
|
|
|
|
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
|
|
|
|
"e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " +
|
|
|
|
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, " +
|
|
|
|
"FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, t.NAME " +
|
|
|
|
"d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " +
|
|
|
|
"AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND t.NAME = ? " +
|
|
|
|
"DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND t.NAME = ? " +
|
|
|
|
"AND d.TENANT_ID = ?) d1 WHERE DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?";
|
|
|
|
"AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, type);
|
|
|
|
stmt.setString(1, type);
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
@ -207,11 +204,10 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
List<Device> devices = new ArrayList<>();
|
|
|
|
List<Device> devices = new ArrayList<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
|
|
|
|
"SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
|
|
|
|
|
|
|
|
"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 t.NAME AS DEVICE_TYPE, d.ID, d.DESCRIPTION, " +
|
|
|
|
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT t.NAME AS DEVICE_TYPE, " +
|
|
|
|
"d.NAME, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t " +
|
|
|
|
"d.ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t " +
|
|
|
|
"WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?) d1 " +
|
|
|
|
"WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?) d1 " +
|
|
|
|
"WHERE DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? AND e.OWNER = ?";
|
|
|
|
"WHERE DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? AND e.OWNER = ?";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
@ -281,12 +277,12 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
List<Device> devices = new ArrayList<>();
|
|
|
|
List<Device> devices = new ArrayList<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
|
|
|
|
"SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, d1.DEVICE_IDENTIFICATION, " +
|
|
|
|
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
|
|
|
|
"e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " +
|
|
|
|
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, " +
|
|
|
|
"FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, d.DESCRIPTION, t.NAME AS DEVICE_TYPE, " +
|
|
|
|
"d.DESCRIPTION, t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, " +
|
|
|
|
"d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID " +
|
|
|
|
"DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.NAME LIKE ? AND d.TENANT_ID = ?) d1 " +
|
|
|
|
"AND d.NAME LIKE ? AND d.TENANT_ID = ?) d1 WHERE DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?";
|
|
|
|
"WHERE DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, deviceName + "%");
|
|
|
|
stmt.setString(1, deviceName + "%");
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
@ -314,9 +310,8 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
int enrolmentId = -1;
|
|
|
|
int enrolmentId = -1;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "INSERT INTO DM_ENROLMENT(DEVICE_ID, OWNER, OWNERSHIP, STATUS,DATE_OF_ENROLMENT, " +
|
|
|
|
"INSERT INTO DM_ENROLMENT(DEVICE_ID, OWNER, OWNERSHIP, STATUS,DATE_OF_ENROLMENT, DATE_OF_LAST_UPDATE, " +
|
|
|
|
"DATE_OF_LAST_UPDATE, TENANT_ID) VALUES(?, ?, ?, ?, ?, ?, ?)";
|
|
|
|
"TENANT_ID) VALUES(?, ?, ?, ?, ?, ?, ?)";
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
|
|
|
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
|
|
|
stmt.setInt(1, device.getId());
|
|
|
|
stmt.setInt(1, device.getId());
|
|
|
|
stmt.setString(2, device.getEnrolmentInfo().getOwner());
|
|
|
|
stmt.setString(2, device.getEnrolmentInfo().getOwner());
|
|
|
@ -346,10 +341,9 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "UPDATE DM_ENROLMENT SET STATUS = ? WHERE DEVICE_ID = (SELECT d.ID FROM DM_DEVICE d, " +
|
|
|
|
"UPDATE DM_ENROLMENT SET STATUS = ? WHERE DEVICE_ID = (SELECT d.ID FROM DM_DEVICE d, DM_DEVICE_TYPE t " +
|
|
|
|
"DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.DEVICE_IDENTIFICATION = ? " +
|
|
|
|
"WHERE d.DEVICE_TYPE_ID = t.ID AND d.DEVICE_IDENTIFICATION = ? AND t.NAME = ? AND d.TENANT_ID = ?) " +
|
|
|
|
"AND t.NAME = ? AND d.TENANT_ID = ?) AND OWNER = ? AND TENANT_ID = ?";
|
|
|
|
"AND OWNER = ? AND TENANT_ID = ?";
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, status.toString());
|
|
|
|
stmt.setString(1, status.toString());
|
|
|
|
stmt.setString(2, deviceId.getId());
|
|
|
|
stmt.setString(2, deviceId.getId());
|
|
|
@ -375,10 +369,9 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
Status status = null;
|
|
|
|
Status status = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "SELECT STATUS FROM DM_ENROLMENT WHERE DEVICE_ID = (SELECT d.ID FROM DM_DEVICE d, " +
|
|
|
|
"SELECT STATUS FROM DM_ENROLMENT WHERE DEVICE_ID = " +
|
|
|
|
"DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.DEVICE_IDENTIFICATION = ? " +
|
|
|
|
"(SELECT d.ID FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND " +
|
|
|
|
"AND t.NAME = ? AND d.TENANT_ID = ?) AND OWNER = ? AND TENANT_ID = ?";
|
|
|
|
"d.DEVICE_IDENTIFICATION = ? AND t.NAME = ? AND d.TENANT_ID = ?) AND OWNER = ? AND TENANT_ID = ?";
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, deviceId.getId());
|
|
|
|
stmt.setString(1, deviceId.getId());
|
|
|
|
stmt.setString(2, deviceId.getType());
|
|
|
|
stmt.setString(2, deviceId.getType());
|
|
|
@ -407,10 +400,10 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
EnrolmentInfo enrolmentInfo = null;
|
|
|
|
EnrolmentInfo enrolmentInfo = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "SELECT ID AS ENROLMENT_ID, DEVICE_ID, OWNER, OWNERSHIP, STATUS, DATE_OF_ENROLMENT, " +
|
|
|
|
"SELECT ID AS ENROLMENT_ID, DEVICE_ID, OWNER, OWNERSHIP, STATUS, DATE_OF_ENROLMENT, DATE_OF_LAST_UPDATE, " +
|
|
|
|
"DATE_OF_LAST_UPDATE, TENANT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = (SELECT d.ID " +
|
|
|
|
"TENANT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = (SELECT d.ID FROM DM_DEVICE d, DM_DEVICE_TYPE t " +
|
|
|
|
"FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID " +
|
|
|
|
"WHERE d.DEVICE_TYPE_ID = t.ID AND d.DEVICE_IDENTIFICATION = ? AND t.NAME = ? AND d.TENANT_ID = ?) " +
|
|
|
|
"AND d.DEVICE_IDENTIFICATION = ? AND t.NAME = ? AND d.TENANT_ID = ?) " +
|
|
|
|
"AND OWNER = ? AND TENANT_ID = ?";
|
|
|
|
"AND OWNER = ? AND TENANT_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, deviceId.getId());
|
|
|
|
stmt.setString(1, deviceId.getId());
|
|
|
@ -438,10 +431,10 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
ResultSet rs = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "SELECT ID AS ENROLMENT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = (SELECT d.ID " +
|
|
|
|
"SELECT ID AS ENROLMENT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = (SELECT d.ID FROM DM_DEVICE d, " +
|
|
|
|
"FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID " +
|
|
|
|
"DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.DEVICE_IDENTIFICATION = ? AND t.NAME = ? " +
|
|
|
|
"AND d.DEVICE_IDENTIFICATION = ? AND t.NAME = ? AND d.TENANT_ID = ?) " +
|
|
|
|
"AND d.TENANT_ID = ?) AND STATUS = ? AND TENANT_ID = ?";
|
|
|
|
"AND STATUS = ? AND TENANT_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, deviceId.getId());
|
|
|
|
stmt.setString(1, deviceId.getId());
|
|
|
|
stmt.setString(2, deviceId.getType());
|
|
|
|
stmt.setString(2, deviceId.getType());
|
|
|
@ -491,13 +484,12 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
List<Device> devices = new ArrayList<>();
|
|
|
|
List<Device> devices = new ArrayList<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql = "SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME AS DEVICE_NAME, t.NAME AS DEVICE_TYPE, " +
|
|
|
|
"SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME AS DEVICE_NAME, t.NAME AS DEVICE_TYPE, " +
|
|
|
|
|
|
|
|
"d.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
|
|
|
|
"d.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
|
|
|
|
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM (SELECT e.ID, e.DEVICE_ID, e.OWNER, e.OWNERSHIP, e.STATUS, " +
|
|
|
|
"e.DATE_OF_ENROLMENT FROM (SELECT e.ID, e.DEVICE_ID, e.OWNER, e.OWNERSHIP, e.STATUS, " +
|
|
|
|
"e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE FROM DM_ENROLMENT e WHERE TENANT_ID = ? " +
|
|
|
|
"e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e " +
|
|
|
|
"AND STATUS = ?) e, DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_ID = e.DEVICE_ID " +
|
|
|
|
"WHERE TENANT_ID = ? AND STATUS = ?) e, DM_DEVICE d, DM_DEVICE_TYPE t " +
|
|
|
|
"AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
|
|
|
"WHERE DEVICE_ID = e.DEVICE_ID AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
stmt.setString(2, status.toString());
|
|
|
|
stmt.setString(2, status.toString());
|
|
|
|