From 5a94ebda407e82a8df4abea1b8a916ea4f88d9cd Mon Sep 17 00:00:00 2001 From: rameshiyer27 Date: Tue, 16 Feb 2021 16:25:18 +0000 Subject: 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 Change-Id: If5b874ec96931d4b8dd142d46a9980e83a4708fc --- .../org/onap/policy/models/pdp/concepts/PdpStatistics.java | 8 ++++---- .../models/pdp/persistence/concepts/JpaPdpStatistics.java | 8 ++++---- .../pdp/persistence/provider/PdpStatisticsProvider.java | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'models-pdp/src/main/java/org/onap') diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java index 1ba983be2..f7a0e7d91 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ package org.onap.policy.models.pdp.concepts; -import java.util.Date; +import java.time.Instant; import java.util.List; import lombok.Data; import lombok.NoArgsConstructor; @@ -39,7 +39,7 @@ import org.onap.policy.models.base.PfUtils; public class PdpStatistics { private String pdpInstanceId; - private Date timeStamp; + private Instant timeStamp; private String pdpGroupName; private String pdpSubGroupName; private long policyDeployCount; @@ -57,7 +57,7 @@ public class PdpStatistics { */ public PdpStatistics(@NonNull PdpStatistics source) { this.pdpInstanceId = source.pdpInstanceId; - this.timeStamp = source.timeStamp == null ? null : new Date(source.timeStamp.getTime()); + this.timeStamp = source.timeStamp; this.pdpGroupName = source.pdpGroupName; this.pdpSubGroupName = source.pdpSubGroupName; this.policyDeployCount = source.policyDeployCount; diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java index 90cf4e468..c3329cfa4 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Model * ================================================================================ - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,7 +24,7 @@ package org.onap.policy.models.pdp.persistence.concepts; import java.io.Serializable; -import java.util.Date; +import java.time.Instant; import java.util.List; import javax.persistence.Column; import javax.persistence.ElementCollection; @@ -167,7 +167,7 @@ public class JpaPdpStatistics extends PfConcept implements PfAuthorative getPdpStatistics(@NonNull final PfDao dao, final String name, final Date timestamp) + public List getPdpStatistics(@NonNull final PfDao dao, final String name, final Instant timestamp) throws PfModelException { List pdpStatistics = new ArrayList<>(); @@ -87,8 +87,8 @@ public class PdpStatisticsProvider { * @throws PfModelException on errors getting policies */ public List getFilteredPdpStatistics(@NonNull final PfDao dao, final String name, - @NonNull final String pdpGroupName, final String pdpSubGroup, final Date startTimeStamp, - final Date endTimeStamp, final String sortOrder, final int getRecordNum) { + @NonNull final String pdpGroupName, final String pdpSubGroup, final Instant startTimeStamp, + final Instant endTimeStamp, final String sortOrder, final int getRecordNum) { Map filterMap = new HashMap<>(); filterMap.put("pdpGroupName", pdpGroupName); if (pdpSubGroup != null) { @@ -181,7 +181,7 @@ public class PdpStatisticsProvider { * @throws PfModelException on errors deleting PDP statistics */ public List deletePdpStatistics(@NonNull final PfDao dao, @NonNull final String name, - final Date timestamp) { + final Instant timestamp) { List pdpStatisticsListToDel = asPdpStatisticsList(dao.getFiltered(JpaPdpStatistics.class, name, PfKey.NULL_KEY_VERSION, timestamp, timestamp, null, DESC_ORDER, 0)); -- cgit 1.2.3-korg