Fixing the isssue in retrieving the device info

revert-70aa11f8
geethkokila 9 years ago
parent 016414c076
commit 626142a59b

@ -60,7 +60,7 @@ public class SearchDAOImpl implements SearchDAO {
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
while (rs.next()) { while (rs.next()) {
if(!devs.containsKey(rs.getInt("ID"))) { if (!devs.containsKey(rs.getInt("ID"))) {
Device device = new Device(); Device device = new Device();
device.setId(rs.getInt("ID")); device.setId(rs.getInt("ID"));
device.setDescription(rs.getString("DESCRIPTION")); device.setDescription(rs.getString("DESCRIPTION"));
@ -142,7 +142,7 @@ public class SearchDAOImpl implements SearchDAO {
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
while (rs.next()) { while (rs.next()) {
if(!devs.containsKey(rs.getInt("ID"))) { if (!devs.containsKey(rs.getInt("ID"))) {
Device device = new Device(); Device device = new Device();
device.setId(rs.getInt("ID")); device.setId(rs.getInt("ID"));
device.setDescription(rs.getString("DESCRIPTION")); device.setDescription(rs.getString("DESCRIPTION"));
@ -238,20 +238,11 @@ public class SearchDAOImpl implements SearchDAO {
} }
rs = stmt.executeQuery(); rs = stmt.executeQuery();
int deviceId = 0; DeviceInfo dInfo;
while (rs.next()) { while (rs.next()) {
DeviceInfo dInfo = new DeviceInfo(); dInfo = this.getDeviceInfo(devices, rs.getInt("DEVICE_ID"));
if (deviceId != rs.getInt("DEVICE_ID")) {
deviceId = rs.getInt("DEVICE_ID");
dInfo = this.getDeviceInfo(devices, deviceId);
if (dInfo != null) {
dInfo.getDeviceDetailsMap().put(rs.getString("KEY_FIELD"), rs.getString("VALUE_FIELD"));
}
} else {
dInfo.getDeviceDetailsMap().put(rs.getString("KEY_FIELD"), rs.getString("VALUE_FIELD")); dInfo.getDeviceDetailsMap().put(rs.getString("KEY_FIELD"), rs.getString("VALUE_FIELD"));
} }
}
} catch (SQLException e) { } catch (SQLException e) {
throw new SearchDAOException("Error occurred while retrieving the device properties.", e); throw new SearchDAOException("Error occurred while retrieving the device properties.", e);
} }
@ -262,6 +253,9 @@ public class SearchDAOImpl implements SearchDAO {
for (DeviceWrapper dw : devices) { for (DeviceWrapper dw : devices) {
if (dw.getDevice().getId() == deviceId) { if (dw.getDevice().getId() == deviceId) {
if (dw.getDeviceInfo() == null) {
dw.setDeviceInfo(new DeviceInfo());
}
return dw.getDeviceInfo(); return dw.getDeviceInfo();
} }
} }

Loading…
Cancel
Save