"AS DEVICE_TYPE FROM DM_DEVICE d, 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 = ?";
stmt=conn.prepareStatement(sql);
stmt.setString(1,type);
stmt.setInt(2,tenantId);
stmt.setInt(3,tenantId);
@ -204,14 +211,17 @@ public class DeviceDAOImpl implements DeviceDAO {
List<Device>devices=newArrayList<Device>();
try{
conn=this.getConnection();
stmt=conn.prepareStatement(
"SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, d.DEVICE_IDENTIFICATION"+
" e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e, (SELECT t.NAME AS DEVICE_TYPE, 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.OWNER =? AND d.TENANT_ID = ?) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?");
stmt.setString(1,username);
Stringsql=
"SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, "+
"e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e, (SELECT t.NAME AS DEVICE_TYPE, 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 DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? AND e.OWNER = ?";
stmt=conn.prepareStatement(sql);
stmt.setInt(1,tenantId);
stmt.setInt(2,tenantId);
stmt.setInt(3,tenantId);
stmt.setString(3,username);
ResultSetrs=stmt.executeQuery();
while(rs.next()){
@ -275,16 +285,16 @@ public class DeviceDAOImpl implements DeviceDAO {
List<Device>devices=newArrayList<Device>();
try{
conn=this.getConnection();
stmt=conn.prepareStatement(
"SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, d.DEVICE_IDENTIFICATION "+
"e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e, (SELECT d.ID AS DEVICE_ID, d.NAME, d.DESCRIPTION, "+
"t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM "+
"DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID "+
"AND d.NAME LIKE ? AND d.TENANT_ID = ?) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?");
Stringsql=
"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, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID "+
"FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, d.DESCRIPTION, t.NAME AS DEVICE_TYPE, "+
"d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID "+
"AND d.NAME LIKE ? AND d.TENANT_ID = ?) d1 WHERE DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?";
stmt=conn.prepareStatement(sql);
stmt.setString(1,deviceName+"%");
stmt.setInt(2,tenantId);
stmt.setInt(3,tenantId);
stmt.setInt(4,tenantId);
ResultSetrs=stmt.executeQuery();
while(rs.next()){
@ -308,8 +318,9 @@ public class DeviceDAOImpl implements DeviceDAO {
intenrolmentId=-1;
try{
conn=this.getConnection();
Stringsql="INSERT INTO DM_ENROLMENT(DEVICE_ID, OWNER, OWNERSHIP, STATUS, "+