Fix "Created Date" search and "Updated Date" search are not working in Operations Log

rm-11592
Pramila Niroshan 4 months ago
parent fa24f95a69
commit 26f57beb23

@ -1858,22 +1858,22 @@ public interface DeviceManagementService {
String ownership, String ownership,
@ApiParam( @ApiParam(
name = "createdFrom", 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") @QueryParam("createdFrom")
Long createdFrom, Long createdFrom,
@ApiParam( @ApiParam(
name = "createdTo", 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") @QueryParam("createdTo")
Long createdTo, Long createdTo,
@ApiParam( @ApiParam(
name = "updatedFrom", 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") @QueryParam("updatedFrom")
Long updatedFrom, Long updatedFrom,
@ApiParam( @ApiParam(
name = "updatedTo", 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") @QueryParam("updatedTo")
Long updatedTo, Long updatedTo,
@ApiParam( @ApiParam(

@ -559,13 +559,11 @@ public class RequestValidationUtil {
} }
if (createdTo != null || createdFrom != null) { if (createdTo != null || createdFrom != null) {
validateDates(createdFrom, createdTo); validateDates(createdFrom, createdTo);
createdFrom = createdFrom * 1000;
//if user only sends the fromDate toDate sets as current date //if user only sends the fromDate toDate sets as current date
if (createdFrom != null && createdTo == null) { if (createdFrom != null && createdTo == null) {
operationLogFilters.setCreatedDayFrom(createdFrom); operationLogFilters.setCreatedDayFrom(createdFrom);
operationLogFilters.setCreatedDayTo(timeMilli); operationLogFilters.setCreatedDayTo(timeMilli);
} else { } else {
createdTo = createdTo * 1000;
operationLogFilters.setCreatedDayFrom(createdFrom); operationLogFilters.setCreatedDayFrom(createdFrom);
operationLogFilters.setCreatedDayTo(createdTo); operationLogFilters.setCreatedDayTo(createdTo);
} }

@ -1372,19 +1372,18 @@ public class GenericOperationDAOImpl implements OperationDAO {
throws OperationManagementDAOException { throws OperationManagementDAOException {
Operation operation; Operation operation;
List<Operation> operations = new ArrayList<>(); List<Operation> operations = new ArrayList<>();
String createdTo = null; Long createdTo = null;
String createdFrom = null; Long createdFrom = null;
ProfileOperation profileOperation = null; ProfileOperation profileOperation = null;
DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
boolean isCreatedDayProvided = false; boolean isCreatedDayProvided = false;
boolean isUpdatedDayProvided = false; //updated day = received day boolean isUpdatedDayProvided = false; //updated day = received day
boolean isOperationCodeProvided = false; boolean isOperationCodeProvided = false;
boolean isStatusProvided = false; boolean isStatusProvided = false;
if (request.getOperationLogFilters().getCreatedDayFrom() != null) { if (request.getOperationLogFilters().getCreatedDayFrom() != null) {
createdFrom = simple.format(request.getOperationLogFilters().getCreatedDayFrom()); createdFrom = request.getOperationLogFilters().getCreatedDayFrom();
} }
if (request.getOperationLogFilters().getCreatedDayTo() != null) { if (request.getOperationLogFilters().getCreatedDayTo() != null) {
createdTo = simple.format(request.getOperationLogFilters().getCreatedDayTo()); createdTo = request.getOperationLogFilters().getCreatedDayTo();
} }
Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom(); Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom();
Long updatedTo = request.getOperationLogFilters().getUpdatedDayTo(); Long updatedTo = request.getOperationLogFilters().getUpdatedDayTo();
@ -1419,7 +1418,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
isUpdatedDayProvided = true; isUpdatedDayProvided = true;
} }
sql.append(") om ON o.ID = om.OPERATION_ID "); 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 ?"); sql.append(" WHERE o.CREATED_TIMESTAMP BETWEEN ? AND ?");
isCreatedDayProvided = true; isCreatedDayProvided = true;
} }
@ -1468,8 +1467,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
stmt.setLong(paramIndex++, updatedTo); stmt.setLong(paramIndex++, updatedTo);
} }
if (isCreatedDayProvided) { if (isCreatedDayProvided) {
stmt.setString(paramIndex++, createdFrom); stmt.setLong(paramIndex++, createdFrom);
stmt.setString(paramIndex++, createdTo); stmt.setLong(paramIndex++, createdTo);
} }
if (isStatusProvided) { if (isStatusProvided) {
for (String s : status) { for (String s : status) {
@ -1643,14 +1642,13 @@ public class GenericOperationDAOImpl implements OperationDAO {
@Override @Override
public int getOperationCountForDevice(int enrolmentId, PaginationRequest request) public int getOperationCountForDevice(int enrolmentId, PaginationRequest request)
throws OperationManagementDAOException { throws OperationManagementDAOException {
String createdTo = null; Long createdTo = null;
String createdFrom = null; Long createdFrom = null;
DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
if (request.getOperationLogFilters().getCreatedDayFrom() != null) { if (request.getOperationLogFilters().getCreatedDayFrom() != null) {
createdFrom = simple.format(request.getOperationLogFilters().getCreatedDayFrom()); createdFrom = request.getOperationLogFilters().getCreatedDayFrom();
} }
if (request.getOperationLogFilters().getCreatedDayTo() != null) { if (request.getOperationLogFilters().getCreatedDayTo() != null) {
createdTo = simple.format(request.getOperationLogFilters().getCreatedDayTo()); createdTo = request.getOperationLogFilters().getCreatedDayTo();
} }
Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom(); Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom();
@ -1681,7 +1679,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
isUpdatedDayProvided = true; isUpdatedDayProvided = true;
} }
sql += ") om ON o.ID = om.OPERATION_ID "; 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 ?"; sql += " WHERE o.CREATED_TIMESTAMP BETWEEN ? AND ?";
isCreatedDayProvided = true; isCreatedDayProvided = true;
} }
@ -1717,8 +1715,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
stmt.setLong(paramIndex++, updatedTo); stmt.setLong(paramIndex++, updatedTo);
} }
if (isCreatedDayProvided) { if (isCreatedDayProvided) {
stmt.setString(paramIndex++, createdFrom); stmt.setLong(paramIndex++, createdFrom);
stmt.setString(paramIndex++, createdTo); stmt.setLong(paramIndex++, createdTo);
} }
if (isStatusProvided) { if (isStatusProvided) {
for (String s : status) { for (String s : status) {

@ -57,18 +57,17 @@ public class OracleOperationDAOImpl extends GenericOperationDAOImpl {
throws OperationManagementDAOException { throws OperationManagementDAOException {
Operation operation; Operation operation;
List<Operation> operations = new ArrayList<Operation>(); List<Operation> operations = new ArrayList<Operation>();
String createdTo = null; Long createdTo = null;
String createdFrom = null; Long createdFrom = null;
DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
boolean isCreatedDayProvided = false; boolean isCreatedDayProvided = false;
boolean isUpdatedDayProvided = false; //updated day = received day boolean isUpdatedDayProvided = false; //updated day = received day
boolean isOperationCodeProvided = false; boolean isOperationCodeProvided = false;
boolean isStatusProvided = false; boolean isStatusProvided = false;
if (request.getOperationLogFilters().getCreatedDayFrom() != null) { if (request.getOperationLogFilters().getCreatedDayFrom() != null) {
createdFrom = simple.format(request.getOperationLogFilters().getCreatedDayFrom()); createdFrom = request.getOperationLogFilters().getCreatedDayFrom();
} }
if (request.getOperationLogFilters().getCreatedDayTo() != null) { if (request.getOperationLogFilters().getCreatedDayTo() != null) {
createdTo = simple.format(request.getOperationLogFilters().getCreatedDayTo()); createdTo = request.getOperationLogFilters().getCreatedDayTo();
} }
Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom(); Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom();
Long updatedTo = request.getOperationLogFilters().getUpdatedDayTo(); Long updatedTo = request.getOperationLogFilters().getUpdatedDayTo();
@ -101,7 +100,7 @@ public class OracleOperationDAOImpl extends GenericOperationDAOImpl {
isUpdatedDayProvided = true; isUpdatedDayProvided = true;
} }
sql = sql + ") om ON o.ID = om.OPERATION_ID "; 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 ?"; sql = sql + " WHERE o.CREATED_TIMESTAMP BETWEEN ? AND ?";
isCreatedDayProvided = true; isCreatedDayProvided = true;
} }
@ -150,8 +149,8 @@ public class OracleOperationDAOImpl extends GenericOperationDAOImpl {
stmt.setLong(paramIndex++, updatedTo); stmt.setLong(paramIndex++, updatedTo);
} }
if (isCreatedDayProvided) { if (isCreatedDayProvided) {
stmt.setString(paramIndex++, createdFrom); stmt.setLong(paramIndex++, createdFrom);
stmt.setString(paramIndex++, createdTo); stmt.setLong(paramIndex++, createdTo);
} }
if (isStatusProvided) { if (isStatusProvided) {
int size = status.size(); int size = status.size();

@ -48,18 +48,17 @@ public class PostgreSQLOperationDAOImpl extends GenericOperationDAOImpl {
throws OperationManagementDAOException { throws OperationManagementDAOException {
Operation operation; Operation operation;
List<Operation> operations = new ArrayList<Operation>(); List<Operation> operations = new ArrayList<Operation>();
String createdTo = null; Long createdTo = null;
String createdFrom = null; Long createdFrom = null;
DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
boolean isCreatedDayProvided = false; boolean isCreatedDayProvided = false;
boolean isUpdatedDayProvided = false; //updated day = received day boolean isUpdatedDayProvided = false; //updated day = received day
boolean isOperationCodeProvided = false; boolean isOperationCodeProvided = false;
boolean isStatusProvided = false; boolean isStatusProvided = false;
if (request.getOperationLogFilters().getCreatedDayFrom() != null) { if (request.getOperationLogFilters().getCreatedDayFrom() != null) {
createdFrom = simple.format(request.getOperationLogFilters().getCreatedDayFrom()); createdFrom = request.getOperationLogFilters().getCreatedDayFrom();
} }
if (request.getOperationLogFilters().getCreatedDayTo() != null) { if (request.getOperationLogFilters().getCreatedDayTo() != null) {
createdTo = simple.format(request.getOperationLogFilters().getCreatedDayTo()); createdTo = request.getOperationLogFilters().getCreatedDayTo();
} }
Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom(); Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom();
Long updatedTo = request.getOperationLogFilters().getUpdatedDayTo(); Long updatedTo = request.getOperationLogFilters().getUpdatedDayTo();
@ -92,7 +91,7 @@ public class PostgreSQLOperationDAOImpl extends GenericOperationDAOImpl {
isUpdatedDayProvided = true; isUpdatedDayProvided = true;
} }
sql = sql + ") om ON o.ID = om.OPERATION_ID "; 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 ?"; sql = sql + " WHERE o.CREATED_TIMESTAMP BETWEEN ? AND ?";
isCreatedDayProvided = true; isCreatedDayProvided = true;
} }
@ -141,8 +140,8 @@ public class PostgreSQLOperationDAOImpl extends GenericOperationDAOImpl {
stmt.setLong(paramIndex++, updatedTo); stmt.setLong(paramIndex++, updatedTo);
} }
if (isCreatedDayProvided) { if (isCreatedDayProvided) {
stmt.setString(paramIndex++, createdFrom); stmt.setLong(paramIndex++, createdFrom);
stmt.setString(paramIndex++, createdTo); stmt.setLong(paramIndex++, createdTo);
} }
if (isStatusProvided) { if (isStatusProvided) {
int size = status.size(); int size = status.size();

@ -60,18 +60,17 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl {
throws OperationManagementDAOException { throws OperationManagementDAOException {
Operation operation; Operation operation;
List<Operation> operations = new ArrayList<Operation>(); List<Operation> operations = new ArrayList<Operation>();
String createdTo = null; Long createdTo = null;
String createdFrom = null; Long createdFrom = null;
DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
boolean isCreatedDayProvided = false; boolean isCreatedDayProvided = false;
boolean isUpdatedDayProvided = false; //updated day = received day boolean isUpdatedDayProvided = false; //updated day = received day
boolean isOperationCodeProvided = false; boolean isOperationCodeProvided = false;
boolean isStatusProvided = false; boolean isStatusProvided = false;
if (request.getOperationLogFilters().getCreatedDayFrom() != null) { if (request.getOperationLogFilters().getCreatedDayFrom() != null) {
createdFrom = simple.format(request.getOperationLogFilters().getCreatedDayFrom()); createdFrom = request.getOperationLogFilters().getCreatedDayFrom();
} }
if (request.getOperationLogFilters().getCreatedDayTo() != null) { if (request.getOperationLogFilters().getCreatedDayTo() != null) {
createdTo = simple.format(request.getOperationLogFilters().getCreatedDayTo()); createdTo = request.getOperationLogFilters().getCreatedDayTo();
} }
Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom(); Long updatedFrom = request.getOperationLogFilters().getUpdatedDayFrom();
Long updatedTo = request.getOperationLogFilters().getUpdatedDayTo(); Long updatedTo = request.getOperationLogFilters().getUpdatedDayTo();
@ -104,7 +103,7 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl {
isUpdatedDayProvided = true; isUpdatedDayProvided = true;
} }
sql = sql + ") om ON o.ID = om.OPERATION_ID "; 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 ?"; sql = sql + " WHERE o.CREATED_TIMESTAMP BETWEEN ? AND ?";
isCreatedDayProvided = true; isCreatedDayProvided = true;
} }
@ -155,8 +154,8 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl {
stmt.setLong(paramIndex++, updatedTo); stmt.setLong(paramIndex++, updatedTo);
} }
if (isCreatedDayProvided) { if (isCreatedDayProvided) {
stmt.setString(paramIndex++, createdFrom); stmt.setLong(paramIndex++, createdFrom);
stmt.setString(paramIndex++, createdTo); stmt.setLong(paramIndex++, createdTo);
} }
if (isStatusProvided) { if (isStatusProvided) {
int size = status.size(); int size = status.size();

Loading…
Cancel
Save