Merge branch 'store-api-new' into 'master'

Accept multiple device status in store API

See merge request entgra/carbon-device-mgt!729
revert-70ac1926
Dharmakeerthi Lasantha 4 years ago
commit 7890517d43

@ -134,7 +134,7 @@ public interface SubscriptionManager {
* @throws {@link ApplicationManagementException} Exception of the application management * @throws {@link ApplicationManagementException} Exception of the application management
*/ */
PaginationResult getAppInstalledDevices(int offsetValue, int limitValue, String appUUID, PaginationResult getAppInstalledDevices(int offsetValue, int limitValue, String appUUID,
String status) throws ApplicationManagementException; List<String> status) throws ApplicationManagementException;
/*** /***
* This method used to get category details. * This method used to get category details.

@ -1214,7 +1214,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
} }
@Override @Override
public PaginationResult getAppInstalledDevices(int offsetValue, int limitValue, String appUUID, String status) public PaginationResult getAppInstalledDevices(int offsetValue, int limitValue, String appUUID, List<String> status)
throws ApplicationManagementException { throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
DeviceManagementProviderService deviceManagementProviderService = HelperUtil DeviceManagementProviderService deviceManagementProviderService = HelperUtil

@ -355,7 +355,7 @@ public interface SubscriptionManagementAPI {
@ApiParam( @ApiParam(
name = "status", name = "status",
value = "Provide the device status details, such as active or inactive.") value = "Provide the device status details, such as active or inactive.")
@QueryParam("status") String status @QueryParam("status") List<String> status
); );
@GET @GET

@ -278,7 +278,7 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
@QueryParam("offset") int offset, @QueryParam("offset") int offset,
@DefaultValue("5") @DefaultValue("5")
@QueryParam("limit") int limit, @QueryParam("limit") int limit,
@QueryParam("status") String status) { @QueryParam("status") List<String> status) {
try { try {
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
PaginationResult subscribedDeviceDetails = subscriptionManager PaginationResult subscribedDeviceDetails = subscriptionManager

@ -647,7 +647,7 @@ public interface DeviceDAO {
* @throws DeviceManagementDAOException if connections establishment fails. * @throws DeviceManagementDAOException if connections establishment fails.
*/ */
List<Device> getSubscribedDevices(int offsetValue, int limitValue, List<Integer> deviceIds, List<Device> getSubscribedDevices(int offsetValue, int limitValue, List<Integer> deviceIds,
int tenantId, String status) throws DeviceManagementDAOException; int tenantId, List<String> status) throws DeviceManagementDAOException;
/** /**
* @param deviceIds device ids of the subscribed devices. * @param deviceIds device ids of the subscribed devices.
@ -656,7 +656,7 @@ public interface DeviceDAO {
* @return number of subscribed device count. * @return number of subscribed device count.
* @throws DeviceManagementDAOException if error occurred while processing the SQL statement. * @throws DeviceManagementDAOException if error occurred while processing the SQL statement.
*/ */
int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, String status) int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
throws DeviceManagementDAOException; throws DeviceManagementDAOException;
/** /**

@ -878,7 +878,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
@Override @Override
public List<Device> getSubscribedDevices(int offsetValue, int limitValue, public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
List<Integer> deviceIds, int tenantId, String status) List<Integer> deviceIds, int tenantId, List<String> status)
throws DeviceManagementDAOException { throws DeviceManagementDAOException {
Connection conn; Connection conn;
@ -894,18 +894,18 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
+ "DM_DEVICE.DESCRIPTION AS DESCRIPTION, " + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, "
+ "DM_DEVICE.DEVICE_TYPE_ID, " + "DM_DEVICE.DEVICE_TYPE_ID, "
+ "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, "
+ "DM_ENROLMENT.ID AS ENROLMENT_ID, " + "e.ID AS ENROLMENT_ID, "
+ "DM_ENROLMENT.OWNER, " + "e.OWNER, "
+ "DM_ENROLMENT.OWNERSHIP, " + "e.OWNERSHIP, "
+ "DM_ENROLMENT.DATE_OF_ENROLMENT, " + "e.DATE_OF_ENROLMENT, "
+ "DM_ENROLMENT.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_LAST_UPDATE, "
+ "DM_ENROLMENT.STATUS, " + "e.STATUS, "
+ "DM_ENROLMENT.IS_TRANSFERRED, " + "e.IS_TRANSFERRED, "
+ "device_types.NAME AS DEVICE_TYPE " + "device_types.NAME AS DEVICE_TYPE "
+ "FROM DM_DEVICE " + "FROM DM_DEVICE "
+ "INNER JOIN DM_ENROLMENT ON " + "INNER JOIN DM_ENROLMENT e ON "
+ "DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID AND " + "DM_DEVICE.ID = e.DEVICE_ID AND "
+ "DM_DEVICE.TENANT_ID = DM_ENROLMENT.TENANT_ID " + "DM_DEVICE.TENANT_ID = e.TENANT_ID "
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID " + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "
+ "WHERE DM_DEVICE.ID IN (", + "WHERE DM_DEVICE.ID IN (",
@ -915,7 +915,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
String query = joiner.toString(); String query = joiner.toString();
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
query = query + " AND DM_ENROLMENT.STATUS=?"; query += buildStatusQuery(status);
isStatusProvided = true; isStatusProvided = true;
} }
@ -929,7 +929,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
ps.setInt(index++, tenantId); ps.setInt(index++, tenantId);
if (isStatusProvided) { if (isStatusProvided) {
ps.setString(index++, status); for (String deviceStatus : status) {
ps.setString(index++, deviceStatus);
}
} }
ps.setInt(index++, offsetValue); ps.setInt(index++, offsetValue);
ps.setInt(index, limitValue); ps.setInt(index, limitValue);
@ -951,7 +953,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
@Override @Override
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, String status) public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
throws DeviceManagementDAOException { throws DeviceManagementDAOException {
try { try {
Connection conn = this.getConnection(); Connection conn = this.getConnection();
@ -967,8 +969,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
deviceIds.stream().map(ignored -> "?").forEach(joiner::add); deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
if (!StringUtils.isBlank(status)) { if (status != null && !status.isEmpty()) {
query = query + " AND e.STATUS = ?"; query += buildStatusQuery(status);
} }
try (PreparedStatement ps = conn.prepareStatement(query)) { try (PreparedStatement ps = conn.prepareStatement(query)) {
@ -977,8 +979,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
ps.setInt(index++, tenantId); ps.setInt(index++, tenantId);
if (!StringUtils.isBlank(status)) { if (status != null && !status.isEmpty()) {
ps.setString(index, status); for (String deviceStatus : status) {
ps.setString(index++, deviceStatus);
}
} }
try (ResultSet rs = ps.executeQuery()) { try (ResultSet rs = ps.executeQuery()) {

@ -848,7 +848,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
@Override @Override
public List<Device> getSubscribedDevices(int offsetValue, int limitValue, public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
List<Integer> deviceIds, int tenantId, String status) List<Integer> deviceIds, int tenantId, List<String> status)
throws DeviceManagementDAOException { throws DeviceManagementDAOException {
Connection conn; Connection conn;
@ -864,18 +864,18 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
+ "DM_DEVICE.DESCRIPTION AS DESCRIPTION, " + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, "
+ "DM_DEVICE.DEVICE_TYPE_ID, " + "DM_DEVICE.DEVICE_TYPE_ID, "
+ "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, "
+ "DM_ENROLMENT.ID AS ENROLMENT_ID, " + "e.ID AS ENROLMENT_ID, "
+ "DM_ENROLMENT.OWNER, " + "e.OWNER, "
+ "DM_ENROLMENT.OWNERSHIP, " + "e.OWNERSHIP, "
+ "DM_ENROLMENT.DATE_OF_ENROLMENT, " + "e.DATE_OF_ENROLMENT, "
+ "DM_ENROLMENT.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_LAST_UPDATE, "
+ "DM_ENROLMENT.STATUS, " + "e.STATUS, "
+ "DM_ENROLMENT.IS_TRANSFERRED, " + "e.IS_TRANSFERRED, "
+ "device_types.NAME AS DEVICE_TYPE " + "device_types.NAME AS DEVICE_TYPE "
+ "FROM DM_DEVICE " + "FROM DM_DEVICE "
+ "INNER JOIN DM_ENROLMENT ON " + "INNER JOIN DM_ENROLMENT e ON "
+ "DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID AND " + "DM_DEVICE.ID = e.DEVICE_ID AND "
+ "DM_DEVICE.TENANT_ID = DM_ENROLMENT.TENANT_ID " + "DM_DEVICE.TENANT_ID = e.TENANT_ID "
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID " + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "
+ "WHERE DM_DEVICE.ID IN (", + "WHERE DM_DEVICE.ID IN (",
@ -885,7 +885,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
String query = joiner.toString(); String query = joiner.toString();
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
query = query + " AND DM_ENROLMENT.STATUS=?"; query += buildStatusQuery(status);
isStatusProvided = true; isStatusProvided = true;
} }
@ -899,7 +899,9 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
ps.setInt(index++, tenantId); ps.setInt(index++, tenantId);
if (isStatusProvided) { if (isStatusProvided) {
ps.setString(index++, status); for (String deviceStatus : status) {
ps.setString(index++, deviceStatus);
}
} }
ps.setInt(index++, offsetValue); ps.setInt(index++, offsetValue);
ps.setInt(index, limitValue); ps.setInt(index, limitValue);
@ -921,7 +923,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
@Override @Override
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, String status) public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
throws DeviceManagementDAOException { throws DeviceManagementDAOException {
try { try {
Connection conn = this.getConnection(); Connection conn = this.getConnection();
@ -937,8 +939,8 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
deviceIds.stream().map(ignored -> "?").forEach(joiner::add); deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
if (!StringUtils.isBlank(status)) { if (status != null && !status.isEmpty()) {
query = query + " AND e.STATUS = ?"; query += buildStatusQuery(status);
} }
try (PreparedStatement ps = conn.prepareStatement(query)) { try (PreparedStatement ps = conn.prepareStatement(query)) {
@ -947,8 +949,10 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
ps.setInt(index++, tenantId); ps.setInt(index++, tenantId);
if (!StringUtils.isBlank(status)) { if (status != null && !status.isEmpty()) {
ps.setString(index, status); for (String deviceStatus : status) {
ps.setString(index++, deviceStatus);
}
} }
try (ResultSet rs = ps.executeQuery()) { try (ResultSet rs = ps.executeQuery()) {

@ -828,7 +828,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
@Override @Override
public List<Device> getSubscribedDevices(int offsetValue, int limitValue, public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
List<Integer> deviceIds, int tenantId, String status) List<Integer> deviceIds, int tenantId, List<String> status)
throws DeviceManagementDAOException { throws DeviceManagementDAOException {
Connection conn; Connection conn;
@ -844,18 +844,18 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
+ "DM_DEVICE.DESCRIPTION AS DESCRIPTION, " + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, "
+ "DM_DEVICE.DEVICE_TYPE_ID, " + "DM_DEVICE.DEVICE_TYPE_ID, "
+ "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, "
+ "DM_ENROLMENT.ID AS ENROLMENT_ID, " + "e.ID AS ENROLMENT_ID, "
+ "DM_ENROLMENT.OWNER, " + "e.OWNER, "
+ "DM_ENROLMENT.OWNERSHIP, " + "e.OWNERSHIP, "
+ "DM_ENROLMENT.DATE_OF_ENROLMENT, " + "e.DATE_OF_ENROLMENT, "
+ "DM_ENROLMENT.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_LAST_UPDATE, "
+ "DM_ENROLMENT.STATUS, " + "e.STATUS, "
+ "DM_ENROLMENT.IS_TRANSFERRED, " + "e.IS_TRANSFERRED, "
+ "device_types.NAME AS DEVICE_TYPE " + "device_types.NAME AS DEVICE_TYPE "
+ "FROM DM_DEVICE " + "FROM DM_DEVICE "
+ "INNER JOIN DM_ENROLMENT ON " + "INNER JOIN DM_ENROLMENT e ON "
+ "DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID AND " + "DM_DEVICE.ID = e.DEVICE_ID AND "
+ "DM_DEVICE.TENANT_ID = DM_ENROLMENT.TENANT_ID " + "DM_DEVICE.TENANT_ID = e.TENANT_ID "
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID " + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "
+ "WHERE DM_DEVICE.ID IN (", + "WHERE DM_DEVICE.ID IN (",
@ -865,7 +865,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
String query = joiner.toString(); String query = joiner.toString();
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
query = query + " AND DM_ENROLMENT.STATUS=?"; query += buildStatusQuery(status);
isStatusProvided = true; isStatusProvided = true;
} }
@ -879,7 +879,9 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
ps.setInt(index++, tenantId); ps.setInt(index++, tenantId);
if (isStatusProvided) { if (isStatusProvided) {
ps.setString(index++, status); for (String deviceStatus : status) {
ps.setString(index++, deviceStatus);
}
} }
ps.setInt(index++, offsetValue); ps.setInt(index++, offsetValue);
ps.setInt(index, limitValue); ps.setInt(index, limitValue);
@ -901,7 +903,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
@Override @Override
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, String status) public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
throws DeviceManagementDAOException { throws DeviceManagementDAOException {
try { try {
Connection conn = this.getConnection(); Connection conn = this.getConnection();
@ -917,8 +919,8 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
deviceIds.stream().map(ignored -> "?").forEach(joiner::add); deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
if (!StringUtils.isBlank(status)) { if (status != null && !status.isEmpty()) {
query = query + " AND e.STATUS = ?"; query += buildStatusQuery(status);
} }
try (PreparedStatement ps = conn.prepareStatement(query)) { try (PreparedStatement ps = conn.prepareStatement(query)) {
@ -927,8 +929,10 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
ps.setInt(index++, tenantId); ps.setInt(index++, tenantId);
if (!StringUtils.isBlank(status)) { if (status != null && !status.isEmpty()) {
ps.setString(index, status); for (String deviceStatus : status) {
ps.setString(index++, deviceStatus);
}
} }
try (ResultSet rs = ps.executeQuery()) { try (ResultSet rs = ps.executeQuery()) {

@ -694,7 +694,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
@Override @Override
public List<Device> getSubscribedDevices(int offsetValue, int limitValue, public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
List<Integer> deviceIds, int tenantId, String status) List<Integer> deviceIds, int tenantId, List<String> status)
throws DeviceManagementDAOException { throws DeviceManagementDAOException {
Connection conn; Connection conn;
@ -710,18 +710,18 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
+ "DM_DEVICE.DESCRIPTION AS DESCRIPTION, " + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, "
+ "DM_DEVICE.DEVICE_TYPE_ID, " + "DM_DEVICE.DEVICE_TYPE_ID, "
+ "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, "
+ "DM_ENROLMENT.ID AS ENROLMENT_ID, " + "e.ID AS ENROLMENT_ID, "
+ "DM_ENROLMENT.OWNER, " + "e.OWNER, "
+ "DM_ENROLMENT.OWNERSHIP, " + "e.OWNERSHIP, "
+ "DM_ENROLMENT.DATE_OF_ENROLMENT, " + "e.DATE_OF_ENROLMENT, "
+ "DM_ENROLMENT.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_LAST_UPDATE, "
+ "DM_ENROLMENT.STATUS, " + "e.STATUS, "
+ "DM_ENROLMENT.IS_TRANSFERRED, " + "e.IS_TRANSFERRED, "
+ "device_types.NAME AS DEVICE_TYPE " + "device_types.NAME AS DEVICE_TYPE "
+ "FROM DM_DEVICE " + "FROM DM_DEVICE "
+ "INNER JOIN DM_ENROLMENT ON " + "INNER JOIN DM_ENROLMENT e ON "
+ "DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID AND " + "DM_DEVICE.ID = e.DEVICE_ID AND "
+ "DM_DEVICE.TENANT_ID = DM_ENROLMENT.TENANT_ID " + "DM_DEVICE.TENANT_ID = e.TENANT_ID "
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID " + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "
+ "WHERE DM_DEVICE.ID IN (", + "WHERE DM_DEVICE.ID IN (",
@ -731,7 +731,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
String query = joiner.toString(); String query = joiner.toString();
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
query = query + " AND DM_ENROLMENT.STATUS=?"; query += buildStatusQuery(status);
isStatusProvided = true; isStatusProvided = true;
} }
@ -745,7 +745,9 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
ps.setInt(index++, tenantId); ps.setInt(index++, tenantId);
if (isStatusProvided) { if (isStatusProvided) {
ps.setString(index++, status); for (String deviceStatus : status) {
ps.setString(index++, deviceStatus);
}
} }
ps.setInt(index++, offsetValue); ps.setInt(index++, offsetValue);
ps.setInt(index, limitValue); ps.setInt(index, limitValue);
@ -1034,7 +1036,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
@Override @Override
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, String status) public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
throws DeviceManagementDAOException { throws DeviceManagementDAOException {
try { try {
Connection conn = this.getConnection(); Connection conn = this.getConnection();
@ -1050,8 +1052,8 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
deviceIds.stream().map(ignored -> "?").forEach(joiner::add); deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
if (!StringUtils.isBlank(status)) { if (status != null && !status.isEmpty()) {
query = query + " AND e.STATUS = ?"; query += buildStatusQuery(status);
} }
try (PreparedStatement ps = conn.prepareStatement(query)) { try (PreparedStatement ps = conn.prepareStatement(query)) {
@ -1060,8 +1062,10 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
ps.setInt(index++, tenantId); ps.setInt(index++, tenantId);
if (!StringUtils.isBlank(status)) { if (status != null && !status.isEmpty()) {
ps.setString(index, status); for (String deviceStatus : status) {
ps.setString(index++, deviceStatus);
}
} }
try (ResultSet rs = ps.executeQuery()) { try (ResultSet rs = ps.executeQuery()) {

@ -884,7 +884,7 @@ public interface DeviceManagementProviderService {
* @throws DeviceManagementException if any service level or DAO level error occurs. * @throws DeviceManagementException if any service level or DAO level error occurs.
*/ */
PaginationResult getAppSubscribedDevices(int offsetValue, int limitValue, PaginationResult getAppSubscribedDevices(int offsetValue, int limitValue,
List<Integer> devicesIds, String status) throws DeviceManagementException; List<Integer> devicesIds, List<String> status) throws DeviceManagementException;
/** /**
* This method is used to get a list of applications installed in all enrolled devices * This method is used to get a list of applications installed in all enrolled devices

@ -4084,7 +4084,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
@Override @Override
public PaginationResult getAppSubscribedDevices(int offsetValue, int limitValue, List<Integer> devicesIds, public PaginationResult getAppSubscribedDevices(int offsetValue, int limitValue, List<Integer> devicesIds,
String status) throws DeviceManagementException { List<String> status) throws DeviceManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {

Loading…
Cancel
Save