100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Hibernate update part2 (#2421)
Eric Bariauxd831bc999a1a
diff --git a/agent/src/main/java/org/openremote/agent/protocol/mail/AbstractMailProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/mail/AbstractMailProtocol.javaindex 8ce56e7dc..e57ebfcb7 100644--- a/agent/src/main/java/org/openremote/agent/protocol/mail/AbstractMailProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/mail/AbstractMailProtocol.java@@ -33,6 +33,7 @@ import org.openremote.model.mail.MailMessage;import org.openremote.model.syslog.SyslogCategory;import java.nio.file.Path;+import java.util.Date;import java.util.Map;import java.util.Optional;import java.util.concurrent.ConcurrentHashMap;@@ -81,7 +82,7 @@ public abstract class AbstractMailProtocol<T extends AbstractMailAgent<T, U, V>,// Set an initial delay to allow attributes to be linked before we read messages - not perfect but it should do.setCheckInitialDelaySeconds(INITIAL_CHECK_DELAY_SECONDS).setPreferHTML(getAgent().getPreferHTML().orElse(false))- .setEarliestMessageDate(agent.getCreatedOn());+ .setEarliestMessageDate(Date.from(agent.getCreatedOn()));oAuthGrant.map(oAuth -> clientBuilder.setOAuth(userPassword.getUsername(), oAuth)).orElseGet(() ->clientBuilder.setBasicAuth(userPassword.getUsername(), userPassword.getPassword()));diff --git a/manager/src/main/java/org/openremote/manager/alarm/AlarmService.java b/manager/src/main/java/org/openremote/manager/alarm/AlarmService.javaindex 0a65599ae..358702b8d 100644--- a/manager/src/main/java/org/openremote/manager/alarm/AlarmService.java+++ b/manager/src/main/java/org/openremote/manager/alarm/AlarmService.java@@ -50,6 +50,7 @@ import org.openremote.model.util.TextUtil;import java.sql.PreparedStatement;import java.sql.Timestamp;import java.text.DateFormat;+import java.time.Instant;import java.util.*;import java.util.logging.Logger;import java.util.stream.Collectors;@@ -176,7 +177,7 @@ public class AlarmService extends RouteBuilder implements ContainerService {Objects.requireNonNull(alarm.getSource(), "Source cannot be null");Objects.requireNonNull(alarm.getSourceId(), "Source ID cannot be null");- Date timestamp = new Date(timerService.getCurrentTimeMillis());+ Instant timestamp = Instant.ofEpochMilli(timerService.getCurrentTimeMillis());SentAlarm sentAlarm = persistenceService.doReturningTransaction(entityManager -> entityManager.merge(new SentAlarm().setAssigneeId(alarm.getAssigneeId()).setRealm(alarm.getRealm())@@ -271,7 +272,7 @@ public class AlarmService extends RouteBuilder implements ContainerService {Map<String, String> result = new LinkedHashMap<>();result.put("Title", alarm.getTitle());result.put("Content", alarm.getContent());- result.put("Created", DateFormat.getDateTimeInstance().format(alarm.getCreatedOn()));+ result.put("Created", DateFormat.getDateTimeInstance().format(Date.from(alarm.getCreatedOn())));result.put("Source", alarm.getSource().name());result.put("Severity", alarm.getSeverity().name());result.put("Status", alarm.getStatus().name());@@ -317,7 +318,7 @@ public class AlarmService extends RouteBuilder implements ContainerService {.setParameter("content", newAlarm.getContent()).setParameter("severity", newAlarm.getSeverity()).setParameter("status", newAlarm.getStatus())- .setParameter("lastModified", new Timestamp(timerService.getCurrentTimeMillis()))+ .setParameter("lastModified", Instant.ofEpochMilli(timerService.getCurrentTimeMillis())).setParameter("assigneeId", newAssigneeId).executeUpdate());diff --git a/manager/src/main/java/org/openremote/manager/notification/NotificationService.java b/manager/src/main/java/org/openremote/manager/notification/NotificationService.javaindex c48fc1cc5..5464c156e 100644--- a/manager/src/main/java/org/openremote/manager/notification/NotificationService.java+++ b/manager/src/main/java/org/openremote/manager/notification/NotificationService.java@@ -217,7 +217,7 @@ public class NotificationService extends RouteBuilder implements ContainerServic.setTarget(target.getType()).setTargetId(target.getId()).setMessage(notification.getMessage())- .setSentOn(Date.from(timerService.getNow()));+ .setSentOn(timerService.getNow());sentNotification = em.merge(sentNotification);long id = sentNotification.getId();@@ -298,7 +298,7 @@ public class NotificationService extends RouteBuilder implements ContainerServicpersistenceService.doTransaction(entityManager -> {Query query = entityManager.createQuery("UPDATE SentNotification SET deliveredOn=:timestamp WHERE id =:id");query.setParameter("id", id);- query.setParameter("timestamp", new Date(timestamp));+ query.setParameter("timestamp", Instant.ofEpochMilli(timestamp));query.executeUpdate();});}@@ -311,7 +311,7 @@ public class NotificationService extends RouteBuilder implements ContainerServicpersistenceService.doTransaction(entityManager -> {Query query = entityManager.createQuery("UPDATE SentNotification SET acknowledgedOn=:timestamp, acknowledgement=:acknowledgement WHERE id =:id");query.setParameter("id", id);- query.setParameter("timestamp", new Date(timestamp));+ query.setParameter("timestamp", Instant.ofEpochMilli(timestamp));query.setParameter("acknowledgement", acknowledgement);query.executeUpdate();});@@ -405,14 +405,14 @@ public class NotificationService extends RouteBuilder implements ContainerServicbuilder.append(" AND n.sentOn >= ?").append(parameters.size() + 1);- parameters.add(new Date(fromTimestamp));+ parameters.add(Instant.ofEpochMilli(fromTimestamp));}if (toTimestamp != null) {builder.append(" AND n.sentOn <= ?").append(parameters.size() + 1);- parameters.add(new Date(toTimestamp));+ parameters.add(Instant.ofEpochMilli(toTimestamp));}if (hasAssets) {@@ -540,8 +540,8 @@ public class NotificationService extends RouteBuilder implements ContainerServicreturn true;}- Date lastSend = persistenceService.doReturningTransaction(entityManager -> entityManager.createQuery(- "SELECT n.sentOn FROM SentNotification n WHERE n.source =:source AND n.sourceId =:sourceId AND n.target =:target AND n.targetId =:targetId AND n.name =:name ORDER BY n.sentOn DESC", Date.class)+ Instant lastSend = persistenceService.doReturningTransaction(entityManager -> entityManager.createQuery(+ "SELECT n.sentOn FROM SentNotification n WHERE n.source =:source AND n.sourceId =:sourceId AND n.target =:target AND n.targetId =:targetId AND n.name =:name ORDER BY n.sentOn DESC", Instant.class).setParameter("source", source).setParameter("sourceId", sourceId).setParameter("target", target.getType())@@ -552,6 +552,6 @@ public class NotificationService extends RouteBuilder implements ContainerServicreturn lastSend == null ||(notification.getRepeatFrequency() != RepeatFrequency.ONCE &&- timerService.getNow().plusSeconds(1).isAfter(getRepeatAfterTimestamp(notification, lastSend.toInstant())));+ timerService.getNow().plusSeconds(1).isAfter(getRepeatAfterTimestamp(notification, lastSend)));}}diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesFacts.java b/manager/src/main/java/org/openremote/manager/rules/RulesFacts.javaindex b557a29b4..dbb4080fb 100644--- a/manager/src/main/java/org/openremote/manager/rules/RulesFacts.java+++ b/manager/src/main/java/org/openremote/manager/rules/RulesFacts.java@@ -500,7 +500,7 @@ public class RulesFacts extends Facts implements RuleListener {boolean reverse = orderBy.descending;keyExtractor = switch (orderBy.property) {- case CREATED_ON -> assetState -> Long.toString(assetState.getCreatedOn().getTime());+ case CREATED_ON -> assetState -> Long.toString(assetState.getCreatedOn().toEpochMilli());case ASSET_TYPE -> AttributeInfo::getAssetType;case PARENT_ID -> AttributeInfo::getParentId;case REALM -> AttributeInfo::getRealm;diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesetStorageService.java b/manager/src/main/java/org/openremote/manager/rules/RulesetStorageService.javaindex 36670e966..b1e473fd8 100644--- a/manager/src/main/java/org/openremote/manager/rules/RulesetStorageService.java+++ b/manager/src/main/java/org/openremote/manager/rules/RulesetStorageService.java@@ -39,6 +39,7 @@ import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;+import java.sql.Timestamp;import java.util.ArrayList;import java.util.List;import java.util.Map;@@ -287,8 +288,10 @@ public class RulesetStorageService implements ContainerService {ruleset.setVersion(rs.getLong("VERSION"));ruleset.setLang(Ruleset.Lang.valueOf(rs.getString("RULES_LANG")));ruleset.setEnabled(rs.getBoolean("ENABLED"));- ruleset.setLastModified(rs.getTimestamp("LAST_MODIFIED"));- ruleset.setCreatedOn(rs.getTimestamp("CREATED_ON"));+ Timestamp lastModified = rs.getTimestamp("LAST_MODIFIED");+ Timestamp createdOn = rs.getTimestamp("CREATED_ON");+ ruleset.setLastModified(lastModified != null ? lastModified.toInstant() : null);+ ruleset.setCreatedOn(createdOn != null ? createdOn.toInstant() : null);if (rs.getString("META") != null) {ruleset.setMeta(ValueUtil.parse(rs.getString("META"), Map.class).orElse(null));}diff --git a/model/src/main/java/org/openremote/model/alarm/AlarmAssetLink.java b/model/src/main/java/org/openremote/model/alarm/AlarmAssetLink.javaindex 5a28a2b28..2fa86cad4 100644--- a/model/src/main/java/org/openremote/model/alarm/AlarmAssetLink.java+++ b/model/src/main/java/org/openremote/model/alarm/AlarmAssetLink.java@@ -25,7 +25,7 @@ import org.hibernate.annotations.Formula;import jakarta.persistence.*;import java.io.Serializable;-import java.util.Date;+import java.time.Instant;import java.util.Objects;@Entity@@ -93,9 +93,8 @@ public class AlarmAssetLink {@EmbeddedIdprotected Id id;- @Temporal(TemporalType.TIMESTAMP)@Column(name = "CREATED_ON", updatable = false, nullable = false, columnDefinition = "TIMESTAMP WITH TIME ZONE")- protected Date createdOn;+ protected Instant createdOn;@Formula("(select a.NAME from ASSET a where a.ID = ASSET_ID)")protected String assetName;@@ -126,11 +125,11 @@ public class AlarmAssetLink {return parentAssetName;}- public Date getCreatedOn() {+ public Instant getCreatedOn() {return createdOn;}- public void setCreatedOn(Date createdOn) {+ public void setCreatedOn(Instant createdOn) {this.createdOn = createdOn;}diff --git a/model/src/main/java/org/openremote/model/alarm/SentAlarm.java b/model/src/main/java/org/openremote/model/alarm/SentAlarm.javaindex 0f9c43b25..0014b141e 100644--- a/model/src/main/java/org/openremote/model/alarm/SentAlarm.java+++ b/model/src/main/java/org/openremote/model/alarm/SentAlarm.java@@ -24,8 +24,8 @@ import jakarta.validation.constraints.NotNull;import org.hibernate.annotations.Formula;import org.openremote.model.asset.Asset;+import java.time.Instant;import java.util.ArrayList;-import java.util.Date;import java.util.List;import static org.openremote.model.Constants.PERSISTENCE_SEQUENCE_ID_GENERATOR;@@ -70,17 +70,14 @@ public class SentAlarm {@Formula("(select u.USERNAME from PUBLIC.USER_ENTITY u where u.ID = SOURCE_ID)")protected String sourceUsername;- @Temporal(TemporalType.TIMESTAMP)@Column(name = "CREATED_ON", updatable = false, nullable = false, columnDefinition = "TIMESTAMP WITH TIME ZONE")- protected Date createdOn;+ protected Instant createdOn;- @Temporal(TemporalType.TIMESTAMP)@Column(name = "ACKNOWLEDGED_ON", columnDefinition = "TIMESTAMP WITH TIME ZONE")- protected Date acknowledgedOn;+ protected Instant acknowledgedOn;- @Temporal(TemporalType.TIMESTAMP)@Column(name = "LAST_MODIFIED", nullable = false, columnDefinition = "TIMESTAMP WITH TIME ZONE")- protected Date lastModified;+ protected Instant lastModified;@Column(name = "ASSIGNEE_ID")protected String assigneeId;@@ -168,29 +165,29 @@ public class SentAlarm {return sourceUsername;}- public Date getCreatedOn() {+ public Instant getCreatedOn() {return createdOn;}- public SentAlarm setCreatedOn(Date createdOn) {+ public SentAlarm setCreatedOn(Instant createdOn) {this.createdOn = createdOn;return this;}- public Date getAcknowledgedOn() {+ public Instant getAcknowledgedOn() {return acknowledgedOn;}- public SentAlarm setAcknowledgedOn(Date acknowledgedOn) {+ public SentAlarm setAcknowledgedOn(Instant acknowledgedOn) {this.acknowledgedOn = acknowledgedOn;return this;}- public Date getLastModified() {+ public Instant getLastModified() {return lastModified;}- public SentAlarm setLastModified(Date lastModified) {+ public SentAlarm setLastModified(Instant lastModified) {this.lastModified = lastModified;return this;}diff --git a/model/src/main/java/org/openremote/model/asset/Asset.java b/model/src/main/java/org/openremote/model/asset/Asset.javaindex 3e4f51ed1..3554fdd0b 100644--- a/model/src/main/java/org/openremote/model/asset/Asset.java+++ b/model/src/main/java/org/openremote/model/asset/Asset.java@@ -56,6 +56,7 @@ import org.openremote.model.value.ValueFormat;import org.openremote.model.value.ValueType;import java.io.IOException;+import java.time.Instant;import java.util.*;import java.util.stream.Collectors;@@ -221,10 +222,9 @@ import static jakarta.persistence.DiscriminatorType.STRING;*/// @formatter:on@Entity-@Table(name = "ASSET")+@Table(name = "ASSET", check = @CheckConstraint(constraint = "ID != PARENT_ID"))@Inheritance(strategy = InheritanceType.SINGLE_TABLE)@DiscriminatorColumn(name = "TYPE", discriminatorType = STRING)-@Check(constraints = "ID != PARENT_ID")@JsonTypeInfo(include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true, use = JsonTypeInfo.Id.CUSTOM, defaultImpl = ThingAsset.class)@JsonTypeIdResolver(AssetTypeIdResolver.class)@AssetValid@@ -292,10 +292,9 @@ public abstract class Asset<T extends Asset<?>> implements IdentifiableEntity<T>@Column(name = "VERSION", nullable = false)protected long version;- @Temporal(TemporalType.TIMESTAMP)@Column(name = "CREATED_ON", updatable = false, nullable = false, columnDefinition = "TIMESTAMP WITH TIME ZONE")@org.hibernate.annotations.CreationTimestamp- protected Date createdOn;+ protected Instant createdOn;@NotBlank(message = "{Asset.name.NotBlank}")@Size(min = 1, max = 1023, message = "{Asset.name.Size}")@@ -359,11 +358,11 @@ public abstract class Asset<T extends Asset<?>> implements IdentifiableEntity<T>return (T) this;}- public Date getCreatedOn() {+ public Instant getCreatedOn() {return createdOn;}- public T setCreatedOn(Date createdOn) {+ public T setCreatedOn(Instant createdOn) {this.createdOn = createdOn;return (T) this;}diff --git a/model/src/main/java/org/openremote/model/asset/AssetEvent.java b/model/src/main/java/org/openremote/model/asset/AssetEvent.javaindex cae7996ec..4bae7d4a4 100644--- a/model/src/main/java/org/openremote/model/asset/AssetEvent.java+++ b/model/src/main/java/org/openremote/model/asset/AssetEvent.java@@ -23,8 +23,8 @@ import com.fasterxml.jackson.annotation.JsonCreator;import com.fasterxml.jackson.annotation.JsonProperty;import org.openremote.model.event.shared.SharedEvent;+import java.time.Instant;import java.util.Arrays;-import java.util.Date;/*** This event is used when an {@link Asset} is created, read, updated or deleted (updates are only fired when one or more top@@ -71,7 +71,7 @@ public class AssetEvent extends SharedEvent implements AssetInfo {}@Override- public Date getCreatedOn() {+ public Instant getCreatedOn() {return asset.createdOn;}diff --git a/model/src/main/java/org/openremote/model/asset/AssetInfo.java b/model/src/main/java/org/openremote/model/asset/AssetInfo.javaindex c9d279e4c..faa0daf49 100644--- a/model/src/main/java/org/openremote/model/asset/AssetInfo.java+++ b/model/src/main/java/org/openremote/model/asset/AssetInfo.java@@ -19,7 +19,7 @@*/package org.openremote.model.asset;-import java.util.Date;+import java.time.Instant;public interface AssetInfo {@@ -39,5 +39,5 @@ public interface AssetInfo {Class<? extends Asset> getAssetClass();- Date getCreatedOn();+ Instant getCreatedOn();}diff --git a/model/src/main/java/org/openremote/model/asset/AssetTreeAsset.java b/model/src/main/java/org/openremote/model/asset/AssetTreeAsset.javaindex 293a6229e..f544181be 100644--- a/model/src/main/java/org/openremote/model/asset/AssetTreeAsset.java+++ b/model/src/main/java/org/openremote/model/asset/AssetTreeAsset.java@@ -19,7 +19,7 @@*/package org.openremote.model.asset;-import java.util.Date;+import java.time.Instant;/*** Minimal representation of asset data for usage in contexts where faster@@ -35,9 +35,9 @@ public class AssetTreeAsset {String[] path;boolean hasChildren;- Date createdOn;+ Instant createdOn;- public AssetTreeAsset(String id, String name, String type, String parentId, String[] path, boolean hasChildren, Date createdOn) {+ public AssetTreeAsset(String id, String name, String type, String parentId, String[] path, boolean hasChildren, Instant createdOn) {this.id = id;this.name = name;this.type = type;@@ -95,11 +95,11 @@ public class AssetTreeAsset {this.hasChildren = hasChildren;}- public Date getCreatedOn() {+ public Instant getCreatedOn() {return createdOn;}- public void setCreatedOn(Date createdOn) {+ public void setCreatedOn(Instant createdOn) {this.createdOn = createdOn;}diff --git a/model/src/main/java/org/openremote/model/asset/UserAssetLink.java b/model/src/main/java/org/openremote/model/asset/UserAssetLink.javaindex e892148ae..96fe399cf 100644--- a/model/src/main/java/org/openremote/model/asset/UserAssetLink.java+++ b/model/src/main/java/org/openremote/model/asset/UserAssetLink.java@@ -24,7 +24,7 @@ import org.openremote.model.value.MetaItemType;import jakarta.persistence.*;import java.io.Serializable;-import java.util.Date;+import java.time.Instant;import java.util.Objects;/**@@ -120,9 +120,8 @@ public class UserAssetLink {@EmbeddedIdprotected Id id;- @Temporal(TemporalType.TIMESTAMP)@Column(name = "CREATED_ON", updatable = false, nullable = false, columnDefinition = "TIMESTAMP WITH TIME ZONE")- protected Date createdOn;+ protected Instant createdOn;@Formula("(select a.NAME from ASSET a where a.ID = ASSET_ID)")protected String assetName;@@ -160,11 +159,11 @@ public class UserAssetLink {return userFullName;}- public Date getCreatedOn() {+ public Instant getCreatedOn() {return createdOn;}- public void setCreatedOn(Date createdOn) {+ public void setCreatedOn(Instant createdOn) {this.createdOn = createdOn;}diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java b/model/src/main/java/org/openremote/model/attribute/AttributeEvent.javaindex b65f0054e..4f586c420 100644--- a/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java+++ b/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java@@ -34,7 +34,6 @@ import org.openremote.model.value.AttributeDescriptor;import org.openremote.model.value.ValueDescriptor;import java.time.Instant;-import java.util.Date;import java.util.Objects;import java.util.Optional;@@ -78,7 +77,7 @@ public class AttributeEvent extends SharedEvent implements AttributeInfo {@JsonIgnoreprotected Class<? extends Asset> assetClass;@JsonView(Enhanced.class)- protected Date createdOn;+ protected Instant createdOn;@JsonIgnoreprotected MetaMap meta;@@ -256,7 +255,7 @@ public class AttributeEvent extends SharedEvent implements AttributeInfo {}@Override- public Date getCreatedOn() {+ public Instant getCreatedOn() {return createdOn;}@@ -358,7 +357,7 @@ public class AttributeEvent extends SharedEvent implements AttributeInfo {@Overridepublic String toString() {return getClass().getSimpleName() + "{" +- "timestamp=" + (timestamp != null ? timestamp.toInstant() : "null") ++ "timestamp=" + (timestamp != null ? timestamp : "null") +", ref=" + ref +", realm=" + realm +", source=" + source +@@ -369,7 +368,7 @@ public class AttributeEvent extends SharedEvent implements AttributeInfo {public String toStringWithValue() {String valueStr = Objects.toString(value);return getClass().getSimpleName() + "{" +- "timestamp=" + timestamp.toInstant() ++ "timestamp=" + timestamp +", ref=" + ref +", realm=" + realm +", source=" + source +diff --git a/model/src/main/java/org/openremote/model/dashboard/Dashboard.java b/model/src/main/java/org/openremote/model/dashboard/Dashboard.javaindex 32c4ff22a..26b55bfd8 100644--- a/model/src/main/java/org/openremote/model/dashboard/Dashboard.java+++ b/model/src/main/java/org/openremote/model/dashboard/Dashboard.java@@ -9,7 +9,7 @@ import org.hibernate.annotations.JdbcTypeCode;import org.hibernate.type.SqlTypes;import org.openremote.model.util.HibernateUniqueIdentifierType;-import java.util.Date;+import java.time.Instant;import java.util.Objects;@Entity@@ -20,10 +20,9 @@ public class Dashboard {@Column(name = "ID", length = 22, columnDefinition = "char(22)")protected String id;- @Temporal(TemporalType.TIMESTAMP)@Column(name = "CREATED_ON", updatable = false, nullable = false, columnDefinition = "TIMESTAMP WITH TIME ZONE")@org.hibernate.annotations.CreationTimestamp- protected Date createdOn;+ protected Instant createdOn;@NotBlank(message = "{Dashboard.realm.NotBlank}")@Size(min = 1, max = 255, message = "{Asset.realm.Size}")@@ -69,7 +68,7 @@ public class Dashboard {return this;}- public Dashboard setCreatedOn(Date createdOn) {+ public Dashboard setCreatedOn(Instant createdOn) {this.createdOn = createdOn;return this;}@@ -108,7 +107,7 @@ public class Dashboard {return this.id;}- public Date getCreatedOn() {+ public Instant getCreatedOn() {return this.createdOn;}diff --git a/model/src/main/java/org/openremote/model/event/Event.java b/model/src/main/java/org/openremote/model/event/Event.javaindex 245172b17..b9fef43c1 100644--- a/model/src/main/java/org/openremote/model/event/Event.java+++ b/model/src/main/java/org/openremote/model/event/Event.java@@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;import jakarta.persistence.*;import org.openremote.model.util.TextUtil;-import java.util.Date;+import java.time.Instant;/*** A timestamped event.@@ -36,16 +36,15 @@ import java.util.Date;@MappedSuperclasspublic abstract class Event {- @Temporal(TemporalType.TIMESTAMP)@Column(name = "TIMESTAMP", updatable = false, nullable = false, columnDefinition = "TIMESTAMP WITH TIME ZONE")@JsonIgnore- protected Date timestamp;+ protected Instant timestamp;@Transientprotected String messageID;protected Event(Long timestamp) {if (timestamp != null) {- this.timestamp = new Date(timestamp);+ this.timestamp = Instant.ofEpochMilli(timestamp);}}@@ -70,11 +69,11 @@ public abstract class Event {@JsonPropertypublic long getTimestamp() {- return timestamp != null ? timestamp.getTime() : 0L;+ return timestamp != null ? timestamp.toEpochMilli() : 0L;}public void setTimestamp(long timestamp) {- this.timestamp = new Date(timestamp);+ this.timestamp = Instant.ofEpochMilli(timestamp);}public String getMessageID() {diff --git a/model/src/main/java/org/openremote/model/flow/Flow.java b/model/src/main/java/org/openremote/model/flow/Flow.javaindex 2a694b1a2..7e15c8589 100644--- a/model/src/main/java/org/openremote/model/flow/Flow.java+++ b/model/src/main/java/org/openremote/model/flow/Flow.java@@ -21,6 +21,7 @@package org.openremote.model.flow;import jakarta.persistence.*;+import java.time.Instant;import java.util.*;@@ -35,8 +36,7 @@ public class Flow extends FlowObject {@Column(name = "CREATED_ON")- @Temporal(TemporalType.TIMESTAMP)- public Date createdOn = new Date();+ public Instant createdOn = Instant.now();@Transientpublic Node[] nodes = new Node[0];@@ -79,7 +79,7 @@ public class Flow extends FlowObject {}- public Date getCreatedOn() {+ public Instant getCreatedOn() {return createdOn;}diff --git a/model/src/main/java/org/openremote/model/notification/SentNotification.java b/model/src/main/java/org/openremote/model/notification/SentNotification.javaindex 3eef3fcd2..84c2e47c8 100644--- a/model/src/main/java/org/openremote/model/notification/SentNotification.java+++ b/model/src/main/java/org/openremote/model/notification/SentNotification.java@@ -24,7 +24,7 @@ import jakarta.validation.constraints.NotNull;import org.hibernate.annotations.JdbcTypeCode;import org.hibernate.type.SqlTypes;-import java.util.Date;+import java.time.Instant;import static org.openremote.model.Constants.PERSISTENCE_SEQUENCE_ID_GENERATOR;@@ -69,17 +69,14 @@ public class SentNotification {@Column(name = "ERROR", length = 4096)protected String error;- @Temporal(TemporalType.TIMESTAMP)@Column(name = "SENT_ON", updatable = false, nullable = false, columnDefinition = "TIMESTAMP WITH TIME ZONE")- protected Date sentOn;+ protected Instant sentOn;- @Temporal(TemporalType.TIMESTAMP)@Column(name = "DELIVERED_ON", columnDefinition = "TIMESTAMP WITH TIME ZONE")- protected Date deliveredOn;+ protected Instant deliveredOn;- @Temporal(TemporalType.TIMESTAMP)@Column(name = "ACKNOWLEDGED_ON", columnDefinition = "TIMESTAMP WITH TIME ZONE")- protected Date acknowledgedOn;+ protected Instant acknowledgedOn;@Column(name = "ACKNOWLEDGEMENT")protected String acknowledgement;@@ -111,11 +108,11 @@ public class SentNotification {return this;}- public Date getSentOn() {+ public Instant getSentOn() {return sentOn;}- public SentNotification setSentOn(Date sentOn) {+ public SentNotification setSentOn(Instant sentOn) {this.sentOn = sentOn;return this;}@@ -165,20 +162,20 @@ public class SentNotification {return this;}- public Date getDeliveredOn() {+ public Instant getDeliveredOn() {return deliveredOn;}- public SentNotification setDeliveredOn(Date deliveredOn) {+ public SentNotification setDeliveredOn(Instant deliveredOn) {this.deliveredOn = deliveredOn;return this;}- public Date getAcknowledgedOn() {+ public Instant getAcknowledgedOn() {return acknowledgedOn;}- public SentNotification setAcknowledgedOn(Date acknowledgedOn) {+ public SentNotification setAcknowledgedOn(Instant acknowledgedOn) {this.acknowledgedOn = acknowledgedOn;return this;}diff --git a/model/src/main/java/org/openremote/model/provisioning/ProvisioningConfig.java b/model/src/main/java/org/openremote/model/provisioning/ProvisioningConfig.javaindex 6d74886c7..77fa1db42 100644--- a/model/src/main/java/org/openremote/model/provisioning/ProvisioningConfig.java+++ b/model/src/main/java/org/openremote/model/provisioning/ProvisioningConfig.java@@ -29,7 +29,7 @@ import jakarta.validation.constraints.NotNull;import jakarta.validation.constraints.Size;import org.openremote.model.security.ClientRole;-import java.util.Date;+import java.time.Instant;import static jakarta.persistence.DiscriminatorType.STRING;import static org.openremote.model.Constants.PERSISTENCE_SEQUENCE_ID_GENERATOR;@@ -55,14 +55,12 @@ public abstract class ProvisioningConfig<T, U extends ProvisioningConfig<T, U>>@SequenceGenerator(name = PERSISTENCE_SEQUENCE_ID_GENERATOR, initialValue = 1000, allocationSize = 1)protected Long id;- @Temporal(TemporalType.TIMESTAMP)@Column(name = "CREATED_ON", updatable = false, nullable = false, columnDefinition= "TIMESTAMP WITH TIME ZONE")@org.hibernate.annotations.CreationTimestamp- protected Date createdOn = new Date();+ protected Instant createdOn = Instant.now();- @Temporal(TemporalType.TIMESTAMP)@Column(name = "LAST_MODIFIED", nullable = false, columnDefinition= "TIMESTAMP WITH TIME ZONE")- protected Date lastModified;+ protected Instant lastModified;@NotNull@Column(name = "NAME", nullable = false)@@ -100,18 +98,18 @@ public abstract class ProvisioningConfig<T, U extends ProvisioningConfig<T, U>>return id;}- public Date getCreatedOn() {+ public Instant getCreatedOn() {return createdOn;}- public Date getLastModified() {+ public Instant getLastModified() {return lastModified;}@PreUpdate@PrePersistprotected void updateLastModified() {- lastModified = new Date();+ lastModified = Instant.now();}public String getName() {diff --git a/model/src/main/java/org/openremote/model/rules/AssetRuleset.java b/model/src/main/java/org/openremote/model/rules/AssetRuleset.javaindex 7071a86a0..e91b82171 100644--- a/model/src/main/java/org/openremote/model/rules/AssetRuleset.java+++ b/model/src/main/java/org/openremote/model/rules/AssetRuleset.java@@ -25,7 +25,7 @@ import jakarta.persistence.Table;import org.hibernate.annotations.Formula;import org.openremote.model.calendar.CalendarEvent;-import java.util.Date;+import java.time.Instant;import java.util.Map;/**@@ -94,13 +94,13 @@ public class AssetRuleset extends Ruleset {}@Override- public AssetRuleset setCreatedOn(Date createdOn) {+ public AssetRuleset setCreatedOn(Instant createdOn) {super.setCreatedOn(createdOn);return this;}@Override- public AssetRuleset setLastModified(Date lastModified) {+ public AssetRuleset setLastModified(Instant lastModified) {super.setLastModified(lastModified);return this;}diff --git a/model/src/main/java/org/openremote/model/rules/GlobalRuleset.java b/model/src/main/java/org/openremote/model/rules/GlobalRuleset.javaindex 3f0d52bd4..ee55c650d 100644--- a/model/src/main/java/org/openremote/model/rules/GlobalRuleset.java+++ b/model/src/main/java/org/openremote/model/rules/GlobalRuleset.java@@ -23,7 +23,7 @@ import jakarta.persistence.Entity;import jakarta.persistence.Table;import org.openremote.model.calendar.CalendarEvent;-import java.util.Date;+import java.time.Instant;import java.util.Map;/**@@ -55,13 +55,13 @@ public class GlobalRuleset extends Ruleset {}@Override- public GlobalRuleset setCreatedOn(Date createdOn) {+ public GlobalRuleset setCreatedOn(Instant createdOn) {super.setCreatedOn(createdOn);return this;}@Override- public GlobalRuleset setLastModified(Date lastModified) {+ public GlobalRuleset setLastModified(Instant lastModified) {super.setLastModified(lastModified);return this;}diff --git a/model/src/main/java/org/openremote/model/rules/RealmRuleset.java b/model/src/main/java/org/openremote/model/rules/RealmRuleset.javaindex ee95579a5..c558d51ec 100644--- a/model/src/main/java/org/openremote/model/rules/RealmRuleset.java+++ b/model/src/main/java/org/openremote/model/rules/RealmRuleset.java@@ -24,7 +24,7 @@ import jakarta.persistence.Entity;import jakarta.persistence.Table;import org.openremote.model.calendar.CalendarEvent;-import java.util.Date;+import java.time.Instant;import java.util.Map;/**@@ -81,13 +81,13 @@ public class RealmRuleset extends Ruleset {}@Override- public RealmRuleset setCreatedOn(Date createdOn) {+ public RealmRuleset setCreatedOn(Instant createdOn) {super.setCreatedOn(createdOn);return this;}@Override- public RealmRuleset setLastModified(Date lastModified) {+ public RealmRuleset setLastModified(Instant lastModified) {super.setLastModified(lastModified);return this;}diff --git a/model/src/main/java/org/openremote/model/rules/Ruleset.java b/model/src/main/java/org/openremote/model/rules/Ruleset.javaindex 41ef8fedd..aac962167 100644--- a/model/src/main/java/org/openremote/model/rules/Ruleset.java+++ b/model/src/main/java/org/openremote/model/rules/Ruleset.java@@ -30,7 +30,7 @@ import org.hibernate.type.SqlTypes;import org.openremote.model.calendar.CalendarEvent;import org.openremote.model.util.ValueUtil;-import java.util.Date;+import java.time.Instant;import java.util.HashMap;import java.util.Map;import java.util.Optional;@@ -74,15 +74,13 @@ public abstract class Ruleset {@Column(name = "VERSION", nullable = false)protected long version;- @Temporal(TemporalType.TIMESTAMP)@Column(name = "CREATED_ON", updatable = false, nullable = false, columnDefinition= "TIMESTAMP WITH TIME ZONE")@org.hibernate.annotations.CreationTimestamp- protected Date createdOn = new Date();+ protected Instant createdOn = Instant.now();- @Temporal(TemporalType.TIMESTAMP)@Column(name = "LAST_MODIFIED", nullable = false, columnDefinition= "TIMESTAMP WITH TIME ZONE")@org.hibernate.annotations.UpdateTimestamp- protected Date lastModified;+ protected Instant lastModified;@NotNull(message = "{Ruleset.name.NotNull}")@Column(name = "NAME", nullable = false)@@ -139,11 +137,11 @@ public abstract class Ruleset {return this;}- public Date getCreatedOn() {+ public Instant getCreatedOn() {return createdOn;}- public Ruleset setCreatedOn(Date createdOn) {+ public Ruleset setCreatedOn(Instant createdOn) {this.createdOn = createdOn;return this;}@@ -151,19 +149,19 @@ public abstract class Ruleset {@PreUpdate@PrePersistprotected void updateLastModified() {- setLastModified(new Date());+ setLastModified(Instant.now());}public Ruleset setLastModified() {- return setLastModified(new Date());+ return setLastModified(Instant.now());}- public Ruleset setLastModified(Date lastModified) {+ public Ruleset setLastModified(Instant lastModified) {this.lastModified = lastModified;return this;}- public Date getLastModified() {+ public Instant getLastModified() {return lastModified;}diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovyindex e213b82eb..69382c651 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy@@ -537,7 +537,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraiAsset apartment1 = assets[0]apartment1.id == managerTestSetup.apartment1Idapartment1.name == "Apartment 1"- apartment1.createdOn.getTime() < System.currentTimeMillis()+ apartment1.createdOn.toEpochMilli() < System.currentTimeMillis()apartment1.realm == keycloakTestSetup.realmBuilding.nameapartment1.type == BuildingAsset.DESCRIPTOR.getName()apartment1.parentId == managerTestSetup.smartBuildingIddiff --git a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovyindex 868a5257c..b07ff76ce 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy@@ -195,7 +195,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {then: "result should match"asset.id == managerTestSetup.smartOfficeId- asset.createdOn.time < System.currentTimeMillis()+ asset.createdOn.toEpochMilli() < System.currentTimeMillis()asset.name == "Smart office"asset.type == BuildingAsset.DESCRIPTOR.getName()asset.parentId == null@@ -210,7 +210,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {then: "result should match"asset.id == managerTestSetup.smartOfficeId- asset.createdOn.time < System.currentTimeMillis()+ asset.createdOn.toEpochMilli() < System.currentTimeMillis()asset.name == "Smart office"asset.type == BuildingAsset.DESCRIPTOR.getName()asset.parentId == null@@ -230,7 +230,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {then: "result should match"assets.size() == 1assets.get(0).id == managerTestSetup.smartOfficeId- assets.get(0).createdOn.time < System.currentTimeMillis()+ assets.get(0).createdOn.toEpochMilli() < System.currentTimeMillis()assets.get(0).name == "Smart office"assets.get(0).type == BuildingAsset.DESCRIPTOR.getName()assets.get(0).parentId == null@@ -247,7 +247,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {then: "result should match"assets.size() == 1assets.get(0).id == managerTestSetup.smartOfficeId- assets.get(0).createdOn.time < System.currentTimeMillis()+ assets.get(0).createdOn.toEpochMilli() < System.currentTimeMillis()assets.get(0).name == "Smart office"assets.get(0).type == BuildingAsset.DESCRIPTOR.getName()assets.get(0).parentId == null@@ -266,7 +266,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {assets.size() == 3assetStorageService.count(query) == 3assets.get(0).id == managerTestSetup.apartment1Id- assets.get(0).createdOn.time < System.currentTimeMillis()+ assets.get(0).createdOn.toEpochMilli() < System.currentTimeMillis()assets.get(0).name == "Apartment 1"assets.get(0).type == BuildingAsset.DESCRIPTOR.getName()assets.get(0).parentId == managerTestSetup.smartBuildingId@@ -544,7 +544,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {then: "result should match"asset.id == managerTestSetup.apartment1LivingroomId- asset.createdOn.time < System.currentTimeMillis()+ asset.createdOn.toEpochMilli() < System.currentTimeMillis()asset.name == "Living Room 1"asset.type == RoomAsset.DESCRIPTOR.getName()asset.parentId != null@@ -568,7 +568,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {then: "result should contain only matches that are protected"asset.id == managerTestSetup.apartment1LivingroomId- asset.createdOn.time < System.currentTimeMillis()+ asset.createdOn.toEpochMilli() < System.currentTimeMillis()asset.name == "Living Room 1"asset.type == RoomAsset.DESCRIPTOR.getName()asset.parentId == managerTestSetup.apartment1Iddiff --git a/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovyindex 5ffa647e3..00c478773 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy@@ -184,7 +184,7 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTraiit.assetName == "Apartment 2" &&it.parentAssetName == "Smart building" &&it.userFullName == "testuser2 (DemoA2 DemoLast)" &&- it.createdOn.time <= timerService.currentTimeMillis+ it.createdOn.toEpochMilli() <= timerService.currentTimeMillis}when: "an asset link is deleted"diff --git a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovyindex 687087ec4..a62c313a3 100644--- a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy+++ b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy@@ -180,7 +180,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {.setId(agentAssetIds[i - 1]).setBaseURI("https://google.co.uk").setRealm(MASTER_REALM)- .setCreatedOn(Date.from(timerService.getNow()))+ .setCreatedOn(timerService.getNow())agent.path = (String[]) [agentAssetIds[i - 1]].toArray(new String[0])agentAssets.add(agent)@@ -194,7 +194,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {def roomAsset = new RoomAsset("Test Building $i Room $j").setId(assetIds[(i - 1) * 5 + j])- .setCreatedOn(Date.from(timerService.getNow()))+ .setCreatedOn(timerService.getNow()).setParentId(assetIds[(i - 1) * 5]).setRealm(MASTER_REALM)@@ -221,7 +221,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {def buildingAsset = new BuildingAsset("Test Building $i").setId(assetIds[(i - 1) * 5])- .setCreatedOn(Date.from(timerService.getNow()))+ .setCreatedOn(timerService.getNow()).setRealm(MASTER_REALM)buildingAsset.path = (String[]) [assetIds[(i - 1) * 5]].toArray(new String[0])@@ -411,7 +411,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {def building1Room5AssetId = UniqueIdentifierGenerator.generateId("Test Building 1 Room 5")def building1Room5Asset = new RoomAsset("Test Building 1 Room 5").setId(building1Room5AssetId)- .setCreatedOn(Date.from(timerService.getNow()))+ .setCreatedOn(timerService.getNow()).setParentId(assetIds[0]).setRealm(MASTER_REALM)building1Room5Asset.path = (String[]) [building1Room5AssetId, assetIds[0]]@@ -531,7 +531,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {gatewayClient.disconnect()def failedAsset = new BuildingAsset("Failed Asset").setId(UniqueIdentifierGenerator.generateId("Failed asset"))- .setCreatedOn(Date.from(timerService.getNow()))+ .setCreatedOn(timerService.getNow()).setParentId(gateway.id).setRealm(managerTestSetup.realmBuildingName)failedAsset.path = (String[]) [UniqueIdentifierGenerator.generateId("Failed asset")].toArray(new String[0])@@ -643,7 +643,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {when: "another asset is added to the gateway during the initial sync process"def building2Room5Asset = new RoomAsset("Test Building 2 Room 5").setId(UniqueIdentifierGenerator.generateId("Test Building 2 Room 5"))- .setCreatedOn(Date.from(timerService.getNow()))+ .setCreatedOn(timerService.getNow()).setParentId(assetIds[5]).setRealm(MASTER_REALM)building2Room5Asset.path = (String[]) [UniqueIdentifierGenerator.generateId("Test Building 2 Room 5"), assetIds[5]]diff --git a/test/src/test/groovy/org/openremote/test/model/AssetModelTest.groovy b/test/src/test/groovy/org/openremote/test/model/AssetModelTest.groovyindex c299208de..0da15a19e 100644--- a/test/src/test/groovy/org/openremote/test/model/AssetModelTest.groovy+++ b/test/src/test/groovy/org/openremote/test/model/AssetModelTest.groovy@@ -37,6 +37,7 @@ import org.openremote.test.ManagerContainerTraitimport spock.lang.Sharedimport spock.lang.Specificationimport spock.lang.Unroll+import java.time.Instantimport java.lang.reflect.Arrayimport java.nio.file.Files@@ -497,7 +498,7 @@ class AssetModelTest extends Specification implements ManagerContainerTrait {def "Serialize/Deserialize asset model"() {given: "An asset"def parentId = UniqueIdentifierGenerator.generateId()- def createdDate = new Date()+ def createdDate = Instant.now()def asset = new LightAsset("Test light").setId(UniqueIdentifierGenerator.generateId()).setRealm(MASTER_REALM)@@ -524,7 +525,7 @@ class AssetModelTest extends Specification implements ManagerContainerTrait {// Inject properties which are normally done by the backend on retrievalasset.path = [asset.id, parentId]asset.createdOn = createdDate- asset.getAttributes().values().forEach {it.setTimestamp(asset.createdOn.getTime())}+ asset.getAttributes().values().forEach {it.setTimestamp(asset.createdOn.toEpochMilli())}expect: "the attributes to match the set values"asset.getTemperature().orElse(null) == 100I@@ -541,7 +542,7 @@ class AssetModelTest extends Specification implements ManagerContainerTrait {assetObjectNode.get("path").get(0).asText() == asset.idassetObjectNode.get("path").get(1).asText() == parentId- assetObjectNode.get("attributes").get("colourRGB").get("timestamp").asLong() == createdDate.getTime()+ assetObjectNode.get("attributes").get("colourRGB").get("timestamp").asLong() == createdDate.toEpochMilli()assetObjectNode.get("attributes").get("colourRGB").get("meta").get(MetaItemType.AGENT_LINK.name).isObject()assetObjectNode.get("attributes").get("colourRGB").get("meta").get(MetaItemType.AGENT_LINK.name).get("id").asText() == "agent_id"assetObjectNode.get("attributes").get("colourRGB").get("meta").get(MetaItemType.AGENT_LINK.name).get("type").asText() == DefaultAgentLink.class.getSimpleName()@@ -556,7 +557,7 @@ class AssetModelTest extends Specification implements ManagerContainerTrait {then: "it should match the original"asset.getName() == asset2.getName()asset2.getType() == asset.getType()- asset2.getCreatedOn() == asset.getCreatedOn()+ asset2.getCreatedOn().toEpochMilli() == asset.getCreatedOn().toEpochMilli()asset2.getParentId() == parentIdasset2.getPath() == asset.getPath()asset2.getTemperature().orElse(null) == asset.getTemperature().orElse(null)@@ -584,7 +585,7 @@ class AssetModelTest extends Specification implements ManagerContainerTrait {def attributeEventObjectNode = ValueUtil.parse(attributeEventStr, ObjectNode.class).get()attributeEventObjectNode.get("ref").get("id").asText() == asset2.idattributeEventObjectNode.get("ref").get("name").asText() == LightAsset.COLOUR_RGB.name- attributeEventObjectNode.get("timestamp").asLong() == createdDate.getTime()+ attributeEventObjectNode.get("timestamp").asLong() == createdDate.toEpochMilli()attributeEventObjectNode.has("realm")attributeEventObjectNode.get("value").isTextual()attributeEventObjectNode.get("value").asText() == "#3264C8"@@ -599,7 +600,7 @@ class AssetModelTest extends Specification implements ManagerContainerTrait {def attributeEventObjectNode2 = ValueUtil.parse(attributeEventStr2, ObjectNode.class).get()attributeEventObjectNode2.get("ref").get("id").asText() == asset2.idattributeEventObjectNode2.get("ref").get("name").asText() == LightAsset.COLOUR_RGB.name- attributeEventObjectNode2.get("timestamp").asLong() == createdDate.getTime()+ attributeEventObjectNode2.get("timestamp").asLong() == createdDate.toEpochMilli()attributeEventObjectNode2.has("realm")attributeEventObjectNode2.get("value").isTextual()attributeEventObjectNode2.get("value").asText() == "#3264C8"diff --git a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovyindex 26980d6bc..bbc9382b2 100644--- a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy+++ b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy@@ -463,7 +463,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {notifications = adminNotificationResource.getNotifications(null, null, PushNotificationMessage.TYPE, null, null, null, null, null).reverse(true)def sentNotification = notifications[0]def removeCount = notifications.count {it.sentOn >= sentNotification.sentOn}- adminNotificationResource.removeNotifications(null, null, PushNotificationMessage.TYPE, sentNotification.sentOn.getTime(), null, null, null, null)+ adminNotificationResource.removeNotifications(null, null, PushNotificationMessage.TYPE, sentNotification.sentOn.toEpochMilli(), null, null, null, null)then: "notifications sent after or at that time should have been removed"conditions.eventually {diff --git a/test/src/test/groovy/org/openremote/test/rules/AlarmRuleTest.groovy b/test/src/test/groovy/org/openremote/test/rules/AlarmRuleTest.groovyindex 103b74384..ab9e5166d 100644--- a/test/src/test/groovy/org/openremote/test/rules/AlarmRuleTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/AlarmRuleTest.groovy@@ -171,8 +171,8 @@ Value: 6000alarm.status == Alarm.Status.OPENalarm.source == Alarm.Source.REALM_RULESETalarm.sourceId == Long.toString(realmRuleset.id)- alarm.createdOn.toInstant().isAfter(Instant.now().minusSeconds(30))- alarm.createdOn.toInstant().isBefore(Instant.now())+ alarm.createdOn.isAfter(Instant.now().minusSeconds(30))+ alarm.createdOn.isBefore(Instant.now())alarm.acknowledgedOn == nullalarm.createdOn == alarm.lastModifiedalarm.assigneeId == assigneeId@@ -184,8 +184,8 @@ Value: 6000assetLink.id.alarmId == alarm.idassetLink.id.realm == managerTestSetup.realmBuildingNameassetLink.id.assetId == managerTestSetup.apartment2LivingroomId- assetLink.createdOn.toInstant().isAfter(Instant.now().minusSeconds(30))- assetLink.createdOn.toInstant().isBefore(Instant.now())+ assetLink.createdOn.isAfter(Instant.now().minusSeconds(30))+ assetLink.createdOn.isBefore(Instant.now())assetLink.assetName == "Living Room 2"assetLink.parentAssetName == "Apartment 2"diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovyindex 238d2fabe..9fb2ce86a 100644--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy@@ -98,8 +98,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"globalRuleset.id == rulesetIdglobalRuleset.version == 0- globalRuleset.createdOn.time < System.currentTimeMillis()- lastModified.time < System.currentTimeMillis()+ globalRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ lastModified.toEpochMilli() < System.currentTimeMillis()globalRuleset.name == "Test global definition"globalRuleset.rules == "SomeRulesCode"globalRuleset.lang == GROOVY@@ -120,8 +120,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"globalRuleset.id == rulesetIdglobalRuleset.version > 0- globalRuleset.createdOn.time < System.currentTimeMillis()- globalRuleset.lastModified.time > lastModified.time+ globalRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ globalRuleset.lastModified.toEpochMilli() > lastModified.toEpochMilli()globalRuleset.name == "Renamed test global definition"globalRuleset.rules == "SomeRulesCodeModified"@@ -164,8 +164,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"realmRuleset.id == rulesetIdrealmRuleset.version == 0- realmRuleset.createdOn.time < System.currentTimeMillis()- lastModified.time < System.currentTimeMillis()+ realmRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ lastModified.toEpochMilli() < System.currentTimeMillis()realmRuleset.name == "Test realm definition"realmRuleset.rules == "SomeRulesCode"realmRuleset.realm == keycloakTestSetup.realmMaster.name@@ -186,8 +186,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"realmRuleset.id == rulesetIdrealmRuleset.version == 1- realmRuleset.createdOn.time < System.currentTimeMillis()- realmRuleset.lastModified.time > lastModified.time+ realmRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ realmRuleset.lastModified.toEpochMilli() > lastModified.toEpochMilli()realmRuleset.name == "Renamed test realm definition"realmRuleset.rules == "SomeRulesCodeModified"realmRuleset.realm == keycloakTestSetup.realmMaster.name@@ -247,8 +247,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"realmRuleset.id == rulesetIdrealmRuleset.version == 0- realmRuleset.createdOn.time < System.currentTimeMillis()- lastModified.time < System.currentTimeMillis()+ realmRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ lastModified.toEpochMilli() < System.currentTimeMillis()realmRuleset.name == "Test realm definition"realmRuleset.rules == "SomeRulesCode"realmRuleset.realm == keycloakTestSetup.realmBuilding.name@@ -270,8 +270,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"assetRuleset.id == rulesetIdassetRuleset.version == 0- assetRuleset.createdOn.time < System.currentTimeMillis()- lastModified.time < System.currentTimeMillis()+ assetRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ lastModified.toEpochMilli() < System.currentTimeMillis()assetRuleset.name == "Test asset definition"assetRuleset.rules == "SomeRulesCode"assetRuleset.assetId == managerTestSetup.smartOfficeId@@ -292,8 +292,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"assetRuleset.id == rulesetIdassetRuleset.version == 1- assetRuleset.createdOn.time < System.currentTimeMillis()- assetRuleset.lastModified.time > lastModified.time+ assetRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ assetRuleset.lastModified.toEpochMilli() > lastModified.toEpochMilli()assetRuleset.name == "Renamed test asset definition"assetRuleset.rules == "SomeRulesCodeModified"assetRuleset.assetId == managerTestSetup.smartOfficeId@@ -352,8 +352,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"assetRuleset.id == rulesetIdassetRuleset.version == 0- assetRuleset.createdOn.time < System.currentTimeMillis()- lastModified.time < System.currentTimeMillis()+ assetRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ lastModified.toEpochMilli() < System.currentTimeMillis()assetRuleset.name == "Test asset definition"assetRuleset.rules == "SomeRulesCode"assetRuleset.assetId == managerTestSetup.apartment2Id@@ -461,8 +461,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"realmRuleset.id == rulesetIdrealmRuleset.version == 0- realmRuleset.createdOn.time < System.currentTimeMillis()- lastModified.time < System.currentTimeMillis()+ realmRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ lastModified.toEpochMilli() < System.currentTimeMillis()realmRuleset.name == "Test realm definition"realmRuleset.rules == "SomeRulesCode"realmRuleset.realm == MASTER_REALM@@ -483,8 +483,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"realmRuleset.id == rulesetIdrealmRuleset.version == 1- realmRuleset.createdOn.time < System.currentTimeMillis()- realmRuleset.lastModified.time > lastModified.time+ realmRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ realmRuleset.lastModified.toEpochMilli() > lastModified.toEpochMilli()realmRuleset.name == "Renamed test realm definition"realmRuleset.rules == "SomeRulesCodeModified"realmRuleset.realm == keycloakTestSetup.realmMaster.name@@ -560,8 +560,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"assetRuleset.id == rulesetIdassetRuleset.version == 0- assetRuleset.createdOn.time < System.currentTimeMillis()- lastModified.time < System.currentTimeMillis()+ assetRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ lastModified.toEpochMilli() < System.currentTimeMillis()assetRuleset.name == "Test asset definition"assetRuleset.rules == "SomeRulesCode"assetRuleset.assetId == managerTestSetup.smartOfficeId@@ -582,8 +582,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"assetRuleset.id == rulesetIdassetRuleset.version == 1- assetRuleset.createdOn.time < System.currentTimeMillis()- assetRuleset.lastModified.time > lastModified.time+ assetRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ assetRuleset.lastModified.toEpochMilli() > lastModified.toEpochMilli()assetRuleset.name == "Renamed test asset definition"assetRuleset.rules == "SomeRulesCodeModified"assetRuleset.assetId == managerTestSetup.smartOfficeId@@ -919,8 +919,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"assetRuleset.id == rulesetIdassetRuleset.version == 0- assetRuleset.createdOn.time < System.currentTimeMillis()- lastModified.time < System.currentTimeMillis()+ assetRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ lastModified.toEpochMilli() < System.currentTimeMillis()assetRuleset.name == "Test asset definition"assetRuleset.rules == "SomeRulesCode"assetRuleset.assetId == managerTestSetup.apartment1Id@@ -941,8 +941,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "result should match"assetRuleset.id == rulesetIdassetRuleset.version == 1- assetRuleset.createdOn.time < System.currentTimeMillis()- assetRuleset.lastModified.time > lastModified.time+ assetRuleset.createdOn.toEpochMilli() < System.currentTimeMillis()+ assetRuleset.lastModified.toEpochMilli() > lastModified.toEpochMilli()assetRuleset.name == "Renamed test asset definition"assetRuleset.rules == "SomeRulesCodeModified"assetRuleset.assetId == managerTestSetup.apartment1Iddiff --git a/test/src/test/groovy/org/openremote/test/rules/ChildAssetControlRulesTest.groovy b/test/src/test/groovy/org/openremote/test/rules/ChildAssetControlRulesTest.groovyindex b832ccbec..f3088f615 100644--- a/test/src/test/groovy/org/openremote/test/rules/ChildAssetControlRulesTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/ChildAssetControlRulesTest.groovy@@ -69,7 +69,7 @@ class ChildAssetControlRulesTest extends Specification implements ManagerContainassert engine != nullassert engine.isRunning()assert engine.facts.assetStates.count { it.id == parentAsset.id} == 4- assert engine.lastFireTimestamp > ruleset.createdOn.getTime()+ assert engine.lastFireTimestamp > ruleset.createdOn.toEpochMilli()assert engine.deployments.get(ruleset.id) != null}diff --git a/test/src/test/groovy/org/openremote/test/rules/GroupSummationRuleTest.groovy b/test/src/test/groovy/org/openremote/test/rules/GroupSummationRuleTest.groovyindex 596bfa818..8e50f6086 100644--- a/test/src/test/groovy/org/openremote/test/rules/GroupSummationRuleTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/GroupSummationRuleTest.groovy@@ -77,7 +77,7 @@ class GroupSummationRuleTest extends Specification implements ManagerContainerTrassert engine != nullassert engine.isRunning()assert engine.facts.assetStates.count { it.id == parentAsset.id } == 3- assert engine.lastFireTimestamp > ruleset.createdOn.getTime()+ assert engine.lastFireTimestamp > ruleset.createdOn.toEpochMilli()assert engine.deployments.get(ruleset.id) != null}