Skip to content

armgit / core

Public Imported from GitHub
0

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

HttpClientProtocol enhancement (added polling attribute), general protocol enhancements (value converter and write value converter), breaking change meta item URN changes

Rich Turner10e498f6f105
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 63bc6d018..07e1f1c03 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java
@@ -21,7 +21,7 @@ package org.openremote.agent.protocol;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
-import org.openremote.model.value.ValueFilter;
+import org.openremote.model.value.*;
import org.openremote.container.Container;
import org.openremote.container.ContainerService;
import org.openremote.container.concurrent.GlobalLock;
@@ -38,9 +38,6 @@ import org.openremote.model.asset.agent.ConnectionStatus;
import org.openremote.model.asset.agent.ProtocolConfiguration;
import org.openremote.model.asset.agent.ProtocolDescriptor;
import org.openremote.model.attribute.*;
-import org.openremote.model.value.Value;
-import org.openremote.model.value.ValueType;
-import org.openremote.model.value.Values;
import java.util.*;
import java.util.concurrent.TimeUnit;
@@ -111,7 +108,6 @@ public abstract class AbstractProtocol implements Protocol {
public static final int PRIORITY = ContainerService.DEFAULT_PRIORITY - 100;
protected final Map<AttributeRef, AssetAttribute> linkedAttributes = new HashMap<>();
protected final Map<AttributeRef, LinkedProtocolInfo> linkedProtocolConfigurations = new HashMap<>();
- protected final Map<AttributeRef, ValueFilter[]> linkedAttributeFilters = new HashMap<>();
protected MessageBrokerContext messageBrokerContext;
protected ProducerTemplate producerTemplate;
protected TimerService timerService;
@@ -210,17 +206,11 @@ public abstract class AbstractProtocol implements Protocol {
// linking process and without entry in the map any update would be blocked
linkedAttributes.put(attributeRef, attribute);
- Optional<ValueFilter[]> messageFilters = Protocol.getLinkedAttributeMessageFilters(attribute);
- messageFilters.ifPresent(mFilters -> {
- linkedAttributeFilters.put(attributeRef, mFilters);
- });
-
try {
doLinkAttribute(attribute, protocolConfiguration);
} catch (Exception e) {
LOG.log(Level.SEVERE, "Failed to link attribute to protocol: " + attribute, e);
linkedAttributes.remove(attributeRef);
- linkedAttributeFilters.remove(attributeRef);
}
});
});
@@ -233,7 +223,6 @@ public abstract class AbstractProtocol implements Protocol {
LOG.fine("Unlinking attribute on '" + getProtocolName() + "': " + attribute);
AttributeRef attributeRef = attribute.getReferenceOrThrow();
linkedAttributes.remove(attributeRef);
- linkedAttributeFilters.remove(attributeRef);
doUnlinkAttribute(attribute, protocolConfiguration);
})
);
@@ -270,6 +259,28 @@ public abstract class AbstractProtocol implements Protocol {
if (attribute == null) {
LOG.warning("Attribute doesn't exist on this protocol: " + event.getAttributeRef());
} else {
+
+ // Do outbound value conversion
+ ObjectValue converter = Values.getMetaItemValueOrThrow(
+ attribute,
+ META_ATTRIBUTE_WRITE_VALUE_CONVERTER,
+ false,
+ false)
+ .flatMap(Values::getObject)
+ .orElse(null);
+
+ if (converter != null) {
+ LOG.fine("Applying attribute value converter to attribute write: " + event.getAttributeRef());
+
+ ConvertedValue convertedValue = assetService.applyValueConverter(event.getValue().orElse(null), converter);
+
+ if (convertedValue.isIgnore()) {
+ LOG.info("Value converter returned '" + ConvertedValue.IGNORE + "' so ignoring attribute value");
+ return;
+ }
+ event.getAttributeState().setValue(convertedValue.getValue());
+ }
+
AssetAttribute protocolConfiguration = getLinkedProtocolConfiguration(attribute);
processLinkedAttributeWrite(event, protocolConfiguration);
}
@@ -318,13 +329,33 @@ public abstract class AbstractProtocol implements Protocol {
if (state.getValue().isPresent()) {
Value value = state.getValue().get();
- ValueFilter[] filters = linkedAttributeFilters.get(state.getAttributeRef());
+ ValueFilter[] filters = Protocol.getLinkedAttributeValueFilters(attribute).orElse(null);
if (filters != null) {
value = assetService.applyValueFilters(value, filters);
}
- // Do basic value conversion
+ ObjectValue converter = Values.getMetaItemValueOrThrow(
+ attribute,
+ META_ATTRIBUTE_VALUE_CONVERTER,
+ false,
+ false)
+ .flatMap(Values::getObject)
+ .orElse(null);
+
+ if (converter != null) {
+ LOG.fine("Applying attribute value converter to attribute: " + state.getAttributeRef());
+
+ ConvertedValue convertedValue = assetService.applyValueConverter(value, converter);
+
+ if (convertedValue.isIgnore()) {
+ LOG.info("Value converter returned '" + ConvertedValue.IGNORE + "' so ignoring attribute value");
+ return;
+ }
+ value = convertedValue.getValue();
+ }
+
+ // Do built in value conversion
Optional<ValueType> attributeValueType = attribute.getType().map(AttributeValueDescriptor::getValueType);
if (value != null && attributeValueType.isPresent()) {
@@ -407,10 +438,28 @@ public abstract class AbstractProtocol implements Protocol {
this instanceof ProtocolLinkedAttributeImport,
getProtocolConfigurationTemplate(),
getProtocolConfigurationMetaItemDescriptors(),
- getLinkedAttributeMetaItemDescriptors()
+ buildLinkedAttributeMetaItemDescriptors()
);
}
+ protected List<MetaItemDescriptor> buildLinkedAttributeMetaItemDescriptors() {
+ List<MetaItemDescriptor> descriptors = getLinkedAttributeMetaItemDescriptors();
+ descriptors = descriptors != null ? new ArrayList<>(descriptors) : new ArrayList<>();
+
+ // Add standard meta item descriptors that all protocols support
+ if (descriptors.stream().noneMatch(d -> d.getUrn().equalsIgnoreCase(META_ATTRIBUTE_VALUE_FILTERS.getUrn()))) {
+ descriptors.add(META_ATTRIBUTE_VALUE_FILTERS);
+ }
+ if (descriptors.stream().noneMatch(d -> d.getUrn().equalsIgnoreCase(META_ATTRIBUTE_VALUE_CONVERTER.getUrn()))) {
+ descriptors.add(META_ATTRIBUTE_VALUE_CONVERTER);
+ }
+ if (descriptors.stream().noneMatch(d -> d.getUrn().equalsIgnoreCase(META_ATTRIBUTE_WRITE_VALUE_CONVERTER.getUrn()))) {
+ descriptors.add(META_ATTRIBUTE_WRITE_VALUE_CONVERTER);
+ }
+
+ return descriptors;
+ }
+
@Override
public AssetAttribute getProtocolConfigurationTemplate() {
return ProtocolConfiguration.initProtocolConfiguration(new AssetAttribute("protocolConfig"), getProtocolName());
@@ -451,9 +500,7 @@ public abstract class AbstractProtocol implements Protocol {
* Get list of {@link MetaItemDescriptor}s that describe the {@link MetaItem}s a {@link ProtocolConfiguration} for this
* protocol supports
*/
- protected List<MetaItemDescriptor> getProtocolConfigurationMetaItemDescriptors() {
- return Collections.emptyList();
- }
+ protected abstract List<MetaItemDescriptor> getProtocolConfigurationMetaItemDescriptors();
/**
* Get list of {@link MetaItemDescriptor}s that describe the {@link MetaItem}s an {@link Attribute} linked to this
diff --git a/agent/src/main/java/org/openremote/agent/protocol/Protocol.java b/agent/src/main/java/org/openremote/agent/protocol/Protocol.java
index c85020629..82d0fd82e 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/Protocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/Protocol.java
@@ -22,8 +22,6 @@ package org.openremote.agent.protocol;
import org.apache.commons.codec.binary.BinaryCodec;
import org.apache.commons.codec.binary.Hex;
import org.openremote.agent.protocol.http.OAuthGrant;
-import org.openremote.agent.protocol.websocket.WebsocketClientProtocol;
-import org.openremote.model.value.*;
import org.openremote.container.Container;
import org.openremote.container.ContainerService;
import org.openremote.model.AbstractValueHolder;
@@ -35,6 +33,7 @@ import org.openremote.model.asset.agent.ProtocolConfiguration;
import org.openremote.model.asset.agent.ProtocolDescriptor;
import org.openremote.model.attribute.*;
import org.openremote.model.util.TextUtil;
+import org.openremote.model.value.*;
import java.io.IOException;
import java.nio.charset.Charset;
@@ -44,11 +43,9 @@ import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
-import static org.openremote.agent.protocol.http.HttpClientProtocol.PROTOCOL_NAME;
import static org.openremote.model.Constants.PROTOCOL_NAMESPACE;
import static org.openremote.model.attribute.MetaItemDescriptor.Access.ACCESS_PRIVATE;
import static org.openremote.model.attribute.MetaItemDescriptorImpl.*;
-import static org.openremote.model.attribute.MetaItemDescriptorImpl.metaItemString;
import static org.openremote.model.util.TextUtil.REGEXP_PATTERN_STRING_NON_EMPTY;
/**
@@ -96,7 +93,7 @@ import static org.openremote.model.util.TextUtil.REGEXP_PATTERN_STRING_NON_EMPTY
* receive and send value change messages with values of that type.
* <p>
* Generic protocols should implement support for filtering state messages from devices (or services) before the
- * protocol updates the linked attribute, to implement this protocols should use the {@link MetaItemType#VALUE_FILTERS}
+ * protocol updates the linked attribute, to implement this protocols should use the {@link #META_ATTRIBUTE_VALUE_FILTERS}
* {@link MetaItem}.
* <p>
* <h1>Dynamic value injection</h1>
@@ -205,6 +202,41 @@ public interface Protocol extends ContainerService {
REGEXP_PATTERN_STRING_NON_EMPTY,
PatternFailure.STRING_EMPTY);
+ /**
+ * Defines {@link ValueFilter}s to apply to values before they are sent through the system (e.g. before it is used
+ * to update a protocol linked attribute); this is particularly useful for generic protocols.
+ * The {@link MetaItem} value should be an {@link ArrayValue} of {@link ObjectValue}s
+ * where each {@link ObjectValue} represents a serialised {@link ValueFilter}. The message should pass through the
+ * filters in array order.
+ */
+ MetaItemDescriptor META_ATTRIBUTE_VALUE_FILTERS = metaItemArray(
+ PROTOCOL_NAMESPACE + ":valueFilters",
+ ACCESS_PRIVATE,
+ false,
+ null);
+
+ /**
+ * Defines a value converter map to allow for basic value type conversion; the incoming value will be converted
+ * to JSON and if this string matches a key in the converter then the value of that key will be pushed through to
+ * the attribute. An example use case is an API that returns "ACTIVE"/"DISABLED" strings but you want to connect
+ * this to a {@link AttributeValueType#BOOLEAN} attribute.
+ */
+ MetaItemDescriptor META_ATTRIBUTE_VALUE_CONVERTER = metaItemObject(
+ PROTOCOL_NAMESPACE + ":valueConverter",
+ ACCESS_PRIVATE,
+ false,
+ null);
+
+ /**
+ * Similar to {@link #META_ATTRIBUTE_VALUE_CONVERTER} but will applied to outgoing values allowing for the opposite
+ * conversion.
+ */
+ MetaItemDescriptor META_ATTRIBUTE_WRITE_VALUE_CONVERTER = metaItemObject(
+ PROTOCOL_NAMESPACE + ":writeValueConverter",
+ ACCESS_PRIVATE,
+ false,
+ null);
+
/**
* Value to be used for attribute writes, protocols that support this should also support dynamic value insertion,
* see interface javadoc for more details; use the {@link #createDynamicAttributeWriteConsumer} helper method where
@@ -308,12 +340,12 @@ public interface Protocol extends ContainerService {
/**
* Extract the {@link ValueFilter}s from the specified {@link Attribute}
*/
- static Optional<ValueFilter[]> getLinkedAttributeMessageFilters(Attribute attribute) {
+ static Optional<ValueFilter[]> getLinkedAttributeValueFilters(Attribute attribute) {
if (attribute == null) {
return Optional.empty();
}
- Optional<ArrayValue> arrayValueOptional = attribute.getMetaItem(MetaItemType.VALUE_FILTERS)
+ Optional<ArrayValue> arrayValueOptional = attribute.getMetaItem(Protocol.META_ATTRIBUTE_VALUE_FILTERS)
.flatMap(AbstractValueHolder::getValueAsArray);
if (!arrayValueOptional.isPresent()) {
diff --git a/agent/src/main/java/org/openremote/agent/protocol/ProtocolAssetService.java b/agent/src/main/java/org/openremote/agent/protocol/ProtocolAssetService.java
index d4be2c5d1..0de55ccbd 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/ProtocolAssetService.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/ProtocolAssetService.java
@@ -23,9 +23,12 @@ import org.openremote.container.ContainerService;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
import org.openremote.model.attribute.AttributeEvent;
+import org.openremote.model.value.ConvertedValue;
+import org.openremote.model.value.ObjectValue;
import org.openremote.model.value.Value;
import org.openremote.model.value.ValueFilter;
+import java.util.Optional;
import java.util.function.Predicate;
/**
@@ -147,4 +150,9 @@ public interface ProtocolAssetService extends ContainerService {
* Apply the specified set of {@link ValueFilter}s to the specified {@link Value}
*/
Value applyValueFilters(Value value, ValueFilter... filters);
+
+ /**
+ * Apply the specified value converter map to the specified value
+ */
+ ConvertedValue applyValueConverter(Value value, ObjectValue converter);
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
index 7562a2f24..b57717ccb 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
@@ -60,7 +60,6 @@ import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
-import static org.openremote.agent.protocol.http.WebTargetBuilder.createClient;
import static org.openremote.container.concurrent.GlobalLock.withLock;
import static org.openremote.model.Constants.PROTOCOL_NAMESPACE;
import static org.openremote.model.attribute.MetaItemDescriptor.Access.ACCESS_PRIVATE;
@@ -90,13 +89,13 @@ import static org.openremote.model.util.TextUtil.REGEXP_PATTERN_STRING_NON_EMPTY
* the response received from this endpoint</b>)</li> <li>{@link #META_QUERY_PARAMETERS}</li>
* <li>{@link #META_FAILURE_CODES}</li>
* <li>{@link #META_HEADERS}</li>
- * <li>{@link MetaItemType#VALUE_FILTERS}</li>
+ * <li>{@link Protocol#META_ATTRIBUTE_VALUE_FILTERS}</li>
* </ul>
* <p>
* <h1>Response filtering</h1>
* <p>
* Any {@link Attribute} whose value is to be set by the HTTP server response (i.e. it has an {@link
- * #META_POLLING_MILLIS} {@link MetaItem}) can use the standard {@link MetaItemType#VALUE_FILTERS} in
+ * #META_POLLING_MILLIS} {@link MetaItem}) can use the standard {@link Protocol#META_ATTRIBUTE_VALUE_FILTERS} in
* order to filter the received HTTP response.
* <p>
* <h1>Connection Status</h1>
@@ -474,6 +473,18 @@ public class HttpClientProtocol extends AbstractProtocol {
REGEXP_PATTERN_STRING_NON_EMPTY,
MetaItemDescriptor.PatternFailure.STRING_EMPTY);
+ /**
+ * Allows the incoming value to come from another attribute within the same asset; this allows for a polling
+ * attribute to be created that retrieves all data in a single request and this data can then be consumed
+ * by many attributes which minimises the number of requests sent to the server.
+ */
+ public static final MetaItemDescriptor META_ATTRIBUTE_POLLING_ATTRIBUTE = metaItemString(
+ PROTOCOL_NAME + ":pollingAttribute",
+ ACCESS_PRIVATE,
+ false,
+ REGEXP_PATTERN_STRING_NON_EMPTY,
+ MetaItemDescriptor.PatternFailure.STRING_EMPTY);
+
/*--------------- META ITEMS TO BE USED ON PROTOCOL CONFIGURATIONS OR LINKED ATTRIBUTES ---------------*/
/**
* HTTP response codes that will automatically disable the {@link ProtocolConfiguration} and in the process
@@ -530,6 +541,7 @@ public class HttpClientProtocol extends AbstractProtocol {
META_ATTRIBUTE_METHOD,
META_ATTRIBUTE_WRITE_VALUE,
META_ATTRIBUTE_CONTENT_TYPE,
+ META_ATTRIBUTE_POLLING_ATTRIBUTE,
META_HEADERS,
META_POLLING_MILLIS,
META_QUERY_PARAMETERS,
@@ -557,6 +569,7 @@ public class HttpClientProtocol extends AbstractProtocol {
protected final Map<AttributeRef, Pair<ResteasyWebTarget, List<Integer>>> clientMap = new HashMap<>();
protected final Map<AttributeRef, HttpClientRequest> requestMap = new HashMap<>();
protected final Map<AttributeRef, ScheduledFuture> pollingMap = new HashMap<>();
+ protected final Map<AttributeRef, Set<AttributeRef>> pollingLinkedAttributeMap = new HashMap<>();
protected ResteasyClient client;
public static Optional<Pair<StringValue, StringValue>> getUsernameAndPassword(AssetAttribute attribute) throws IllegalArgumentException {
@@ -820,6 +833,8 @@ public class HttpClientProtocol extends AbstractProtocol {
@Override
protected void doLinkAttribute(AssetAttribute attribute, AssetAttribute protocolConfiguration) {
+ AttributeRef attributeRef = attribute.getReferenceOrThrow();
+
String method = Values.getMetaItemValueOrThrow(
attribute,
META_ATTRIBUTE_METHOD,
@@ -898,7 +913,27 @@ public class HttpClientProtocol extends AbstractProtocol {
.flatMap(Values::getBoolean)
.orElse(false);
- final AttributeRef attributeRef = attribute.getReferenceOrThrow();
+ String pollingAttribute = Values.getMetaItemValueOrThrow(
+ attribute,
+ META_ATTRIBUTE_POLLING_ATTRIBUTE,
+ false,
+ true)
+ .flatMap(Values::getString)
+ .orElse(null);
+
+ if (!TextUtil.isNullOrEmpty(pollingAttribute)) {
+ synchronized (pollingLinkedAttributeMap) {
+ AttributeRef pollingSourceRef = new AttributeRef(attributeRef.getEntityId(), pollingAttribute);
+ pollingLinkedAttributeMap.compute(pollingSourceRef, (ref, links) -> {
+ if (links == null) {
+ links = new HashSet<>();
+ }
+ links.add(attributeRef);
+
+ return links;
+ });
+ }
+ }
addHttpClientRequest(protocolConfiguration,
attributeRef,
@@ -978,6 +1013,21 @@ public class HttpClientProtocol extends AbstractProtocol {
AttributeRef attributeRef = attribute.getReferenceOrThrow();
requestMap.remove(attributeRef);
cancelPolling(attributeRef);
+
+ String pollingAttribute = Values.getMetaItemValueOrThrow(
+ attribute,
+ META_ATTRIBUTE_POLLING_ATTRIBUTE,
+ false,
+ true)
+ .flatMap(Values::getString)
+ .orElse(null);
+
+ if (!TextUtil.isNullOrEmpty(pollingAttribute)) {
+ synchronized (pollingLinkedAttributeMap) {
+ pollingLinkedAttributeMap.remove(attributeRef);
+ pollingLinkedAttributeMap.values().forEach(links -> links.remove(attributeRef));
+ }
+ }
}
@Override
@@ -1162,6 +1212,15 @@ public class HttpClientProtocol extends AbstractProtocol {
if (attributeRef != null) {
updateLinkedAttribute(new AttributeState(attributeRef, value));
+
+ // Look for any attributes that also want to use this polling response
+ synchronized (pollingLinkedAttributeMap) {
+ Set<AttributeRef> linkedRefs = pollingLinkedAttributeMap.get(attributeRef);
+ if (linkedRefs != null) {
+ Value finalValue = value;
+ linkedRefs.forEach(ref -> updateLinkedAttribute(new AttributeState(ref, finalValue)));
+ }
+ }
}
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/udp/UdpClientProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/udp/UdpClientProtocol.java
index edc7c6d34..e96b6a019 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/udp/UdpClientProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/udp/UdpClientProtocol.java
@@ -62,8 +62,8 @@ import static org.openremote.model.syslog.SyslogCategory.PROTOCOL;
* <h1>Protocol -> Attribute</h1>
* <p>
* When a new value comes from the protocol destined for a linked {@link Attribute} the actual value written to the
- * attribute can be filtered in the standard way using {@link ValueFilter}s via the{@link MetaItemType#META_VALUE_FILTERS}
- * {@link MetaItem}.
+ * attribute can be filtered in the standard way using {@link ValueFilter}s via the
+ * {@link Protocol#META_ATTRIBUTE_VALUE_FILTERS} {@link MetaItem}.
* <h1>Attribute -> Protocol</h1>
* <p>
* When a linked {@link Attribute} is written to, the actual value written to the protocol can either be the exact value
diff --git a/agent/src/main/java/org/openremote/agent/protocol/websocket/WebsocketClientProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/websocket/WebsocketClientProtocol.java
index 93b3c9332..b2e47405f 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/websocket/WebsocketClientProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/websocket/WebsocketClientProtocol.java
@@ -80,7 +80,7 @@ import static org.openremote.model.util.TextUtil.REGEXP_PATTERN_STRING_NON_EMPTY
* <h1>Protocol -> Attribute</h1>
* <p>
* When a new value comes from the protocol destined for a linked {@link Attribute} the actual value written to the
- * attribute can be filtered in the standard way using {@link ValueFilter}s via the{@link MetaItemType#VALUE_FILTERS}
+ * attribute can be filtered in the standard way using {@link ValueFilter}s via the{@link Protocol#META_ATTRIBUTE_VALUE_FILTERS}
* {@link MetaItem}.
* <h1>Attribute -> Protocol</h1>
* <p>
@@ -150,7 +150,7 @@ public class WebsocketClientProtocol extends AbstractProtocol {
* {@link ValueFilter}s to apply to incoming messages with the final result being compared to the
* {@link #META_ATTRIBUTE_MESSAGE_MATCH_PREDICATE}, if they are equal (e.g. {@link String#equals}) then the message
* is intended for this linked attribute and the message can be once again filtered using the
- * {@link MetaItemType#VALUE_FILTERS} {@link MetaItem}. The {@link MetaItem} value should be an {@link ArrayValue}
+ * {@link Protocol#META_ATTRIBUTE_VALUE_FILTERS} {@link MetaItem}. The {@link MetaItem} value should be an {@link ArrayValue}
* of {@link ObjectValue}s where each {@link ObjectValue} represents a serialised {@link ValueFilter}. The message
* will pass through the filters in array order
*/
diff --git a/client/src/main/resources/org/openremote/app/client/i18n/ManagerMessages.properties b/client/src/main/resources/org/openremote/app/client/i18n/ManagerMessages.properties
index 0240bb663..114749a53 100644
--- a/client/src/main/resources/org/openremote/app/client/i18n/ManagerMessages.properties
+++ b/client/src/main/resources/org/openremote/app/client/i18n/ManagerMessages.properties
@@ -350,7 +350,9 @@ metaItemDisplayName[urnopenremoteassetmetadisabled]=Disabled
metaItemDisplayName[urnopenremoteassetmetaexecutable]=Executable
metaItemDisplayName[urnopenremoteassetmetaallowedValues]=Allowed values
metaItemDisplayName[urnopenremoteassetmetadataPointsMaxAgeDays]=Data points max age (days)
-metaItemDisplayName[urnopenremoteassetmetavalueFilters]=Value filters
+metaItemDisplayName[urnopenremoteprotocolvalueFilters]=Value filters
+metaItemDisplayName[urnopenremoteprotocolvalueConverter]=Value converter
+metaItemDisplayName[urnopenremoteprotocolwriteValueConverter]=Value write converter
metaItemDisplayName[urnopenremoteprotocolpollingMillis]=Polling interval (ms)
metaItemDisplayName[urnopenremoteprotocolwriteValue]=Write value
metaItemDisplayName[urnopenremoteprotocolcharset]=Charset
@@ -393,7 +395,7 @@ metaItemDisplayName[urnopenremoteprotocolhttpClientpingMillis]=HTTP ping interva
metaItemDisplayName[urnopenremoteprotocolhttpClientpingQueryParameters]=HTTP ping query parameters
metaItemDisplayName[urnopenremoteprotocolhttpClientpath]=HTTP path
metaItemDisplayName[urnopenremoteprotocolhttpClientmethod]=HTTP method
-metaItemDisplayName[urnopenremoteprotocolhttpClientbody]=HTTP body
+metaItemDisplayName[urnopenremoteprotocolhttpClientpollingAttribute]=Polling attribute
metaItemDisplayName[urnopenremoteprotocolhttpClientcontentType]=HTTP content type
metaItemDisplayName[urnopenremoteprotocolhttpClientfollowRedirects]=HTTP follow redirects
metaItemDisplayName[urnopenremoteprotocolhttpClientqueryParameters]=HTTP query parameters
diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.json
index 58adbc591..4269269ea 100644
--- a/deployment/manager/shared/locales/en/or.json
+++ b/deployment/manager/shared/locales/en/or.json
@@ -1,6 +1,6 @@
{
- "asset": "Asset",
- "asset_plural": "Assets",
+ "asset": "asset",
+ "asset_plural": "assets",
"scenes": "Scenes",
"settings": "Settings",
"selectLanguage": "Select Language",
diff --git a/deployment/manager/shared/locales/nl/or.json b/deployment/manager/shared/locales/nl/or.json
index 94367bbd4..3ae3316df 100644
--- a/deployment/manager/shared/locales/nl/or.json
+++ b/deployment/manager/shared/locales/nl/or.json
@@ -1,6 +1,6 @@
{
- "asset": "Asset",
- "asset_plural": "Assets",
+ "asset": "asset",
+ "asset_plural": "assets",
"scenes": "Scenes",
"settings": "Instellingen",
"selectLanguage": "Taal kiezen",
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 41a76cd15..1a94af03d 100644
--- a/manager/src/main/java/org/openremote/manager/agent/AgentService.java
+++ b/manager/src/main/java/org/openremote/manager/agent/AgentService.java
@@ -19,7 +19,6 @@
*/
package org.openremote.manager.agent;
-import com.fasterxml.jackson.databind.JsonNode;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.ParseContext;
@@ -773,6 +772,31 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse
});
}
+ public ConvertedValue applyValueConverter(Value value, ObjectValue converter) {
+
+ if (converter == null) {
+ return new ConvertedValue(false, value);
+ }
+
+ String converterKey = value == null ? "@NULL" : value.toString().toUpperCase(Locale.ROOT);
+ return converter.get(converterKey)
+ .map(v -> {
+ if (v.getType() == ValueType.STRING) {
+ String valStr = v.toString();
+ if (ConvertedValue.IGNORE.equalsIgnoreCase(valStr)) {
+ return new ConvertedValue(true, null);
+ }
+
+ if (ConvertedValue.NULL.equalsIgnoreCase(valStr)) {
+ return new ConvertedValue(false, null);
+ }
+ }
+
+ return new ConvertedValue(false, v);
+ })
+ .orElse(new ConvertedValue(true, value));
+ }
+
@SuppressWarnings("unchecked")
@Override
public Value applyValueFilters(Value value, ValueFilter... filters) {
@@ -897,6 +921,18 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse
Object obj = jsonPathParser.parse(value.toJson()).read(filter.path);
String pathJson = obj != null ? obj.toString() : null;
- return TextUtil.isNullOrEmpty(pathJson) ? null : Values.parse(pathJson).orElse(null);
+ if (TextUtil.isNullOrEmpty(pathJson)) {
+ return null;
+ }
+
+ if (filter.returnFirst) {
+ Value pathValue = Values.parse(pathJson).orElse(null);
+ if (pathValue != null && pathValue.getType() == ValueType.ARRAY) {
+ pathValue = Values.getArray(pathValue).flatMap(arr -> arr.length() > 0 ? arr.get(0) : Optional.empty()).orElse(null);
+ }
+ return pathValue;
+ }
+
+ return Values.parse(pathJson).orElse(null);
}
}
\ No newline at end of file
diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.java b/manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.java
index 2e299edd4..c2a25a873 100644
--- a/manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.java
+++ b/manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.java
@@ -25,25 +25,22 @@ import org.openremote.manager.agent.AgentService;
import org.openremote.manager.asset.AssetProcessingException.Reason;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.attribute.MetaItemType;
-import org.openremote.model.query.AssetQuery;
import org.openremote.model.attribute.*;
import org.openremote.model.attribute.AttributeEvent.Source;
-import org.openremote.model.util.Pair;
+import org.openremote.model.query.AssetQuery;
import org.openremote.model.value.*;
import javax.persistence.EntityManager;
import java.io.IOException;
-import java.util.Locale;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
-import static org.openremote.model.query.AssetQuery.Include;
-import static org.openremote.model.query.AssetQuery.Select;
import static org.openremote.model.attribute.AttributeEvent.Source.ATTRIBUTE_LINKING_SERVICE;
import static org.openremote.model.attribute.MetaItem.isMetaNameEqualTo;
+import static org.openremote.model.query.AssetQuery.Include;
+import static org.openremote.model.query.AssetQuery.Select;
/**
* This service processes asset updates on attributes that have one or more {@link MetaItemType#ATTRIBUTE_LINK} meta items.
@@ -154,45 +151,53 @@ public class AssetAttributeLinkingService implements ContainerService, AssetUpda
}
// Convert the value as required
- Pair<Boolean, Value> sendConvertedValue = convertValueForLinkedAttribute(
+ ConvertedValue sendConvertedValue = convertValueForLinkedAttribute(
em,
assetStorageService,
attributeState.getValue().orElse(null),
attributeLink
);
- if (!sendConvertedValue.key) {
- // Do not forward the attribute state (conversion resulted in NULL or IGNORE)
+ if (sendConvertedValue.isIgnore()) {
+ LOG.info("Value converter match was '" + ConvertedValue.IGNORE + "' so ignoring value");
return;
}
- sendAttributeEvent(new AttributeEvent(attributeLink.getAttributeRef(), sendConvertedValue.value));
+ sendAttributeEvent(new AttributeEvent(attributeLink.getAttributeRef(), sendConvertedValue.getValue()));
}
- protected Pair<Boolean, Value> convertValueForLinkedAttribute(EntityManager em,
+ protected ConvertedValue convertValueForLinkedAttribute(EntityManager em,
AssetStorageService assetStorageService,
Value originalValue,
AttributeLink attributeLink) throws AssetProcessingException {
- Pair<Boolean, Value> ignoreValuePair = attributeLink.getConverter()
+
+ // Filter the value first
+ if (attributeLink.getFilters() != null) {
+ originalValue = agentService.applyValueFilters(originalValue, attributeLink.getFilters());
+ }
+ Value finalOriginalValue = originalValue;
+
+ // Apply converter
+ return attributeLink.getConverter()
.map(
converter -> {
- String converterKey = originalValue == null ? "NULL" : originalValue.toString().toUpperCase(Locale.ROOT);
- Optional<Value> converterValue = converter.get(converterKey);
- // Convert the value
- return converterValue
- .map(value ->
- getSpecialConverter(value)
- .map(c -> doSpecialConversion(em, assetStorageService, c, attributeLink.getAttributeRef()))
- .orElse(new Pair<>(true, value))) // use the converter value as the new value
- .orElseGet(() -> new Pair<>(true, originalValue)); // use the original value
- })
- .orElse(new Pair<>(true, originalValue)); // use the original value
+ ConvertedValue converterValue = agentService.applyValueConverter(finalOriginalValue, converter);
- if (ignoreValuePair.key && attributeLink.getFilters() != null) {
- ignoreValuePair.value = agentService.applyValueFilters(ignoreValuePair.value, attributeLink.getFilters());
- }
+ if (converterValue.isIgnore()) {
+ return converterValue;
+ }
- return ignoreValuePair;
+ // Do special value conversion
+ return getSpecialConverter(converterValue.getValue()).map(
+ specialConverter -> doSpecialConversion(
+ em,
+ assetStorageService,
+ specialConverter,
+ attributeLink.getAttributeRef()
+ )
+ ).orElse(converterValue);
+ })
+ .orElse(new ConvertedValue(false, originalValue));
}
protected static Optional<AttributeLink.ConverterType> getSpecialConverter(Value value) {
@@ -202,16 +207,11 @@ public class AssetAttributeLinkingService implements ContainerService, AssetUpda
return Optional.empty();
}
- protected static Pair<Boolean, Value> doSpecialConversion(EntityManager em,
+ protected static ConvertedValue doSpecialConversion(EntityManager em,
AssetStorageService assetStorageService,
AttributeLink.ConverterType converter,
AttributeRef linkedAttributeRef) throws AssetProcessingException {
switch (converter) {
- case IGNORE:
- LOG.fine("Converter set to ignore value so not forwarding to linked attribute");
- return new Pair<>(false, null);
- case NULL:
- return new Pair<>(true, null);
case TOGGLE:
// Look up current value of the linked attribute within the same database session
try {
@@ -222,10 +222,10 @@ public class AssetAttributeLinkingService implements ContainerService, AssetUpda
"cannot toggle value as attribute is not of type BOOLEAN: " + linkedAttributeRef
);
}
- return new Pair<>(true, Values.create(!((BooleanValue) currentValue).getBoolean()));
+ return new ConvertedValue(false, Values.create(!((BooleanValue) currentValue).getBoolean()));
} catch (NoSuchElementException e) {
LOG.fine("The attribute doesn't exist so ignoring toggle value request: " + linkedAttributeRef);
- return new Pair<>(false, null);
+ return new ConvertedValue(true, null);
}
case INCREMENT:
case DECREMENT:
@@ -239,10 +239,10 @@ public class AssetAttributeLinkingService implements ContainerService, AssetUpda
);
}
int change = converter == AttributeLink.ConverterType.INCREMENT ? +1 : -1;
- return new Pair<>(true, Values.create(((NumberValue) currentValue).getNumber() + change));
+ return new ConvertedValue(false, Values.create(((NumberValue) currentValue).getNumber() + change));
} catch (NoSuchElementException e) {
LOG.fine("The attribute doesn't exist so ignoring increment/decrement value request: " + linkedAttributeRef);
- return new Pair<>(false, null);
+ return new ConvertedValue(true, null);
}
default:
throw new AssetProcessingException(
diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeLink.java b/model/src/main/java/org/openremote/model/attribute/AttributeLink.java
index c28ec6f8c..0c558e52c 100644
--- a/model/src/main/java/org/openremote/model/attribute/AttributeLink.java
+++ b/model/src/main/java/org/openremote/model/attribute/AttributeLink.java
@@ -36,16 +36,6 @@ public class AttributeLink {
public enum ConverterType {
- /**
- * Ignore this value (do not send to the linked attribute)
- */
- IGNORE("@IGNORE"),
-
- /**
- * Send a null vale to the linked attribute
- */
- NULL("@NULL"),
-
/**
* Toggle the value of the linked attribute; the linked attribute's type must be
* {@link AttributeValueType#BOOLEAN}
diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeState.java b/model/src/main/java/org/openremote/model/attribute/AttributeState.java
index 91d030299..34c610ca1 100644
--- a/model/src/main/java/org/openremote/model/attribute/AttributeState.java
+++ b/model/src/main/java/org/openremote/model/attribute/AttributeState.java
@@ -76,6 +76,10 @@ public class AttributeState {
return Optional.ofNullable(value);
}
+ public void setValue(Value value) {
+ this.value = value;
+ }
+
public boolean isDeleted() {
return deleted;
}
diff --git a/model/src/main/java/org/openremote/model/attribute/MetaItemType.java b/model/src/main/java/org/openremote/model/attribute/MetaItemType.java
index 536a88f62..8ff6cb4e6 100644
--- a/model/src/main/java/org/openremote/model/attribute/MetaItemType.java
+++ b/model/src/main/java/org/openremote/model/attribute/MetaItemType.java
@@ -402,23 +402,6 @@ public enum MetaItemType implements MetaItemDescriptor {
null,
null,
null,
- false),
-
- /**
- * {@link MetaItem} for defining {@link ValueFilter}s to apply to values before they are sent through the system
- * (e.g. before it is used to update a protocol linked attribute or to filter value when updating an attribute
- * linked attribute see {@link #ATTRIBUTE_LINK}); this is particularly useful for generic protocols.
- * The {@link MetaItem} value should be an {@link ArrayValue} of {@link ObjectValue}s
- * where each {@link ObjectValue} represents a serialised {@link ValueFilter}. The message should pass through the
- * filters in array order.
- */
- VALUE_FILTERS(
- ASSET_META_NAMESPACE + ":valueFilters",
- new Access(true, false, true),
- ValueType.ARRAY,
- null,
- null,
- null,
false);
final protected String urn;
diff --git a/model/src/main/java/org/openremote/model/query/filter/StringPredicate.java b/model/src/main/java/org/openremote/model/query/filter/StringPredicate.java
index 443eb5691..bd21c13f0 100644
--- a/model/src/main/java/org/openremote/model/query/filter/StringPredicate.java
+++ b/model/src/main/java/org/openremote/model/query/filter/StringPredicate.java
@@ -72,11 +72,11 @@ public class StringPredicate implements ValuePredicate {
public static Predicate<String> asPredicate(StringPredicate predicate) {
return string -> {
if (string == null && predicate.value == null)
- return true;
+ return !predicate.negate;
if (string == null)
- return false;
+ return predicate.negate;
if (predicate.value == null)
- return false;
+ return predicate.negate;
String shouldMatch = predicate.caseSensitive ? predicate.value : predicate.value.toUpperCase(Locale.ROOT);
String have = predicate.caseSensitive ? string : string.toUpperCase(Locale.ROOT);
@@ -123,10 +123,14 @@ public class StringPredicate implements ValuePredicate {
public ObjectValue toModelValue() {
ObjectValue objectValue = Values.createObject();
objectValue.put("predicateType", name);
- objectValue.put("match", Values.create(match.toString()));
+ if (match != null) {
+ objectValue.put("match", Values.create(match.toString()));
+ }
objectValue.put("caseSensitive", Values.create(caseSensitive));
objectValue.put("negate", Values.create(negate));
- objectValue.put("value", Values.create(value));
+ if (value != null) {
+ objectValue.put("value", Values.create(value));
+ }
return objectValue;
}
diff --git a/model/src/main/java/org/openremote/model/value/ConvertedValue.java b/model/src/main/java/org/openremote/model/value/ConvertedValue.java
new file mode 100644
index 000000000..ff894b5e4
--- /dev/null
+++ b/model/src/main/java/org/openremote/model/value/ConvertedValue.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2019, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.model.value;
+
+public class ConvertedValue {
+
+
+ /**
+ * Ignore this value (do not send to the linked attribute)
+ */
+ public static final String IGNORE = "@IGNORE";
+
+ /**
+ * Send a null value to the linked attribute
+ */
+ public static final String NULL = "@NULL";
+
+ protected boolean ignore;
+ protected Value value;
+
+ public ConvertedValue(boolean ignore, Value value) {
+ this.ignore = ignore;
+ this.value = value;
+ }
+
+ public boolean isIgnore() {
+ return ignore;
+ }
+
+ public Value getValue() {
+ return value;
+ }
+}
diff --git a/model/src/main/java/org/openremote/model/value/JsonPathFilter.java b/model/src/main/java/org/openremote/model/value/JsonPathFilter.java
index 0dbcf467b..bf2888a30 100644
--- a/model/src/main/java/org/openremote/model/value/JsonPathFilter.java
+++ b/model/src/main/java/org/openremote/model/value/JsonPathFilter.java
@@ -22,10 +22,6 @@ package org.openremote.model.value;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
-import org.openremote.model.util.TextUtil;
-
-import java.util.Arrays;
-import java.util.List;
import static org.openremote.model.value.RegexValueFilter.NAME;
@@ -37,9 +33,14 @@ public class JsonPathFilter extends ValueFilter<Value> {
@JsonProperty
public String path;
+ @JsonProperty
+ public boolean returnFirst;
+
@JsonCreator
- public JsonPathFilter(@JsonProperty("path") String path) {
+ public JsonPathFilter(@JsonProperty("path") String path,
+ @JsonProperty("returnFirst") boolean returnFirst) {
this.path = path;
+ this.returnFirst = returnFirst;
}
@Override
diff --git a/model/src/main/java/org/openremote/model/value/Values.java b/model/src/main/java/org/openremote/model/value/Values.java
index 6ca1d97f9..f09e8b78f 100644
--- a/model/src/main/java/org/openremote/model/value/Values.java
+++ b/model/src/main/java/org/openremote/model/value/Values.java
@@ -15,16 +15,14 @@
*/
package org.openremote.model.value;
-import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gwt.core.shared.GwtIncompatible;
import jsinterop.annotations.JsIgnore;
import jsinterop.annotations.JsMethod;
import jsinterop.base.Any;
-import org.openremote.model.asset.AssetAttribute;
+import org.openremote.model.attribute.Attribute;
import org.openremote.model.attribute.MetaItem;
import org.openremote.model.attribute.MetaItemDescriptor;
-import org.openremote.model.util.TextUtil;
import org.openremote.model.value.impl.ValueFactoryImpl;
import java.util.List;
@@ -178,7 +176,7 @@ public class Values {
}
@SuppressWarnings("unchecked")
- public static <T extends Value> Optional<T> getMetaItemValueOrThrow(AssetAttribute attribute,
+ public static <T extends Value> Optional<T> getMetaItemValueOrThrow(Attribute attribute,
MetaItemDescriptor metaItemDescriptor,
boolean throwIfMetaMissing,
boolean throwIfValueMissing)
@@ -192,7 +190,7 @@ public class Values {
}
@SuppressWarnings("unchecked")
- public static <T extends Value> Optional<T> getMetaItemValueOrThrow(AssetAttribute attribute,
+ public static <T extends Value> Optional<T> getMetaItemValueOrThrow(Attribute attribute,
String name,
Class<T> valueClazz,
boolean throwIfMetaMissing,
@@ -257,7 +255,13 @@ public class Values {
}
break;
case BOOLEAN:
- outputValue = (T) Values.create(Boolean.parseBoolean(value.toString()));
+ if ("ON".equalsIgnoreCase(value.toString())) {
+ outputValue = (T) Values.create(true);
+ } else if ("OFF".equalsIgnoreCase(value.toString())) {
+ outputValue = (T) Values.create(false);
+ } else {
+ outputValue = (T) Values.create(Boolean.parseBoolean(value.toString()));
+ }
break;
case ARRAY:
case OBJECT:
diff --git a/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
index 672594353..95dea792d 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
@@ -20,6 +20,7 @@
package org.openremote.test.protocol
import org.openremote.agent.protocol.AbstractProtocol
+import org.openremote.agent.protocol.Protocol
import org.openremote.container.util.Util
import org.openremote.manager.agent.AgentService
import org.openremote.manager.asset.AssetProcessingService
@@ -310,7 +311,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
new AttributeRef(mockAgent.getId(), "mockConfig1").toArrayValue()
),
new MetaItem(
- MetaItemType.VALUE_FILTERS,
+ Protocol.META_ATTRIBUTE_VALUE_FILTERS,
Values.createArray().add(Util.objectToValue(new RegexValueFilter("\\w(\\d+)", 1, 2)).get())
)
),
@@ -322,7 +323,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
new AttributeRef(mockAgent.getId(), "mockConfig1").toArrayValue()
),
new MetaItem(
- MetaItemType.VALUE_FILTERS,
+ Protocol.META_ATTRIBUTE_VALUE_FILTERS,
Values.createArray().add(Util.objectToValue(new SubStringValueFilter(10, 12)).get())
)
),
@@ -334,7 +335,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
new AttributeRef(mockAgent.getId(), "mockConfig1").toArrayValue()
),
new MetaItem(
- MetaItemType.VALUE_FILTERS,
+ Protocol.META_ATTRIBUTE_VALUE_FILTERS,
Values.createArray()
.add(Util.objectToValue(new SubStringValueFilter(23)).get())
.add(Util.objectToValue(new RegexValueFilter("[a-z|\\s]+(\\d+)%\"}", 1, 0)).get())
diff --git a/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
index 8fd8c8902..0b2c64245 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
@@ -488,7 +488,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_PATH, Values.create("get_poll_slow")),
new MetaItem(HttpClientProtocol.META_POLLING_MILLIS, Values.create(50)), // This is ms in testing
new MetaItem(
- MetaItemType.VALUE_FILTERS,
+ Protocol.META_ATTRIBUTE_VALUE_FILTERS,
Values.createArray().add(Util.objectToValue(new RegexValueFilter("\\d+", 0, 0)).get())
)
),
@@ -499,7 +499,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_PATH, Values.create("get_poll_fast")),
new MetaItem(HttpClientProtocol.META_POLLING_MILLIS, Values.create(40)), // This is ms in testing
new MetaItem(
- MetaItemType.VALUE_FILTERS,
+ Protocol.META_ATTRIBUTE_VALUE_FILTERS,
Values.createArray().add(Util.objectToValue(new RegexValueFilter("\\d+", 0, 1)).get())
)
)
diff --git a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovy
index 382c25f27..19d40d90c 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovy
@@ -210,7 +210,7 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
, Container.JSON).orElse(null)),
new MetaItem(WebsocketClientProtocol.META_ATTRIBUTE_MESSAGE_MATCH_PREDICATE,
new StringPredicate(BaseAssetQuery.Match.CONTAINS, true, "targetTemperature").toModelValue()),
- new MetaItem(MetaItemType.VALUE_FILTERS,
+ new MetaItem(Protocol.META_ATTRIBUTE_VALUE_FILTERS,
Values.convert(
[
new SubStringValueFilter(SharedEvent.MESSAGE_PREFIX.length()),
@@ -239,7 +239,7 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
, Container.JSON).orElse(null)),
new MetaItem(WebsocketClientProtocol.META_ATTRIBUTE_MESSAGE_MATCH_PREDICATE,
new StringPredicate(BaseAssetQuery.Match.CONTAINS, "co2Level").toModelValue()),
- new MetaItem(MetaItemType.VALUE_FILTERS,
+ new MetaItem(Protocol.META_ATTRIBUTE_VALUE_FILTERS,
Values.convert(
[
new SubStringValueFilter(SharedEvent.MESSAGE_PREFIX.length()),