diff options
author | Jozsef Csongvai <jozsef.csongvai@bell.ca> | 2020-03-05 11:31:59 -0500 |
---|---|---|
committer | Jozsef Csongvai <jozsef.csongvai@bell.ca> | 2020-03-06 17:54:09 +0000 |
commit | f098f1a57f024df9396ec994129f0a01b7a94248 (patch) | |
tree | 1d812b2111598af4233e36606a9d5262c106d96b /mso-api-handlers/mso-requests-db-repositories/src/main/java | |
parent | 4d1e251ebcde26583cc85abef7b6909e9808771c (diff) |
Enable date span filtering for getOrchestrationFiltersFromInfraActive
Issue-ID: SO-2715
Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
Change-Id: I9cfeacce1e82eeacd2c6267523e5f3b950a68d3d
Diffstat (limited to 'mso-api-handlers/mso-requests-db-repositories/src/main/java')
-rw-r--r-- | mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java | 11 |
1 files changed, 8 insertions, 3 deletions
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)); |