aboutsummaryrefslogtreecommitdiffstats
path: root/tosca-controlloop/models/src/main/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2021-02-22 08:57:47 +0000
committerliamfallon <liam.fallon@est.tech>2021-02-22 09:01:02 +0000
commit0440c94ef2a7e9c66eefbae4bf09aa5207dc019d (patch)
treef677fb70fead1ef2a680a17cda44d54d3db36718 /tosca-controlloop/models/src/main/java
parentaf040a80000e4a0f1a98d251a78fc6b55aa6c1f4 (diff)
Convert Date to Instant in TOSCA PoC
Issue-ID: POLICY-3069 Change-Id: I9efbc42c4fcc97f79799f3e09ed3424dcc86a891 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'tosca-controlloop/models/src/main/java')
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java4
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java4
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java12
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java23
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java8
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java8
6 files changed, 23 insertions, 36 deletions
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<C
@VerifyKey
@NotNull
// @formatter:off
- @AttributeOverrides({
- @AttributeOverride(name = "name", column = @Column(name = "cl_element_name")),
- @AttributeOverride(name = "version", column = @Column(name = "cl_element_version"))
- })
+ @AttributeOverride(name = "name", column = @Column(name = "cl_element_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "cl_element_version"))
private PfConceptKey clElementId;
// @formatter: on
@@ -127,12 +123,10 @@ public class JpaClElementStatistics extends PfConcept implements PfAuthorative<C
this.fromAuthorative(authorativeConcept);
}
-
-
@Override
public ClElementStatistics toAuthorative() {
ClElementStatistics clElementStatistics = new ClElementStatistics();
- clElementStatistics.setTimeStamp(new Date(key.getTimeStamp().getTime()));
+ clElementStatistics.setTimeStamp(key.getTimeStamp().toInstant());
clElementStatistics.setControlLoopElementId(new ToscaConceptIdentifier(clElementId));
clElementStatistics.setControlLoopState(state);
clElementStatistics.setClElementUptime(clElementUptime);
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java
index 1877d98a1..84c7f0d59 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java
@@ -22,10 +22,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;
@@ -60,8 +58,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@Data
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
-public class JpaParticipantStatistics extends PfConcept
- implements PfAuthorative<ParticipantStatistics>, Serializable {
+public class JpaParticipantStatistics extends PfConcept implements PfAuthorative<ParticipantStatistics>, 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<ClElementStatistics> 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> clElementStatistics = new ArrayList<>(1);
@@ -139,8 +139,8 @@ public class ClElementStatisticsProvider extends AbstractModelsProvider {
* @throws PfModelException on errors getting policies
*/
public List<ClElementStatistics> getFilteredClElementStatistics(final String name, final String version,
- final Date startTimeStamp, final Date endTimeStamp, Map<String, Object> filterMap, final String sortOrder,
- final int getRecordNum) {
+ final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> 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<ParticipantStatistics> 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> participantStatistics = new ArrayList<>(1);
@@ -87,8 +87,8 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
* @throws PfModelException on errors getting policies
*/
public List<ParticipantStatistics> getFilteredParticipantStatistics(final String name, final String version,
- final Date startTimeStamp, final Date endTimeStamp, Map<String, Object> filterMap, final String sortOrder,
- final int getRecordNum) {
+ final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap,
+ final String sortOrder, final int getRecordNum) {
return asParticipantStatisticsList(getPfDao().getFiltered(JpaParticipantStatistics.class, name, version,
startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum));