From f098f1a57f024df9396ec994129f0a01b7a94248 Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Thu, 5 Mar 2020 11:31:59 -0500 Subject: Enable date span filtering for getOrchestrationFiltersFromInfraActive Issue-ID: SO-2715 Signed-off-by: Jozsef Csongvai Change-Id: I9cfeacce1e82eeacd2c6267523e5f3b950a68d3d --- .../data/repository/InfraActiveRequestsRepositoryImpl.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'mso-api-handlers/mso-requests-db-repositories/src/main/java/org') diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java index da8f30ab1e..b669b7d837 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java @@ -277,17 +277,22 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep mapKey = "startTime"; } + final String operator = entry.getValue().get(0); final String propertyValue = entry.getValue().get(1); if ("startTime".equals(mapKey)) { final SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy"); try { final Date thisDate = format.parse(propertyValue); final Timestamp minTime = new Timestamp(thisDate.getTime()); - final Timestamp maxTime = new Timestamp(thisDate.getTime() + TimeUnit.DAYS.toMillis(1)); + Timestamp maxTime = new Timestamp(thisDate.getTime() + TimeUnit.DAYS.toMillis(1)); - if ("DOES_NOT_EQUAL".equalsIgnoreCase(entry.getValue().get(0))) { + if ("DOES_NOT_EQUAL".equalsIgnoreCase(operator)) { predicates.add(cb.or(cb.lessThan(tableRoot.get(mapKey), minTime), cb.greaterThanOrEqualTo(tableRoot.get(mapKey), maxTime))); + } else if ("BETWEEN_DATES".equalsIgnoreCase(operator)) { + Date endDate = format.parse(entry.getValue().get(2)); + maxTime = new Timestamp(endDate.getTime()); + predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime)); } else { predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime)); } @@ -295,7 +300,7 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep logger.debug("Exception in getOrchestrationFiltersFromInfraActive(): {}", e.getMessage(), e); return null; } - } else if ("DOES_NOT_EQUAL".equalsIgnoreCase(entry.getValue().get(0))) { + } else if ("DOES_NOT_EQUAL".equalsIgnoreCase(operator)) { predicates.add(cb.notEqual(tableRoot.get(mapKey), propertyValue)); } else { predicates.add(cb.equal(tableRoot.get(mapKey), propertyValue)); -- cgit 1.2.3-korg