mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Adding the changes for device search
This commit is contained in:
parent
e4b400a5e7
commit
e2d67fc92c
@ -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.setId(rs.getInt("ID"));
|
||||||
|
device.setDescription(rs.getString("DESCRIPTION"));
|
||||||
|
device.setName("NAME");
|
||||||
|
device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
||||||
|
device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
||||||
|
|
||||||
Device device = new Device();
|
DeviceIdentifier identifier = new DeviceIdentifier();
|
||||||
device.setId(rs.getInt("ID"));
|
identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
||||||
device.setDescription(rs.getString("DESCRIPTION"));
|
identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
||||||
device.setName("NAME");
|
|
||||||
device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
||||||
device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
|
||||||
|
|
||||||
DeviceIdentifier identifier = new DeviceIdentifier();
|
DeviceInfo deviceInfo = new DeviceInfo();
|
||||||
identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
deviceInfo.setDeviceId(rs.getInt("ID"));
|
||||||
identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
||||||
|
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
||||||
|
deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
||||||
|
deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
||||||
|
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
||||||
|
deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
||||||
|
deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
||||||
|
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
||||||
|
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
||||||
|
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
||||||
|
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
||||||
|
deviceInfo.setSsid(rs.getString("SSID"));
|
||||||
|
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
||||||
|
deviceInfo.setVendor(rs.getString("VENDOR"));
|
||||||
|
deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
||||||
|
|
||||||
DeviceInfo deviceInfo = new DeviceInfo();
|
DeviceLocation deviceLocation = new DeviceLocation();
|
||||||
deviceInfo.setDeviceId(rs.getInt("ID"));
|
deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
||||||
deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
||||||
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
deviceLocation.setStreet1(rs.getString("STREET1"));
|
||||||
deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
deviceLocation.setStreet2(rs.getString("STREET2"));
|
||||||
deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
deviceLocation.setCity(rs.getString("CITY"));
|
||||||
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
deviceLocation.setState(rs.getString("STATE"));
|
||||||
deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
deviceLocation.setZip(rs.getString("ZIP"));
|
||||||
deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
deviceLocation.setCountry(rs.getString("COUNTRY"));
|
||||||
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
deviceLocation.setDeviceId(rs.getInt("ID"));
|
||||||
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
||||||
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
|
||||||
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
|
||||||
deviceInfo.setSsid(rs.getString("SSID"));
|
|
||||||
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
|
||||||
deviceInfo.setVendor(rs.getString("VENDOR"));
|
|
||||||
deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
|
||||||
|
|
||||||
DeviceLocation deviceLocation = new DeviceLocation();
|
DeviceWrapper wrapper = new DeviceWrapper();
|
||||||
deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
wrapper.setDevice(device);
|
||||||
deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
wrapper.setDeviceInfo(deviceInfo);
|
||||||
deviceLocation.setStreet1(rs.getString("STREET1"));
|
wrapper.setDeviceLocation(deviceLocation);
|
||||||
deviceLocation.setStreet2(rs.getString("STREET2"));
|
wrapper.setDeviceIdentifier(identifier);
|
||||||
deviceLocation.setCity(rs.getString("CITY"));
|
devices.add(wrapper);
|
||||||
deviceLocation.setState(rs.getString("STATE"));
|
devs.put(device.getId(), device.getId());
|
||||||
deviceLocation.setZip(rs.getString("ZIP"));
|
}
|
||||||
deviceLocation.setCountry(rs.getString("COUNTRY"));
|
|
||||||
deviceLocation.setDeviceId(rs.getInt("ID"));
|
|
||||||
deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
|
||||||
|
|
||||||
DeviceWrapper wrapper = new DeviceWrapper();
|
|
||||||
wrapper.setDevice(device);
|
|
||||||
wrapper.setDeviceInfo(deviceInfo);
|
|
||||||
wrapper.setDeviceLocation(deviceLocation);
|
|
||||||
wrapper.setDeviceIdentifier(identifier);
|
|
||||||
devices.add(wrapper);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} 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.setId(rs.getInt("ID"));
|
||||||
|
device.setDescription(rs.getString("DESCRIPTION"));
|
||||||
|
device.setName(rs.getString("NAME"));
|
||||||
|
device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
||||||
|
device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
||||||
|
|
||||||
Device device = new Device();
|
DeviceIdentifier identifier = new DeviceIdentifier();
|
||||||
device.setId(rs.getInt("ID"));
|
identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
||||||
device.setDescription(rs.getString("DESCRIPTION"));
|
identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
||||||
device.setName(rs.getString("NAME"));
|
|
||||||
device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
||||||
device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
|
||||||
|
|
||||||
DeviceIdentifier identifier = new DeviceIdentifier();
|
DeviceInfo deviceInfo = new DeviceInfo();
|
||||||
identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
deviceInfo.setDeviceId(rs.getInt("ID"));
|
||||||
identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
||||||
|
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
||||||
|
deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
||||||
|
deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
||||||
|
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
||||||
|
deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
||||||
|
deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
||||||
|
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
||||||
|
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
||||||
|
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
||||||
|
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
||||||
|
deviceInfo.setSsid(rs.getString("SSID"));
|
||||||
|
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
||||||
|
deviceInfo.setVendor(rs.getString("VENDOR"));
|
||||||
|
deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
||||||
|
|
||||||
DeviceInfo deviceInfo = new DeviceInfo();
|
DeviceLocation deviceLocation = new DeviceLocation();
|
||||||
deviceInfo.setDeviceId(rs.getInt("ID"));
|
deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
||||||
deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
||||||
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
deviceLocation.setStreet1(rs.getString("STREET1"));
|
||||||
deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
deviceLocation.setStreet2(rs.getString("STREET2"));
|
||||||
deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
deviceLocation.setCity(rs.getString("CITY"));
|
||||||
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
deviceLocation.setState(rs.getString("STATE"));
|
||||||
deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
deviceLocation.setZip(rs.getString("ZIP"));
|
||||||
deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
deviceLocation.setCountry(rs.getString("COUNTRY"));
|
||||||
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
deviceLocation.setDeviceId(rs.getInt("ID"));
|
||||||
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
||||||
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
|
||||||
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
|
||||||
deviceInfo.setSsid(rs.getString("SSID"));
|
|
||||||
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
|
||||||
deviceInfo.setVendor(rs.getString("VENDOR"));
|
|
||||||
deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
|
||||||
|
|
||||||
DeviceLocation deviceLocation = new DeviceLocation();
|
DeviceWrapper wrapper = new DeviceWrapper();
|
||||||
deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
wrapper.setDevice(device);
|
||||||
deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
wrapper.setDeviceInfo(deviceInfo);
|
||||||
deviceLocation.setStreet1(rs.getString("STREET1"));
|
wrapper.setDeviceLocation(deviceLocation);
|
||||||
deviceLocation.setStreet2(rs.getString("STREET2"));
|
wrapper.setDeviceIdentifier(identifier);
|
||||||
deviceLocation.setCity(rs.getString("CITY"));
|
|
||||||
deviceLocation.setState(rs.getString("STATE"));
|
|
||||||
deviceLocation.setZip(rs.getString("ZIP"));
|
|
||||||
deviceLocation.setCountry(rs.getString("COUNTRY"));
|
|
||||||
deviceLocation.setDeviceId(rs.getInt("ID"));
|
|
||||||
deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
|
||||||
|
|
||||||
DeviceWrapper wrapper = new DeviceWrapper();
|
devices.add(wrapper);
|
||||||
wrapper.setDevice(device);
|
devs.put(device.getId(), device.getId());
|
||||||
wrapper.setDeviceInfo(deviceInfo);
|
}
|
||||||
wrapper.setDeviceLocation(deviceLocation);
|
|
||||||
wrapper.setDeviceIdentifier(identifier);
|
|
||||||
devices.add(wrapper);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|||||||
@ -114,7 +114,7 @@ public class QueryBuilderImpl implements QueryBuilder {
|
|||||||
for (Condition con : conditions) {
|
for (Condition con : conditions) {
|
||||||
if (Utils.checkDeviceDetailsColumns(con.getKey())) {
|
if (Utils.checkDeviceDetailsColumns(con.getKey())) {
|
||||||
querySuffix = querySuffix + " AND DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey()) +
|
querySuffix = querySuffix + " AND DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey()) +
|
||||||
con.getOperator() + con.getValue();
|
con.getOperator() + Utils.getConvertedValue(con.getKey(), con.getValue());
|
||||||
} else if (Utils.checkDeviceLocationColumns(con.getKey())) {
|
} else if (Utils.checkDeviceLocationColumns(con.getKey())) {
|
||||||
querySuffix = querySuffix + " AND DL." + Utils.getDeviceLocationColumnNames().get(con.getKey()) +
|
querySuffix = querySuffix + " AND DL." + Utils.getDeviceLocationColumnNames().get(con.getKey()) +
|
||||||
con.getOperator() + con.getValue();
|
con.getOperator() + con.getValue();
|
||||||
@ -132,7 +132,7 @@ public class QueryBuilderImpl implements QueryBuilder {
|
|||||||
for (Condition con : conditions) {
|
for (Condition con : conditions) {
|
||||||
if (Utils.checkDeviceDetailsColumns(con.getKey())) {
|
if (Utils.checkDeviceDetailsColumns(con.getKey())) {
|
||||||
querySuffix = querySuffix + " OR DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey()) +
|
querySuffix = querySuffix + " OR DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey()) +
|
||||||
con.getOperator() + con.getValue();
|
con.getOperator() + Utils.getConvertedValue(con.getKey(), con.getValue());
|
||||||
} else if (Utils.checkDeviceLocationColumns(con.getKey())) {
|
} else if (Utils.checkDeviceLocationColumns(con.getKey())) {
|
||||||
querySuffix = querySuffix + " OR DL." + Utils.getDeviceLocationColumnNames().get(con.getKey()) +
|
querySuffix = querySuffix + " OR DL." + Utils.getDeviceLocationColumnNames().get(con.getKey()) +
|
||||||
con.getOperator() + con.getValue();
|
con.getOperator() + con.getValue();
|
||||||
|
|||||||
@ -60,6 +60,41 @@ public class Utils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean checkColumnType(String column) {
|
||||||
|
|
||||||
|
boolean bool = false;
|
||||||
|
|
||||||
|
switch (column) {
|
||||||
|
case "deviceModel":
|
||||||
|
bool = true;
|
||||||
|
break;
|
||||||
|
case "vendor":
|
||||||
|
bool = true;
|
||||||
|
break;
|
||||||
|
case "osVersion":
|
||||||
|
bool = true;
|
||||||
|
break;
|
||||||
|
case "connectionType":
|
||||||
|
bool = true;
|
||||||
|
break;
|
||||||
|
case "ssid":
|
||||||
|
bool = true;
|
||||||
|
break;
|
||||||
|
default: bool =false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getConvertedValue(String column, String value) {
|
||||||
|
|
||||||
|
if(checkColumnType(column)){
|
||||||
|
return "\'" + value + "\'";
|
||||||
|
} else return value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static Map<String, String> getDeviceDetailsColumnNames() {
|
public static Map<String, String> getDeviceDetailsColumnNames() {
|
||||||
return genericColumnsMap;
|
return genericColumnsMap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,62 +93,91 @@ public class SearchDevice extends BaseDeviceManagementTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
// public void doValidLocationSearch() throws Exception{
|
public void doValidLocationSearch() throws Exception{
|
||||||
//
|
|
||||||
// SearchContext context = new SearchContext();
|
SearchContext context = new SearchContext();
|
||||||
// List<Condition> conditions = new ArrayList<>();
|
List<Condition> conditions = new ArrayList<>();
|
||||||
//
|
|
||||||
// Condition cond = new Condition();
|
Condition cond = new Condition();
|
||||||
// cond.setKey("LOCATION");
|
cond.setKey("LOCATION");
|
||||||
// cond.setOperator("=");
|
cond.setOperator("=");
|
||||||
// cond.setValue("Karan");
|
cond.setValue("Karan");
|
||||||
// cond.setState(Condition.State.AND);
|
cond.setState(Condition.State.AND);
|
||||||
// conditions.add(cond);
|
conditions.add(cond);
|
||||||
//
|
|
||||||
// context.setConditions(conditions);
|
context.setConditions(conditions);
|
||||||
//
|
|
||||||
// SearchManagerService service = new SearchManagerServiceImpl();
|
SearchManagerService service = new SearchManagerServiceImpl();
|
||||||
// List<DeviceWrapper> deviceWrappers = service.search(context);
|
List<DeviceWrapper> deviceWrappers = service.search(context);
|
||||||
//
|
|
||||||
// Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
// String bbbb = gson.toJson(deviceWrappers);
|
String bbbb = gson.toJson(deviceWrappers);
|
||||||
// log.info("Valid Search " + bbbb);
|
log.info("Valid Search " + bbbb);
|
||||||
//
|
|
||||||
//
|
|
||||||
// for (DeviceWrapper dw : deviceWrappers) {
|
for (DeviceWrapper dw : deviceWrappers) {
|
||||||
// log.debug(dw.getDevice().getDescription());
|
log.debug(dw.getDevice().getDescription());
|
||||||
// log.debug(dw.getDevice().getDeviceIdentifier());
|
log.debug(dw.getDevice().getDeviceIdentifier());
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Test
|
@Test
|
||||||
// public void doInvalidLocationSearch() throws Exception{
|
public void doInvalidLocationSearch() throws Exception{
|
||||||
//
|
|
||||||
// SearchContext context = new SearchContext();
|
SearchContext context = new SearchContext();
|
||||||
// List<Condition> conditions = new ArrayList<>();
|
List<Condition> conditions = new ArrayList<>();
|
||||||
//
|
|
||||||
// Condition cond = new Condition();
|
Condition cond = new Condition();
|
||||||
// cond.setKey("LOCATION");
|
cond.setKey("LOCATION");
|
||||||
// cond.setOperator("=");
|
cond.setOperator("=");
|
||||||
// cond.setValue("Colombo");
|
cond.setValue("Colombo");
|
||||||
// cond.setState(Condition.State.AND);
|
cond.setState(Condition.State.AND);
|
||||||
// conditions.add(cond);
|
conditions.add(cond);
|
||||||
//
|
|
||||||
// context.setConditions(conditions);
|
context.setConditions(conditions);
|
||||||
//
|
|
||||||
// SearchManagerService service = new SearchManagerServiceImpl();
|
SearchManagerService service = new SearchManagerServiceImpl();
|
||||||
// List<DeviceWrapper> deviceWrappers = service.search(context);
|
List<DeviceWrapper> deviceWrappers = service.search(context);
|
||||||
//
|
|
||||||
// Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
// String bbbb = gson.toJson(deviceWrappers);
|
String bbbb = gson.toJson(deviceWrappers);
|
||||||
// log.info("Invalid Search " + bbbb);
|
log.info("Invalid Search " + bbbb);
|
||||||
//
|
|
||||||
//
|
|
||||||
// for (DeviceWrapper dw : deviceWrappers) {
|
for (DeviceWrapper dw : deviceWrappers) {
|
||||||
// log.debug(dw.getDevice().getDescription());
|
log.debug(dw.getDevice().getDescription());
|
||||||
// log.debug(dw.getDevice().getDeviceIdentifier());
|
log.debug(dw.getDevice().getDeviceIdentifier());
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void doStringSearch() throws Exception{
|
||||||
|
|
||||||
|
SearchContext context = new SearchContext();
|
||||||
|
List<Condition> conditions = new ArrayList<>();
|
||||||
|
|
||||||
|
Condition cond = new Condition();
|
||||||
|
cond.setKey("deviceModel");
|
||||||
|
cond.setOperator("=");
|
||||||
|
cond.setValue("SM-T520");
|
||||||
|
cond.setState(Condition.State.AND);
|
||||||
|
conditions.add(cond);
|
||||||
|
|
||||||
|
context.setConditions(conditions);
|
||||||
|
|
||||||
|
SearchManagerService service = new SearchManagerServiceImpl();
|
||||||
|
List<DeviceWrapper> deviceWrappers = service.search(context);
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String bbbb = gson.toJson(deviceWrappers);
|
||||||
|
log.info("Invalid Search " + bbbb);
|
||||||
|
|
||||||
|
|
||||||
|
for (DeviceWrapper dw : deviceWrappers) {
|
||||||
|
log.debug(dw.getDevice().getDescription());
|
||||||
|
log.debug(dw.getDevice().getDeviceIdentifier());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user