|
|
|
@ -575,7 +575,6 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
|
|
|
|
|
"FROM DM_ENROLMENT e " +
|
|
|
|
|
"JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " +
|
|
|
|
|
"WHERE e.OWNER = ? AND e.TENANT_ID = ?";
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getConnection();
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
@ -609,25 +608,26 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
|
|
|
|
|
public OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId, int tenantId)
|
|
|
|
|
throws DeviceManagementDAOException {
|
|
|
|
|
OwnerWithDeviceDTO deviceOwnerWithStatus = new OwnerWithDeviceDTO();
|
|
|
|
|
|
|
|
|
|
Connection conn = null;
|
|
|
|
|
String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME " +
|
|
|
|
|
"FROM DM_ENROLMENT e " +
|
|
|
|
|
"JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " +
|
|
|
|
|
"WHERE e.DEVICE_ID = ? AND e.TENANT_ID = ?";
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getConnection();
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
|
stmt.setInt(1, deviceId);
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
|
|
|
|
|
try (Connection conn = this.getConnection();
|
|
|
|
|
PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
|
stmt.setInt(1, deviceId);
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
|
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
deviceOwnerWithStatus.setUserName(rs.getString("OWNER"));
|
|
|
|
|
deviceOwnerWithStatus.setDeviceStatus(rs.getString("DEVICE_STATUS"));
|
|
|
|
|
List<Integer> deviceIds = new ArrayList<>();
|
|
|
|
|
deviceIds.add(rs.getInt("DEVICE_ID"));
|
|
|
|
|
deviceOwnerWithStatus.setDeviceIds(deviceIds);
|
|
|
|
|
deviceOwnerWithStatus.setDeviceNames(rs.getString("DEVICE_NAME"));
|
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
deviceOwnerWithStatus.setUserName(rs.getString("OWNER"));
|
|
|
|
|
deviceOwnerWithStatus.setDeviceStatus(rs.getString("DEVICE_STATUS"));
|
|
|
|
|
List<Integer> deviceIds = new ArrayList<>();
|
|
|
|
|
deviceIds.add(rs.getInt("DEVICE_ID"));
|
|
|
|
|
deviceOwnerWithStatus.setDeviceIds(deviceIds);
|
|
|
|
|
deviceOwnerWithStatus.setDeviceNames(rs.getString("DEVICE_NAME"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|