aboutsummaryrefslogtreecommitdiffstats
path: root/models-dao/src/main
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2021-02-16 16:25:18 +0000
committerrameshiyer27 <ramesh.murugan.iyer@est.tech>2021-02-19 15:26:11 +0000
commit5a94ebda407e82a8df4abea1b8a916ea4f88d9cd (patch)
tree9372cfd5e716196ddd1bf908d4da5db7e64f93c0 /models-dao/src/main
parent7e4f9950ed004042e36e7e1f6f78224d62888e74 (diff)
Refactor timestamp property in policy models to use Instant
Updated JPA classes to use java.sql.TImestamp rather than Instant. Issue-ID: POLICY-3069 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: If5b874ec96931d4b8dd142d46a9980e83a4708fc
Diffstat (limited to 'models-dao/src/main')
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java8
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java19
2 files changed, 14 insertions, 13 deletions
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java
index 6c862bb64..05f907fdd 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,8 +21,8 @@
package org.onap.policy.models.dao;
+import java.time.Instant;
import java.util.Collection;
-import java.util.Date;
import java.util.List;
import java.util.Map;
import org.onap.policy.models.base.PfConcept;
@@ -168,8 +168,8 @@ public interface PfDao {
* @param getRecordNum Total query count from database
* @return the objects that was retrieved from the database
*/
- <T extends PfConcept> List<T> getFiltered(Class<T> someClass, String name, String version, Date startTime,
- Date endTime, Map<String, Object> filterMap, String sortOrder, int getRecordNum);
+ <T extends PfConcept> List<T> getFiltered(Class<T> someClass, String name, String version, Instant startTime,
+ Instant endTime, Map<String, Object> filterMap, String sortOrder, int getRecordNum);
/**
* Get an object from the database, referred to by concept key.
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
index 5e89ee591..c29c4bf2d 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,9 +21,10 @@
package org.onap.policy.models.dao.impl;
+import java.sql.Timestamp;
+import java.time.Instant;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
@@ -355,7 +356,7 @@ public class DefaultPfDao implements PfDao {
@Override
public <T extends PfConcept> List<T> getFiltered(final Class<T> someClass, final String name, final String version,
- final Date startTime, final Date endTime, final Map<String, Object> filterMap, final String sortOrder,
+ final Instant startTime, final Instant endTime, final Map<String, Object> filterMap, final String sortOrder,
final int getRecordNum) {
final EntityManager mg = getEntityManager();
@@ -381,14 +382,14 @@ public class DefaultPfDao implements PfDao {
}
if (startTime != null) {
if (endTime != null) {
- query.setParameter("startTime", startTime);
- query.setParameter("endTime", endTime);
+ query.setParameter("startTime", Timestamp.from(startTime));
+ query.setParameter("endTime", Timestamp.from(endTime));
} else {
- query.setParameter("startTime", startTime);
+ query.setParameter("startTime", Timestamp.from(startTime));
}
} else {
if (endTime != null) {
- query.setParameter("endTime", endTime);
+ query.setParameter("endTime", Timestamp.from(endTime));
}
}
if (getRecordNum > 0) {
@@ -620,8 +621,8 @@ public class DefaultPfDao implements PfDao {
* endTime. null for ignore end time
* @return the filter string to query database
*/
- private String addKeyFilterString(String inputFilterString, final String name, final Date startTime,
- final Date endTime) {
+ private String addKeyFilterString(String inputFilterString, final String name, final Instant startTime,
+ final Instant endTime) {
String filterQueryString;
if (name != null) {
inputFilterString += NAME_FILTER + AND;