From 61c05143c4dd5410fcc9810edfa62f9074d76dd9 Mon Sep 17 00:00:00 2001 From: Ace Date: Fri, 23 Oct 2020 16:59:35 +0530 Subject: [PATCH] Fixing activity retrieval with intiatedBy --- .../mgt/dao/impl/GenericOperationDAOImpl.java | 2 +- .../dao/impl/operation/MySQLOperationDAOImpl.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index caa2a86601..caa4de580a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -1090,7 +1090,7 @@ public class GenericOperationDAOImpl implements OperationDAO { ResultSet rs = null; try { Connection conn = OperationManagementDAOFactory.getConnection(); - String sql = "SELECT COUNT(*) AS COUNT " + + String sql = "SELECT COUNT(DISTINCT(OPERATION_ID)) AS COUNT " + "FROM DM_ENROLMENT_OP_MAPPING AS m " + " INNER JOIN " + " DM_OPERATION dp ON dp.ID = m.OPERATION_ID " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/operation/MySQLOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/operation/MySQLOperationDAOImpl.java index ec097133c5..532f0ca364 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/operation/MySQLOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/operation/MySQLOperationDAOImpl.java @@ -285,20 +285,20 @@ public class MySQLOperationDAOImpl extends GenericOperationDAOImpl { "LEFT JOIN " + " DM_DEVICE_OPERATION_RESPONSE opr ON opr.EN_OP_MAP_ID = eom.ID " + "INNER JOIN " + - " (SELECT DISTINCT OPERATION_ID FROM DM_ENROLMENT_OP_MAPPING ORDER BY OPERATION_ID ASC limit ? , ? ) eom_ordered " + + " (SELECT DISTINCT OPERATION_ID FROM DM_ENROLMENT_OP_MAPPING WHERE INITIATED_BY = ? " + + " ORDER BY OPERATION_ID ASC limit ? , ? ) eom_ordered " + " ON eom_ordered.OPERATION_ID = eom.OPERATION_ID " + "WHERE " + " eom.UPDATED_TIMESTAMP > ? " + " AND eom.TENANT_ID = ? " + - " AND eom.INITIATED_BY = ? " + "ORDER BY eom.OPERATION_ID, eom.UPDATED_TIMESTAMP"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, offset); - stmt.setInt(2, limit); - stmt.setLong(3, timestamp); - stmt.setInt(4, tenantId); - stmt.setString(5, user); + stmt.setString(1, user); + stmt.setInt(2, offset); + stmt.setInt(3, limit); + stmt.setLong(4, timestamp); + stmt.setInt(5, tenantId); try (ResultSet rs = stmt.executeQuery()) { ActivityHolder activityHolder = OperationDAOUtil.getActivityHolder(rs);