From 0440c94ef2a7e9c66eefbae4bf09aa5207dc019d Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 22 Feb 2021 08:57:47 +0000 Subject: Convert Date to Instant in TOSCA PoC Issue-ID: POLICY-3069 Change-Id: I9efbc42c4fcc97f79799f3e09ed3424dcc86a891 Signed-off-by: liamfallon --- .../controlloop/concepts/ClElementStatistics.java | 4 ++-- .../concepts/ParticipantStatistics.java | 4 ++-- .../concepts/JpaClElementStatistics.java | 12 +++-------- .../concepts/JpaParticipantStatistics.java | 23 ++++++++-------------- .../provider/ClElementStatisticsProvider.java | 8 ++++---- .../provider/ParticipantStatisticsProvider.java | 8 ++++---- 6 files changed, 23 insertions(+), 36 deletions(-) (limited to 'tosca-controlloop/models/src/main/java') diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java index 1e264ef99..ec96830e2 100644 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java +++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java @@ -21,7 +21,7 @@ package org.onap.policy.clamp.controlloop.models.controlloop.concepts; import java.io.Serializable; -import java.util.Date; +import java.time.Instant; import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; @@ -39,7 +39,7 @@ public class ClElementStatistics implements Serializable { private ToscaConceptIdentifier controlLoopElementId; @NonNull - private Date timeStamp; + private Instant timeStamp; @NonNull private ControlLoopState controlLoopState; diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java index 0b895d418..3a7b21fa1 100644 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java +++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java @@ -21,7 +21,7 @@ package org.onap.policy.clamp.controlloop.models.controlloop.concepts; import java.io.Serializable; -import java.util.Date; +import java.time.Instant; import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; @@ -39,7 +39,7 @@ public class ParticipantStatistics implements Serializable { private ToscaConceptIdentifier participantId; @NonNull - private Date timeStamp; + private Instant timeStamp; private ParticipantState state; private ParticipantHealthStatus healthStatus; diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java index badf02066..abe0737f6 100644 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java +++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java @@ -21,10 +21,8 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; import java.io.Serializable; -import java.util.Date; import java.util.List; import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; import javax.persistence.Column; import javax.persistence.EmbeddedId; import javax.persistence.Entity; @@ -70,10 +68,8 @@ public class JpaClElementStatistics extends PfConcept implements PfAuthorative, Serializable { +public class JpaParticipantStatistics extends PfConcept implements PfAuthorative, Serializable { private static final long serialVersionUID = -5992214428190133190L; @@ -72,11 +69,8 @@ public class JpaParticipantStatistics extends PfConcept @VerifyKey @NotNull - @AttributeOverrides({ - @AttributeOverride(name = "name", column = @Column(name = "participant_name")), - @AttributeOverride(name = "version", column = @Column(name = "participant_version")) - } - ) + @AttributeOverride(name = "name", column = @Column(name = "participant_name")) + @AttributeOverride(name = "version", column = @Column(name = "participant_version")) private PfConceptKey participantId; @Column @@ -119,8 +113,8 @@ public class JpaParticipantStatistics extends PfConcept * @param key the key */ public JpaParticipantStatistics(@NonNull final PfTimestampKey key) { - this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.HEALTHY, 0L, 0L, - 0.0d, 0L, 0L, 0L); + this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.HEALTHY, 0L, 0L, 0.0d, 0L, 0L, + 0L); } @@ -196,7 +190,7 @@ public class JpaParticipantStatistics extends PfConcept @Override public ParticipantStatistics toAuthorative() { ParticipantStatistics participantStatistics = new ParticipantStatistics(); - participantStatistics.setTimeStamp(new Date(key.getTimeStamp().getTime())); + participantStatistics.setTimeStamp(key.getTimeStamp().toInstant()); participantStatistics.setParticipantId(new ToscaConceptIdentifier(participantId)); participantStatistics.setState(state); participantStatistics.setHealthStatus(healthStatus); @@ -214,8 +208,7 @@ public class JpaParticipantStatistics extends PfConcept public void fromAuthorative(@NonNull final ParticipantStatistics participantStatistics) { if (this.key == null || this.getKey().isNullKey()) { this.setKey(new PfTimestampKey(participantStatistics.getParticipantId().getName(), - participantStatistics.getParticipantId().getVersion(), - participantStatistics.getTimeStamp())); + participantStatistics.getParticipantId().getVersion(), participantStatistics.getTimeStamp())); } this.setParticipantId(participantStatistics.getParticipantId().asConceptKey()); this.setState(participantStatistics.getState()); @@ -241,4 +234,4 @@ public class JpaParticipantStatistics extends PfConcept key.clean(); participantId.clean(); } -} \ No newline at end of file +} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java index b1cdf62b0..1250dfce0 100644 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java +++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java @@ -20,8 +20,8 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; +import java.time.Instant; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -115,7 +115,7 @@ public class ClElementStatisticsProvider extends AbstractModelsProvider { * @throws PfModelException on errors getting clElement statistics */ public List getClElementStatistics(final String name, final String version, - final Date timestamp) throws PfModelException { + final Instant timestamp) throws PfModelException { if (name != null && version != null && timestamp != null) { List clElementStatistics = new ArrayList<>(1); @@ -139,8 +139,8 @@ public class ClElementStatisticsProvider extends AbstractModelsProvider { * @throws PfModelException on errors getting policies */ public List getFilteredClElementStatistics(final String name, final String version, - final Date startTimeStamp, final Date endTimeStamp, Map filterMap, final String sortOrder, - final int getRecordNum) { + final Instant startTimeStamp, final Instant endTimeStamp, Map filterMap, + final String sortOrder, final int getRecordNum) { return asClElementStatisticsList(getPfDao().getFiltered(JpaClElementStatistics.class, name, version, startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum)); } diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java index 5a0bb011c..3cbe901ab 100644 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java +++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java @@ -20,8 +20,8 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; +import java.time.Instant; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -62,7 +62,7 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider { * @throws PfModelException on errors getting participant statistics */ public List getParticipantStatistics(final String name, final String version, - final Date timestamp) throws PfModelException { + final Instant timestamp) throws PfModelException { if (name != null && version != null && timestamp != null) { List participantStatistics = new ArrayList<>(1); @@ -87,8 +87,8 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider { * @throws PfModelException on errors getting policies */ public List getFilteredParticipantStatistics(final String name, final String version, - final Date startTimeStamp, final Date endTimeStamp, Map filterMap, final String sortOrder, - final int getRecordNum) { + final Instant startTimeStamp, final Instant endTimeStamp, Map filterMap, + final String sortOrder, final int getRecordNum) { return asParticipantStatisticsList(getPfDao().getFiltered(JpaParticipantStatistics.class, name, version, startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum)); -- cgit 1.2.3-korg