From 32ea2e52c4a61cb278b0463d84e651a0364e0dbb Mon Sep 17 00:00:00 2001 From: megala21 Date: Fri, 21 Apr 2017 15:18:20 +0530 Subject: [PATCH] Fixes https://github.com/wso2/product-iots/issues/373 and https://github.com/wso2/product-iots/issues/370 --- .../jaxrs/service/impl/DeviceManagementServiceImpl.java | 1 + .../device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 2 +- .../device/mgt/core/search/mgt/impl/QueryBuilderImpl.java | 8 ++++---- .../carbon/device/mgt/core/search/mgt/impl/Utils.java | 8 -------- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index 3f3185a30d..c5446035c8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -436,6 +436,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } deviceList.setList(devices); + deviceList.setCount(devices.size()); return Response.status(Response.Status.OK).entity(deviceList).build(); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 4e37aca000..29cb889400 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -165,7 +165,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { stmt.setInt(paramIdx, tenantId); rs = stmt.executeQuery(); if (rs.next()) { - device = DeviceManagementDAOUtil.loadMatchingDevice(rs, true); + device = DeviceManagementDAOUtil.loadMatchingDevice(rs, false); } } catch (SQLException e) { throw new DeviceManagementDAOException("Error occurred while listing device for type " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java index 253e95fdd0..936f8f68f1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java @@ -145,10 +145,10 @@ public class QueryBuilderImpl implements QueryBuilder { ValueType type = new ValueType(); if (Utils.checkColumnType(con.getKey())) { type.setColumnType(ValueType.columnType.STRING); - type.setStringValue(Utils.getConvertedValue(con.getKey(), con.getValue())); + type.setStringValue(con.getValue()); } else { type.setColumnType(ValueType.columnType.INTEGER); - type.setIntValue(Integer.parseInt(Utils.getConvertedValue(con.getKey(), con.getValue()))); + type.setIntValue(Integer.parseInt(con.getValue())); } valueType[x] = type; x++; @@ -193,10 +193,10 @@ public class QueryBuilderImpl implements QueryBuilder { ValueType type = new ValueType(); if (Utils.checkColumnType(con.getKey())) { type.setColumnType(ValueType.columnType.STRING); - type.setStringValue(Utils.getConvertedValue(con.getKey(), con.getValue())); + type.setStringValue(con.getValue()); } else { type.setColumnType(ValueType.columnType.INTEGER); - type.setIntValue(Integer.parseInt(Utils.getConvertedValue(con.getKey(), con.getValue()))); + type.setIntValue(Integer.parseInt(con.getValue())); } valueType[x] = type; x++; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/Utils.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/Utils.java index 10e12f24ce..9e0d044e1e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/Utils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/Utils.java @@ -103,14 +103,6 @@ public class Utils { return bool; } - public static String getConvertedValue(String column, String value) { - - if (checkColumnType(column)) { - return "\'" + value + "\'"; - } else return value; - - } - public static Map getDeviceDetailsColumnNames() { return genericColumnsMap; }