From cf4f45c89da605411730a93d3e10f161ceabf9cb Mon Sep 17 00:00:00 2001 From: Pahansith Gunathilake Date: Wed, 1 Dec 2021 17:10:45 +0530 Subject: [PATCH] Change time filtering DB column --- .../mgt/jaxrs/service/impl/util/RequestValidationUtil.java | 5 +++-- .../operation/mgt/dao/impl/GenericOperationDAOImpl.java | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java index 4d16878f73..116c715eb2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java @@ -773,8 +773,9 @@ public class RequestValidationUtil { public static void validateTimeDuration(long startTimestamp, long endTimestamp) { if (startTimestamp > endTimestamp) { throw new InputValidationException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request parameter startTimestamp" + - " should not be higher values than endTimestamp").build()); + new ErrorResponse.ErrorResponseBuilder().setCode(400l) + .setMessage("Request parameter startTimestamp should not be " + + "a higher value than endTimestamp").build()); } } } 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 1c48fa63bf..de92618c46 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 @@ -1769,7 +1769,7 @@ public class GenericOperationDAOImpl implements OperationDAO { } if (activityPaginationRequest.getStartTimestamp() > 0 && activityPaginationRequest.getEndTimestamp() > 0) { isTimeDurationFilteringProvided = true; - sql += "AND UPDATED_TIMESTAMP BETWEEN ? AND ? "; + sql += "AND CREATED_TIMESTAMP BETWEEN ? AND ? "; } if (activityPaginationRequest.getType() != null) { sql += "AND TYPE = ? "; @@ -1797,7 +1797,7 @@ public class GenericOperationDAOImpl implements OperationDAO { sql += "AND eom.UPDATED_TIMESTAMP > ? "; } if (isTimeDurationFilteringProvided) { - sql += "AND eom.UPDATED_TIMESTAMP BETWEEN ? AND ? "; + sql += "AND eom.CREATED_TIMESTAMP BETWEEN ? AND ? "; } if (activityPaginationRequest.getType() != null) { sql += "AND eom.TYPE = ? "; @@ -1917,8 +1917,9 @@ public class GenericOperationDAOImpl implements OperationDAO { } if (activityPaginationRequest.getStartTimestamp() > 0 && activityPaginationRequest.getEndTimestamp() > 0) { isTimeDurationFilteringProvided = true; - sql += "AND UPDATED_TIMESTAMP BETWEEN ? AND ? "; + sql += "AND CREATED_TIMESTAMP BETWEEN ? AND ? "; } + int index = 1; try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setInt(index++, tenantId);