From 0900034e29a118de66c0af726aebe5d4089912b2 Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Tue, 20 Aug 2019 17:24:40 +0530 Subject: [PATCH] Modify get applications query to support retrieving all applications --- .../application/GenericApplicationDAOImpl.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index dfde043ef5..1b6496db2c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -172,6 +172,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic sql += " AND AP_APP.DEVICE_TYPE_ID = ?"; } + if (filter.getLimit() == -1) { + sql = sql.replace("LIMIT ? OFFSET ?", ""); + } + String sortingOrder = "ASC"; if (!StringUtils.isEmpty(filter.getSortBy() )) { sortingOrder = filter.getSortBy(); @@ -182,12 +186,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql); ){ - if (filter.getLimit() == 0) { - stmt.setInt(paramIndex++, 100); - } else { - stmt.setInt(paramIndex++, filter.getLimit()); + if (filter.getLimit() != -1) { + if (filter.getLimit() == 0) { + stmt.setInt(paramIndex++, 100); + } else { + stmt.setInt(paramIndex++, filter.getLimit()); + } + stmt.setInt(paramIndex++, filter.getOffset()); } - stmt.setInt(paramIndex++, filter.getOffset()); stmt.setInt(paramIndex++, tenantId); if (filter.getAppType() != null && !filter.getAppType().isEmpty()) {