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 d96920d703a..7089f5dfd12 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 @@ -355,6 +355,7 @@ public class GenericOperationDAOImpl implements OperationDAO { int operationId = 0; int enrolmentId = 0; + int responceId = 0; Activity activity = null; ActivityStatus activityStatus = null; while (rs.next()) { @@ -380,8 +381,9 @@ public class GenericOperationDAOImpl implements OperationDAO { activityStatus.setStatus(ActivityStatus.Status.valueOf(rs.getString("STATUS"))); List operationResponses = new ArrayList<>(); - if (rs.getInt("UPDATED_TIMESTAMP") != 0) { + if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) { operationResponses.add(this.getOperationResponse(rs)); + responceId = rs.getInt("OP_RES_ID"); } activityStatus.setResponses(operationResponses); statusList.add(activityStatus); @@ -407,6 +409,7 @@ public class GenericOperationDAOImpl implements OperationDAO { List operationResponses = new ArrayList<>(); if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) { operationResponses.add(this.getOperationResponse(rs)); + responceId = rs.getInt("OP_RES_ID"); } activityStatus.setResponses(operationResponses); activity.getActivityStatus().add(activityStatus); @@ -414,9 +417,10 @@ public class GenericOperationDAOImpl implements OperationDAO { enrolmentId = rs.getInt("ENROLMENT_ID"); } - if (operationId == rs.getInt("OPERATION_ID") && enrolmentId == rs.getInt("ENROLMENT_ID")){ + if (rs.getInt("OP_RES_ID") != 0 && responceId != rs.getInt("OP_RES_ID")){ if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) { activityStatus.getResponses().add(this.getOperationResponse(rs)); + responceId = rs.getInt("OP_RES_ID"); } } }