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

pull/480/head
Pramila Niroshan 3 months ago
parent fa24f95a69
commit 26f57beb23

@ -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(

@ -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);
}

@ -1372,19 +1372,18 @@ public class GenericOperationDAOImpl implements OperationDAO {
throws OperationManagementDAOException {
Operation operation;
List<Operation> 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) {

@ -57,18 +57,17 @@ public class OracleOperationDAOImpl extends GenericOperationDAOImpl {
throws OperationManagementDAOException {
Operation operation;
List<Operation> operations = new ArrayList<Operation>();
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();

@ -48,18 +48,17 @@ public class PostgreSQLOperationDAOImpl extends GenericOperationDAOImpl {
throws OperationManagementDAOException {
Operation operation;
List<Operation> operations = new ArrayList<Operation>();
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();

@ -60,18 +60,17 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl {
throws OperationManagementDAOException {
Operation operation;
List<Operation> operations = new ArrayList<Operation>();
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();

Loading…
Cancel
Save