diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java index 5c41168bcb..dfff9c61d0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java @@ -1858,22 +1858,22 @@ public interface DeviceManagementService { String ownership, @ApiParam( name = "createdFrom", - value = "Since when user wants to filter operation logs using the created data and time") + value = "Since when user wants to filter operation logs using the created data and time (timestamp in seconds)") @QueryParam("createdFrom") Long createdFrom, @ApiParam( name = "createdTo", - value = "Till when user wants to filter operation logs using the created data and time") + value = "Till when user wants to filter operation logs using the created data and time (timestamp in seconds)") @QueryParam("createdTo") Long createdTo, @ApiParam( name = "updatedFrom", - value = "Since when user wants to filter operation logs using the received date and time") + value = "Since when user wants to filter operation logs using the received date and time (timestamp in seconds)") @QueryParam("updatedFrom") Long updatedFrom, @ApiParam( name = "updatedTo", - value = "Till when user wants to filter operation logs using the received date and time") + value = "Till when user wants to filter operation logs using the received date and time (timestamp in seconds)") @QueryParam("updatedTo") Long updatedTo, @ApiParam( diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java index ab66e75d1c..7848114f39 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java @@ -559,13 +559,11 @@ public class RequestValidationUtil { } if (createdTo != null || createdFrom != null) { validateDates(createdFrom, createdTo); - createdFrom = createdFrom * 1000; //if user only sends the fromDate toDate sets as current date if (createdFrom != null && createdTo == null) { operationLogFilters.setCreatedDayFrom(createdFrom); operationLogFilters.setCreatedDayTo(timeMilli); } else { - createdTo = createdTo * 1000; operationLogFilters.setCreatedDayFrom(createdFrom); operationLogFilters.setCreatedDayTo(createdTo); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index 50ec3f1071..8d11ad9da6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -1372,19 +1372,18 @@ public class GenericOperationDAOImpl implements OperationDAO { throws OperationManagementDAOException { Operation operation; List operations = new ArrayList<>(); - String createdTo = null; - String createdFrom = null; + Long createdTo = null; + Long createdFrom = null; ProfileOperation profileOperation = null; - DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); boolean isCreatedDayProvided = false; boolean isUpdatedDayProvided = false; //updated day = received day boolean isOperationCodeProvided = false; boolean isStatusProvided = false; if (request.getOperationLogFilters().getCreatedDayFrom() != null) { - createdFrom = simple.format(request.getOperationLogFilters().getCreatedDayFrom()); + createdFrom = request.getOperationLogFilters().getCreatedDayFrom(); } if (request.getOperationLogFilters().getCreatedDayTo() != null) { - createdTo = simple.format(request.getOperationLogFilters().getCreatedDayTo()); + createdTo = request.getOperationLogFilters().getCreatedDayTo(); } Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom(); Long updatedTo = request.getOperationLogFilters().getUpdatedDayTo(); @@ -1419,7 +1418,7 @@ public class GenericOperationDAOImpl implements OperationDAO { isUpdatedDayProvided = true; } sql.append(") om ON o.ID = om.OPERATION_ID "); - if (createdFrom != null && !createdFrom.isEmpty() && createdTo != null && !createdTo.isEmpty()) { + if (createdFrom != null && createdFrom != 0 && createdTo != null && createdTo != 0) { sql.append(" WHERE o.CREATED_TIMESTAMP BETWEEN ? AND ?"); isCreatedDayProvided = true; } @@ -1468,8 +1467,8 @@ public class GenericOperationDAOImpl implements OperationDAO { stmt.setLong(paramIndex++, updatedTo); } if (isCreatedDayProvided) { - stmt.setString(paramIndex++, createdFrom); - stmt.setString(paramIndex++, createdTo); + stmt.setLong(paramIndex++, createdFrom); + stmt.setLong(paramIndex++, createdTo); } if (isStatusProvided) { for (String s : status) { @@ -1643,14 +1642,13 @@ public class GenericOperationDAOImpl implements OperationDAO { @Override public int getOperationCountForDevice(int enrolmentId, PaginationRequest request) throws OperationManagementDAOException { - String createdTo = null; - String createdFrom = null; - DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + Long createdTo = null; + Long createdFrom = null; if (request.getOperationLogFilters().getCreatedDayFrom() != null) { - createdFrom = simple.format(request.getOperationLogFilters().getCreatedDayFrom()); + createdFrom = request.getOperationLogFilters().getCreatedDayFrom(); } if (request.getOperationLogFilters().getCreatedDayTo() != null) { - createdTo = simple.format(request.getOperationLogFilters().getCreatedDayTo()); + createdTo = request.getOperationLogFilters().getCreatedDayTo(); } Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom(); @@ -1681,7 +1679,7 @@ public class GenericOperationDAOImpl implements OperationDAO { isUpdatedDayProvided = true; } sql += ") om ON o.ID = om.OPERATION_ID "; - if (createdFrom != null && !createdFrom.isEmpty() && createdTo != null && !createdTo.isEmpty()) { + if (createdFrom != null && createdFrom != 0 && createdTo != null && createdTo != 0) { sql += " WHERE o.CREATED_TIMESTAMP BETWEEN ? AND ?"; isCreatedDayProvided = true; } @@ -1717,8 +1715,8 @@ public class GenericOperationDAOImpl implements OperationDAO { stmt.setLong(paramIndex++, updatedTo); } if (isCreatedDayProvided) { - stmt.setString(paramIndex++, createdFrom); - stmt.setString(paramIndex++, createdTo); + stmt.setLong(paramIndex++, createdFrom); + stmt.setLong(paramIndex++, createdTo); } if (isStatusProvided) { for (String s : status) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/OracleOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/OracleOperationDAOImpl.java index 9a53353a2e..5dab77e009 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/OracleOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/OracleOperationDAOImpl.java @@ -57,18 +57,17 @@ public class OracleOperationDAOImpl extends GenericOperationDAOImpl { throws OperationManagementDAOException { Operation operation; List operations = new ArrayList(); - String createdTo = null; - String createdFrom = null; - DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + Long createdTo = null; + Long createdFrom = null; boolean isCreatedDayProvided = false; boolean isUpdatedDayProvided = false; //updated day = received day boolean isOperationCodeProvided = false; boolean isStatusProvided = false; if (request.getOperationLogFilters().getCreatedDayFrom() != null) { - createdFrom = simple.format(request.getOperationLogFilters().getCreatedDayFrom()); + createdFrom = request.getOperationLogFilters().getCreatedDayFrom(); } if (request.getOperationLogFilters().getCreatedDayTo() != null) { - createdTo = simple.format(request.getOperationLogFilters().getCreatedDayTo()); + createdTo = request.getOperationLogFilters().getCreatedDayTo(); } Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom(); Long updatedTo = request.getOperationLogFilters().getUpdatedDayTo(); @@ -101,7 +100,7 @@ public class OracleOperationDAOImpl extends GenericOperationDAOImpl { isUpdatedDayProvided = true; } sql = sql + ") om ON o.ID = om.OPERATION_ID "; - if (createdFrom != null && !createdFrom.isEmpty() && createdTo != null && !createdTo.isEmpty()) { + if (createdFrom != null && createdFrom != 0 && createdTo != null && createdTo != 0) { sql = sql + " WHERE o.CREATED_TIMESTAMP BETWEEN ? AND ?"; isCreatedDayProvided = true; } @@ -150,8 +149,8 @@ public class OracleOperationDAOImpl extends GenericOperationDAOImpl { stmt.setLong(paramIndex++, updatedTo); } if (isCreatedDayProvided) { - stmt.setString(paramIndex++, createdFrom); - stmt.setString(paramIndex++, createdTo); + stmt.setLong(paramIndex++, createdFrom); + stmt.setLong(paramIndex++, createdTo); } if (isStatusProvided) { int size = status.size(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/PostgreSQLOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/PostgreSQLOperationDAOImpl.java index ede11203d3..0b76e5ccce 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/PostgreSQLOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/PostgreSQLOperationDAOImpl.java @@ -48,18 +48,17 @@ public class PostgreSQLOperationDAOImpl extends GenericOperationDAOImpl { throws OperationManagementDAOException { Operation operation; List operations = new ArrayList(); - String createdTo = null; - String createdFrom = null; - DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + Long createdTo = null; + Long createdFrom = null; boolean isCreatedDayProvided = false; boolean isUpdatedDayProvided = false; //updated day = received day boolean isOperationCodeProvided = false; boolean isStatusProvided = false; if (request.getOperationLogFilters().getCreatedDayFrom() != null) { - createdFrom = simple.format(request.getOperationLogFilters().getCreatedDayFrom()); + createdFrom = request.getOperationLogFilters().getCreatedDayFrom(); } if (request.getOperationLogFilters().getCreatedDayTo() != null) { - createdTo = simple.format(request.getOperationLogFilters().getCreatedDayTo()); + createdTo = request.getOperationLogFilters().getCreatedDayTo(); } Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom(); Long updatedTo = request.getOperationLogFilters().getUpdatedDayTo(); @@ -92,7 +91,7 @@ public class PostgreSQLOperationDAOImpl extends GenericOperationDAOImpl { isUpdatedDayProvided = true; } sql = sql + ") om ON o.ID = om.OPERATION_ID "; - if (createdFrom != null && !createdFrom.isEmpty() && createdTo != null && !createdTo.isEmpty()) { + if (createdFrom != null && createdFrom != 0 && createdTo != null && createdTo != 0) { sql = sql + " WHERE o.CREATED_TIMESTAMP BETWEEN ? AND ?"; isCreatedDayProvided = true; } @@ -141,8 +140,8 @@ public class PostgreSQLOperationDAOImpl extends GenericOperationDAOImpl { stmt.setLong(paramIndex++, updatedTo); } if (isCreatedDayProvided) { - stmt.setString(paramIndex++, createdFrom); - stmt.setString(paramIndex++, createdTo); + stmt.setLong(paramIndex++, createdFrom); + stmt.setLong(paramIndex++, createdTo); } if (isStatusProvided) { int size = status.size(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/SQLServerOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/SQLServerOperationDAOImpl.java index c6d29acd78..2d2939eb57 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/SQLServerOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/SQLServerOperationDAOImpl.java @@ -60,18 +60,17 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl { throws OperationManagementDAOException { Operation operation; List operations = new ArrayList(); - String createdTo = null; - String createdFrom = null; - DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + Long createdTo = null; + Long createdFrom = null; boolean isCreatedDayProvided = false; boolean isUpdatedDayProvided = false; //updated day = received day boolean isOperationCodeProvided = false; boolean isStatusProvided = false; if (request.getOperationLogFilters().getCreatedDayFrom() != null) { - createdFrom = simple.format(request.getOperationLogFilters().getCreatedDayFrom()); + createdFrom = request.getOperationLogFilters().getCreatedDayFrom(); } if (request.getOperationLogFilters().getCreatedDayTo() != null) { - createdTo = simple.format(request.getOperationLogFilters().getCreatedDayTo()); + createdTo = request.getOperationLogFilters().getCreatedDayTo(); } Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom(); Long updatedTo = request.getOperationLogFilters().getUpdatedDayTo(); @@ -104,7 +103,7 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl { isUpdatedDayProvided = true; } sql = sql + ") om ON o.ID = om.OPERATION_ID "; - if (createdFrom != null && !createdFrom.isEmpty() && createdTo != null && !createdTo.isEmpty()) { + if (createdFrom != null && createdFrom != 0 && createdTo != null && createdTo != 0) { sql = sql + " WHERE o.CREATED_TIMESTAMP BETWEEN ? AND ?"; isCreatedDayProvided = true; } @@ -155,8 +154,8 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl { stmt.setLong(paramIndex++, updatedTo); } if (isCreatedDayProvided) { - stmt.setString(paramIndex++, createdFrom); - stmt.setString(paramIndex++, createdTo); + stmt.setLong(paramIndex++, createdFrom); + stmt.setLong(paramIndex++, createdTo); } if (isStatusProvided) { int size = status.size();