Fix issues in get devices method

stream-api
prathabanKavin 4 months ago
parent aa9f3da380
commit 2021a0b37a

@ -1484,34 +1484,35 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
stmt.setInt(3, limit); stmt.setInt(3, limit);
stmt.setInt(4, offset); stmt.setInt(4, offset);
try (ResultSet rs = stmt.executeQuery()) { try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) { while (rs.next()) {
if (groupDetails.getGroupId() == 0) { if (groupDetails.getGroupId() == 0) {
groupDetails.setGroupId(rs.getInt("GROUP_ID")); groupDetails.setGroupId(rs.getInt("GROUP_ID"));
groupDetails.setGroupName(rs.getString("GROUP_NAME")); groupDetails.setGroupName(rs.getString("GROUP_NAME"));
groupDetails.setGroupOwner(rs.getString("GROUP_OWNER")); groupDetails.setGroupOwner(rs.getString("GROUP_OWNER"));
}
int deviceId = rs.getInt("DEVICE_ID");
deviceIds.add(deviceId);
deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER"));
deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS"));
deviceNames.put(deviceId, rs.getString("DEVICE_NAME"));
deviceTypes.put(deviceId, rs.getString("DEVICE_TYPE"));
deviceIdentifiers.put(deviceId, rs.getString("DEVICE_IDENTIFICATION"));
} }
int deviceId = rs.getInt("DEVICE_ID");
deviceIds.add(deviceId);
deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER"));
deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS"));
deviceNames.put(deviceId, rs.getString("DEVICE_NAME"));
deviceTypes.put(deviceId, rs.getString("DEVICE_TYPE"));
deviceIdentifiers.put(deviceId, rs.getString("DEVICE_IDENTIFICATION"));
} }
} groupDetails.setDeviceIds(deviceIds);
} catch (SQLException e) { groupDetails.setDeviceCount(deviceIds.size());
String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; groupDetails.setDeviceOwners(deviceOwners);
log.error(msg, e); groupDetails.setDeviceStatuses(deviceStatuses);
throw new GroupManagementDAOException(msg, e); groupDetails.setDeviceNames(deviceNames);
groupDetails.setDeviceTypes(deviceTypes);
groupDetails.setDeviceIdentifiers(deviceIdentifiers);
return groupDetails;
} }
groupDetails.setDeviceIds(deviceIds); } catch (SQLException e) {
groupDetails.setDeviceCount(deviceIds.size()); String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName;
groupDetails.setDeviceOwners(deviceOwners); log.error(msg, e);
groupDetails.setDeviceStatuses(deviceStatuses); throw new GroupManagementDAOException(msg, e);
groupDetails.setDeviceNames(deviceNames); }
groupDetails.setDeviceTypes(deviceTypes);
groupDetails.setDeviceIdentifiers(deviceIdentifiers);
return groupDetails;
} }
} }

Loading…
Cancel
Save