|
|
@ -34,7 +34,9 @@ import org.wso2.carbon.device.mgt.core.search.mgt.impl.Utils;
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.*;
|
|
|
|
import java.sql.*;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class SearchDAOImpl implements SearchDAO {
|
|
|
|
public class SearchDAOImpl implements SearchDAO {
|
|
|
@ -52,59 +54,62 @@ public class SearchDAOImpl implements SearchDAO {
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet rs;
|
|
|
|
ResultSet rs;
|
|
|
|
List<DeviceWrapper> devices = new ArrayList<>();
|
|
|
|
List<DeviceWrapper> devices = new ArrayList<>();
|
|
|
|
|
|
|
|
Map<Integer, Integer> devs = new HashMap<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
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"))) {
|
|
|
|
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"));
|
|
|
|
device.setName("NAME");
|
|
|
|
device.setName("NAME");
|
|
|
|
device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
|
|
device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
|
|
device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
|
|
|
device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
|
|
|
|
|
|
|
|
|
|
|
DeviceIdentifier identifier = new DeviceIdentifier();
|
|
|
|
DeviceIdentifier identifier = new DeviceIdentifier();
|
|
|
|
identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
|
|
identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
|
|
identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
|
|
|
identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
|
|
|
|
|
|
|
|
|
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
|
|
deviceInfo.setDeviceId(rs.getInt("ID"));
|
|
|
|
deviceInfo.setDeviceId(rs.getInt("ID"));
|
|
|
|
deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
|
|
|
deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
|
|
|
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
|
|
|
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
|
|
|
deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
|
|
|
deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
|
|
|
deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
|
|
|
deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
|
|
|
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
|
|
|
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
|
|
|
deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
|
|
|
deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
|
|
|
deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
|
|
|
deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
|
|
|
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
|
|
|
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
|
|
|
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
|
|
|
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
|
|
|
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
|
|
|
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
|
|
|
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
|
|
|
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
|
|
|
deviceInfo.setSsid(rs.getString("SSID"));
|
|
|
|
deviceInfo.setSsid(rs.getString("SSID"));
|
|
|
|
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
|
|
|
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
|
|
|
deviceInfo.setVendor(rs.getString("VENDOR"));
|
|
|
|
deviceInfo.setVendor(rs.getString("VENDOR"));
|
|
|
|
deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
|
|
|
deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
|
|
|
|
|
|
|
|
|
|
|
DeviceLocation deviceLocation = new DeviceLocation();
|
|
|
|
DeviceLocation deviceLocation = new DeviceLocation();
|
|
|
|
deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
|
|
|
deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
|
|
|
deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
|
|
|
deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
|
|
|
deviceLocation.setStreet1(rs.getString("STREET1"));
|
|
|
|
deviceLocation.setStreet1(rs.getString("STREET1"));
|
|
|
|
deviceLocation.setStreet2(rs.getString("STREET2"));
|
|
|
|
deviceLocation.setStreet2(rs.getString("STREET2"));
|
|
|
|
deviceLocation.setCity(rs.getString("CITY"));
|
|
|
|
deviceLocation.setCity(rs.getString("CITY"));
|
|
|
|
deviceLocation.setState(rs.getString("STATE"));
|
|
|
|
deviceLocation.setState(rs.getString("STATE"));
|
|
|
|
deviceLocation.setZip(rs.getString("ZIP"));
|
|
|
|
deviceLocation.setZip(rs.getString("ZIP"));
|
|
|
|
deviceLocation.setCountry(rs.getString("COUNTRY"));
|
|
|
|
deviceLocation.setCountry(rs.getString("COUNTRY"));
|
|
|
|
deviceLocation.setDeviceId(rs.getInt("ID"));
|
|
|
|
deviceLocation.setDeviceId(rs.getInt("ID"));
|
|
|
|
deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
|
|
|
deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
|
|
|
|
|
|
|
|
|
|
|
DeviceWrapper wrapper = new DeviceWrapper();
|
|
|
|
DeviceWrapper wrapper = new DeviceWrapper();
|
|
|
|
wrapper.setDevice(device);
|
|
|
|
wrapper.setDevice(device);
|
|
|
|
wrapper.setDeviceInfo(deviceInfo);
|
|
|
|
wrapper.setDeviceInfo(deviceInfo);
|
|
|
|
wrapper.setDeviceLocation(deviceLocation);
|
|
|
|
wrapper.setDeviceLocation(deviceLocation);
|
|
|
|
wrapper.setDeviceIdentifier(identifier);
|
|
|
|
wrapper.setDeviceIdentifier(identifier);
|
|
|
|
devices.add(wrapper);
|
|
|
|
devices.add(wrapper);
|
|
|
|
|
|
|
|
devs.put(device.getId(), device.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
@ -132,59 +137,63 @@ public class SearchDAOImpl implements SearchDAO {
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet rs;
|
|
|
|
ResultSet rs;
|
|
|
|
List<DeviceWrapper> devices = new ArrayList<>();
|
|
|
|
List<DeviceWrapper> devices = new ArrayList<>();
|
|
|
|
|
|
|
|
Map<Integer, Integer> devs = new HashMap<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
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"))) {
|
|
|
|
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"));
|
|
|
|
device.setName(rs.getString("NAME"));
|
|
|
|
device.setName(rs.getString("NAME"));
|
|
|
|
device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
|
|
device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
|
|
device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
|
|
|
device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
|
|
|
|
|
|
|
|
|
|
|
DeviceIdentifier identifier = new DeviceIdentifier();
|
|
|
|
DeviceIdentifier identifier = new DeviceIdentifier();
|
|
|
|
identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
|
|
identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
|
|
identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
|
|
|
identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
|
|
|
|
|
|
|
|
|
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
|
|
deviceInfo.setDeviceId(rs.getInt("ID"));
|
|
|
|
deviceInfo.setDeviceId(rs.getInt("ID"));
|
|
|
|
deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
|
|
|
deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
|
|
|
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
|
|
|
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
|
|
|
deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
|
|
|
deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
|
|
|
deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
|
|
|
deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
|
|
|
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
|
|
|
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
|
|
|
deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
|
|
|
deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
|
|
|
deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
|
|
|
deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
|
|
|
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
|
|
|
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
|
|
|
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
|
|
|
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
|
|
|
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
|
|
|
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
|
|
|
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
|
|
|
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
|
|
|
deviceInfo.setSsid(rs.getString("SSID"));
|
|
|
|
deviceInfo.setSsid(rs.getString("SSID"));
|
|
|
|
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
|
|
|
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
|
|
|
deviceInfo.setVendor(rs.getString("VENDOR"));
|
|
|
|
deviceInfo.setVendor(rs.getString("VENDOR"));
|
|
|
|
deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
|
|
|
deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
|
|
|
|
|
|
|
|
|
|
|
DeviceLocation deviceLocation = new DeviceLocation();
|
|
|
|
DeviceLocation deviceLocation = new DeviceLocation();
|
|
|
|
deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
|
|
|
deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
|
|
|
deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
|
|
|
deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
|
|
|
deviceLocation.setStreet1(rs.getString("STREET1"));
|
|
|
|
deviceLocation.setStreet1(rs.getString("STREET1"));
|
|
|
|
deviceLocation.setStreet2(rs.getString("STREET2"));
|
|
|
|
deviceLocation.setStreet2(rs.getString("STREET2"));
|
|
|
|
deviceLocation.setCity(rs.getString("CITY"));
|
|
|
|
deviceLocation.setCity(rs.getString("CITY"));
|
|
|
|
deviceLocation.setState(rs.getString("STATE"));
|
|
|
|
deviceLocation.setState(rs.getString("STATE"));
|
|
|
|
deviceLocation.setZip(rs.getString("ZIP"));
|
|
|
|
deviceLocation.setZip(rs.getString("ZIP"));
|
|
|
|
deviceLocation.setCountry(rs.getString("COUNTRY"));
|
|
|
|
deviceLocation.setCountry(rs.getString("COUNTRY"));
|
|
|
|
deviceLocation.setDeviceId(rs.getInt("ID"));
|
|
|
|
deviceLocation.setDeviceId(rs.getInt("ID"));
|
|
|
|
deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
|
|
|
deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
|
|
|
|
|
|
|
|
|
|
|
DeviceWrapper wrapper = new DeviceWrapper();
|
|
|
|
DeviceWrapper wrapper = new DeviceWrapper();
|
|
|
|
wrapper.setDevice(device);
|
|
|
|
wrapper.setDevice(device);
|
|
|
|
wrapper.setDeviceInfo(deviceInfo);
|
|
|
|
wrapper.setDeviceInfo(deviceInfo);
|
|
|
|
wrapper.setDeviceLocation(deviceLocation);
|
|
|
|
wrapper.setDeviceLocation(deviceLocation);
|
|
|
|
wrapper.setDeviceIdentifier(identifier);
|
|
|
|
wrapper.setDeviceIdentifier(identifier);
|
|
|
|
devices.add(wrapper);
|
|
|
|
|
|
|
|
|
|
|
|
devices.add(wrapper);
|
|
|
|
|
|
|
|
devs.put(device.getId(), device.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|