|
|
|
@ -53,7 +53,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|
|
|
|
String sql = "INSERT INTO DM_DEVICE(DESCRIPTION, NAME, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, " +
|
|
|
|
|
"LAST_UPDATED_TIMESTAMP, TENANT_ID) " +
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?)";
|
|
|
|
|
stmt = conn.prepareStatement(sql, new String[] {"id"});
|
|
|
|
|
stmt = conn.prepareStatement(sql, new String[]{"id"});
|
|
|
|
|
stmt.setString(1, device.getDescription());
|
|
|
|
|
stmt.setString(2, device.getName());
|
|
|
|
|
stmt.setInt(3, typeId);
|
|
|
|
@ -85,7 +85,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|
|
|
|
String sql = "UPDATE DM_DEVICE SET NAME = ?, DESCRIPTION = ?, LAST_UPDATED_TIMESTAMP = ? " +
|
|
|
|
|
"WHERE DEVICE_TYPE_ID = (SELECT ID FROM DM_DEVICE_TYPE WHERE NAME = ? AND PROVIDER_TENANT_ID = ?) " +
|
|
|
|
|
"AND DEVICE_IDENTIFICATION = ? AND TENANT_ID = ?";
|
|
|
|
|
stmt = conn.prepareStatement(sql, new String[] {"id"});
|
|
|
|
|
stmt = conn.prepareStatement(sql, new String[]{"id"});
|
|
|
|
|
stmt.setString(1, device.getName());
|
|
|
|
|
stmt.setString(2, device.getDescription());
|
|
|
|
|
stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
|
|
|
|
@ -154,7 +154,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|
|
|
|
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID 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, DM_DEVICE_DETAIL dt " +
|
|
|
|
|
"WHERE t.NAME = ? AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? AND dt.DEVICE_ID = d.ID " +
|
|
|
|
|
"AND dt.UPDATE_TIMESTAMP > ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?" ;
|
|
|
|
|
"AND dt.UPDATE_TIMESTAMP > ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?";
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
int paramIdx = 1;
|
|
|
|
|
stmt.setString(paramIdx++, deviceIdentifier.getType());
|
|
|
|
@ -716,7 +716,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|
|
|
|
conn = this.getConnection();
|
|
|
|
|
String sql = "INSERT INTO DM_ENROLMENT(DEVICE_ID, OWNER, OWNERSHIP, STATUS,DATE_OF_ENROLMENT, " +
|
|
|
|
|
"DATE_OF_LAST_UPDATE, TENANT_ID) VALUES(?, ?, ?, ?, ?, ?, ?)";
|
|
|
|
|
stmt = conn.prepareStatement(sql, new String[] {"id"});
|
|
|
|
|
stmt = conn.prepareStatement(sql, new String[]{"id"});
|
|
|
|
|
stmt.setInt(1, device.getId());
|
|
|
|
|
stmt.setString(2, device.getEnrolmentInfo().getOwner());
|
|
|
|
|
stmt.setString(3, device.getEnrolmentInfo().getOwnership().toString());
|
|
|
|
@ -1062,4 +1062,27 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|
|
|
|
return devices;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Integer> getDeviceEnrolledTenants() throws DeviceManagementDAOException {
|
|
|
|
|
Connection conn;
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
List<Integer> tenants = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getConnection();
|
|
|
|
|
String sql = "SELECT distinct(TENANT_ID) FROM DM_DEVICE";
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
tenants.add(rs.getInt("TENANT_ID"));
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving tenants which have " +
|
|
|
|
|
"device registered.", e);
|
|
|
|
|
} finally {
|
|
|
|
|
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
|
|
|
|
}
|
|
|
|
|
return tenants;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|