Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Logging tidy up and changed AssetDatapointService and AssetPredictedDatapointService to use LocalDateTime rather than ambiguous long values

Rich Turner11adf540861a
diff --git a/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java
index f515e5c34..35db4fada 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java
@@ -280,7 +280,7 @@ public abstract class AbstractProtocol<T extends Agent<T, ?, U>, U extends Agent
}
AttributeEvent attributeEvent = new AttributeEvent(new AttributeState(state.getRef(), ignoreAndConverted.value), timestamp);
- LOG.fine("Sending linked attribute update on sensor queue: " + attributeEvent);
+ LOG.finer("Sending linked attribute update on sensor queue: " + attributeEvent);
producerTemplate.sendBodyAndHeader(SENSOR_QUEUE, attributeEvent, Protocol.SENSOR_QUEUE_SOURCE_PROTOCOL, getProtocolName());
}
@@ -293,7 +293,7 @@ public abstract class AbstractProtocol<T extends Agent<T, ?, U>, U extends Agent
return;
}
AttributeEvent attributeEvent = new AttributeEvent(state, timerService.getCurrentTimeMillis());
- LOG.fine("Sending protocol agent attribute update: " + attributeEvent);
+ LOG.finer("Sending protocol agent attribute update: " + attributeEvent);
assetService.sendAttributeEvent(attributeEvent);
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/ProtocolPredictedAssetService.java b/agent/src/main/java/org/openremote/agent/protocol/ProtocolPredictedAssetService.java
index 457c86bd5..3aabc92a9 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/ProtocolPredictedAssetService.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/ProtocolPredictedAssetService.java
@@ -22,9 +22,11 @@ package org.openremote.agent.protocol;
import org.openremote.model.ContainerService;
import org.openremote.model.attribute.AttributeRef;
+import java.time.LocalDateTime;
+
public interface ProtocolPredictedAssetService extends ContainerService {
- void updateValue(AttributeRef attributeRef, Object value, long timestamp);
+ void updateValue(AttributeRef attributeRef, Object value, LocalDateTime timestamp);
- void updateValue(String assetId, String attributeName, Object value, long timestamp);
+ void updateValue(String assetId, String attributeName, Object value, LocalDateTime timestamp);
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/controller/ControllerProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/controller/ControllerProtocol.java
index 7e8141222..5290768f3 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/controller/ControllerProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/controller/ControllerProtocol.java
@@ -177,7 +177,7 @@ public class ControllerProtocol extends AbstractProtocol<ControllerAgent, Contro
* Build Sensor Status info for polling request
*/
if (sensorName != null) {
- LOG.fine("### Adding new sensor [" + deviceName + "," + sensorName + "] linked to " + agent.getId() + " (" + agent.getName() + ")");
+ LOG.finer("### Adding new sensor [" + deviceName + "," + sensorName + "] linked to " + agent.getId() + " (" + agent.getName() + ")");
controller.addSensor(attributeRef, new ControllerSensor(deviceName, sensorName));
// Properly stop previously existing polling on device name --> use of false parameter
@@ -229,7 +229,7 @@ public class ControllerProtocol extends AbstractProtocol<ControllerAgent, Contro
*/
@Override
protected void doLinkedAttributeWrite(Attribute<?> attribute, ControllerAgentLink agentLink, AttributeEvent event, Object processedValue) {
- LOG.fine("### Process Linked Attribute Write");
+ LOG.finer("### Process Linked Attribute Write");
AttributeRef attributeRef = event.getAttributeRef();
ControllerCommand controllerCommand = controller.getCommand(attributeRef);
@@ -290,7 +290,7 @@ public class ControllerProtocol extends AbstractProtocol<ControllerAgent, Contro
private void onInitialStatusResponse(AttributeRef attributeRef, String deviceName, String sensorName, Response response) {
if (response != null) {
if (response.getStatusInfo().equals(Response.Status.OK)) {
- LOG.fine("### New sensor [" + sensorName + "] status received");
+ LOG.finer("### New sensor [" + sensorName + "] status received");
ArrayNode arrayValue = response.readEntity(ArrayNode.class);
if (arrayValue.isEmpty()) {
@@ -435,7 +435,7 @@ public class ControllerProtocol extends AbstractProtocol<ControllerAgent, Contro
private void onAttributeWriteResponse(Response response) {
if (response != null) {
- LOG.fine("### Response from command (204 is a valid and success return) : " + response.getStatus());
+ LOG.finer("### Response from command (204 is a valid and success return) : " + response.getStatus());
if (response.getStatus() != 204) {
LOG.severe("### Linked attribute Write request return with an error (different from 204) : " + response.getStatusInfo().getReasonPhrase());
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/io/AbstractIoClientProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/io/AbstractIoClientProtocol.java
index 705452486..cb6259e44 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/io/AbstractIoClientProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/io/AbstractIoClientProtocol.java
@@ -146,7 +146,7 @@ public abstract class AbstractIoClientProtocol<T extends AbstractIoClientProtoco
LOG.fine("Created IO client '" + client.ioClient.getClientUri() + "' for protocol: " + this);
client.connect();
} catch (Exception e) {
- LOG.log(Level.SEVERE, "Failed to create IO client for protocol: " + this, e);
+ LOG.log(Level.WARNING, "Failed to create IO client for protocol: " + this, e);
setConnectionStatus(ConnectionStatus.ERROR);
}
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/io/AbstractNettyIoClient.java b/agent/src/main/java/org/openremote/agent/protocol/io/AbstractNettyIoClient.java
index 66cf99835..ebf02e3ab 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/io/AbstractNettyIoClient.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/io/AbstractNettyIoClient.java
@@ -193,12 +193,12 @@ public abstract class AbstractNettyIoClient<T, U extends SocketAddress> implemen
public void connect() {
synchronized (this) {
if (permanentError) {
- LOG.fine("Unable to connect as permanent error has been set");
+ LOG.info("Unable to connect as permanent error has been set");
return;
}
if (connectionStatus != ConnectionStatus.DISCONNECTED) {
- LOG.finest("Must be disconnected before calling connect: " + getClientUri());
+ LOG.finer("Must be disconnected before calling connect: " + getClientUri());
return;
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/knx/KNXConnection.java b/agent/src/main/java/org/openremote/agent/protocol/knx/KNXConnection.java
index 38e66a262..80c4f172d 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/knx/KNXConnection.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/knx/KNXConnection.java
@@ -101,7 +101,7 @@ public class KNXConnection implements NetworkLinkListener, ProcessListener {
onConnectionStatusChanged(ConnectionStatus.CONNECTED);
// Get the values of all registered group addresses
- LOG.fine("Initialising group address values");
+ LOG.finer("Initialising group address values");
synchronized (groupAddressConsumerMap) {
groupAddressConsumerMap.forEach((groupAddress, datapointConsumerList) -> {
if (!datapointConsumerList.isEmpty()) {
@@ -167,7 +167,7 @@ public class KNXConnection implements NetworkLinkListener, ProcessListener {
public void sendCommand(Datapoint datapoint, Optional<Object> value) {
try {
if (this.connectionStatus == ConnectionStatus.CONNECTED && value.isPresent()) {
- LOG.fine("Sending to KNX action datapoint '" + datapoint + "': " + value);
+ LOG.finer("Sending to KNX action datapoint '" + datapoint + "': " + value);
Object val = value.get();
DPTXlator translator = TypeMapper.toDPTXlator(datapoint, val);
processCommunicator.write(datapoint.getMainAddress(), translator);
@@ -301,12 +301,12 @@ public class KNXConnection implements NetworkLinkListener, ProcessListener {
protected void getGroupAddressValue(GroupAddress groupAddress, Priority priority) {
if (knxLink == null || !knxLink.isOpen()) {
- LOG.fine("Cannot send read request not currently connected: " + groupAddress);
+ LOG.finer("Cannot send read request not currently connected: " + groupAddress);
return;
}
try {
- LOG.fine("Sending read request to KNX group address: " + groupAddress);
+ LOG.finer("Sending read request to KNX group address: " + groupAddress);
this.knxLink.sendRequest(groupAddress, priority, DataUnitBuilder.createLengthOptimizedAPDU(0x00, null));
} catch (Exception e) {
LOG.log(Level.INFO, "Error sending KNX read request for group address: " + groupAddress, e);
diff --git a/agent/src/main/java/org/openremote/agent/protocol/macro/MacroProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/macro/MacroProtocol.java
index b1c7daa72..6e17632f0 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/macro/MacroProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/macro/MacroProtocol.java
@@ -164,7 +164,7 @@ public class MacroProtocol extends AbstractProtocol<MacroAgent, MacroAgent.Macro
// Check for executable meta item
if (attribute.getType().getType() == AttributeExecuteStatus.class) {
- LOG.fine("Macro linked attribute is marked as executable so it will be linked to the firing of the macro");
+ LOG.finer("Macro linked attribute is marked as executable so it will be linked to the firing of the macro");
// Update the command Status of this attribute
updateLinkedAttribute(
new AttributeState(
@@ -185,11 +185,11 @@ public class MacroProtocol extends AbstractProtocol<MacroAgent, MacroAgent.Macro
Object actionValue = null;
if (actions.isEmpty()) {
- LOG.fine("No actions are available for the linked macro, maybe it is disabled?: " + this);
+ LOG.finer("No actions are available for the linked macro, maybe it is disabled?: " + this);
} else {
actionIndex = Math.min(actions.size(), Math.max(0, actionIndex));
actionValue = actions.get(actionIndex).getAttributeState().getValue().orElse(null);
- LOG.fine("Attribute is linked to the value of macro action index: actionIndex");
+ LOG.finer("Attribute is linked to the value of macro action index: actionIndex");
}
// Push the value of this macro action into the attribute
diff --git a/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java
index 0fcfc9c2d..40bced952 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java
@@ -106,7 +106,7 @@ public class SimulatorProtocol extends AbstractProtocol<SimulatorAgent, Simulato
}
// Assume write through and endpoint returned the value we sent
- LOG.fine("Write to linked attribute so simulating that the endpoint returned the written value");
+ LOG.finer("Write to linked attribute so simulating that the endpoint returned the written value");
updateSensor(event.getAttributeRef(), processedValue);
}
@@ -141,7 +141,7 @@ public class SimulatorProtocol extends AbstractProtocol<SimulatorAgent, Simulato
}
protected ScheduledFuture<?> scheduleReplay(AttributeRef attributeRef, SimulatorReplayDatapoint[] simulatorReplayDatapoints) {
- LOG.fine("Scheduling linked attribute replay update");
+ LOG.finer("Scheduling linked attribute replay update");
long now = LocalDateTime.now().get(ChronoField.SECOND_OF_DAY);
diff --git a/agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.java
index 03fdfdd05..f914c456f 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.java
@@ -96,7 +96,7 @@ public class TimerProtocol extends AbstractProtocol<TimerAgent, TimerAgent.Timer
protected void doLinkAttribute(String assetId, Attribute<?> attribute, TimerAgent.TimerAgentLink agentLink) throws RuntimeException {
TimerValue timerValue = getOrThrowAgentLinkProperty(agentLink.getTimerValue(), "timer value");
- LOG.fine("Attribute is linked to timer value: " + timerValue);
+ LOG.finer("Attribute is linked to timer value: " + timerValue);
AttributeRef attributeRef = new AttributeRef(assetId, attribute.getName());
updateLinkedAttributeTimerValue(timerValue, attributeRef);
}
@@ -121,7 +121,7 @@ public class TimerProtocol extends AbstractProtocol<TimerAgent, TimerAgent.Timer
if (this.active == active) {
return;
} else {
- LOG.fine("Updating timer enabled status: " + active);
+ LOG.finer("Updating timer enabled status: " + active);
updateActive(active);
updateAgentAttribute(new AttributeState(agent.getId(), TimerAgent.TIMER_ACTIVE.getName(), active));
updateLinkedAttributesTimerValues();
diff --git a/agent/src/main/java/org/openremote/agent/protocol/tradfri/TradfriProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/tradfri/TradfriProtocol.java
index c9f9702e5..f241f38b0 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/tradfri/TradfriProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/tradfri/TradfriProtocol.java
@@ -164,7 +164,7 @@ public class TradfriProtocol extends AbstractProtocol<TradfriAgent, AgentLink.De
.collect(Collectors.toList());
if (!obsoleteAssetIds.isEmpty()) {
- LOG.fine("Removing " + obsoleteAssetIds.size() + " obsolete asset(s): " + this);
+ LOG.finer("Removing " + obsoleteAssetIds.size() + " obsolete asset(s): " + this);
assetService.deleteAssets(obsoleteAssetIds.toArray(new String[0]));
}
@@ -189,7 +189,7 @@ public class TradfriProtocol extends AbstractProtocol<TradfriAgent, AgentLink.De
});
if (!obsoleteAssetIds.isEmpty()) {
- LOG.fine("Removing " + obsoleteAssetIds.size() + " obsolete asset(s): " + this);
+ LOG.finer("Removing " + obsoleteAssetIds.size() + " obsolete asset(s): " + this);
obsoleteAssetIds.forEach(this::removeDevice);
assetService.deleteAssets(obsoleteAssetIds.toArray(new String[0]));
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/VelbusDevice.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/VelbusDevice.java
index 9e922310e..253ee652f 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/VelbusDevice.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/VelbusDevice.java
@@ -150,7 +150,7 @@ public class VelbusDevice {
// Send the status request packets for this device
if (isInitialisedAndValid() && featureProcessors != null) {
- LOG.fine("Sending module status request packets");
+ LOG.finer("Sending module status request packets");
velbusNetwork.sendPackets(Arrays.stream(featureProcessors)
.flatMap(processor -> processor.getStatusRequestPackets(this).stream())
.distinct().toArray(VelbusPacket[]::new));
@@ -195,7 +195,7 @@ public class VelbusDevice {
public void writeProperty(String property, Object value) {
if (!isInitialisedAndValid()) {
- LOG.fine("Ignoring property write as device is not initialised and/or it is invalid");
+ LOG.finer("Ignoring property write as device is not initialised and/or it is invalid");
return;
}
diff --git a/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java b/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java
index 5fb6b7917..338f27d10 100644
--- a/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java
+++ b/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java
@@ -196,7 +196,7 @@ public abstract class KeycloakIdentityProvider implements IdentityProvider {
// The realm we authenticate against must be available as a request header
String realm = request.getHeader(REQUEST_HEADER_REALM);
if (realm == null || realm.length() == 0) {
- LOG.fine("No realm in request, no authentication will be attempted: " + request.getURI());
+ LOG.finer("No realm in request, no authentication will be attempted: " + request.getURI());
return notAuthenticatedKeycloakDeployment;
}
KeycloakDeployment keycloakDeployment = getKeycloakDeployment(realm, clientId);
diff --git a/container/src/main/java/org/openremote/container/web/socket/WebsocketProducer.java b/container/src/main/java/org/openremote/container/web/socket/WebsocketProducer.java
index 146203ca2..18c875f64 100644
--- a/container/src/main/java/org/openremote/container/web/socket/WebsocketProducer.java
+++ b/container/src/main/java/org/openremote/container/web/socket/WebsocketProducer.java
@@ -97,7 +97,7 @@ public class WebsocketProducer extends DefaultProducer {
if (session != null && session.isOpen()) {
if (message instanceof String) {
if (LOG.isLoggable(Level.FINE))
- LOG.fine("Sending to session " + session.getId() + ": " + message);
+ LOG.finer("Sending to session " + session.getId() + ": " + message);
session.getBasicRemote().sendText((String) message);
}
}
diff --git a/manager/src/main/java/org/openremote/manager/agent/AgentService.java b/manager/src/main/java/org/openremote/manager/agent/AgentService.java
index a0d036ec9..cd59a87fa 100644
--- a/manager/src/main/java/org/openremote/manager/agent/AgentService.java
+++ b/manager/src/main/java/org/openremote/manager/agent/AgentService.java
@@ -411,7 +411,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse
protocol.start(container);
LOG.fine("Started protocol instance:" + protocol);
- LOG.fine("Linking attributes to protocol instance: " + protocol);
+ LOG.finer("Linking attributes to protocol instance: " + protocol);
// Get all assets that have attributes with agent link meta for this agent
List<Asset<?>> assets = assetStorageService.findAll(
@@ -423,7 +423,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse
)
);
- LOG.fine("Found '" + assets.size() + "' asset(s) with attributes linked to this protocol instance: " + protocol);
+ LOG.finer("Found '" + assets.size() + "' asset(s) with attributes linked to this protocol instance: " + protocol);
assets.forEach(
asset ->
@@ -485,7 +485,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse
AttributeRef attributeRef = new AttributeRef(assetId, attribute.getName());
try {
if (!protocol.getLinkedAttributes().containsKey(attributeRef)) {
- LOG.fine("Linking attribute '" + attributeRef + "' to protocol: " + protocol);
+ LOG.finer("Linking attribute '" + attributeRef + "' to protocol: " + protocol);
protocol.linkAttribute(assetId, attribute);
}
} catch (Exception ex) {
@@ -509,7 +509,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse
try {
AttributeRef attributeRef = new AttributeRef(assetId, attribute.getName());
if (protocol.getLinkedAttributes().containsKey(attributeRef)) {
- LOG.fine("Unlinking attribute '" + attributeRef + "' to protocol: " + protocol);
+ LOG.finer("Unlinking attribute '" + attributeRef + "' to protocol: " + protocol);
protocol.unlinkAttribute(assetId, attribute);
}
} catch (Exception ex) {
@@ -553,7 +553,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse
agent.addOrReplaceAttributes(attribute);
if (source == CLIENT && agent.isConfigurationAttribute(attribute.getName())) {
- LOG.fine("Agent attribute event occurred from a client for an agent config attribute so updating: agent=" + agent.getId() + ", event=" + attributeEvent);
+ LOG.finer("Agent attribute event occurred from a client for an agent config attribute so updating: agent=" + agent.getId() + ", event=" + attributeEvent);
onAgentUpdated(agent);
}
}
@@ -565,7 +565,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse
Boolean result = withLockReturning(getClass().getSimpleName() + "::processAssetUpdate", () ->
attribute.getMetaValue(AGENT_LINK)
.map(agentLink -> {
- LOG.fine("Attribute write for agent linked attribute: agent=" + agentLink.getId() + ", asset=" + asset.getId() + ", attribute=" + attribute.getName());
+ LOG.finer("Attribute write for agent linked attribute: agent=" + agentLink.getId() + ", asset=" + asset.getId() + ", attribute=" + attribute.getName());
messageBrokerService.getProducerTemplate().sendBodyAndHeader(
ACTUATOR_TOPIC,
@@ -686,7 +686,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse
protected void notifyChildAssetChange(String agentId, PersistenceEvent<Asset<?>> assetPersistenceEvent) {
withLock(getClass().getSimpleName() + "::notifyChildAssetChange", () ->
childAssetSubscriptions.computeIfPresent(agentId, (id, consumerList) -> {
- LOG.fine("Notifying child asset change consumers of change to agent child asset: Agent ID=" + id + ", Asset<?> ID=" + assetPersistenceEvent.getEntity().getId());
+ LOG.finer("Notifying child asset change consumers of change to agent child asset: Agent ID=" + id + ", Asset<?> ID=" + assetPersistenceEvent.getEntity().getId());
try {
consumerList.forEach(consumer -> consumer.accept(assetPersistenceEvent));
} catch (Exception e) {
diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java b/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java
index 8c51a88cd..d1d66561c 100644
--- a/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java
@@ -198,7 +198,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
throw new WebApplicationException(NOT_FOUND);
if (!isTenantActiveAndAccessible(asset.getRealm())) {
- LOG.fine("Forbidden access for user '" + getUsername() + "': " + asset);
+ LOG.info("Forbidden access for user '" + getUsername() + "': " + asset);
throw new WebApplicationException(FORBIDDEN);
}
@@ -222,17 +222,17 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
// Realm of asset must be accessible
if (!isTenantActiveAndAccessible(storageAsset.getRealm())) {
- LOG.fine("Tenant not accessible by user '" + getUsername() + "', can't update: " + storageAsset);
+ LOG.info("Tenant not accessible by user '" + getUsername() + "', can't update: " + storageAsset);
throw new WebApplicationException(FORBIDDEN);
}
if (!storageAsset.getRealm().equals(asset.getRealm())) {
- LOG.fine("Cannot change asset's realm: " + storageAsset);
+ LOG.info("Cannot change asset's realm: " + storageAsset);
throw new WebApplicationException(FORBIDDEN);
}
if (!storageAsset.getType().equals(asset.getType())) {
- LOG.fine("Cannot change asset's type: " + storageAsset);
+ LOG.info("Cannot change asset's type: " + storageAsset);
throw new WebApplicationException(FORBIDDEN);
}
@@ -268,7 +268,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
// If the existing attribute is not writable by restricted client, ignore it
if (!existingAttribute.getMetaValue(ACCESS_RESTRICTED_WRITE).orElse(false)) {
- LOG.fine("Existing attribute not writable by restricted client, ignoring update of: " + updatedAttributeName);
+ LOG.info("Existing attribute not writable by restricted client, ignoring update of: " + updatedAttributeName);
continue;
}
@@ -400,7 +400,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
}
if (asset == null) {
- LOG.fine("No asset in request");
+ LOG.finer("No asset in request");
throw new WebApplicationException(BAD_REQUEST);
}
@@ -408,7 +408,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
if (asset.getRealm() == null || asset.getRealm().length() == 0) {
asset.setRealm(getAuthenticatedTenant().getRealm());
} else if (!isTenantActiveAndAccessible(asset.getRealm())) {
- LOG.fine("Forbidden access for user '" + getUsername() + "', can't create: " + asset);
+ LOG.info("Forbidden access for user '" + getUsername() + "', can't create: " + asset);
throw new WebApplicationException(FORBIDDEN);
}
@@ -475,7 +475,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
}
if (assets.stream().map(Asset::getRealm).distinct().anyMatch(asset -> !isTenantActiveAndAccessible(asset))) {
- LOG.fine("Forbidden access for user '" + getUsername() + "', can't delete requested assets");
+ LOG.info("Forbidden access for user '" + getUsername() + "', can't delete requested assets");
throw new WebApplicationException(FORBIDDEN);
}
diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java b/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java
index c81e01996..352a0f68e 100644
--- a/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java
+++ b/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java
@@ -359,7 +359,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic
.choice()
.when(or(body().isInstanceOf(ReadAssetEvent.class), body().isInstanceOf(ReadAttributeEvent.class)))
.process(exchange -> {
- LOG.fine("Handling from client: " + exchange.getIn().getBody());
+ LOG.finer("Handling from client: " + exchange.getIn().getBody());
String assetId;
String attributeName = null;
diff --git a/manager/src/main/java/org/openremote/manager/asset/AttributeLinkingService.java b/manager/src/main/java/org/openremote/manager/asset/AttributeLinkingService.java
index cb31480c7..93446827a 100644
--- a/manager/src/main/java/org/openremote/manager/asset/AttributeLinkingService.java
+++ b/manager/src/main/java/org/openremote/manager/asset/AttributeLinkingService.java
@@ -115,7 +115,7 @@ public class AttributeLinkingService implements ContainerService, AssetUpdatePro
Attribute<?> attribute,
Source source) throws AssetProcessingException {
if (source == ATTRIBUTE_LINKING_SERVICE) {
- LOG.fine("Attribute update came from this service so ignoring to avoid infinite loops: " + attribute);
+ LOG.finest("Attribute update came from this service so ignoring to avoid infinite loops: " + attribute);
return false;
}
@@ -128,14 +128,14 @@ public class AttributeLinkingService implements ContainerService, AssetUpdatePro
}
protected void sendAttributeEvent(AttributeEvent attributeEvent) {
- LOG.fine("Sending attribute event for linked attribute: " + attributeEvent);
+ LOG.finer("Sending attribute event for linked attribute: " + attributeEvent);
assetProcessingService.sendAttributeEvent(attributeEvent, ATTRIBUTE_LINKING_SERVICE);
}
protected void processLinkedAttributeUpdate(EntityManager em, AttributeLink attributeLink, AttributeState attributeState) {
if (attributeState == null)
return;
- LOG.fine("Processing attribute state for linked attribute");
+ LOG.finer("Processing attribute state for linked attribute");
if (attributeLink == null) {
throw new AssetProcessingException(Reason.INVALID_ATTRIBUTE_LINK);
@@ -150,7 +150,7 @@ public class AttributeLinkingService implements ContainerService, AssetUpdatePro
);
if (sendConvertedValue.key) {
- LOG.fine("Value converter matched ignore value");
+ LOG.finer("Value converter matched ignore value");
return;
}
diff --git a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointResourceImpl.java b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointResourceImpl.java
index d5cefafb6..5204179db 100644
--- a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointResourceImpl.java
@@ -33,6 +33,9 @@ import org.openremote.model.http.RequestParams;
import javax.ws.rs.BeanParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
import java.util.logging.Logger;
public class AssetDatapointResourceImpl extends ManagerWebResource implements AssetDatapointResource {
@@ -71,7 +74,7 @@ public class AssetDatapointResourceImpl extends ManagerWebResource implements As
}
if (!isTenantActiveAndAccessible(asset.getRealm())) {
- LOG.fine("Forbidden access for user '" + getUsername() + "': " + asset);
+ LOG.info("Forbidden access for user '" + getUsername() + "': " + asset);
throw new WebApplicationException(Response.Status.FORBIDDEN);
}
@@ -82,8 +85,8 @@ public class AssetDatapointResourceImpl extends ManagerWebResource implements As
return assetDatapointService.getValueDatapoints(assetId,
attribute,
interval,
- fromTimestamp,
- toTimestamp);
+ LocalDateTime.ofInstant(Instant.ofEpochMilli(fromTimestamp), ZoneId.systemDefault()),
+ LocalDateTime.ofInstant(Instant.ofEpochMilli(toTimestamp), ZoneId.systemDefault()));
} catch (IllegalStateException ex) {
throw new WebApplicationException(ex, Response.Status.BAD_REQUEST);
}
diff --git a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java
index 022c1f01e..2ac22248e 100644
--- a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java
+++ b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java
@@ -32,6 +32,7 @@ import javax.persistence.TypedQuery;
import java.sql.*;
import java.time.Duration;
import java.time.Instant;
+import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
@@ -194,8 +195,8 @@ public class AssetDatapointService implements ContainerService, AssetUpdateProce
public ValueDatapoint<?>[] getValueDatapoints(AttributeRef attributeRef,
DatapointInterval datapointInterval,
- long fromTimestamp,
- long toTimestamp) {
+ LocalDateTime fromTimestamp,
+ LocalDateTime toTimestamp) {
Asset<?> asset = assetStorageService.find(attributeRef.getId());
if (asset == null) {
@@ -210,12 +211,12 @@ public class AssetDatapointService implements ContainerService, AssetUpdateProce
public ValueDatapoint<?>[] getValueDatapoints(String assetId, Attribute<?> attribute,
DatapointInterval datapointInterval,
- long fromTimestamp,
- long toTimestamp) {
+ LocalDateTime fromTimestamp,
+ LocalDateTime toTimestamp) {
AttributeRef attributeRef = new AttributeRef(assetId, attribute.getName());
- LOG.fine("Getting datapoints for: " + attributeRef);
+ LOG.finer("Getting datapoints for: " + attributeRef);
return persistenceService.doReturningTransaction(entityManager ->
entityManager.unwrap(Session.class).doReturningWork(new AbstractReturningWork<ValueDatapoint<?>[]>() {
@@ -266,7 +267,7 @@ public class AssetDatapointService implements ContainerService, AssetUpdateProce
query.append("select PERIOD.TS as X, coalesce(AVG_VALUE, null) as Y " +
" from ( " +
" select date_trunc(?, GS)::timestamp TS " +
- " from generate_series(to_timestamp(?), to_timestamp(?), ?) GS " +
+ " from generate_series(?, ?, ?) GS " +
" ) PERIOD " +
" left join ( " +
" select " +
@@ -280,9 +281,9 @@ public class AssetDatapointService implements ContainerService, AssetUpdateProce
query.append(" from ASSET_DATAPOINT " +
" where " +
- " TIMESTAMP >= to_timestamp(?) " +
+ " TIMESTAMP >= ? " +
" and " +
- " TIMESTAMP <= to_timestamp(?) " +
+ " TIMESTAMP <= ? " +
" and " +
" ENTITY_ID = ? and ATTRIBUTE_NAME = ? " +
" group by TS " +
@@ -292,9 +293,9 @@ public class AssetDatapointService implements ContainerService, AssetUpdateProce
} else {
query.append("select distinct TIMESTAMP AS X, value AS Y from ASSET_DATAPOINT " +
"where " +
- "TIMESTAMP >= to_timestamp(?)" +
+ "TIMESTAMP >= ?" +
"and " +
- "TIMESTAMP <= to_timestamp(?) " +
+ "TIMESTAMP <= ? " +
"and " +
"ENTITY_ID = ? and ATTRIBUTE_NAME = ? "
);
@@ -302,22 +303,20 @@ public class AssetDatapointService implements ContainerService, AssetUpdateProce
try (PreparedStatement st = connection.prepareStatement(query.toString())) {
- long fromTimestampSeconds = fromTimestamp / 1000;
- long toTimestampSeconds = toTimestamp / 1000;
if (downsample) {
st.setString(1, truncateX);
- st.setLong(2, fromTimestampSeconds);
- st.setLong(3, toTimestampSeconds);
+ st.setObject(2, fromTimestamp);
+ st.setObject(3, toTimestamp);
st.setObject(4, new PGInterval(interval));
st.setString(5, truncateX);
- st.setLong(6, fromTimestampSeconds);
- st.setLong(7, toTimestampSeconds);
+ st.setObject(6, fromTimestamp);
+ st.setObject(7, toTimestamp);
st.setString(8, attributeRef.getId());
st.setString(9, attributeRef.getName());
st.setObject(10, new PGInterval(interval));
} else {
- st.setLong(1, fromTimestampSeconds);
- st.setLong(2, toTimestampSeconds);
+ st.setObject(1, fromTimestamp);
+ st.setObject(2, toTimestamp);
st.setString(3, attributeRef.getId());
st.setString(4, attributeRef.getName());
}
diff --git a/manager/src/main/java/org/openremote/manager/datapoint/AssetPredictedDatapointResourceImpl.java b/manager/src/main/java/org/openremote/manager/datapoint/AssetPredictedDatapointResourceImpl.java
index 2ac598b8d..7ec39bfcf 100644
--- a/manager/src/main/java/org/openremote/manager/datapoint/AssetPredictedDatapointResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/datapoint/AssetPredictedDatapointResourceImpl.java
@@ -33,6 +33,9 @@ import org.openremote.model.datapoint.AssetPredictedDatapointResource;
import javax.ws.rs.BeanParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
import java.util.logging.Logger;
public class AssetPredictedDatapointResourceImpl extends ManagerWebResource implements AssetPredictedDatapointResource {
@@ -71,15 +74,15 @@ public class AssetPredictedDatapointResourceImpl extends ManagerWebResource impl
}
if (!isTenantActiveAndAccessible(asset.getRealm())) {
- LOG.fine("Forbidden access for user '" + getUsername() + "': " + asset);
+ LOG.info("Forbidden access for user '" + getUsername() + "': " + asset);
throw new WebApplicationException(Response.Status.FORBIDDEN);
}
return assetPredictedDatapointService.getValueDatapoints(
new AttributeRef(assetId, attributeName),
datapointInterval,
- fromTimestamp,
- toTimestamp);
+ LocalDateTime.ofInstant(Instant.ofEpochMilli(fromTimestamp), ZoneId.systemDefault()),
+ LocalDateTime.ofInstant(Instant.ofEpochMilli(toTimestamp), ZoneId.systemDefault()));
} catch (IllegalStateException ex) {
throw new WebApplicationException(ex, Response.Status.BAD_REQUEST);
}
diff --git a/manager/src/main/java/org/openremote/manager/datapoint/AssetPredictedDatapointService.java b/manager/src/main/java/org/openremote/manager/datapoint/AssetPredictedDatapointService.java
index 0ba6b1d7c..e84a848b9 100644
--- a/manager/src/main/java/org/openremote/manager/datapoint/AssetPredictedDatapointService.java
+++ b/manager/src/main/java/org/openremote/manager/datapoint/AssetPredictedDatapointService.java
@@ -36,12 +36,14 @@ import org.openremote.model.datapoint.DatapointInterval;
import org.openremote.model.datapoint.ValueDatapoint;
import org.openremote.model.value.Values;
import org.postgresql.util.PGInterval;
+import org.postgresql.util.PGobject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import java.sql.*;
import java.time.Duration;
import java.time.Instant;
+import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
@@ -130,8 +132,8 @@ public class AssetPredictedDatapointService implements ContainerService, Protoco
public ValueDatapoint<?>[] getValueDatapoints(AttributeRef attributeRef,
String truncate,
String interval,
- long fromTimestamp,
- long toTimestamp) {
+ LocalDateTime fromTimestamp,
+ LocalDateTime toTimestamp) {
String assetId = attributeRef.getId();
String attributeName = attributeRef.getName();
@@ -143,7 +145,7 @@ public class AssetPredictedDatapointService implements ContainerService, Protoco
Attribute<?> attribute = asset.getAttribute(attributeName)
.orElseThrow(() -> new IllegalStateException("Attribute not found: " + attributeName));
- LOG.fine("Getting predicted datapoints for: " + attributeName);
+ LOG.finer("Getting predicted datapoints for: " + attributeName);
return persistenceService.doReturningTransaction(entityManager ->
entityManager.unwrap(Session.class).doReturningWork(new AbstractReturningWork<ValueDatapoint<?>[]>() {
@@ -155,14 +157,14 @@ public class AssetPredictedDatapointService implements ContainerService, Protoco
boolean isNumber = Number.class.isAssignableFrom(attributeType);
boolean isBoolean = Boolean.class.isAssignableFrom(attributeType);
StringBuilder query = new StringBuilder();
- boolean downsample = isNumber || isBoolean;;
+ boolean downsample = isNumber || isBoolean;
if (downsample) {
// TODO: Change this to use something like this max min decimation algorithm https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019YLKSA2&l=en-GB)
query.append("select PERIOD.TS as X, coalesce(AVG_VALUE, null) as Y " +
" from ( " +
" select date_trunc(?, GS)::timestamp TS " +
- " from generate_series(to_timestamp(?), to_timestamp(?), ?) GS " +
+ " from generate_series(?, ?, ?) GS " +
" ) PERIOD " +
" left join ( " +
" select " +
@@ -176,9 +178,9 @@ public class AssetPredictedDatapointService implements ContainerService, Protoco
query.append(" from ASSET_PREDICTED_DATAPOINT " +
" where " +
- " TIMESTAMP >= to_timestamp(?) " +
+ " TIMESTAMP >= ? " +
" and " +
- " TIMESTAMP <= to_timestamp(?) " +
+ " TIMESTAMP <= ? " +
" and " +
" ENTITY_ID = ? and ATTRIBUTE_NAME = ? " +
" group by TS " +
@@ -189,9 +191,9 @@ public class AssetPredictedDatapointService implements ContainerService, Protoco
} else {
query.append("select distinct TIMESTAMP AS X, value AS Y from ASSET_PREDICTED_DATAPOINT " +
"where " +
- "TIMESTAMP >= to_timestamp(?) " +
+ "TIMESTAMP >= ? " +
"and " +
- "TIMESTAMP < to_timestamp(?) " +
+ "TIMESTAMP < ? " +
"and " +
"ENTITY_ID = ? and ATTRIBUTE_NAME = ? "
);
@@ -199,23 +201,20 @@ public class AssetPredictedDatapointService implements ContainerService, Protoco
try (PreparedStatement st = connection.prepareStatement(query.toString())) {
- long fromTimestampSeconds = fromTimestamp / 1000;
- long toTimestampSeconds = toTimestamp / 1000;
-
if (downsample) {
st.setString(1, truncate);
- st.setLong(2, fromTimestampSeconds);
- st.setLong(3, toTimestampSeconds);
+ st.setObject(2, fromTimestamp);
+ st.setObject(3, toTimestamp);
st.setObject(4, new PGInterval(interval));
st.setString(5, truncate);
- st.setLong(6, fromTimestampSeconds);
- st.setLong(7, toTimestampSeconds);
+ st.setObject(6, fromTimestamp);
+ st.setObject(7, toTimestamp);
st.setString(8, assetId);
st.setString(9, attributeName);
st.setObject(10, new PGInterval(interval));
} else {
- st.setLong(1, fromTimestampSeconds);
- st.setLong(2, toTimestampSeconds);
+ st.setObject(1, fromTimestamp);
+ st.setObject(2, toTimestamp);
st.setString(3, assetId);
st.setString(4, attributeName);
}
@@ -235,9 +234,9 @@ public class AssetPredictedDatapointService implements ContainerService, Protoco
}
public ValueDatapoint<?>[] getValueDatapoints(AttributeRef attributeRef,
- DatapointInterval datapointInterval,
- long fromTimestamp,
- long toTimestamp) {
+ DatapointInterval datapointInterval,
+ LocalDateTime fromTimestamp,
+ LocalDateTime toTimestamp) {
String truncateX;
String interval;
@@ -273,20 +272,35 @@ public class AssetPredictedDatapointService implements ContainerService, Protoco
return getValueDatapoints(attributeRef, truncateX, interval, fromTimestamp, toTimestamp);
}
- public void updateValue(AttributeRef attributeRef, Object value, long timestamp) {
- persistenceService.doTransaction(em -> upsertValue(em, attributeRef.getId(), attributeRef.getName(), value, timestamp));
+ public void updateValue(AttributeRef attributeRef, Object value, LocalDateTime timestamp) {
+ updateValue(attributeRef.getId(), attributeRef.getName(), value, timestamp);
}
- public void updateValue(String assetId, String attributeName, Object value, long timestamp) {
- updateValue(new AttributeRef(assetId, attributeName), value, timestamp);
+ public void updateValue(String assetId, String attributeName, Object value, LocalDateTime timestamp) {
+ persistenceService.doTransaction(em -> upsertValue(em, assetId, attributeName, value, timestamp));
}
- private void upsertValue(EntityManager entityManager, String assetId, String attributeName, Object value, long timestamp) {
- entityManager.createNativeQuery(String.format("INSERT INTO asset_predicted_datapoint (entity_id, attribute_name, value, timestamp) \n" +
- "VALUES ('%1$s', '%2$s', '%3$s', to_timestamp(%4$d))\n" +
- "ON CONFLICT (entity_id, attribute_name, timestamp) DO UPDATE \n" +
- " SET value = excluded.value", assetId, attributeName, value, timestamp))
- .executeUpdate();
+ protected void upsertValue(EntityManager em, String assetId, String attributeName, Object value, LocalDateTime timestamp) {
+ PGobject pgJsonValue = new PGobject();
+ pgJsonValue.setType("jsonb");
+ try {
+ pgJsonValue.setValue(Values.asJSON(value).orElse("null"));
+ } catch (SQLException e) {
+ LOG.log(Level.WARNING, "Failed to store predicted data point: " + new AttributeRef(assetId, attributeName), e);
+ }
+
+ em.unwrap(Session.class).doWork(connection -> {
+ PreparedStatement st = connection.prepareStatement("INSERT INTO asset_predicted_datapoint (entity_id, attribute_name, value, timestamp) \n" +
+ "VALUES (?, ?, ?, ?)\n" +
+ "ON CONFLICT (entity_id, attribute_name, timestamp) DO UPDATE \n" +
+ " SET value = excluded.value");
+
+ st.setString(1, assetId);
+ st.setString(2, attributeName);
+ st.setObject(3, pgJsonValue);
+ st.setObject(4, timestamp);
+ st.executeUpdate();
+ });
}
protected void purgeDataPoints() {
@@ -294,7 +308,7 @@ public class AssetPredictedDatapointService implements ContainerService, Protoco
try {
// Purge data points not in the above list using default duration
- LOG.fine("Purging predicted data points older than 1 day");
+ LOG.finer("Purging predicted data points older than 1 day");
persistenceService.doTransaction(em -> em.createQuery(
"delete from AssetPredictedDatapoint dp " +
diff --git a/manager/src/main/java/org/openremote/manager/event/ClientEventService.java b/manager/src/main/java/org/openremote/manager/event/ClientEventService.java
index 037b78f69..e2a452199 100644
--- a/manager/src/main/java/org/openremote/manager/event/ClientEventService.java
+++ b/manager/src/main/java/org/openremote/manager/event/ClientEventService.java
@@ -261,7 +261,7 @@ public class ClientEventService implements ProtocolClientEventService {
.stop()
.endChoice()
.otherwise()
- .process(exchange -> LOG.fine("Unsupported message body: " + exchange.getIn().getBody()))
+ .process(exchange -> LOG.info("Unsupported message body: " + exchange.getIn().getBody()))
.end();
}
});
@@ -398,7 +398,7 @@ public class ClientEventService implements ProtocolClientEventService {
if (messageBrokerService != null && messageBrokerService.getProducerTemplate() != null) {
// Don't log that we are publishing a syslog event,
if (!(event instanceof SyslogEvent)) {
- LOG.fine("Publishing: " + event);
+ LOG.finer("Publishing: " + event);
}
messageBrokerService.getProducerTemplate()
.sendBodyAndHeader(CLIENT_EVENT_QUEUE, event, HEADER_ACCESS_RESTRICTED, accessRestricted);
@@ -407,7 +407,7 @@ public class ClientEventService implements ProtocolClientEventService {
public void sendToSession(String sessionKey, Object data) {
if (messageBrokerService != null && messageBrokerService.getProducerTemplate() != null) {
- LOG.fine("Sending to session '" + sessionKey + "': " + data);
+ LOG.finer("Sending to session '" + sessionKey + "': " + data);
SessionInfo sessionInfo = sessionKeyInfoMap.get(sessionKey);
if (sessionInfo == null) {
LOG.info("Cannot send to requested session it doesn't exist or is disconnected");
@@ -446,7 +446,7 @@ public class ClientEventService implements ProtocolClientEventService {
interceptor.accept(exchange);
boolean stop = exchange.getProperty(Exchange.ROUTE_STOP, false, Boolean.class);
if (stop) {
- LOG.fine("Client event interceptor marked exchange as `stop routing`");
+ LOG.finer("Client event interceptor marked exchange as `stop routing`");
}
return stop;
}));
diff --git a/manager/src/main/java/org/openremote/manager/event/EventSubscriptions.java b/manager/src/main/java/org/openremote/manager/event/EventSubscriptions.java
index 285e29e1d..75b5916ee 100644
--- a/manager/src/main/java/org/openremote/manager/event/EventSubscriptions.java
+++ b/manager/src/main/java/org/openremote/manager/event/EventSubscriptions.java
@@ -121,7 +121,7 @@ public class EventSubscriptions {
public void createOrUpdate(String sessionKey, boolean restrictedUser, EventSubscription<?> subscription) {
synchronized (this.sessionSubscriptionIdMap) {
// TODO Check if the user can actually subscribe to the events it wants, how do we do that?
- LOG.fine("For session '" + sessionKey + "', creating/updating: " + subscription);
+ LOG.finer("For session '" + sessionKey + "', creating/updating: " + subscription);
SessionSubscriptions sessionSubscriptions =
this.sessionSubscriptionIdMap.computeIfAbsent(sessionKey, k -> new SessionSubscriptions());
sessionSubscriptions.createOrUpdate(restrictedUser, subscription);
@@ -132,7 +132,7 @@ public class EventSubscriptions {
synchronized (this.sessionSubscriptionIdMap) {
SessionSubscriptions sessionSubscriptions = this.sessionSubscriptionIdMap.get(sessionKey);
if (sessionSubscriptions != null) {
- LOG.fine("For session '" + sessionKey + "', updating: " + Arrays.toString(subscriptionIds));
+ LOG.finer("For session '" + sessionKey + "', updating: " + Arrays.toString(subscriptionIds));
sessionSubscriptions.update(restrictedUser, subscriptionIds);
}
}
@@ -146,7 +146,7 @@ public class EventSubscriptions {
if (subscription.getEventType() == null && subscription.getSubscriptionId() == null) {
return;
}
- LOG.fine("For session '" + sessionKey + "', cancelling: " + subscription);
+ LOG.finer("For session '" + sessionKey + "', cancelling: " + subscription);
SessionSubscriptions sessionSubscriptions = this.sessionSubscriptionIdMap.get(sessionKey);
if (!TextUtil.isNullOrEmpty(subscription.getSubscriptionId())) {
sessionSubscriptions.cancelById(subscription.getSubscriptionId());
@@ -159,7 +159,7 @@ public class EventSubscriptions {
public void cancelAll(String sessionKey) {
synchronized (this.sessionSubscriptionIdMap) {
if (this.sessionSubscriptionIdMap.containsKey(sessionKey)) {
- LOG.fine("Cancelling all subscriptions for session: " + sessionKey);
+ LOG.finer("Cancelling all subscriptions for session: " + sessionKey);
this.sessionSubscriptionIdMap.remove(sessionKey);
}
}
@@ -190,7 +190,7 @@ public class EventSubscriptions {
if (sessionSubscription.subscription.getFilter() == null
|| sessionSubscription.subscription.getFilter().apply(event)) {
- LOG.fine("Creating message for subscribed session '" + sessionKey + "': " + event);
+ LOG.finer("Creating message for subscribed session '" + sessionKey + "': " + event);
List<SharedEvent> events = Collections.singletonList(event);
TriggeredEventSubscription<?> triggeredEventSubscription = new TriggeredEventSubscription<>(events, sessionSubscription.subscriptionId);
diff --git a/manager/src/main/java/org/openremote/manager/gateway/GatewayClientService.java b/manager/src/main/java/org/openremote/manager/gateway/GatewayClientService.java
index a05c20bf7..3208c98c5 100644
--- a/manager/src/main/java/org/openremote/manager/gateway/GatewayClientService.java
+++ b/manager/src/main/java/org/openremote/manager/gateway/GatewayClientService.java
@@ -309,7 +309,7 @@ public class GatewayClientService extends RouteBuilder implements ContainerServi
if (assetEvent.getCause() == AssetEvent.Cause.CREATE || assetEvent.getCause() == AssetEvent.Cause.UPDATE) {
Asset asset = assetEvent.getAsset();
asset.setRealm(connection.getLocalRealm());
- LOG.fine("Request from central manager to create/update an asset: Realm=" + connection.getLocalRealm() + ", Asset<?> ID=" + asset.getId());
+ LOG.finer("Request from central manager to create/update an asset: Realm=" + connection.getLocalRealm() + ", Asset<?> ID=" + asset.getId());
try {
asset = assetStorageService.merge(asset, true);
} catch (Exception e) {
@@ -318,7 +318,7 @@ public class GatewayClientService extends RouteBuilder implements ContainerServi
}
} else if (event instanceof DeleteAssetsRequestEvent) {
DeleteAssetsRequestEvent deleteRequest = (DeleteAssetsRequestEvent)event;
- LOG.fine("Request from central manager to delete asset(s): Realm=" + connection.getLocalRealm() + ", Asset<?> IDs=" + Arrays.toString(deleteRequest.getAssetIds().toArray()));
+ LOG.finer("Request from central manager to delete asset(s): Realm=" + connection.getLocalRealm() + ", Asset<?> IDs=" + Arrays.toString(deleteRequest.getAssetIds().toArray()));
boolean success = false;
try {
success = assetStorageService.delete(deleteRequest.getAssetIds());
diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java b/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java
index a12b8e211..f37b29060 100644
--- a/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java
+++ b/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java
@@ -633,7 +633,7 @@ public class RulesEngine<T extends Ruleset> {
engineInfo
);
- LOG.fine("Publishing rules engine status event: " + event);
+ LOG.finer("Publishing rules engine status event: " + event);
// Notify clients
clientEventService.publishEvent(event);
@@ -655,7 +655,7 @@ public class RulesEngine<T extends Ruleset> {
ruleset
);
- LOG.fine("Publishing ruleset status event: " + event);
+ LOG.finer("Publishing ruleset status event: " + event);
// Notify clients
clientEventService.publishEvent(event);
diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesFacts.java b/manager/src/main/java/org/openremote/manager/rules/RulesFacts.java
index 99e976789..967e720ab 100644
--- a/manager/src/main/java/org/openremote/manager/rules/RulesFacts.java
+++ b/manager/src/main/java/org/openremote/manager/rules/RulesFacts.java
@@ -631,7 +631,7 @@ public class RulesFacts extends Facts implements RuleListener {
protected void storeLocationPredicates(List<GeofencePredicate> foundLocationPredicates) {
if (foundLocationPredicates != null && !foundLocationPredicates.isEmpty()) {
- LOG.fine("Location predicate found");
+ LOG.finer("Location predicate found");
// Collect asset states only where the attribute is location (location predicates only make sense when the location
// attribute is exposed to rules - we don't support RULE_EVENT facts just RULE_STATE
Collection<AssetState<?>> locationAssetStates = getAssetStates().stream().filter(assetState -> assetState.getName().equalsIgnoreCase(Asset.LOCATION.getName())).collect(Collectors.toSet());
diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesResourceImpl.java b/manager/src/main/java/org/openremote/manager/rules/RulesResourceImpl.java
index 327adda31..dfb8174b9 100644
--- a/manager/src/main/java/org/openremote/manager/rules/RulesResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/rules/RulesResourceImpl.java
@@ -252,7 +252,7 @@ public class RulesResourceImpl extends ManagerWebResource implements RulesResour
throw new WebApplicationException(BAD_REQUEST);
}
if (!isTenantActiveAndAccessible(tenant) || isRestrictedUser()) {
- LOG.fine("Forbidden access for user '" + getUsername() + "': " + tenant);
+ LOG.info("Forbidden access for user '" + getUsername() + "': " + tenant);
throw new WebApplicationException(Response.Status.FORBIDDEN);
}
ruleset = rulesetStorageService.merge(ruleset);
diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesService.java b/manager/src/main/java/org/openremote/manager/rules/RulesService.java
index fc3d2fd25..0ae429fc4 100644
--- a/manager/src/main/java/org/openremote/manager/rules/RulesService.java
+++ b/manager/src/main/java/org/openremote/manager/rules/RulesService.java
@@ -482,7 +482,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse
return;
AssetState<?> assetState = buildAssetState.apply(loadedAsset, attribute);
- LOG.fine("Asset was persisted (" + persistenceEvent.getCause() + "), inserting fact: " + assetState);
+ LOG.finer("Asset was persisted (" + persistenceEvent.getCause() + "), inserting fact: " + assetState);
updateAssetState(assetState);
});
break;
@@ -515,7 +515,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse
obsoleteOrModified.forEach(attribute -> {
AssetState<?> assetState = buildAssetState.apply(loadedAsset, attribute);
- LOG.fine("Asset was persisted (" + persistenceEvent.getCause() + "), retracting fact: " + assetState);
+ LOG.finer("Asset was persisted (" + persistenceEvent.getCause() + "), retracting fact: " + assetState);
retractAssetState(assetState);
});
@@ -524,7 +524,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse
!oldStateAttributes.contains(attr) || obsoleteOrModified.contains(attr))
.forEach(attribute -> {
AssetState<?> assetState = buildAssetState.apply(loadedAsset, attribute);
- LOG.fine("Asset was persisted (" + persistenceEvent.getCause() + "), inserting fact: " + assetState);
+ LOG.finer("Asset was persisted (" + persistenceEvent.getCause() + "), inserting fact: " + assetState);
updateAssetState(assetState);
});
break;
@@ -535,7 +535,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse
.filter(RulesService::attributeIsRuleState)
.forEach(attribute -> {
AssetState<?> assetState = new AssetState<>(asset, attribute, Source.INTERNAL);
- LOG.fine("Asset was persisted (" + persistenceEvent.getCause() + "), retracting fact: " + assetState);
+ LOG.finer("Asset was persisted (" + persistenceEvent.getCause() + "), retracting fact: " + assetState);
retractAssetState(assetState);
});
break;
@@ -788,7 +788,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse
withLock(getClass().getSimpleName() + "::updateAssetState", () -> {
// TODO: implement rules processing error state handling
- LOG.fine("Updating asset state: " + assetState);
+ LOG.finer("Updating asset state: " + assetState);
// Get the chain of rule engines that we need to pass through
List<RulesEngine<?>> rulesEngines = getEnginesInScope(assetState.getRealm(), assetState.getPath());
@@ -812,7 +812,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse
assetStates.remove(assetState);
if (rulesEngines.size() == 0) {
- LOG.fine("Ignoring as there are no matching rules engines: " + assetState);
+ LOG.finer("Ignoring as there are no matching rules engines: " + assetState);
}
// Pass through each rules engine
diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesetDeployment.java b/manager/src/main/java/org/openremote/manager/rules/RulesetDeployment.java
index 56ede85ae..7e2ccc234 100644
--- a/manager/src/main/java/org/openremote/manager/rules/RulesetDeployment.java
+++ b/manager/src/main/java/org/openremote/manager/rules/RulesetDeployment.java
@@ -270,7 +270,7 @@ public class RulesetDeployment {
jsonRulesBuilder = new JsonRulesBuilder(ruleset, timerService, assetStorageService, executorService, assetsFacade, usersFacade, notificationsFacade, historicDatapointsFacade, predictedDatapointsFacade, this::scheduleRuleAction);
for (Rule rule : jsonRulesBuilder.build()) {
- RulesEngine.LOG.fine("Registering JSON rule: " + rule.getName());
+ RulesEngine.LOG.finer("Registering JSON rule: " + rule.getName());
rules.register(rule);
}
@@ -416,7 +416,7 @@ public class RulesetDeployment {
throw new IllegalArgumentException("Defined 'then' is not a function in rule: " + name);
}
- RulesEngine.LOG.fine("Registering javascript rule: " + name);
+ RulesEngine.LOG.finer("Registering javascript rule: " + name);
rules.register(
new RuleBuilder().name(name).description(description).priority(priority).when(when).then(then).build()
@@ -441,7 +441,7 @@ public class RulesetDeployment {
script.setBinding(binding);
script.run();
for (Rule rule : rulesBuilder.build()) {
- RulesEngine.LOG.fine("Registering groovy rule: " + rule.getName());
+ RulesEngine.LOG.finer("Registering groovy rule: " + rule.getName());
rules.register(rule);
}
diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesetStorageService.java b/manager/src/main/java/org/openremote/manager/rules/RulesetStorageService.java
index e593cff3c..7106921f4 100644
--- a/manager/src/main/java/org/openremote/manager/rules/RulesetStorageService.java
+++ b/manager/src/main/java/org/openremote/manager/rules/RulesetStorageService.java
@@ -120,7 +120,7 @@ public class RulesetStorageService implements ContainerService {
public <T extends Ruleset> List<T> findAll(Class<T> rulesetType, RulesetQuery query) {
return persistenceService.doReturningTransaction(em -> {
- LOG.fine("Building: " + query);
+ LOG.finer("Building: " + query);
StringBuilder sb = new StringBuilder();
List<ParameterBinder> binders = new ArrayList<>();
appendSelectString(sb, rulesetType, query);
@@ -134,7 +134,7 @@ public class RulesetStorageService implements ContainerService {
return em.unwrap(Session.class).doReturningWork(new AbstractReturningWork<List<T>>() {
@Override
public List<T> execute(Connection connection) throws SQLException {
- LOG.fine("Executing: " + sqlQuery);
+ LOG.finer("Executing: " + sqlQuery);
try (PreparedStatement st = connection.prepareStatement(sqlQuery)) {
binders.forEach(parameterBinder -> parameterBinder.accept(st));
diff --git a/manager/src/main/java/org/openremote/manager/rules/facade/HistoricFacade.java b/manager/src/main/java/org/openremote/manager/rules/facade/HistoricFacade.java
index eba42431e..2334b4b04 100644
--- a/manager/src/main/java/org/openremote/manager/rules/facade/HistoricFacade.java
+++ b/manager/src/main/java/org/openremote/manager/rules/facade/HistoricFacade.java
@@ -27,6 +27,7 @@ import org.openremote.model.datapoint.ValueDatapoint;
import org.openremote.model.rules.HistoricDatapoints;
import org.openremote.model.rules.Ruleset;
+import java.time.LocalDateTime;
import java.util.logging.Logger;
public class HistoricFacade<T extends Ruleset> extends HistoricDatapoints {
@@ -41,7 +42,7 @@ public class HistoricFacade<T extends Ruleset> extends HistoricDatapoints {
}
@Override
- public ValueDatapoint<?>[] getValueDataPoints(AttributeRef attributeRef, DatapointInterval interval, long fromTimestamp, long toTimestamp) {
+ public ValueDatapoint<?>[] getValueDataPoints(AttributeRef attributeRef, DatapointInterval interval, LocalDateTime fromTimestamp, LocalDateTime toTimestamp) {
return assetDatapointService.getValueDatapoints(attributeRef, interval, fromTimestamp, toTimestamp);
}
}
diff --git a/manager/src/main/java/org/openremote/manager/rules/facade/PredictedFacade.java b/manager/src/main/java/org/openremote/manager/rules/facade/PredictedFacade.java
index 37959f327..746b84486 100644
--- a/manager/src/main/java/org/openremote/manager/rules/facade/PredictedFacade.java
+++ b/manager/src/main/java/org/openremote/manager/rules/facade/PredictedFacade.java
@@ -27,6 +27,8 @@ import org.openremote.model.datapoint.ValueDatapoint;
import org.openremote.model.rules.PredictedDatapoints;
import org.openremote.model.rules.Ruleset;
+import java.time.LocalDateTime;
+
public class PredictedFacade<T extends Ruleset> extends PredictedDatapoints {
protected final RulesEngineId<T> rulesEngineId;
@@ -38,22 +40,22 @@ public class PredictedFacade<T extends Ruleset> extends PredictedDatapoints {
}
@Override
- public ValueDatapoint<?>[] getValueDatapoints(AttributeRef attributeRef, String truncate, String interval, long fromTimestamp, long toTimestamp) {
+ public ValueDatapoint<?>[] getValueDatapoints(AttributeRef attributeRef, String truncate, String interval, LocalDateTime fromTimestamp, LocalDateTime toTimestamp) {
return assetPredictedDatapointService.getValueDatapoints(attributeRef, truncate, interval, fromTimestamp, toTimestamp);
}
@Override
- public ValueDatapoint<?>[] getValueDatapoints(AttributeRef attributeRef, DatapointInterval interval, long fromTimestamp, long toTimestamp) {
+ public ValueDatapoint<?>[] getValueDatapoints(AttributeRef attributeRef, DatapointInterval interval, LocalDateTime fromTimestamp, LocalDateTime toTimestamp) {
return assetPredictedDatapointService.getValueDatapoints(attributeRef, interval, fromTimestamp, toTimestamp);
}
@Override
- public void updateValue(String assetId, String attributeName, Object value, long timestamp) {
+ public void updateValue(String assetId, String attributeName, Object value, LocalDateTime timestamp) {
assetPredictedDatapointService.updateValue(assetId, attributeName, value, timestamp);
}
@Override
- public void updateValue(AttributeRef attributeRef, Object value, long timestamp) {
+ public void updateValue(AttributeRef attributeRef, Object value, LocalDateTime timestamp) {
updateValue(attributeRef.getId(), attributeRef.getName(), value, timestamp);
}
}
diff --git a/manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java b/manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java
index f7d6766ea..ee0383bd0 100644
--- a/manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java
+++ b/manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java
@@ -225,7 +225,7 @@ public class ORConsoleGeofenceAssetAdapter extends RouteBuilder implements Geofe
if (assetStateLocationPredicates == null) {
// No geofences exist for this asset
- LOG.fine("Request for console '" + assetId + "' geofences: 0 found");
+ LOG.finer("Request for console '" + assetId + "' geofences: 0 found");
return new GeofenceDefinition[0];
}
@@ -235,7 +235,7 @@ public class ORConsoleGeofenceAssetAdapter extends RouteBuilder implements Geofe
locationPredicate))
.toArray(GeofenceDefinition[]::new);
- LOG.fine("Request for console '" + assetId + "' geofences: " + geofences.length + " found");
+ LOG.finer("Request for console '" + assetId + "' geofences: " + geofences.length + " found");
return geofences;
}
diff --git a/manager/src/main/java/org/openremote/manager/security/TenantResourceImpl.java b/manager/src/main/java/org/openremote/manager/security/TenantResourceImpl.java
index 54545f80a..0321652d3 100644
--- a/manager/src/main/java/org/openremote/manager/security/TenantResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/security/TenantResourceImpl.java
@@ -66,7 +66,7 @@ public class TenantResourceImpl extends ManagerWebResource implements TenantReso
if (tenant == null)
throw new WebApplicationException(NOT_FOUND);
if (!isTenantActiveAndAccessible(tenant)) {
- LOG.fine("Forbidden access for user '" + getUsername() + "': " + tenant);
+ LOG.info("Forbidden access for user '" + getUsername() + "': " + tenant);
throw new WebApplicationException(Response.Status.FORBIDDEN);
}
return tenant;
diff --git a/manager/src/main/java/org/openremote/manager/simulator/SimulatorService.java b/manager/src/main/java/org/openremote/manager/simulator/SimulatorService.java
index f5fadef77..b007a8452 100644
--- a/manager/src/main/java/org/openremote/manager/simulator/SimulatorService.java
+++ b/manager/src/main/java/org/openremote/manager/simulator/SimulatorService.java
@@ -101,7 +101,7 @@ public class SimulatorService extends RouteBuilder implements ContainerService {
.filter(body().isInstanceOf(RequestSimulatorState.class))
.process(exchange -> {
RequestSimulatorState event = exchange.getIn().getBody(RequestSimulatorState.class);
- LOG.fine("Handling from client: " + event);
+ LOG.finer("Handling from client: " + event);
String sessionKey = getSessionKey(exchange);
AuthContext authContext = exchange.getIn().getHeader(Constants.AUTH_CONTEXT, AuthContext.class);
@@ -116,7 +116,7 @@ public class SimulatorService extends RouteBuilder implements ContainerService {
}
protected void publishSimulatorState(String sessionKey, String agentId) {
- LOG.fine("Attempting to publish simulator state: Agent ID=" + agentId);
+ LOG.finer("Attempting to publish simulator state: Agent ID=" + agentId);
Protocol<?> protocol = agentService.getProtocolInstance(agentId);
diff --git a/manager/src/main/java/org/openremote/manager/syslog/SyslogService.java b/manager/src/main/java/org/openremote/manager/syslog/SyslogService.java
index 7c8ad79a7..0dcb3e428 100644
--- a/manager/src/main/java/org/openremote/manager/syslog/SyslogService.java
+++ b/manager/src/main/java/org/openremote/manager/syslog/SyslogService.java
@@ -278,7 +278,7 @@ public class SyslogService extends Handler implements ContainerService {
batch.clear();
if (transientEvents.size() == 0)
return;
- LOG.fine("Flushing syslog batch: " + transientEvents.size());
+ LOG.finer("Flushing syslog batch: " + transientEvents.size());
try {
persistenceService.doTransaction(em -> {
try {
diff --git a/manager/src/main/java/org/openremote/manager/web/ManagerFileServlet.java b/manager/src/main/java/org/openremote/manager/web/ManagerFileServlet.java
index fddbd49cd..c940ac3bc 100644
--- a/manager/src/main/java/org/openremote/manager/web/ManagerFileServlet.java
+++ b/manager/src/main/java/org/openremote/manager/web/ManagerFileServlet.java
@@ -122,7 +122,7 @@ public class ManagerFileServlet extends FileServlet {
String requestPath = exchange.getRequestPath();
Matcher staticMatcher = requestPattern.matcher(requestPath);
if (staticMatcher.matches()) {
- LOG.fine("Serving static resource: " + requestPath);
+ LOG.finer("Serving static resource: " + requestPath);
String remaining = staticMatcher.group(1);
String relativePath = remaining == null || remaining.length() == 0 ? "/" : remaining;
exchange.setRelativePath(relativePath);
diff --git a/manager/src/main/java/org/openremote/manager/web/ManagerWebService.java b/manager/src/main/java/org/openremote/manager/web/ManagerWebService.java
index 8d76dab3e..227eb6eee 100644
--- a/manager/src/main/java/org/openremote/manager/web/ManagerWebService.java
+++ b/manager/src/main/java/org/openremote/manager/web/ManagerWebService.java
@@ -171,7 +171,7 @@ public class ManagerWebService extends WebService {
"Default app redirect",
exchange -> exchange.getRequestPath().equals("/"),
exchange -> {
- LOG.fine("Handling root request, redirecting client to default app");
+ LOG.finer("Handling root request, redirecting client to default app");
new RedirectHandler(redirect(exchange, rootRedirectPath)).handleRequest(exchange);
}));
}
diff --git a/model/src/main/java/org/openremote/model/asset/impl/ElectricityChargerAsset.java b/model/src/main/java/org/openremote/model/asset/impl/ElectricityChargerAsset.java
index 911d68bfb..b541954f7 100644
--- a/model/src/main/java/org/openremote/model/asset/impl/ElectricityChargerAsset.java
+++ b/model/src/main/java/org/openremote/model/asset/impl/ElectricityChargerAsset.java
@@ -47,24 +47,7 @@ public class ElectricityChargerAsset extends ElectricityStorageAsset {
public static final AttributeDescriptor<Boolean> VEHICLE_CONNECTED = new AttributeDescriptor<>("vehicleConnected", ValueType.BOOLEAN,
new MetaItem<>(MetaItemType.READ_ONLY));
public static final AttributeDescriptor<String> VEHICLE_ID = new AttributeDescriptor<>("vehicleID", ValueType.TEXT,
- new MetaItem<>(MetaItemType.READ_ONLY, true)).withOptional(true);
-
- public static final AttributeDescriptor<Double> POWER_IMPORT_MIN = ElectricityAsset.POWER_IMPORT_MIN.withOptional(true);
- public static final AttributeDescriptor<Double> POWER_EXPORT_MIN = ElectricityAsset.POWER_EXPORT_MIN.withOptional(true);
- public static final AttributeDescriptor<Double> POWER_EXPORT_MAX = ElectricityAsset.POWER_EXPORT_MAX.withOptional(true);
- public static final AttributeDescriptor<Double> ENERGY_EXPORT_TOTAL = ElectricityAsset.ENERGY_EXPORT_TOTAL.withOptional(true);
- public static final AttributeDescriptor<Double> ENERGY_LEVEL = ElectricityStorageAsset.ENERGY_LEVEL.withOptional(true);
- public static final AttributeDescriptor<Double> ENERGY_CAPACITY = ElectricityStorageAsset.ENERGY_CAPACITY.withOptional(true);
- public static final AttributeDescriptor<Integer> ENERGY_LEVEL_PERCENTAGE = ElectricityStorageAsset.ENERGY_LEVEL_PERCENTAGE.withOptional(true);
- public static final AttributeDescriptor<Integer> ENERGY_LEVEL_PERCENTAGE_MAX = ElectricityStorageAsset.ENERGY_LEVEL_PERCENTAGE_MAX.withOptional(true);
- public static final AttributeDescriptor<Integer> ENERGY_LEVEL_PERCENTAGE_MIN = ElectricityStorageAsset.ENERGY_LEVEL_PERCENTAGE_MIN.withOptional(true);
- public static final AttributeDescriptor<Integer> EFFICIENCY_IMPORT = ElectricityAsset.EFFICIENCY_IMPORT.withOptional(true);
- public static final AttributeDescriptor<Integer> EFFICIENCY_EXPORT = ElectricityAsset.EFFICIENCY_EXPORT.withOptional(true);
- public static final AttributeDescriptor<Double> TARIFF_IMPORT = ElectricitySupplierAsset.TARIFF_IMPORT.withOptional(true);
- public static final AttributeDescriptor<Double> TARIFF_EXPORT = ElectricitySupplierAsset.TARIFF_EXPORT.withOptional(true);
- public static final AttributeDescriptor<Double> CARBON_IMPORT = ElectricitySupplierAsset.CARBON_IMPORT.withOptional(true);
- public static final AttributeDescriptor<Integer> CARBON_IMPORT_TOTAL = ElectricitySupplierAsset.CARBON_IMPORT_TOTAL.withOptional(true);
- public static final AttributeDescriptor<Integer> CARBON_EXPORT_TOTAL = ElectricitySupplierAsset.CARBON_EXPORT_TOTAL.withOptional(true);
+ new MetaItem<>(MetaItemType.READ_ONLY, true));
public static final AssetDescriptor<ElectricityChargerAsset> DESCRIPTOR = new AssetDescriptor<>("ev-station", "8A293D", ElectricityChargerAsset.class);
diff --git a/model/src/main/java/org/openremote/model/asset/impl/ElectricityStorageAsset.java b/model/src/main/java/org/openremote/model/asset/impl/ElectricityStorageAsset.java
index a2a8a346c..f7fdfc243 100644
--- a/model/src/main/java/org/openremote/model/asset/impl/ElectricityStorageAsset.java
+++ b/model/src/main/java/org/openremote/model/asset/impl/ElectricityStorageAsset.java
@@ -49,6 +49,7 @@ public abstract class ElectricityStorageAsset extends ElectricityAsset<Electrici
public static final AttributeDescriptor<Integer[][]> ENERGY_LEVEL_SCHEDULE = new AttributeDescriptor<>("energyLevelSchedule", ValueType.POSITIVE_INTEGER.asArray().asArray())
.withOptional(true);
+ public static final AttributeDescriptor<Double> POWER_SETPOINT = ElectricityAsset.POWER_SETPOINT.withOptional(false);
public static final AttributeDescriptor<Double> POWER_IMPORT_MIN = ElectricityAsset.POWER_IMPORT_MIN.withOptional(true);
public static final AttributeDescriptor<Double> POWER_EXPORT_MIN = ElectricityAsset.POWER_EXPORT_MIN.withOptional(true);
public static final AttributeDescriptor<Double> CARBON_IMPORT = ElectricitySupplierAsset.CARBON_IMPORT.withOptional(true);
diff --git a/model/src/main/java/org/openremote/model/asset/impl/ElectricitySupplierAsset.java b/model/src/main/java/org/openremote/model/asset/impl/ElectricitySupplierAsset.java
index 314b1147c..547883cda 100644
--- a/model/src/main/java/org/openremote/model/asset/impl/ElectricitySupplierAsset.java
+++ b/model/src/main/java/org/openremote/model/asset/impl/ElectricitySupplierAsset.java
@@ -51,6 +51,7 @@ public class ElectricitySupplierAsset extends ElectricityAsset<ElectricitySuppli
public static final AttributeDescriptor<Integer> EFFICIENCY_IMPORT = ElectricityAsset.EFFICIENCY_IMPORT.withOptional(true);
public static final AttributeDescriptor<Integer> EFFICIENCY_EXPORT = ElectricityAsset.EFFICIENCY_EXPORT.withOptional(true);
public static final AttributeDescriptor<Double> TARIFF_IMPORT = ElectricityAsset.TARIFF_IMPORT.withOptional(false);
+ public static final AttributeDescriptor<Double> TARIFF_EXPORT = ElectricityAsset.TARIFF_EXPORT.withOptional(false);
public static final AssetDescriptor<ElectricitySupplierAsset> DESCRIPTOR = new AssetDescriptor<>("upload-network", "9257A9", ElectricitySupplierAsset.class);
public static final AttributeDescriptor<Double> CARBON_IMPORT = new AttributeDescriptor<>("carbonImport", ValueType.NUMBER)
diff --git a/model/src/main/java/org/openremote/model/event/bus/EventBus.java b/model/src/main/java/org/openremote/model/event/bus/EventBus.java
index a3d1e3fb2..b0946c9b3 100644
--- a/model/src/main/java/org/openremote/model/event/bus/EventBus.java
+++ b/model/src/main/java/org/openremote/model/event/bus/EventBus.java
@@ -123,7 +123,7 @@ public class EventBus {
}
}
} else if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("Dropping vetoed event: " + event);
+ LOG.finer("Dropping vetoed event: " + event);
}
}
}
diff --git a/model/src/main/java/org/openremote/model/protocol/ProtocolUtil.java b/model/src/main/java/org/openremote/model/protocol/ProtocolUtil.java
index 0a90118ec..8f8964cd6 100644
--- a/model/src/main/java/org/openremote/model/protocol/ProtocolUtil.java
+++ b/model/src/main/java/org/openremote/model/protocol/ProtocolUtil.java
@@ -105,7 +105,7 @@ public final class ProtocolUtil {
// value conversion
Object finalValue = value;
ignoreAndConvertedValue = agentLink.getWriteValueConverter().map(converter -> {
- Protocol.LOG.fine("Applying attribute write value converter to attribute: assetId=" + assetId + ", attribute=" + attribute.getName());
+ Protocol.LOG.finer("Applying attribute write value converter to attribute: assetId=" + assetId + ", attribute=" + attribute.getName());
return applyValueConverter(finalValue, converter);
}).orElse(new Pair<>(false, finalValue));
@@ -146,7 +146,7 @@ public final class ProtocolUtil {
// value filtering
agentLink.getValueFilters().ifPresent(valueFilters -> {
- Protocol.LOG.fine("Applying attribute value filters to attribute: assetId=" + assetId + ", attribute=" + attribute.getName());
+ Protocol.LOG.finer("Applying attribute value filters to attribute: assetId=" + assetId + ", attribute=" + attribute.getName());
Object o = Values.applyValueFilters(value, valueFilters);
if (o == null) {
Protocol.LOG.info("Value filters generated a null value for attribute: assetId=" + assetId + ", attribute=" + attribute.getName());
@@ -156,7 +156,7 @@ public final class ProtocolUtil {
// value conversion
ignoreAndConvertedValue = agentLink.getValueConverter().map(converter -> {
- Protocol.LOG.fine("Applying attribute value converter to attribute: assetId=" + assetId + ", attribute=" + attribute.getName());
+ Protocol.LOG.finer("Applying attribute value converter to attribute: assetId=" + assetId + ", attribute=" + attribute.getName());
return applyValueConverter(valRef.get(), converter);
}).orElse(new Pair<>(false, valRef.get()));
@@ -173,7 +173,7 @@ public final class ProtocolUtil {
Class<?> fromType = valRef.get().getClass();
if (toType != fromType) {
- Protocol.LOG.fine("Applying built in attribute value conversion: " + fromType + " -> " + toType);
+ Protocol.LOG.finer("Applying built in attribute value conversion: " + fromType + " -> " + toType);
valRef.set(Values.getValueCoerced(valRef.get(), toType).orElse(null));
if (valRef.get() == null) {
diff --git a/model/src/main/java/org/openremote/model/rules/HistoricDatapoints.java b/model/src/main/java/org/openremote/model/rules/HistoricDatapoints.java
index 70f8d55c1..473c6897b 100644
--- a/model/src/main/java/org/openremote/model/rules/HistoricDatapoints.java
+++ b/model/src/main/java/org/openremote/model/rules/HistoricDatapoints.java
@@ -24,6 +24,8 @@ import org.openremote.model.datapoint.DatapointInterval;
import org.openremote.model.datapoint.ValueDatapoint;
import org.openremote.model.util.TsIgnore;
+import java.time.LocalDateTime;
+
/**
* Facade for historic data points in rules
*/
@@ -32,6 +34,6 @@ public abstract class HistoricDatapoints {
public abstract ValueDatapoint<?>[] getValueDataPoints(AttributeRef attributeRef,
DatapointInterval interval,
- long fromTimestamp,
- long toTimestamp);
+ LocalDateTime fromTimestamp,
+ LocalDateTime toTimestamp);
}
diff --git a/model/src/main/java/org/openremote/model/rules/PredictedDatapoints.java b/model/src/main/java/org/openremote/model/rules/PredictedDatapoints.java
index c0a3f1796..d31412a31 100644
--- a/model/src/main/java/org/openremote/model/rules/PredictedDatapoints.java
+++ b/model/src/main/java/org/openremote/model/rules/PredictedDatapoints.java
@@ -24,6 +24,9 @@ import org.openremote.model.datapoint.DatapointInterval;
import org.openremote.model.datapoint.ValueDatapoint;
import org.openremote.model.util.TsIgnore;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
/**
* Facade for predicted datapoints in rules
*/
@@ -34,15 +37,15 @@ public abstract class PredictedDatapoints {
public abstract ValueDatapoint<?>[] getValueDatapoints(AttributeRef attributeRef,
String truncate,
String interval,
- long fromTimestamp,
- long toTimestamp);
+ LocalDateTime fromTimestamp,
+ LocalDateTime toTimestamp);
public abstract ValueDatapoint<?>[] getValueDatapoints(AttributeRef attributeRef,
DatapointInterval interval,
- long fromTimestamp,
- long toTimestamp);
+ LocalDateTime fromTimestamp,
+ LocalDateTime toTimestamp);
- public abstract void updateValue(String assetId, String attributeName, Object value, long timestamp);
- public abstract void updateValue(AttributeRef attributeRef, Object value, long timestamp);
+ public abstract void updateValue(String assetId, String attributeName, Object value, LocalDateTime timestamp);
+ public abstract void updateValue(AttributeRef attributeRef, Object value, LocalDateTime timestamp);
}
diff --git a/test/src/main/groovy/org/openremote/test/setup/ManagerTestSetup.java b/test/src/main/groovy/org/openremote/test/setup/ManagerTestSetup.java
index f7b503ef3..436262c3e 100644
--- a/test/src/main/groovy/org/openremote/test/setup/ManagerTestSetup.java
+++ b/test/src/main/groovy/org/openremote/test/setup/ManagerTestSetup.java
@@ -34,6 +34,7 @@ import org.openremote.model.attribute.Attribute;
import org.openremote.model.attribute.MetaItem;
import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.security.Tenant;
+import org.openremote.model.value.MetaItemType;
import org.openremote.model.value.ValueConstraint;
import org.openremote.model.value.ValueType;
import org.openremote.model.value.Values;
@@ -219,23 +220,36 @@ public class ManagerTestSetup extends ManagerSetup {
ElectricityConsumerAsset electricityConsumerAsset = new ElectricityConsumerAsset("Consumer");
electricityConsumerAsset.setParent(electricityOptimisationAsset);
+ electricityConsumerAsset.getAttribute(ElectricityAsset.POWER).ifPresent(attr ->
+ attr.addMeta(new MetaItem<>(HAS_PREDICTED_DATA_POINTS))
+ );
electricityConsumerAsset = assetStorageService.merge(electricityConsumerAsset);
electricityConsumerAssetId = electricityConsumerAsset.getId();
ElectricityProducerSolarAsset electricitySolarAsset = new ElectricityProducerSolarAsset("Producer");
electricitySolarAsset.setParent(electricityOptimisationAsset);
+ electricitySolarAsset.getAttribute(ElectricityAsset.POWER).ifPresent(attr ->
+ attr.addMeta(new MetaItem<>(HAS_PREDICTED_DATA_POINTS))
+ );
electricitySolarAsset = assetStorageService.merge(electricitySolarAsset);
electricitySolarAssetId = electricitySolarAsset.getId();
ElectricityBatteryAsset electricityBatteryAsset = new ElectricityBatteryAsset("Battery");
electricityBatteryAsset.setParent(electricityOptimisationAsset);
- electricityBatteryAsset.setEnergyCapacity(100d);
- electricityBatteryAsset.setPowerImportMax(25d);
- electricityBatteryAsset.setPowerExportMax(25d);
+ electricityBatteryAsset.setEnergyCapacity(200d);
+ electricityBatteryAsset.setEnergyLevelPercentageMin(20);
+ electricityBatteryAsset.setEnergyLevelPercentageMax(80);
+ electricityBatteryAsset.setEnergyLevel(100d);
+ electricityBatteryAsset.setPowerImportMax(7d);
+ electricityBatteryAsset.setPowerExportMax(20d);
+ electricityBatteryAsset.setPowerSetpoint(0d);
electricityBatteryAsset.setEfficiencyImport(95);
electricityBatteryAsset.setEfficiencyExport(98);
electricityBatteryAsset.setSupportsExport(true);
electricityBatteryAsset.setSupportsImport(true);
+ electricityBatteryAsset.getAttribute(ElectricityAsset.POWER_SETPOINT).ifPresent(attr ->
+ attr.addMeta(new MetaItem<>(HAS_PREDICTED_DATA_POINTS))
+ );
electricityBatteryAsset = assetStorageService.merge(electricityBatteryAsset);
electricityBatteryAssetId = electricityBatteryAsset.getId();
@@ -243,6 +257,12 @@ public class ManagerTestSetup extends ManagerSetup {
electricitySupplierAsset.setParent(electricityOptimisationAsset);
electricitySupplierAsset.setTariffExport(-0.05);
electricitySupplierAsset.setTariffImport(0.08);
+ electricitySupplierAsset.getAttribute(ElectricityAsset.TARIFF_IMPORT).ifPresent(attr ->
+ attr.addMeta(new MetaItem<>(HAS_PREDICTED_DATA_POINTS))
+ );
+ electricitySupplierAsset.getAttribute(ElectricityAsset.TARIFF_EXPORT).ifPresent(attr ->
+ attr.addMeta(new MetaItem<>(HAS_PREDICTED_DATA_POINTS))
+ );
electricitySupplierAsset = assetStorageService.merge(electricitySupplierAsset);
electricitySupplierAssetId = electricitySupplierAsset.getId();
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy
index 9db05416d..340081fd5 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy
@@ -15,6 +15,9 @@ import spock.lang.Specification
import spock.util.concurrent.PollingConditions
import java.time.Instant
+import java.time.LocalDateTime
+import java.time.ZoneId
+import java.time.temporal.ChronoUnit
import java.util.concurrent.TimeUnit
import static java.util.concurrent.TimeUnit.DAYS
@@ -129,8 +132,8 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
thing.getId(),
thing.getAttribute("light1PowerConsumption").orElseThrow({ new RuntimeException("Missing attribute") }),
DatapointInterval.MINUTE,
- getClockTimeOf(container),
- getClockTimeOf(container) + 3600000
+ LocalDateTime.ofInstant(Instant.ofEpochMilli(getClockTimeOf(container)), ZoneId.systemDefault()),
+ LocalDateTime.ofInstant(Instant.ofEpochMilli(getClockTimeOf(container)), ZoneId.systemDefault()).plus(1, ChronoUnit.HOURS)
)
assert aggregatedDatapoints.size() == 61
}
@@ -194,8 +197,8 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
thing.getId(),
thing.getAttribute(thingLightToggleAttributeName).orElseThrow({ new RuntimeException("Missing attribute") }),
DatapointInterval.MINUTE,
- getClockTimeOf(container),
- getClockTimeOf(container) + 3600000
+ LocalDateTime.ofInstant(Instant.ofEpochMilli(getClockTimeOf(container)), ZoneId.systemDefault()),
+ LocalDateTime.ofInstant(Instant.ofEpochMilli(getClockTimeOf(container)), ZoneId.systemDefault()).plus(1, ChronoUnit.HOURS)
)
assert aggregatedDatapoints.size() == 61
}
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
index cbfa444b4..6fdbdcf3f 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
@@ -981,9 +981,8 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
def "DateTime queries"() {
when: "the lobby has an opening date and the date falls is between the filtering date"
def lobby = assetStorageService.find(managerTestSetup.lobbyId, true)
-
lobby.addAttributes(
- new Attribute<>("openingDate", TIMESTAMP_ISO8601, "2018-01-28T15:00:00+00:00")
+ new Attribute<>("openingDate", TIMESTAMP_ISO8601, ZonedDateTime.ofInstant(Instant.ofEpochMilli(1517151600000), ZoneOffset.UTC).format(ISO_ZONED_DATE_TIME)) // 28/01/2018 @ 2:00pm (UTC)
)
lobby = assetStorageService.merge(lobby)