100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Implement asset sync rules for GatewayConnectors (#1619)
Panos Kalogeropoulos7f99edeba4cd
diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java b/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.javaindex 4472ebc48..fbb848dfb 100644--- a/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java+++ b/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java@@ -44,6 +44,7 @@ import org.openremote.model.Container;import org.openremote.model.ContainerService;import org.openremote.model.PersistenceEvent;import org.openremote.model.asset.*;+import org.openremote.model.asset.impl.GatewayAsset;import org.openremote.model.asset.impl.GroupAsset;import org.openremote.model.asset.impl.ThingAsset;import org.openremote.model.attribute.Attribute;@@ -68,7 +69,10 @@ import java.sql.*;import java.util.*;import java.util.concurrent.ExecutorService;import java.util.concurrent.atomic.AtomicInteger;-import java.util.function.*;+import java.util.function.BiConsumer;+import java.util.function.Consumer;+import java.util.function.Predicate;+import java.util.function.Supplier;import java.util.logging.Level;import java.util.logging.Logger;import java.util.stream.Collectors;@@ -562,7 +566,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic* @throws IllegalArgumentException if the realm or parent is illegal, or other asset constraint is violated.*/public <T extends Asset<?>> T merge(T asset, boolean overrideVersion) throws IllegalStateException, ConstraintViolationException {- return merge(asset, overrideVersion, false, null);+ return merge(asset, overrideVersion, null, null);}/**@@ -571,41 +575,49 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic* @throws IllegalArgumentException if the realm or parent is illegal, or other asset constraint is violated.*/public <T extends Asset<?>> T merge(T asset, String userName) throws IllegalStateException, ConstraintViolationException {- return merge(asset, false, false, userName);+ return merge(asset, false, null, userName);}/*** Merge the requested {@link Asset} checking that it meets all constraint requirements before doing so; the* timestamp of each {@link Attribute} will also be updated to the current system time if it has changed to assist* with {@link Attribute} equality (see {@link Attribute#equals}).- * @param overrideVersion If <code>true</code>, the merge will override the data in the database, independent of- * version.- * @param skipGatewayCheck Don't check if asset is a gateway asset and merge asset into local persistence service.- * @param userName the user which this asset needs to be assigned to.+ * @param overrideVersion If <code>true</code>, the merge will override the data in the database, independent of+ * version.+ * @param requestingGatewayAsset If set this is the {@link GatewayAsset} merging the asset so skip standard checks+ * @param userName the user which this asset needs to be assigned to.* @return The current stored asset state.* @throws IllegalArgumentException if the realm or parent is illegal, or other asset constraint is violated.*/@SuppressWarnings("unchecked")- public <T extends Asset<?>> T merge(T asset, boolean overrideVersion, boolean skipGatewayCheck, String userName) throws IllegalStateException, ConstraintViolationException {+ public <T extends Asset<?>> T merge(T asset, boolean overrideVersion, GatewayAsset requestingGatewayAsset, String userName) throws IllegalStateException, ConstraintViolationException {if (LOG.isLoggable(Level.FINEST)) {LOG.finest("Merging asset: " + asset);}- if (asset.getId() != null || asset.getParentId() != null) {- String gatewayId = gatewayService.getLocallyRegisteredGatewayId(asset.getId(), asset.getParentId());+ long startTime = System.currentTimeMillis();+ String assetId = asset.getId() != null ? asset.getId() : "";- if (!skipGatewayCheck && gatewayId != null) {- String msg = "Cannot directly add or modify a descendant asset on a gateway asset, do this on the gateway itself: Gateway ID=" + gatewayId;- LOG.info(msg);+ // We skip all standard checks as asset is coming from a gateway and would be validated from there+ if (requestingGatewayAsset != null) {+ if (asset.getId() == null || asset.getParentId() == null || asset.getRealm() == null) {+ String msg = "GatewayAsset descendant must have an ID, parent ID and realm defined: asset=" + asset;+ LOG.warning(msg);throw new IllegalStateException(msg);}- }+ } else {+ String gatewayId = null;- String assetId = asset.getId() != null ? asset.getId() : "";- return withAssetLock(assetId, () -> persistenceService.doReturningTransaction(em -> {+ if (asset.getId() != null || asset.getParentId() != null) {+ gatewayId = gatewayService.getLocallyRegisteredGatewayId(asset.getId(), asset.getParentId());+ }- long startTime = System.currentTimeMillis();+ if (gatewayId != null) {+ String msg = "Cannot directly add or modify a descendant asset on a gateway asset, do this on the gateway itself: Gateway ID=" + gatewayId;+ LOG.info(msg);+ throw new IllegalStateException(msg);+ }// Validate realmif (asset.getRealm() == null) {@@ -615,6 +627,8 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic}// Do standard JSR-380 validation on the asset (includes custom validation using descriptors and constraints)+ // Only do validation on non gateway descendants as the asset types in the central instance may not+ // match the edge gatewaySet<ConstraintViolation<Asset<?>>> validationFailures = ValueUtil.validate(asset);if (!validationFailures.isEmpty()) {@@ -623,6 +637,9 @@ public class AssetStorageService extends RouteBuilder implements ContainerServicLOG.log(Level.WARNING, msg + ", exception=" + ex.getMessage());throw ex;}+ }++ return withAssetLock(assetId, () -> persistenceService.doReturningTransaction(em -> {T existingAsset = TextUtil.isNullOrEmpty(asset.getId()) ? null : (T)em.find(Asset.class, asset.getId());diff --git a/manager/src/main/java/org/openremote/manager/asset/AttributeLinkingService.java b/manager/src/main/java/org/openremote/manager/asset/AttributeLinkingService.javaindex ea2a24296..dbc36ea31 100644--- a/manager/src/main/java/org/openremote/manager/asset/AttributeLinkingService.java+++ b/manager/src/main/java/org/openremote/manager/asset/AttributeLinkingService.java@@ -80,6 +80,11 @@ public class AttributeLinkingService implements ContainerService {return;}+ if (gatewayService.getLocallyRegisteredGatewayId(event.getId(), null) != null) {+ // This is an event for a gateway descendant asset we don't follow attribute links of these+ return;+ }+event.getMetaValue(MetaItemType.ATTRIBUTE_LINKS).ifPresent(attributeLinks ->Arrays.stream(attributeLinks).forEach(attributeLink ->diff --git a/manager/src/main/java/org/openremote/manager/event/ClientEventService.java b/manager/src/main/java/org/openremote/manager/event/ClientEventService.javaindex cb9adb8d1..b0538609f 100644--- a/manager/src/main/java/org/openremote/manager/event/ClientEventService.java+++ b/manager/src/main/java/org/openremote/manager/event/ClientEventService.java@@ -394,7 +394,11 @@ public class ClientEventService extends RouteBuilder implements ContainerService}Consumer<T> consumer = (Consumer<T>)eventSubscriptionConsumerPair.getValue();- consumer.accept(filteredEvent);+ try {+ consumer.accept(filteredEvent);+ } catch (Exception e) {+ LOG.log(WARNING, "Event subscriber has thrown an exception: " + consumer, e);+ }});}diff --git a/manager/src/main/java/org/openremote/manager/gateway/GatewayClientService.java b/manager/src/main/java/org/openremote/manager/gateway/GatewayClientService.javaindex 1a8251d70..19450b4a2 100644--- a/manager/src/main/java/org/openremote/manager/gateway/GatewayClientService.java+++ b/manager/src/main/java/org/openremote/manager/gateway/GatewayClientService.java@@ -38,8 +38,7 @@ import org.openremote.model.ContainerService;import org.openremote.model.PersistenceEvent;import org.openremote.model.asset.*;import org.openremote.model.asset.agent.ConnectionStatus;-import org.openremote.model.attribute.AttributeEvent;-import org.openremote.model.attribute.AttributeRef;+import org.openremote.model.attribute.*;import org.openremote.model.auth.OAuthClientCredentialsGrant;import org.openremote.model.event.shared.EventFilter;import org.openremote.model.event.shared.EventSubscription;@@ -256,8 +255,7 @@ public class GatewayClientService extends RouteBuilder implements ContainerServiclient.addMessageConsumer(message -> onCentralManagerMessage(connection, message));- realmAssetEventConsumer = assetEvent ->- sendCentralManagerMessage(connection.getLocalRealm(), messageToString(SharedEvent.MESSAGE_PREFIX, assetEvent));+ realmAssetEventConsumer = assetEvent -> sendAssetEvent(connection, assetEvent);// Subscribe to Asset<?> and attribute events of local realm and pass through to connected managerclientEventService.addSubscription(@@ -265,12 +263,11 @@ public class GatewayClientService extends RouteBuilder implements ContainerServinew AssetFilter<AssetEvent>().setRealm(connection.getLocalRealm()),realmAssetEventConsumer);- realmAttributeEventConsumer = attributeEvent ->- sendCentralManagerMessage(connection.getLocalRealm(), messageToString(SharedEvent.MESSAGE_PREFIX, attributeEvent));+ realmAttributeEventConsumer = attributeEvent -> sendAttributeEvent(connection, attributeEvent);clientEventService.addSubscription(AttributeEvent.class,- getOutboundAttribueEventFilter(connection),+ getOutboundAttributeEventFilter(connection),realmAttributeEventConsumer);client.connect();@@ -285,7 +282,31 @@ public class GatewayClientService extends RouteBuilder implements ContainerServireturn null;}- protected EventFilter<AttributeEvent> getOutboundAttribueEventFilter(GatewayConnection gatewayConnection) {+ protected void sendAssetEvent(GatewayConnection connection, AssetEvent event) {+ if (connection.getAssetSyncRules() != null) {+ // Apply sync rules to the asset+ event = ValueUtil.clone(event);+ applySyncRules(event.getAsset(), connection.getAssetSyncRules());+ }+ sendCentralManagerMessage(connection.getLocalRealm(), messageToString(SharedEvent.MESSAGE_PREFIX, event));+ }++ protected void sendAttributeEvent(GatewayConnection connection, AttributeEvent event) {+ if (connection.getAssetSyncRules() != null) {+ // Attribute exclusion from sync rules has already been applied+ // Apply sync rules to the event meta+ event = ValueUtil.clone(event);+ event.setMeta(event.getMeta() != null ? event.getMeta() : new MetaMap());+ applySyncRuleToMeta(+ event.getName(),+ event.getMeta(),+ connection.getAssetSyncRules().getOrDefault(event.getAssetType(),+ connection.getAssetSyncRules().get("*")));+ }+ sendCentralManagerMessage(connection.getLocalRealm(), messageToString(SharedEvent.MESSAGE_PREFIX, event));+ }++ protected EventFilter<AttributeEvent> getOutboundAttributeEventFilter(GatewayConnection gatewayConnection) {// Convert filters to predicates for efficiencyList<Pair<AssetQueryPredicate, GatewayAttributeFilter>> predicatesWithFilters;@@ -364,6 +385,15 @@ public class GatewayClientService extends RouteBuilder implements ContainerServireturn false;}).orElse(true);+ // Skip any events for attributes excluded by sync rules+ if (allowEvent && gatewayConnection.getAssetSyncRules() != null) {+ GatewayAssetSyncRule syncRule = gatewayConnection.getAssetSyncRules().getOrDefault(ev.getAssetType(), gatewayConnection.getAssetSyncRules().get("*"));+ if (syncRule != null && syncRule.excludeAttributes != null && syncRule.excludeAttributes.contains(ev.getName())) {+ LOG.finer(() -> "Attribute event excluded due to sync rule: " + ev);+ allowEvent = false;+ }+ }+return allowEvent ? ev : null;};}@@ -461,6 +491,9 @@ public class GatewayClientService extends RouteBuilder implements ContainerServi// Force realm to be the one that this client is associated withquery.realm(new RealmPredicate(connection.getLocalRealm()));List<Asset<?>> assets = assetStorageService.findAll(readAssets.getAssetQuery());+ assets = assets.stream()+ .map(it -> this.applySyncRules(it, connection.getAssetSyncRules()))+ .collect(Collectors.toList());AssetsEvent responseEvent = new AssetsEvent(assets);responseEvent.setMessageID(event.getMessageID());sendCentralManagerMessage(@@ -544,4 +577,55 @@ public class GatewayClientService extends RouteBuilder implements ContainerServiGatewayIOClient client = clientRealmMap.get(realm);return client != null ? client.getConnectionStatus() : null;}++ /**+ *+ * If the assetSyncRules affect this AssetType:+ * 1) Filter out the attributes that have been defined in GatewayAssetSyncRule.<assetType>.excludeAttributes+ * 2) Find the metaItem exclusions, with the specific attibuteName having priority over the wildcard. If none are found, Use Optional.Empty+ * 3) Put the attribute and the List of excluded metaItems in a Tuple (MutablePair)+ * 4) Filter out any excluded metaItems by using Attribute.setMeta(Attribute.getMeta)+ * 5)+ *+ * @param asset Asset to filter+ * @param assetSyncRules Asset Sync Rules as found in GatewayConnection+ * @return The asset as given, with attributes and metaItems stripped out as instructed by the assetSyncRules+ */+ protected Asset<?> applySyncRules(Asset<?> asset, Map<String, GatewayAssetSyncRule> assetSyncRules) {++ if (asset == null || assetSyncRules == null) {+ return asset;+ }++ GatewayAssetSyncRule syncRule = assetSyncRules.getOrDefault(asset.getType(), assetSyncRules.get("*"));++ if (syncRule == null) {+ return asset;+ }++ List<Attribute<?>> attributes = asset.getAttributes().stream()+ .filter(it -> syncRule.excludeAttributes == null || !syncRule.excludeAttributes.contains(it.getName()))+ .peek(attribute -> applySyncRuleToMeta(attribute.getName(), attribute.getMeta(), syncRule)).toList();++ asset.setAttributes(attributes);+ return asset;+ }++ protected void applySyncRuleToMeta(String attributeName, MetaMap meta, GatewayAssetSyncRule syncRule) {+ if (syncRule == null) {+ return;+ }+ if (syncRule.excludeAttributeMeta != null && !meta.isEmpty()) {+ List<String> excludeMetaRules = syncRule.excludeAttributeMeta.getOrDefault(attributeName, syncRule.excludeAttributeMeta.get("*"));+ if (excludeMetaRules != null && !excludeMetaRules.isEmpty()) {+ meta.keySet().removeIf(excludeMetaRules::contains);+ }+ }+ if (syncRule.addAttributeMeta != null) {+ Map<String, MetaItem<?>> addMetaRules = syncRule.addAttributeMeta.getOrDefault(attributeName, syncRule.addAttributeMeta.get("*"));+ if (addMetaRules != null && !addMetaRules.isEmpty()) {+ meta.addAll(addMetaRules);+ }+ }+ }}diff --git a/manager/src/main/java/org/openremote/manager/gateway/GatewayConnector.java b/manager/src/main/java/org/openremote/manager/gateway/GatewayConnector.javaindex a33780d32..eb2b0641e 100644--- a/manager/src/main/java/org/openremote/manager/gateway/GatewayConnector.java+++ b/manager/src/main/java/org/openremote/manager/gateway/GatewayConnector.java@@ -75,6 +75,7 @@ public class GatewayConnector {protected ScheduledFuture<?> syncProcessorFuture;protected Future<?> capabilitiesFuture;List<String> syncAssetIds;+ protected GatewayAsset gatewayAsset;int syncIndex;int syncErrors;String expectedSyncResponseName;@@ -111,6 +112,7 @@ public class GatewayConnector {this.disabled = gateway.getDisabled().orElse(false);this.realm = gateway.getRealm();this.gatewayId = gateway.getId();+ this.gatewayAsset = gateway;// Setup static inbound event handlingsynchronized(eventConsumerMap) {@@ -139,7 +141,7 @@ public class GatewayConnector {synchronized (this.sessionId) {if (getSessionId() != null) {- disconnect();+ disconnect(GatewayDisconnectEvent.Reason.ALREADY_CONNECTED);}this.sessionId.set(sessionId);}@@ -184,9 +186,12 @@ public class GatewayConnector {publishAttributeEvent(new AttributeEvent(gatewayId, GatewayAsset.STATUS, ConnectionStatus.DISCONNECTED));}- protected void disconnect() {+ protected void disconnect(GatewayDisconnectEvent.Reason reason) {synchronized (this.sessionId) {if (isConnected()) {+ if (disabled) {+ sendMessageToGateway(new GatewayDisconnectEvent(reason));+ }requestDisconnect.run();disconnected(getSessionId());}@@ -371,7 +376,7 @@ public class GatewayConnector {protected void setDisabled(boolean disabled) {this.disabled = disabled;- this.disconnect();+ disconnect(GatewayDisconnectEvent.Reason.DISABLED);}protected String getSessionId() {@@ -383,22 +388,26 @@ public class GatewayConnector {}synchronized protected void onGatewayEvent(SharedEvent e) {-- if (initialSyncInProgress) {- if (e instanceof AssetsEvent) {- onSyncAssetsResponse((AssetsEvent) e);- } else if (e instanceof AttributeEvent) {- cachedAttributeEvents.add((AttributeEvent) e);- } else if (e instanceof AssetEvent) {- cachedAssetEvents.add((AssetEvent) e);- }- } else {- synchronized (eventConsumerMap) {- Consumer<SharedEvent> consumer = eventConsumerMap.get(e.getClass());- if (consumer != null) {- consumer.accept(e);+ try {+ if (initialSyncInProgress) {+ if (e instanceof AssetsEvent) {+ onSyncAssetsResponse((AssetsEvent) e);+ } else if (e instanceof AttributeEvent) {+ cachedAttributeEvents.add((AttributeEvent) e);+ } else if (e instanceof AssetEvent) {+ cachedAssetEvents.add((AssetEvent) e);+ }+ } else {+ synchronized (eventConsumerMap) {+ Consumer<SharedEvent> consumer = eventConsumerMap.get(e.getClass());+ if (consumer != null) {+ consumer.accept(e);+ }}}+ } catch (Exception ex) {+ LOG.log(Level.WARNING, ex, () -> "An error occurred while processing a gateway event: event=" + e + ", connector=" + this);+ disconnect(GatewayDisconnectEvent.Reason.SYNC_ERROR);}}@@ -545,7 +554,7 @@ public class GatewayConnector {// Returned asset order may not match request order so re-orderreturnedAssets = returnedAssets.stream().sorted(Comparator.comparingInt(a -> syncAssetIds.indexOf(a.getId())))- .collect(Collectors.toList());+ .toList();// Merge returned assets ensuring the latest version of each is mergedreturnedAssets.stream()@@ -650,20 +659,8 @@ public class GatewayConnector {synchronized protected void onAssetEvent(AssetEvent e) {switch (e.getCause()) {- case CREATE, READ, UPDATE -> {- try {- saveAssetLocally(e.getAsset());- } catch (Exception ex) {- LOG.log(Level.SEVERE, "Updating/creating asset failed: " + e.getId() + ": " + this, ex);- }- }- case DELETE -> {- try {- deleteAssetsLocally(Collections.singletonList(mapAssetId(gatewayId, e.getId(), false)));- } catch (Exception ex) {- LOG.log(Level.SEVERE, "Removing obsolete asset failed: " + e.getId() + ": " + this, ex);- }- }+ case CREATE, READ, UPDATE -> saveAssetLocally(e.getAsset());+ case DELETE -> deleteAssetsLocally(Collections.singletonList(mapAssetId(gatewayId, e.getId(), false)));}}@@ -678,7 +675,7 @@ public class GatewayConnector {asset.setParentId(asset.getParentId() != null ? mapAssetId(gatewayId, asset.getParentId(), false) : gatewayId);asset.setRealm(realm);LOG.fine("Creating/updating gateway asset: Asset ID=" + assetId + ", Asset ID Mapped=" + asset.getId() + ": " + this);- return assetStorageService.merge(asset, true, true, null);+ return assetStorageService.merge(asset, true, gatewayAsset, null);}protected boolean deleteAssetsLocally(List<String> assetIds) {@@ -686,6 +683,10 @@ public class GatewayConnector {return assetStorageService.delete(assetIds, true);}+ public GatewayAsset getGatewayAsset() {+ return gatewayAsset;+ }+@Overridepublic String toString() {return GatewayConnector.class.getSimpleName() + "{" +diff --git a/manager/src/main/java/org/openremote/manager/gateway/GatewayService.java b/manager/src/main/java/org/openremote/manager/gateway/GatewayService.javaindex a3e99668b..4d82fbd64 100644--- a/manager/src/main/java/org/openremote/manager/gateway/GatewayService.java+++ b/manager/src/main/java/org/openremote/manager/gateway/GatewayService.java@@ -272,7 +272,7 @@ public class GatewayService extends RouteBuilder implements ContainerService {@Overridepublic void stop(Container container) throws Exception {- gatewayConnectorMap.values().forEach(GatewayConnector::disconnect);+ gatewayConnectorMap.values().forEach(connector -> connector.disconnect(GatewayDisconnectEvent.Reason.TERMINATING));gatewayConnectorMap.clear();assetIdGatewayIdMap.clear();tunnelInfos.clear();@@ -413,7 +413,7 @@ public class GatewayService extends RouteBuilder implements ContainerService {newSecret = identityProvider.resetSecret(event.getRealm(), gatewayServiceUser.getId(), newSecret);// Disconnect current session- connector.disconnect();+ connector.disconnect(GatewayDisconnectEvent.Reason.TERMINATING);// Update the event value with the potentially newly generated secretevent.setValue(newSecret);@@ -707,9 +707,6 @@ public class GatewayService extends RouteBuilder implements ContainerService {// Check if disabledboolean isNowDisabled = gateway.getDisabled().orElse(false);- if (isNowDisabled) {- connector.sendMessageToGateway(new GatewayDisconnectEvent(GatewayDisconnectEvent.Reason.DISABLED));- }connector.setDisabled(isNowDisabled);if (persistenceEvent.hasPropertyChanged("attributes")) {@@ -742,7 +739,7 @@ public class GatewayService extends RouteBuilder implements ContainerService {connector = gatewayConnectorMap.remove(gateway.getId().toLowerCase(Locale.ROOT));if (connector != null) {- connector.disconnect();+ connector.disconnect(GatewayDisconnectEvent.Reason.UNRECOGNISED);}removeGatewayServiceUser(gateway);diff --git a/manager/src/main/resources/org/openremote/manager/setup/database/V20250218_01__UpdateGatewayConnection.sql b/manager/src/main/resources/org/openremote/manager/setup/database/V20250218_01__UpdateGatewayConnection.sqlnew file mode 100644index 000000000..e811ef702--- /dev/null+++ b/manager/src/main/resources/org/openremote/manager/setup/database/V20250218_01__UpdateGatewayConnection.sql@@ -0,0 +1,2 @@+ALTER TABLE GATEWAY_CONNECTION+ ADD SYNC_RULES jsonb;diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java b/model/src/main/java/org/openremote/model/attribute/AttributeEvent.javaindex d87c08d5d..38bb2cd00 100644--- a/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java+++ b/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java@@ -272,6 +272,11 @@ public class AttributeEvent extends SharedEvent implements AttributeInfo {return meta;}+ public AttributeEvent setMeta(MetaMap meta) {+ this.meta = meta;+ return this;+ }+@JsonIgnore@Overridepublic String getName() {diff --git a/model/src/main/java/org/openremote/model/gateway/GatewayAssetSyncRule.java b/model/src/main/java/org/openremote/model/gateway/GatewayAssetSyncRule.javanew file mode 100644index 000000000..032da9779--- /dev/null+++ b/model/src/main/java/org/openremote/model/gateway/GatewayAssetSyncRule.java@@ -0,0 +1,72 @@+package org.openremote.model.gateway;++import org.openremote.model.attribute.MetaMap;++import java.util.List;+import java.util.Map;+import java.util.Objects;++/**+ * A sync rule lists any {@link org.openremote.model.attribute.Attribute}s and/or+ * {@link org.openremote.model.attribute.MetaItem}s that should be removed and/or added from/to a given asset type+ * before it is sent to the central instance+ */+public class GatewayAssetSyncRule {+ /**+ * List of {@link org.openremote.model.attribute.Attribute} names to be stripped from the asset before syncing.+ */+ public List<String> excludeAttributes;+ /**+ * A map where keys should be the name of an {@link org.openremote.model.attribute.Attribute} to which the exclusions+ * should be applied; to apply to all attributes use the * wildcard. The list of+ * {@link org.openremote.model.attribute.MetaItem} will then be stripped from these attributes before syncing.+ */+ public Map<String, List<String>> excludeAttributeMeta;++ /**+ * A map where keys should be the name of an {@link org.openremote.model.attribute.Attribute} to which the additions+ * should be applied; to apply to all attributes use the * wildcard. The {@link MetaMap} will then be added to each+ * matching attribute before syncing.+ */+ public Map<String, MetaMap> addAttributeMeta;++ public List<String> getExcludeAttributes() {+ return excludeAttributes;+ }++ public GatewayAssetSyncRule setExcludeAttributes(List<String> excludeAttributes) {+ this.excludeAttributes = excludeAttributes;+ return this;+ }++ public Map<String, List<String>> getExcludeAttributeMeta() {+ return excludeAttributeMeta;+ }++ public GatewayAssetSyncRule setExcludeAttributeMeta(Map<String, List<String>> excludeAttributeMeta) {+ this.excludeAttributeMeta = excludeAttributeMeta;+ return this;+ }++ public Map<String, MetaMap> getAddAttributeMeta() {+ return addAttributeMeta;+ }++ public GatewayAssetSyncRule setAddAttributeMeta(Map<String, MetaMap> addAttributeMeta) {+ this.addAttributeMeta = addAttributeMeta;+ return this;+ }++ @Override+ public boolean equals(Object o) {+ if (this == o) return true;+ if (o == null || getClass() != o.getClass()) return false;+ GatewayAssetSyncRule that = (GatewayAssetSyncRule) o;+ return Objects.equals(excludeAttributes, that.excludeAttributes) && Objects.equals(excludeAttributeMeta, that.excludeAttributeMeta) && Objects.equals(addAttributeMeta, that.addAttributeMeta);+ }++ @Override+ public int hashCode() {+ return Objects.hash(excludeAttributes, excludeAttributeMeta, addAttributeMeta);+ }+}diff --git a/model/src/main/java/org/openremote/model/gateway/GatewayConnection.java b/model/src/main/java/org/openremote/model/gateway/GatewayConnection.javaindex 763313183..e25ec5539 100644--- a/model/src/main/java/org/openremote/model/gateway/GatewayConnection.java+++ b/model/src/main/java/org/openremote/model/gateway/GatewayConnection.java@@ -33,6 +33,7 @@ import org.hibernate.annotations.JdbcTypeCode;import org.hibernate.type.SqlTypes;import java.util.List;+import java.util.Map;@Entity@Table(name = "GATEWAY_CONNECTION")@@ -80,6 +81,14 @@ public class GatewayConnection {@JdbcTypeCode(SqlTypes.JSON)protected List<GatewayAttributeFilter> attributeFilters;+ /**+ * A map of {@link GatewayAssetSyncRule}s where the key should be an {@link org.openremote.model.asset.Asset} type+ * to which the rules should be applied, to apply to all asset types use the * wildcard.+ */+ @Column(name = "SYNC_RULES")+ @JdbcTypeCode(SqlTypes.JSON)+ protected Map<String, GatewayAssetSyncRule> assetSyncRules;+/*** For JPA*/@@ -96,6 +105,7 @@ public class GatewayConnection {String clientSecret,Boolean secured,List<GatewayAttributeFilter> attributeFilters,+ Map<String, GatewayAssetSyncRule> assetSyncRules,boolean disabled) {this.localRealm = localRealm;this.host = host;@@ -106,6 +116,7 @@ public class GatewayConnection {this.secured = secured;this.disabled = disabled;this.attributeFilters = attributeFilters;+ this.assetSyncRules = assetSyncRules;}public GatewayConnection(@@ -202,6 +213,15 @@ public class GatewayConnection {return this;}+ public Map<String, GatewayAssetSyncRule> getAssetSyncRules() {+ return assetSyncRules;+ }++ public GatewayConnection setAssetSyncRules(Map<String, GatewayAssetSyncRule> assetSyncRules) {+ this.assetSyncRules = assetSyncRules;+ return this;+ }+@Overridepublic String toString() {return getClass().getSimpleName() + "{" +@@ -211,6 +231,7 @@ public class GatewayConnection {", realm='" + realm + '\'' +", secured=" + secured +", attributeFilters=" + (attributeFilters != null && !attributeFilters.isEmpty()) ++ ", assetSyncRules=" + assetSyncRules +", disabled=" + disabled +'}';}diff --git a/model/src/main/java/org/openremote/model/gateway/GatewayDisconnectEvent.java b/model/src/main/java/org/openremote/model/gateway/GatewayDisconnectEvent.javaindex 30129fc44..c041ddbdb 100644--- a/model/src/main/java/org/openremote/model/gateway/GatewayDisconnectEvent.java+++ b/model/src/main/java/org/openremote/model/gateway/GatewayDisconnectEvent.java@@ -37,7 +37,8 @@ public class GatewayDisconnectEvent extends SharedEvent {DISABLED,ALREADY_CONNECTED,UNRECOGNISED,- PERMANENT_ERROR+ PERMANENT_ERROR,+ SYNC_ERROR}protected Reason reason;diff --git a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovyindex 92df8ab65..d300ad2dd 100644--- a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy+++ b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy@@ -1,11 +1,7 @@package org.openremote.test.gateway-import com.hivemq.client.internal.mqtt.mqtt3.Mqtt3AsyncClientView-import com.hivemq.client.internal.mqtt.mqtt3.Mqtt3ClientConfigView-import com.hivemq.client.mqtt.MqttClientConfig-import com.hivemq.client.mqtt.MqttClientConnectionConfig+import io.netty.channel.ChannelHandler-import io.netty.channel.socket.SocketChannelimport org.apache.http.client.utils.URIBuilderimport org.openremote.agent.protocol.http.HTTPAgentimport org.openremote.agent.protocol.http.HTTPAgentLink@@ -21,6 +17,7 @@ import org.openremote.manager.gateway.*import org.openremote.manager.security.ManagerIdentityServiceimport org.openremote.manager.security.ManagerKeycloakIdentityProviderimport org.openremote.manager.setup.SetupService+import org.openremote.model.Constantsimport org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetEventimport org.openremote.model.asset.AssetsEvent@@ -30,6 +27,7 @@ import org.openremote.model.asset.impl.*import org.openremote.model.attribute.Attributeimport org.openremote.model.attribute.AttributeEventimport org.openremote.model.attribute.MetaItem+import org.openremote.model.attribute.MetaMapimport org.openremote.model.auth.OAuthClientCredentialsGrantimport org.openremote.model.event.shared.SharedEventimport org.openremote.model.gateway.*@@ -39,6 +37,7 @@ import org.openremote.model.query.filter.RealmPredicateimport org.openremote.model.security.Userimport org.openremote.model.util.UniqueIdentifierGeneratorimport org.openremote.model.util.ValueUtil+import org.openremote.model.value.ValueFormatimport org.openremote.setup.integration.ManagerTestSetupimport org.openremote.test.ManagerContainerTraitimport spock.lang.Ignore@@ -85,7 +84,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {when: "a gateway is provisioned in this manager"GatewayAsset gateway = assetStorageService.merge(new GatewayAsset("Test gateway")- .setRealm(managerTestSetup.realmBuildingName))+ .setRealm(managerTestSetup.realmBuildingName))then: "a keycloak client should have been created for this gateway"conditions.eventually {@@ -109,12 +108,12 @@ class GatewayTest extends Specification implements ManagerContainerTrait {when: "the Gateway client is created"def gatewayClient = new GatewayIOClient(- new URIBuilder("ws://127.0.0.1:$serverPort/websocket/events?Realm=$managerTestSetup.realmBuildingName").build(),- null,- new OAuthClientCredentialsGrant("http://127.0.0.1:$serverPort/auth/realms/$managerTestSetup.realmBuildingName/protocol/openid-connect/token",- gateway.getClientId().orElse(""),- gateway.getClientSecret().orElse(""),- null).setBasicAuthHeader(true))+ new URIBuilder("ws://127.0.0.1:$serverPort/websocket/events?Realm=$managerTestSetup.realmBuildingName").build(),+ null,+ new OAuthClientCredentialsGrant("http://127.0.0.1:$serverPort/auth/realms/$managerTestSetup.realmBuildingName/protocol/openid-connect/token",+ gateway.getClientId().orElse(""),+ gateway.getClientSecret().orElse(""),+ null).setBasicAuthHeader(true))gatewayClient.setEncoderDecoderProvider({[new AbstractNettyIOClient.MessageToMessageDecoder<String>(String.class, gatewayClient)].toArray(new ChannelHandler[0])})@@ -163,62 +162,62 @@ class GatewayTest extends Specification implements ManagerContainerTrait {List<String> assetIds = []List<Asset> assets = []- IntStream.rangeClosed(1, 5).forEach {i ->+ IntStream.rangeClosed(1, 5).forEach { i ->agentAssetIds.add(UniqueIdentifierGenerator.generateId("Test Agent $i"))def agent = new HTTPAgent("Test Agent $i")- .setId(agentAssetIds[i-1])+ .setId(agentAssetIds[i - 1]).setBaseURI("https://google.co.uk").setRealm(MASTER_REALM).setCreatedOn(Date.from(timerService.getNow()))- agent.path = (String[])[agentAssetIds[i-1]].toArray(new String[0])+ agent.path = (String[]) [agentAssetIds[i - 1]].toArray(new String[0])agentAssets.add(agent)assetIds.add(UniqueIdentifierGenerator.generateId("Test Building $i"))// Add assets out of order to test gateway connector re-ordering logic- IntStream.rangeClosed(1, 4).forEach{j ->+ IntStream.rangeClosed(1, 4).forEach { j ->assetIds.add(UniqueIdentifierGenerator.generateId("Test Building $i Room $j"))def roomAsset = new RoomAsset("Test Building $i Room $j")- .setId(assetIds[(i-1)*5+j])- .setCreatedOn(Date.from(timerService.getNow()))- .setParentId(assetIds[(i-1)*5])- .setRealm(MASTER_REALM)+ .setId(assetIds[(i - 1) * 5 + j])+ .setCreatedOn(Date.from(timerService.getNow()))+ .setParentId(assetIds[(i - 1) * 5])+ .setRealm(MASTER_REALM)- roomAsset.path = (String[])[assetIds[(i-1)*5+j], assetIds[(i-1)*5]].toArray(new String[0])+ roomAsset.path = (String[]) [assetIds[(i - 1) * 5 + j], assetIds[(i - 1) * 5]].toArray(new String[0])roomAsset.addOrReplaceAttributes(- new Attribute<>(Asset.LOCATION, new GeoJSONPoint(10,11)).addOrReplaceMeta(- new MetaItem<>(ACCESS_PUBLIC_READ)- ),- new Attribute<>("temp", NUMBER).addOrReplaceMeta(- new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[i-1])- .setPath("")),- new MetaItem<>(UNITS, units(UNITS_CELSIUS))- ),- new Attribute<>("tempSetpoint", NUMBER).addMeta(- new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[i-1])- .setPath("")),- new MetaItem<>(UNITS, units(UNITS_CELSIUS))- )+ new Attribute<>(Asset.LOCATION, new GeoJSONPoint(10, 11)).addOrReplaceMeta(+ new MetaItem<>(ACCESS_PUBLIC_READ)+ ),+ new Attribute<>("temp", NUMBER).addOrReplaceMeta(+ new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[i - 1])+ .setPath("")),+ new MetaItem<>(UNITS, Constants.units(UNITS_CELSIUS))+ ),+ new Attribute<>("tempSetpoint", NUMBER).addMeta(+ new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[i - 1])+ .setPath("")),+ new MetaItem<>(UNITS, Constants.units(UNITS_CELSIUS))+ ))assets.add(roomAsset)}def buildingAsset = new BuildingAsset("Test Building $i")- .setId(assetIds[(i-1)*5])- .setCreatedOn(Date.from(timerService.getNow()))- .setRealm(MASTER_REALM)+ .setId(assetIds[(i - 1) * 5])+ .setCreatedOn(Date.from(timerService.getNow()))+ .setRealm(MASTER_REALM)- buildingAsset.path = (String[])[assetIds[(i-1)*5]].toArray(new String[0])+ buildingAsset.path = (String[]) [assetIds[(i - 1) * 5]].toArray(new String[0])buildingAsset.addOrReplaceAttributes(- new Attribute<>(Asset.LOCATION, new GeoJSONPoint(10,11)).addMeta(- new MetaItem<>(ACCESS_PUBLIC_READ)- )+ new Attribute<>(Asset.LOCATION, new GeoJSONPoint(10, 11)).addMeta(+ new MetaItem<>(ACCESS_PUBLIC_READ)+ ))assets.add(buildingAsset)@@ -244,14 +243,14 @@ class GatewayTest extends Specification implements ManagerContainerTrait {assert readAssetsEvent.assetQuery != nullassert readAssetsEvent.assetQuery.ids != nullassert readAssetsEvent.assetQuery.ids.length == GatewayConnector.SYNC_ASSET_BATCH_SIZE- assert agentAssetIds.stream().filter{readAssetsEvent.assetQuery.ids.contains(it)}.count() == agentAssetIds.size()- assert assetIds.stream().filter{readAssetsEvent.assetQuery.ids.contains(it)}.count() == GatewayConnector.SYNC_ASSET_BATCH_SIZE - agentAssetIds.size()+ assert agentAssetIds.stream().filter { readAssetsEvent.assetQuery.ids.contains(it) }.count() == agentAssetIds.size()+ assert assetIds.stream().filter { readAssetsEvent.assetQuery.ids.contains(it) }.count() == GatewayConnector.SYNC_ASSET_BATCH_SIZE - agentAssetIds.size()}when: "the gateway returns the requested assets"sendAssets = []sendAssets.addAll(agentAssets)- sendAssets.addAll(Arrays.stream(readAssetsEvent.assetQuery.ids).filter{!agentAssetIds.contains(it)}.map{id -> assets.stream().filter{asset -> asset.id == id}.findFirst().orElse(null)}.collect(Collectors.toList()))+ sendAssets.addAll(Arrays.stream(readAssetsEvent.assetQuery.ids).filter { !agentAssetIds.contains(it) }.map { id -> assets.stream().filter { asset -> asset.id == id }.findFirst().orElse(null) }.collect(Collectors.toList()))readAssetsReplyEvent = new AssetsEvent(sendAssets)readAssetsReplyEvent.setMessageID(messageId)gatewayClient.sendMessage(SharedEvent.MESSAGE_PREFIX + ValueUtil.asJSON(readAssetsReplyEvent).get())@@ -260,39 +259,39 @@ class GatewayTest extends Specification implements ManagerContainerTrait {conditions.eventually {def syncedAssets = assetStorageService.findAll(new AssetQuery().parents(gateway.getId()).recursive(true))assert syncedAssets.size() == sendAssets.size()- assert syncedAssets.stream().filter{syncedAsset -> sendAssets.stream().anyMatch{mapAssetId(gateway.getId(), it.id, false) == syncedAsset.id}}.count() == sendAssets.size()- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[0]}.getName() == "Test Agent 1"- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[0]}.getType() == HTTPAgent.DESCRIPTOR.name- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[0]}.getRealm() == managerTestSetup.realmBuildingName- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[0]}.getParentId() == gateway.getId()- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[4]}.getName() == "Test Agent 5"- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[4]}.getType() == HTTPAgent.DESCRIPTOR.name- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[4]}.getRealm() == managerTestSetup.realmBuildingName- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[4]}.getParentId() == gateway.getId()- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[0]}.getName() == "Test Building 1"- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[0]}.getType() == BuildingAsset.DESCRIPTOR.name- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[0]}.getRealm() == managerTestSetup.realmBuildingName- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[0]}.getParentId() == gateway.getId()- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[0]}.getLocation().get().x == 10- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[0]}.getLocation().get().y == 11+ assert syncedAssets.stream().filter { syncedAsset -> sendAssets.stream().anyMatch { mapAssetId(gateway.getId(), it.id, false) == syncedAsset.id } }.count() == sendAssets.size()+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[0] }.getName() == "Test Agent 1"+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[0] }.getType() == HTTPAgent.DESCRIPTOR.name+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[0] }.getRealm() == managerTestSetup.realmBuildingName+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[0] }.getParentId() == gateway.getId()+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[4] }.getName() == "Test Agent 5"+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[4] }.getType() == HTTPAgent.DESCRIPTOR.name+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[4] }.getRealm() == managerTestSetup.realmBuildingName+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == agentAssetIds[4] }.getParentId() == gateway.getId()+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[0] }.getName() == "Test Building 1"+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[0] }.getType() == BuildingAsset.DESCRIPTOR.name+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[0] }.getRealm() == managerTestSetup.realmBuildingName+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[0] }.getParentId() == gateway.getId()+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[0] }.getLocation().get().x == 10+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[0] }.getLocation().get().y == 11assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[0]}.getAttribute(Asset.LOCATION).flatMap{it.getMetaItem(ACCESS_PUBLIC_READ)}.isPresent()- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[1]}.getName() == "Test Building 1 Room 1"- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[1]}.getType() == RoomAsset.DESCRIPTOR.getName()- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[1]}.getRealm() == managerTestSetup.realmBuildingName- assert mapAssetId(gateway.getId(), syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[1]}.getParentId(), true) == assetIds[0]+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[1] }.getName() == "Test Building 1 Room 1"+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[1] }.getType() == RoomAsset.DESCRIPTOR.getName()+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[1] }.getRealm() == managerTestSetup.realmBuildingName+ assert mapAssetId(gateway.getId(), syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[1] }.getParentId(), true) == assetIds[0]assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[1]}.getAttribute("temp").map{it.hasMeta(AGENT_LINK)}.orElse(false)assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[1]}.getAttribute("tempSetpoint").map{it.hasMeta(AGENT_LINK)}.orElse(false)- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[5]}.getName() == "Test Building 2"- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[5]}.getType() == BuildingAsset.DESCRIPTOR.getName()- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[5]}.getRealm() == managerTestSetup.realmBuildingName- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[5]}.getParentId() == gateway.getId()- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[5]}.getLocation().get().x == 10- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[5]}.getLocation().get().y == 11+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[5] }.getName() == "Test Building 2"+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[5] }.getType() == BuildingAsset.DESCRIPTOR.getName()+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[5] }.getRealm() == managerTestSetup.realmBuildingName+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[5] }.getParentId() == gateway.getId()+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[5] }.getLocation().get().x == 10+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[5] }.getLocation().get().y == 11assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[5]}.getAttribute(Asset.LOCATION).flatMap{it.getMetaItem(ACCESS_PUBLIC_READ)}.isPresent()- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[6]}.getName() == "Test Building 2 Room 1"- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[6]}.getType() == RoomAsset.DESCRIPTOR.getName()- assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[6]}.getRealm() == managerTestSetup.realmBuildingName- assert mapAssetId(gateway.getId(), syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[6]}.getParentId(), true) == assetIds[5]+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[6] }.getName() == "Test Building 2 Room 1"+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[6] }.getType() == RoomAsset.DESCRIPTOR.getName()+ assert syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[6] }.getRealm() == managerTestSetup.realmBuildingName+ assert mapAssetId(gateway.getId(), syncedAssets.find { mapAssetId(gateway.getId(), it.id, true) == assetIds[6] }.getParentId(), true) == assetIds[5]assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[6]}.getAttribute("temp").map{it.hasMeta(AGENT_LINK)}.orElse(false)assert syncedAssets.find {mapAssetId(gateway.getId(), it.id, true) == assetIds[6]}.getAttribute("tempSetpoint").map{it.hasMeta(AGENT_LINK)}.orElse(false)}@@ -307,12 +306,12 @@ class GatewayTest extends Specification implements ManagerContainerTrait {assert readAssetsEvent.assetQuery != nullassert readAssetsEvent.assetQuery.ids != nullassert readAssetsEvent.assetQuery.ids.length == agentAssetIds.size() + assetIds.size() - GatewayConnector.SYNC_ASSET_BATCH_SIZE- assert assetIds.stream().filter{id -> sendAssets.stream().noneMatch{it.id == id}}.count() == readAssetsEvent.assetQuery.ids.length+ assert assetIds.stream().filter { id -> sendAssets.stream().noneMatch { it.id == id } }.count() == readAssetsEvent.assetQuery.ids.length}when: "the gateway returns the requested assets"sendAssets = []- sendAssets.addAll(Arrays.stream(readAssetsEvent.assetQuery.ids).map{id -> assets.stream().filter{asset -> asset.id == id}.findFirst().orElse(null)}.collect(Collectors.toList()))+ sendAssets.addAll(Arrays.stream(readAssetsEvent.assetQuery.ids).map { id -> assets.stream().filter { asset -> asset.id == id }.findFirst().orElse(null) }.collect(Collectors.toList()))readAssetsReplyEvent = new AssetsEvent(sendAssets)readAssetsReplyEvent.setMessageID(messageId)gatewayClient.sendMessage(SharedEvent.MESSAGE_PREFIX + ValueUtil.asJSON(readAssetsReplyEvent).get())@@ -393,32 +392,32 @@ class GatewayTest extends Specification implements ManagerContainerTrait {then: "the descendant asset in the local manager should contain the new attribute value"conditions.eventually {def building1Room1Asset = assetStorageService.find(mapAssetId(gateway.id, assetIds[1], false))- assert building1Room1Asset.getAttribute("tempSetpoint").flatMap {it.getValue()}.orElse(0d) == 20d+ assert building1Room1Asset.getAttribute("tempSetpoint").flatMap { it.getValue() }.orElse(0d) == 20d}when: "an asset is added on the gateway and the local manager is notified"def building1Room5AssetId = UniqueIdentifierGenerator.generateId("Test Building 1 Room 5")def building1Room5Asset = new RoomAsset("Test Building 1 Room 5")- .setId(building1Room5AssetId)- .setCreatedOn(Date.from(timerService.getNow()))- .setParentId(assetIds[0])- .setRealm(MASTER_REALM)- building1Room5Asset.path = (String[])[building1Room5AssetId, assetIds[0]]+ .setId(building1Room5AssetId)+ .setCreatedOn(Date.from(timerService.getNow()))+ .setParentId(assetIds[0])+ .setRealm(MASTER_REALM)+ building1Room5Asset.path = (String[]) [building1Room5AssetId, assetIds[0]]building1Room5Asset.addOrReplaceAttributes(- new Attribute<>(Asset.LOCATION, new GeoJSONPoint(10,11)).addOrReplaceMeta(- new MetaItem<>(ACCESS_PUBLIC_READ)- ),- new Attribute<>("temp", NUMBER).addOrReplaceMeta(- new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[0])- .setPath("")),- new MetaItem<>(UNITS, units(UNITS_CELSIUS))- ),- new Attribute<>("tempSetpoint", NUMBER).addMeta(- new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[0])- .setPath("")),- new MetaItem<>(UNITS, units(UNITS_CELSIUS))- )+ new Attribute<>(Asset.LOCATION, new GeoJSONPoint(10, 11)).addOrReplaceMeta(+ new MetaItem<>(ACCESS_PUBLIC_READ)+ ),+ new Attribute<>("temp", NUMBER).addOrReplaceMeta(+ new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[0])+ .setPath("")),+ new MetaItem<>(UNITS, Constants.units(UNITS_CELSIUS))+ ),+ new Attribute<>("tempSetpoint", NUMBER).addMeta(+ new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[0])+ .setPath("")),+ new MetaItem<>(UNITS, Constants.units(UNITS_CELSIUS))+ ))gatewayClient.sendMessage(SharedEvent.MESSAGE_PREFIX + ValueUtil.asJSON(new AssetEvent(AssetEvent.Cause.CREATE, building1Room5Asset, null)).get())@@ -439,11 +438,11 @@ class GatewayTest extends Specification implements ManagerContainerTrait {building1Room5Asset.setName("Test Building 1 Room 5 Updated")building1Room5Asset.setVersion(1)building1Room5Asset.addAttributes(- new Attribute<>("co2Level", POSITIVE_INTEGER, 500)- .addMeta(- new MetaItem<>(UNITS, units(UNITS_PART_PER_MILLION)),- new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[0]).setPath(""))- )+ new Attribute<>("co2Level", POSITIVE_INTEGER, 500)+ .addMeta(+ new MetaItem<>(UNITS, Constants.units(UNITS_PART_PER_MILLION)),+ new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[0]).setPath(""))+ ))gatewayClient.sendMessage(SharedEvent.MESSAGE_PREFIX + ValueUtil.asJSON(new AssetEvent(AssetEvent.Cause.UPDATE, building1Room5Asset, (String[]) ["name", "attributes"].toArray(new String[0]))).get())@@ -457,7 +456,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {assert localBuilding1Room5Asset.getRealm() == managerTestSetup.realmBuildingNameassert localBuilding1Room5Asset.getParentId() == mapAssetId(gateway.id, assetIds[0], false)assert localBuilding1Room5Asset.getAttributes().size() == 7- assert localBuilding1Room5Asset.getAttribute("co2Level").flatMap{it.getValue()}.orElse(0i) == 500i+ assert localBuilding1Room5Asset.getAttribute("co2Level").flatMap { it.getValue() }.orElse(0i) == 500i}when: "an asset is deleted on the gateway and the local manager is notified"@@ -519,15 +518,15 @@ class GatewayTest extends Specification implements ManagerContainerTrait {when: "an attempt is made to add a descendant asset to a gateway that isn't connected"gatewayClient.disconnect()def failedAsset = new BuildingAsset("Failed Asset")- .setId(UniqueIdentifierGenerator.generateId("Failed asset"))- .setCreatedOn(Date.from(timerService.getNow()))- .setParentId(gateway.id)- .setRealm(managerTestSetup.realmBuildingName)- failedAsset.path = (String[])[UniqueIdentifierGenerator.generateId("Failed asset")].toArray(new String[0])+ .setId(UniqueIdentifierGenerator.generateId("Failed asset"))+ .setCreatedOn(Date.from(timerService.getNow()))+ .setParentId(gateway.id)+ .setRealm(managerTestSetup.realmBuildingName)+ failedAsset.path = (String[]) [UniqueIdentifierGenerator.generateId("Failed asset")].toArray(new String[0])failedAsset.addOrReplaceAttributes(- new Attribute<>(Asset.LOCATION, new GeoJSONPoint(10,11)).addMeta(- new MetaItem<>(ACCESS_PUBLIC_READ)- )+ new Attribute<>(Asset.LOCATION, new GeoJSONPoint(10, 11)).addMeta(+ new MetaItem<>(ACCESS_PUBLIC_READ)+ ))assetStorageService.merge(failedAsset)@@ -537,7 +536,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {when: "gateway assets are modified whilst the gateway is disconnected (building1Room5 re-added, building5 and descendants removed and building1 modified and building1Room1 attribute updated)"assets[4].setName("Test Building 1 Updated")assets[4].setVersion(2L)- assets[0].getAttribute("temp").ifPresent{it.setValue(10)}+ assets[0].getAttribute("temp").ifPresent { it.setValue(10) }assets = assets.subList(0, 20)and: "the client received messages are cleared"@@ -601,7 +600,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {and: "the local manager should have sent an asset read request"conditions.eventually {assert clientReceivedMessages.size() >= 1- assert clientReceivedMessages.find {it.startsWith(SharedEvent.MESSAGE_PREFIX) && it.contains("read-assets")} != null+ assert clientReceivedMessages.find { it.startsWith(SharedEvent.MESSAGE_PREFIX) && it.contains("read-assets") } != null}when: "the previously received messages are cleared"@@ -625,32 +624,32 @@ class GatewayTest extends Specification implements ManagerContainerTrait {assert readAssetsEvent.assetQuery != nullassert readAssetsEvent.assetQuery.ids != nullassert readAssetsEvent.assetQuery.ids.length == GatewayConnector.SYNC_ASSET_BATCH_SIZE- assert agentAssetIds.stream().filter{readAssetsEvent.assetQuery.ids.contains(it)}.count() == agentAssetIds.size()- assert assetIds.stream().filter{readAssetsEvent.assetQuery.ids.contains(it)}.count() + 1 == GatewayConnector.SYNC_ASSET_BATCH_SIZE - agentAssetIds.size()+ assert agentAssetIds.stream().filter { readAssetsEvent.assetQuery.ids.contains(it) }.count() == agentAssetIds.size()+ assert assetIds.stream().filter { readAssetsEvent.assetQuery.ids.contains(it) }.count() + 1 == GatewayConnector.SYNC_ASSET_BATCH_SIZE - agentAssetIds.size()}when: "another asset is added to the gateway during the initial sync process"def building2Room5Asset = new RoomAsset("Test Building 2 Room 5")- .setId(UniqueIdentifierGenerator.generateId("Test Building 2 Room 5"))- .setCreatedOn(Date.from(timerService.getNow()))- .setParentId(assetIds[5])- .setRealm(MASTER_REALM)- building2Room5Asset.path = (String[])[UniqueIdentifierGenerator.generateId("Test Building 2 Room 5"), assetIds[5]]+ .setId(UniqueIdentifierGenerator.generateId("Test Building 2 Room 5"))+ .setCreatedOn(Date.from(timerService.getNow()))+ .setParentId(assetIds[5])+ .setRealm(MASTER_REALM)+ building2Room5Asset.path = (String[]) [UniqueIdentifierGenerator.generateId("Test Building 2 Room 5"), assetIds[5]]building2Room5Asset.addOrReplaceAttributes(- new Attribute<>(Asset.LOCATION, new GeoJSONPoint(10,11)).addOrReplaceMeta(- new MetaItem<>(ACCESS_PUBLIC_READ)- ),- new Attribute<>("temp", NUMBER).addOrReplaceMeta(- new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[1])- .setPath("")),- new MetaItem<>(UNITS, units(UNITS_CELSIUS))- ),- new Attribute<>("tempSetpoint", NUMBER).addMeta(- new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[1])- .setPath("")),- new MetaItem<>(UNITS, units(UNITS_CELSIUS))- )+ new Attribute<>(Asset.LOCATION, new GeoJSONPoint(10, 11)).addOrReplaceMeta(+ new MetaItem<>(ACCESS_PUBLIC_READ)+ ),+ new Attribute<>("temp", NUMBER).addOrReplaceMeta(+ new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[1])+ .setPath("")),+ new MetaItem<>(UNITS, Constants.units(UNITS_CELSIUS))+ ),+ new Attribute<>("tempSetpoint", NUMBER).addMeta(+ new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[1])+ .setPath("")),+ new MetaItem<>(UNITS, Constants.units(UNITS_CELSIUS))+ ))gatewayClient.sendMessage(SharedEvent.MESSAGE_PREFIX + ValueUtil.asJSON(new AssetEvent(AssetEvent.Cause.CREATE, building2Room5Asset, null)).get())@@ -662,7 +661,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {and: "the gateway returns the requested assets (minus the deleted Building 3 Room 1 asset)"sendAssets = [building1Room5Asset]sendAssets.addAll(agentAssets)- sendAssets.addAll(Arrays.stream(readAssetsEvent.assetQuery.ids).filter{!agentAssetIds.contains(it) && it != removedAsset.id && it != building1Room5Asset.id}.map{id -> assets.stream().filter{it.id == id}.findFirst().orElse(null)}.collect(Collectors.toList()))+ sendAssets.addAll(Arrays.stream(readAssetsEvent.assetQuery.ids).filter { !agentAssetIds.contains(it) && it != removedAsset.id && it != building1Room5Asset.id }.map { id -> assets.stream().filter { it.id == id }.findFirst().orElse(null) }.collect(Collectors.toList()))readAssetsReplyEvent = new AssetsEvent(sendAssets)readAssetsReplyEvent.setMessageID(messageId)gatewayClient.sendMessage(SharedEvent.MESSAGE_PREFIX + ValueUtil.asJSON(readAssetsReplyEvent).get())@@ -677,12 +676,12 @@ class GatewayTest extends Specification implements ManagerContainerTrait {assert readAssetsEvent.assetQuery != nullassert readAssetsEvent.assetQuery.ids != nullassert readAssetsEvent.assetQuery.ids.length == agentAssetIds.size() + assets.size() + 1 - GatewayConnector.SYNC_ASSET_BATCH_SIZE + 1- assert assets.stream().filter{asset -> sendAssets.stream().noneMatch{it.id == asset.id}}.count() == readAssetsEvent.assetQuery.ids.length+ assert assets.stream().filter { asset -> sendAssets.stream().noneMatch { it.id == asset.id } }.count() == readAssetsEvent.assetQuery.ids.length}when: "the gateway returns the requested assets"sendAssets = []- sendAssets.addAll(Arrays.stream(readAssetsEvent.assetQuery.ids).map{id -> assets.stream().filter{asset -> asset.id == id}.findFirst().orElse(null)}.collect(Collectors.toList()))+ sendAssets.addAll(Arrays.stream(readAssetsEvent.assetQuery.ids).map { id -> assets.stream().filter { asset -> asset.id == id }.findFirst().orElse(null) }.collect(Collectors.toList()))readAssetsReplyEvent = new AssetsEvent(sendAssets)readAssetsReplyEvent.setMessageID(messageId)gatewayClient.sendMessage(SharedEvent.MESSAGE_PREFIX + ValueUtil.asJSON(readAssetsReplyEvent).get())@@ -748,11 +747,11 @@ class GatewayTest extends Specification implements ManagerContainerTrait {and: "an authenticated admin user"def accessToken = authenticate(- container,- MASTER_REALM,- KEYCLOAK_CLIENT_ID,- MASTER_REALM_ADMIN_USER,- getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)+ container,+ MASTER_REALM,+ KEYCLOAK_CLIENT_ID,+ MASTER_REALM_ADMIN_USER,+ getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)).token@@ -765,7 +764,8 @@ class GatewayTest extends Specification implements ManagerContainerTrait {}when: "a gateway is provisioned in this manager in the building realm"- GatewayAsset gateway = assetStorageService.merge(new GatewayAsset("Test gateway").setRealm(managerTestSetup.realmBuildingName))+ GatewayAsset gateway = assetStorageService.merge(new GatewayAsset("Test gateway")+ .setRealm(managerTestSetup.realmBuildingName))then: "a set of credentials should have been created for this gateway and be stored against the gateway for easy reference"conditions.eventually {@@ -782,15 +782,16 @@ class GatewayTest extends Specification implements ManagerContainerTrait {when: "a gateway client connection is created to connect the city realm to the gateway in the building realm"def gatewayConnection = new GatewayConnection(- managerTestSetup.realmCityName,- "127.0.0.1",- serverPort,- managerTestSetup.realmBuildingName,- gateway.getClientId().orElse(""),- gateway.getClientSecret().orElse(""),- false,- null,- false+ managerTestSetup.realmCityName,+ "127.0.0.1",+ serverPort,+ managerTestSetup.realmBuildingName,+ gateway.getClientId().orElse(""),+ gateway.getClientSecret().orElse(""),+ false,+ null,+ Map.of("test", new GatewayAssetSyncRule()),+ false)gatewayClientResource.setConnection(null, managerTestSetup.realmCityName, gatewayConnection)@@ -836,7 +837,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {MicrophoneAsset microphone1 = assetStorageService.find(managerTestSetup.microphone1Id)microphone1.setName("Microphone 1 Updated")microphone1.addAttributes(- new Attribute<>("test", NUMBER, 100d)+ new Attribute<>("test", NUMBER, 100d))microphone1 = assetStorageService.merge(microphone1)@@ -844,18 +845,18 @@ class GatewayTest extends Specification implements ManagerContainerTrait {conditions.eventually {def mirroredMicrophone = assetStorageService.find(mapAssetId(gateway.id, managerTestSetup.microphone1Id, false))assert mirroredMicrophone != null- assert mirroredMicrophone.getAttributes().get(MicrophoneAsset.SOUND_LEVEL).flatMap{it.getMetaItem(READ_ONLY)}.flatMap{it.getValue()}.orElse(false)+ assert mirroredMicrophone.getAttributes().get(MicrophoneAsset.SOUND_LEVEL).flatMap { it.getMetaItem(READ_ONLY) }.flatMap { it.getValue() }.orElse(false)assert mirroredMicrophone.getAttribute("test").isPresent()- assert mirroredMicrophone.getAttribute("test").flatMap{it.getValue()}.orElse(0d) == 100d+ assert mirroredMicrophone.getAttribute("test").flatMap { it.getValue() }.orElse(0d) == 100d}when: "a gateway client asset is added"MicrophoneAsset microphone2 = new MicrophoneAsset("Microphone 2")- .setRealm(managerTestSetup.realmCityName)- .setParentId(managerTestSetup.area1Id)- .addAttributes(- new Attribute<>("test", TEXT, "testValue")- )+ .setRealm(managerTestSetup.realmCityName)+ .setParentId(managerTestSetup.area1Id)+ .addAttributes(+ new Attribute<>("test", TEXT, "testValue")+ )microphone2 = assetStorageService.merge(microphone2)then: "the new asset should have been created in the gateway and also mirrored under the gateway asset"@@ -864,20 +865,39 @@ class GatewayTest extends Specification implements ManagerContainerTrait {def mirroredMicrophone2 = assetStorageService.find(mapAssetId(gateway.id, microphone2.id, false))assert mirroredMicrophone2 != nullassert mirroredMicrophone2.getAttributes().get(MicrophoneAsset.SOUND_LEVEL).isPresent()- assert mirroredMicrophone2.getAttribute("test").flatMap{it.getValue()}.orElse("") == "testValue"+ assert mirroredMicrophone2.getAttribute("test").flatMap { it.getValue() }.orElse("") == "testValue"}when: "an attempt is made to add an asset under the gateway asset"def microphone3 = ValueUtil.clone(microphone1)- .setName("Microphone 3")- .setId(null)- .setRealm(managerTestSetup.realmBuildingName)- .setParentId(mapAssetId(gateway.id, managerTestSetup.area1Id, false))+ .setName("Microphone 3")+ .setId(null)+ .setRealm(managerTestSetup.realmBuildingName)+ .setParentId(mapAssetId(gateway.id, managerTestSetup.area1Id, false))microphone3 = assetStorageService.merge(microphone3)then: "an exception should be thrown"thrown(IllegalStateException)+ when: "an asset with a type unknown on the central instance is added on the gateway"+ // We simulate this as both edge and central are in the same instance here in the test+ def msgEvent = new AssetEvent(+ AssetEvent.Cause.CREATE,+ new BuildingAsset("UnknownAssetType")+ .setId(UniqueIdentifierGenerator.generateId()),+ null+ )+ msgEvent.asset.type = "CustomBuildingAsset"+ gatewayClientService.sendCentralManagerMessage(gatewayConnection.getLocalRealm(), gatewayClientService.messageToString(SharedEvent.MESSAGE_PREFIX, msgEvent))++ then: "it should be added to the central instance as a thing asset"+ conditions.eventually {+ def mirroredCustomAssetType = assetStorageService.find(mapAssetId(gateway.id, msgEvent.asset.id, false))+ assert mirroredCustomAssetType != null+ assert mirroredCustomAssetType instanceof UnknownAsset+ assert mirroredCustomAssetType.type == "CustomBuildingAsset"+ }+when: "an attribute is updated on the gateway client"assetProcessingService.sendAttributeEvent(new AttributeEvent(microphone2.id, "test", "newValue"))@@ -885,7 +905,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {conditions.eventually {def mirroredMicrophone2 = assetStorageService.find(mapAssetId(gateway.id, microphone2.id, false))assert mirroredMicrophone2 != null- assert mirroredMicrophone2.getAttribute("test").flatMap{it.getValue()}.orElse("") == "newValue"+ assert mirroredMicrophone2.getAttribute("test").flatMap { it.getValue() }.orElse("") == "newValue"}when: "time advances"@@ -900,8 +920,8 @@ class GatewayTest extends Specification implements ManagerContainerTrait {def mirroredMicrophone2 = assetStorageService.find(mapAssetId(gateway.id, microphone2.id, false))assert microphone2 != nullassert mirroredMicrophone2 != null- assert microphone2.getAttribute("test").flatMap{it.getValue()}.orElse("") == "newerValue"- assert mirroredMicrophone2.getAttribute("test").flatMap{it.getValue()}.orElse("") == "newerValue"+ assert microphone2.getAttribute("test").flatMap { it.getValue() }.orElse("") == "newerValue"+ assert mirroredMicrophone2.getAttribute("test").flatMap { it.getValue() }.orElse("") == "newerValue"}when: "we subscribe to attribute events"@@ -917,10 +937,10 @@ class GatewayTest extends Specification implements ManagerContainerTrait {then: "only four attribute events should have been generated, one for each of light1 and light2 and one for each of their mirrored assets below the gateway asset"delayedConditions.eventually {assert attributeEvents.size() == 4- assert attributeEvents.any{it.id == managerTestSetup.light2Id && it.name == LightAsset.ON_OFF.name && it.value.orElse(false)}- assert attributeEvents.any{it.id == managerTestSetup.light1Id && it.name == LightAsset.ON_OFF.name && it.value.orElse(false)}- assert attributeEvents.any{it.id == mapAssetId(gateway.id, managerTestSetup.light2Id, false) && it.name == LightAsset.ON_OFF.name && it.value.orElse(false)}- assert attributeEvents.any{it.id == mapAssetId(gateway.id, managerTestSetup.light1Id, false) && it.name == LightAsset.ON_OFF.name && it.value.orElse(false)}+ assert attributeEvents.any { it.id == managerTestSetup.light2Id && it.name == LightAsset.ON_OFF.name && it.value.orElse(false) }+ assert attributeEvents.any { it.id == managerTestSetup.light1Id && it.name == LightAsset.ON_OFF.name && it.value.orElse(false) }+ assert attributeEvents.any { it.id == mapAssetId(gateway.id, managerTestSetup.light2Id, false) && it.name == LightAsset.ON_OFF.name && it.value.orElse(false) }+ assert attributeEvents.any { it.id == mapAssetId(gateway.id, managerTestSetup.light1Id, false) && it.name == LightAsset.ON_OFF.name && it.value.orElse(false) }}when: "a gateway client asset is deleted"@@ -936,7 +956,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {gatewayConnection.setAttributeFilters([new GatewayAttributeFilter().setMatcher(new AssetQuery().types(LightAsset.class)).setValueChange(true),new GatewayAttributeFilter().setMatcher(new AssetQuery().types(PeopleCounterAsset.class).attributeNames(PeopleCounterAsset.COUNT_TOTAL.name, PeopleCounterAsset.COUNT_GROWTH_PER_MINUTE.name))- .setDelta(1.5d),+ .setDelta(1.5d),new GatewayAttributeFilter().setMatcher(new AssetQuery().names("Microphone 2")).setDuration("PT1M"),// Ignore any other attributenew GatewayAttributeFilter().setSkipAlways(true)@@ -951,7 +971,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {GatewayConnector connector = gatewayService.gatewayConnectorMap.get(gateway.getId().toLowerCase(Locale.ROOT))assert connector != nullassert !connector.initialSyncInProgress- assert attributeEvents.any{it.id == gateway.id && it.value.get() == ConnectionStatus.CONNECTED}+ assert attributeEvents.any { it.id == gateway.id && it.value.get() == ConnectionStatus.CONNECTED }}when: "an attribute event occurs in the edge gateway realm for an attribute with a value change filter and the attribute value has not changed"@@ -960,8 +980,8 @@ class GatewayTest extends Specification implements ManagerContainerTrait {then: "the value should not have been forwarded to the central instance"delayedConditions.eventually {- assert attributeEvents.any{it.id == managerTestSetup.light2Id && it.name == LightAsset.ON_OFF.name && it.value.orElse(false)}- assert !attributeEvents.any{it.id == mapAssetId(gateway.id, managerTestSetup.light2Id, false) && it.name == LightAsset.ON_OFF.name}+ assert attributeEvents.any { it.id == managerTestSetup.light2Id && it.name == LightAsset.ON_OFF.name && it.value.orElse(false) }+ assert !attributeEvents.any { it.id == mapAssetId(gateway.id, managerTestSetup.light2Id, false) && it.name == LightAsset.ON_OFF.name }}when: "an attribute event occurs in the edge gateway realm for an attribute with a value change filter and the attribute value has changed"@@ -972,9 +992,9 @@ class GatewayTest extends Specification implements ManagerContainerTrait {conditions.eventually {def mirroredLight2 = assetStorageService.find(mapAssetId(gateway.id, managerTestSetup.light2Id, false))assert mirroredLight2 != null- assert !mirroredLight2.getAttribute(LightAsset.ON_OFF).flatMap{it.getValue()}.orElse(true)- assert attributeEvents.any{it.id == managerTestSetup.light2Id && it.name == LightAsset.ON_OFF.name && !it.value.orElse(true)}- assert attributeEvents.any{it.id == mapAssetId(gateway.id, managerTestSetup.light2Id, false) && it.name == LightAsset.ON_OFF.name && !it.value.orElse(true)}+ assert !mirroredLight2.getAttribute(LightAsset.ON_OFF).flatMap { it.getValue() }.orElse(true)+ assert attributeEvents.any { it.id == managerTestSetup.light2Id && it.name == LightAsset.ON_OFF.name && !it.value.orElse(true) }+ assert attributeEvents.any { it.id == mapAssetId(gateway.id, managerTestSetup.light2Id, false) && it.name == LightAsset.ON_OFF.name && !it.value.orElse(true) }}when: "an attribute event occurs in the edge gateway realm for an attribute with a delta filter and the attribute value has changed by less than delta"@@ -983,8 +1003,8 @@ class GatewayTest extends Specification implements ManagerContainerTrait {then: "the value should not have been forwarded to the central instance"delayedConditions.eventually {- assert attributeEvents.any{it.id == managerTestSetup.peopleCounter1AssetId && it.name == PeopleCounterAsset.COUNT_GROWTH_PER_MINUTE.name && Math.abs(it.value.orElse(0d) - 0.5d) < 0.000001d}- assert !attributeEvents.any{it.id == mapAssetId(gateway.id, managerTestSetup.peopleCounter1AssetId, false) && it.name == PeopleCounterAsset.COUNT_GROWTH_PER_MINUTE.name}+ assert attributeEvents.any { it.id == managerTestSetup.peopleCounter1AssetId && it.name == PeopleCounterAsset.COUNT_GROWTH_PER_MINUTE.name && Math.abs(it.value.orElse(0d) - 0.5d) < 0.000001d }+ assert !attributeEvents.any { it.id == mapAssetId(gateway.id, managerTestSetup.peopleCounter1AssetId, false) && it.name == PeopleCounterAsset.COUNT_GROWTH_PER_MINUTE.name }}when: "an attribute event occurs in the edge gateway realm for an attribute with a delta filter and the attribute value has changed by more than delta"@@ -993,8 +1013,8 @@ class GatewayTest extends Specification implements ManagerContainerTrait {then: "the value should have been forwarded to the central instance"conditions.eventually {- assert attributeEvents.any{it.id == managerTestSetup.peopleCounter1AssetId && it.name == PeopleCounterAsset.COUNT_GROWTH_PER_MINUTE.name && Math.abs(it.value.orElse(0d) + 1.1d) < 0.000001d}- assert attributeEvents.any{it.id == mapAssetId(gateway.id, managerTestSetup.peopleCounter1AssetId, false) && it.name == PeopleCounterAsset.COUNT_GROWTH_PER_MINUTE.name && Math.abs(it.value.orElse(0d) + 1.1d) < 0.000001d}+ assert attributeEvents.any { it.id == managerTestSetup.peopleCounter1AssetId && it.name == PeopleCounterAsset.COUNT_GROWTH_PER_MINUTE.name && Math.abs(it.value.orElse(0d) + 1.1d) < 0.000001d }+ assert attributeEvents.any { it.id == mapAssetId(gateway.id, managerTestSetup.peopleCounter1AssetId, false) && it.name == PeopleCounterAsset.COUNT_GROWTH_PER_MINUTE.name && Math.abs(it.value.orElse(0d) + 1.1d) < 0.000001d }}when: "an attribute event occurs in the edge gateway realm for an attribute with a duration filter"@@ -1004,8 +1024,8 @@ class GatewayTest extends Specification implements ManagerContainerTrait {then: "the value should have been forwarded to the central instance (as no prior value has been sent since the filter was created)"conditions.eventually {- assert attributeEvents.any{it.id == microphone2.id && it.name == MicrophoneAsset.SOUND_LEVEL.name && Math.abs(it.value.orElse(0d) - 50d) < 0.000001d}- assert attributeEvents.any{it.id == mapAssetId(gateway.id, microphone2.id, false) && it.name == MicrophoneAsset.SOUND_LEVEL.name && Math.abs(it.value.orElse(0d) - 50d) < 0.000001d}+ assert attributeEvents.any { it.id == microphone2.id && it.name == MicrophoneAsset.SOUND_LEVEL.name && Math.abs(it.value.orElse(0d) - 50d) < 0.000001d }+ assert attributeEvents.any { it.id == mapAssetId(gateway.id, microphone2.id, false) && it.name == MicrophoneAsset.SOUND_LEVEL.name && Math.abs(it.value.orElse(0d) - 50d) < 0.000001d }}when: "an attribute event occurs in the edge gateway realm for the same attribute before the duration filter has elapsed"@@ -1014,8 +1034,8 @@ class GatewayTest extends Specification implements ManagerContainerTrait {then: "the value should not have been forwarded to the central instance"delayedConditions.eventually {- assert attributeEvents.any{it.id == microphone2.id && it.name == MicrophoneAsset.SOUND_LEVEL.name && Math.abs(it.value.orElse(0d) - 60d) < 0.000001d}- assert !attributeEvents.any{it.id == mapAssetId(gateway.id, microphone2.id, false) && it.name == MicrophoneAsset.SOUND_LEVEL.name}+ assert attributeEvents.any { it.id == microphone2.id && it.name == MicrophoneAsset.SOUND_LEVEL.name && Math.abs(it.value.orElse(0d) - 60d) < 0.000001d }+ assert !attributeEvents.any { it.id == mapAssetId(gateway.id, microphone2.id, false) && it.name == MicrophoneAsset.SOUND_LEVEL.name }}when: "an attribute event occurs in the edge gateway realm for an attribute that matches the catch all and skip filter"@@ -1024,8 +1044,8 @@ class GatewayTest extends Specification implements ManagerContainerTrait {then: "the value should not have been forwarded to the central instance"delayedConditions.eventually {- assert attributeEvents.any{it.id == managerTestSetup.area1Id && it.name == Asset.NOTES.name && "Some test notes".equals(it.value.orElse(null))}- assert !attributeEvents.any{it.id == mapAssetId(gateway.id, managerTestSetup.area1Id, false) && it.name == Asset.NOTES.name}+ assert attributeEvents.any { it.id == managerTestSetup.area1Id && it.name == Asset.NOTES.name && "Some test notes".equals(it.value.orElse(null)) }+ assert !attributeEvents.any { it.id == mapAssetId(gateway.id, managerTestSetup.area1Id, false) && it.name == Asset.NOTES.name }}cleanup: "Remove any subscriptions created"@@ -1095,4 +1115,130 @@ class GatewayTest extends Specification implements ManagerContainerTrait {client.close()}}++ def "Verify GatewayAssetSyncRules"() {++ given: "the container environment is started"+ def conditions = new PollingConditions(timeout: 30, delay: 0.2)+ def delayedConditions = new PollingConditions(initialDelay: 1, delay: 1, timeout: 10)+ def container = startContainer(defaultConfig(), defaultServices())+ def timerService = container.getService(TimerService.class)+ def assetProcessingService = container.getService(AssetProcessingService.class)+ def assetStorageService = container.getService(AssetStorageService.class)+ def gatewayService = container.getService(GatewayService.class)+ def gatewayClientService = container.getService(GatewayClientService.class)+ def agentService = container.getService(AgentService.class)+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)+ def clientEventService = container.getService(ClientEventService.class)++ and: "an authenticated admin user"+ def accessToken = authenticate(+ container,+ MASTER_REALM,+ KEYCLOAK_CLIENT_ID,+ MASTER_REALM_ADMIN_USER,+ getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)+ ).token++ and: "the gateway client resource"+ def gatewayClientResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(GatewayClientResource.class)++ expect: "the system should settle down"+ conditions.eventually {+ assert noEventProcessedIn(assetProcessingService, 300)+ }++ when: "a gateway asset is provisioned in this manager in the building realm"+ GatewayAsset gateway = assetStorageService.merge(new GatewayAsset("Test gateway")+ .setRealm(managerTestSetup.realmBuildingName))++ then: "a set of credentials should have been created for this gateway and be stored against the gateway for easy reference"+ conditions.eventually {+ gateway = assetStorageService.find(gateway.getId(), true) as GatewayAsset+ assert !isNullOrEmpty(gateway.getClientId().orElse(null))+ assert !isNullOrEmpty(gateway.getClientSecret().orElse(null))+ }++ and: "a gateway connector should have been created for this gateway"+ conditions.eventually {+ assert gatewayService.gatewayConnectorMap.size() == 1+ assert gatewayService.gatewayConnectorMap.get(gateway.getId().toLowerCase(Locale.ROOT)).gatewayId == gateway.getId()+ }++ when: "a gateway client connection is created to connect the city realm to the gateway in the building realm"+ def gatewayConnection = new GatewayConnection(+ managerTestSetup.realmCityName,+ "127.0.0.1",+ serverPort,+ managerTestSetup.realmBuildingName,+ gateway.getClientId().orElse(""),+ gateway.getClientSecret().orElse(""),+ false,+ null,+ [+ "*" : new GatewayAssetSyncRule().setExcludeAttributeMeta([+ "*": [+ ACCESS_PUBLIC_READ.name,+ ACCESS_PUBLIC_WRITE.name,+ STORE_DATA_POINTS.name+ ]+ ]).setAddAttributeMeta([+ "*": new MetaMap([+ new MetaItem<>(ACCESS_RESTRICTED_READ, true)+ ])+ ]).setExcludeAttributes([+ Asset.NOTES.name+ ]),+ "LightAsset" : new GatewayAssetSyncRule().setExcludeAttributeMeta([+ "*": [+ ATTRIBUTE_LINKS.name,+ ACCESS_PUBLIC_WRITE.name,+ FORMAT.name+ ]+ ]).setAddAttributeMeta([+ "onOff" : new MetaMap([+ new MetaItem<>(FORMAT, ValueFormat.BOOLEAN_AS_PRESSED_RELEASED())+ ])+ ]).setExcludeAttributes([+ LightAsset.COLOUR_RGB.name+ ])+ ] as Map<String, GatewayAssetSyncRule>,+ false+ )+ gatewayClientResource.setConnection(null, managerTestSetup.realmCityName, gatewayConnection)++ then: "the gateway client should become connected"+ conditions.eventually {+ assert gatewayClientService.clientRealmMap.get(managerTestSetup.realmCityName) != null+ }++ and: "the gateway asset connection status should become CONNECTED"+ conditions.eventually {+ gateway = assetStorageService.find(gateway.getId())+ assert gateway.getGatewayStatus().orElse(null) == ConnectionStatus.CONNECTED+ }++ and: "the assets should have been created under the gateway asset"+ conditions.eventually {+ def gatewayAssets = assetStorageService.findAll(new AssetQuery().parents(gateway.id).recursive(true))+ def cityAssets = assetStorageService.findAll(new AssetQuery().realm(new RealmPredicate(managerTestSetup.realmCityName)))+ assert gatewayAssets.size() == cityAssets.size()+ }++ and: "the asset sync rules should have been applied"+ conditions.eventually {+ def mirroredMicrophone = assetStorageService.find(mapAssetId(gateway.id, managerTestSetup.microphone1Id, false))+ def mirroredLight = assetStorageService.find(mapAssetId(gateway.id, managerTestSetup.light1Id, false))+ assert mirroredMicrophone != null+ assert mirroredLight != null+ assert mirroredMicrophone.getAttributes().get(MicrophoneAsset.SOUND_LEVEL).flatMap { it.getMetaItem(READ_ONLY) }.flatMap { it.getValue() }.orElse(false)+ assert mirroredMicrophone.getAttributes().get(MicrophoneAsset.SOUND_LEVEL).flatMap { it.getMetaItem(ACCESS_RESTRICTED_READ) }.flatMap { it.getValue() }.orElse(false)+ assert !mirroredMicrophone.getAttributes().get(MicrophoneAsset.SOUND_LEVEL).flatMap { it.getMetaItem(STORE_DATA_POINTS) }.flatMap { it.getValue() }.orElse(false)+ assert mirroredMicrophone.getAttributes().get(MicrophoneAsset.LOCATION).flatMap { it.getMetaItem(ACCESS_RESTRICTED_READ) }.flatMap { it.getValue() }.orElse(false)+ assert !mirroredMicrophone.getAttribute(Asset.NOTES).isPresent()+ assert mirroredLight.getAttributes().get(LightAsset.ON_OFF).flatMap { it.getMetaItem(FORMAT) }.flatMap { it.getValue() }.map {it.asPressedReleased}.orElse(false) == ValueFormat.BOOLEAN_AS_PRESSED_RELEASED().asPressedReleased+ assert !mirroredLight.getAttribute(LightAsset.COLOUR_RGB).isPresent()+ assert mirroredLight.getAttribute(Asset.NOTES).isPresent()+ }+ }}diff --git a/ui/app/manager/src/pages/page-gateway.ts b/ui/app/manager/src/pages/page-gateway.tsindex 428f1cec7..0dd4b7636 100644--- a/ui/app/manager/src/pages/page-gateway.ts+++ b/ui/app/manager/src/pages/page-gateway.ts@@ -6,7 +6,7 @@ import {until} from "lit/directives/until.js";import {createRef, Ref, ref} from "lit/directives/ref.js";import "@openremote/or-components/or-panel";import {OrMwcDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";-import {AttributeDescriptor, AttributePredicate, ClientRole, ConnectionStatus, GatewayAttributeFilter, GatewayConnection, GatewayConnectionStatusEvent, LogicGroupOperator} from "@openremote/model";+import {AttributeDescriptor, AttributePredicate, ClientRole, ConnectionStatus, GatewayAttributeFilter, GatewayConnection, GatewayConnectionStatusEvent, LogicGroupOperator, GatewayAssetSyncRule} from "@openremote/model";import manager, {DefaultColor1, DefaultColor3} from "@openremote/core";import {InputType, OrInputChangedEvent} from "@openremote/or-mwc-components/or-mwc-input";import {AppStateKeyed, Page, PageProvider} from "@openremote/or-app";@@ -90,6 +90,7 @@ export class PageGateway extends Page<AppStateKeyed> {width: calc(100% - 40px);max-width: 1360px;margin: 0 auto 16px;+ --or-panel-heading-text-transform: uppercase;}.gateway-status-header {@@ -244,7 +245,7 @@ export class PageGateway extends Page<AppStateKeyed> {${until(this._getTitleTemplate(connection, this._connectionStatus, disabled))}- <or-panel ?disabled="${disabled}" .heading="${i18next.t("connectionDetails")}">+ <or-panel ?disabled="${disabled}" .heading="${i18next.t("gateway.connectionDetails")}">${when(this._connectionStatus, () => html`<div class="gateway-status-header"><or-translate value="status" style="font-weight: normal;"></or-translate>:@@ -254,13 +255,17 @@ export class PageGateway extends Page<AppStateKeyed> {${until(this._getContentTemplate(() => this._getSettingsColumns(connection, disabled)))}</or-panel>- <or-panel ?disabled="${disabled}" heading="${i18next.t("dataSharing")}">+ <or-panel ?disabled="${disabled}" heading="${i18next.t("gateway.dataSharing")}"><div class="gateway-status-header"><or-mwc-input .type="${InputType.BUTTON}" label="JSON" outlined icon="pencil"@or-mwc-input-changed="${() => this._openConnectionJSONEditor(connection)}"></or-mwc-input></div>${until(this._getContentTemplate(() => this._getDataSharingColumns(connection, this._isDataSharingCustom(connection), disabled)))}+ </or-panel>++ <or-panel ?disabled="${disabled}" heading="${i18next.t("gateway.assetSyncRules")}">+ ${until(this._getContentTemplate(() => this._getAssetSyncRulesColumns(connection, disabled)))}</or-panel></div>`;@@ -373,7 +378,28 @@ export class PageGateway extends Page<AppStateKeyed> {<or-translate value="gateway.limit_sharing_rate_suffix"></or-translate></div></div>- <div></div>+ </div>+ `;+ }++ protected async _getAssetSyncRulesColumns(connection: GatewayConnection, disabled = true): Promise<TemplateResult> {+ const controlStyling = disabled ? "--mdc-theme-text-primary-on-background: lightgray; color: lightgray" : undefined;+ return html`+ <div id="gateway-column-4" class="gateway-column">+ <div class="gateway-sharing-control" style="${controlStyling}">+ <or-mwc-input .label="${i18next.t("gateway.assetSyncRulesEnable")}" .type="${InputType.CHECKBOX}"+ ?disabled="${disabled}" .value="${!!connection.assetSyncRules}"+ @or-mwc-input-changed="${(e: OrInputChangedEvent) => this._onAssetSyncRulesToggle(!!e.detail.value)}"+ ></or-mwc-input>+ <div class="gateway-sharing-control-child">+ <or-mwc-input .type="${InputType.JSON_OBJECT}" ?disabled="${disabled || !connection.assetSyncRules}"+ .value="${connection?.assetSyncRules}"+ resizevertical+ @or-mwc-input-changed="${(e: OrInputChangedEvent) => this._setConnectionProperty("assetSyncRules", e.detail.value)}"+ .label="${i18next.t('gateway.assetSyncRulesInput')}" style="width: 100%;"></or-mwc-input>+ <or-translate value=""></or-translate>+ </div>+ </div></div>`;}@@ -460,6 +486,44 @@ export class PageGateway extends Page<AppStateKeyed> {this._updateAttributeFilters(attributeFilters);}+ protected _onAssetSyncRulesToggle(enabled: boolean) {+ if (!enabled) {+ this._setConnectionProperty("assetSyncRules", undefined);+ } else {+ this._setConnectionProperty("assetSyncRules", this._getDefaultGatewayAssetSyncRules());+ }+ }++ /**+ * HTML callback for when the GatewayAssetSyncRules updates.+ */+ protected _onAssetSyncRulesUpdated(syncRules?: { [index: string]: GatewayAssetSyncRule }) {+ this._setConnectionProperty("assetSyncRules", syncRules);+ }++ protected _getDefaultGatewayAssetSyncRules(): { [index: string]: GatewayAssetSyncRule } {+ return {+ "*" : {+ excludeAttributeMeta: {+ "*": [+ "accessPublicRead",+ "accessPublicWrite",+ "accessRestrictedRead",+ "accessRestrictedWrite"+ ]+ },+ addAttributeMeta: {+ "*": {+ "storeDataPoints": true+ }+ },+ excludeAttributes: [+ "notes"+ ]+ }+ }+ }+/*** Internal function that returns a map of {@link AttributeDescriptor[]}, based on the {@link GatewayAttributeFilter}.* Mainly meant for the attribute-picker, as it uses AttributeDescriptors instead.diff --git a/ui/app/shared/locales/ar/or.json b/ui/app/shared/locales/ar/or.jsonindex 013c46c56..f0cd782c2 100644--- a/ui/app/shared/locales/ar/or.json+++ b/ui/app/shared/locales/ar/or.json@@ -236,8 +236,10 @@"GROOVY": "Groovy","JAVASCRIPT": "JavaScript"},- "gatewayConnection": "إدارة الإتصال الداخلي ",- "connectionDetails": "معلومات الإتصال",+ "gateway": {+ "": "إدارة الإتصال الداخلي ",+ "connectionDetails": "معلومات الإتصال"+ },"secured": "محمي","clientSecret": "كلمة سر المستخدم","clientId": "الرقم التعريقي للمستخدم",diff --git a/ui/app/shared/locales/cn/or.json b/ui/app/shared/locales/cn/or.jsonindex 4fb3fbc2f..876dc1977 100644--- a/ui/app/shared/locales/cn/or.json+++ b/ui/app/shared/locales/cn/or.json@@ -251,8 +251,10 @@"GROOVY": "Groovy","JAVASCRIPT": "JavaScript"},- "gatewayConnection": "管理器互联",- "connectionDetails": "连接详情",+ "gateway": {+ "": "管理器互联",+ "connectionDetails": "连接详情"+ },"secured": "安全","clientSecret": "客户端密钥","clientId": "客户端标识",diff --git a/ui/app/shared/locales/de/or.json b/ui/app/shared/locales/de/or.jsonindex 19cfacf3a..68d380a33 100644--- a/ui/app/shared/locales/de/or.json+++ b/ui/app/shared/locales/de/or.json@@ -270,8 +270,10 @@"GROOVY": "Groovy","JAVASCRIPT": "JavaScript"},- "gatewayConnection": "Manager verbindung",- "connectionDetails": "VERBINDUNGSDETAILS",+ "gateway": {+ "": "Manager verbindung",+ "connectionDetails": "Verbindungsdetails"+ },"secured": "Gesichert","clientSecret": "Client secret","clientId": "Client ID",diff --git a/ui/app/shared/locales/en/or.json b/ui/app/shared/locales/en/or.jsonindex 1785ebde4..d83d803dd 100644--- a/ui/app/shared/locales/en/or.json+++ b/ui/app/shared/locales/en/or.json@@ -348,11 +348,16 @@"gatewayConnection": "Manager interconnect","gateway": {"": "Manager interconnect",+ "connectionDetails": "Connection details",+ "dataSharing": "Data sharing",+ "assetSyncRules": "Asset synchronization","limit_sharing_is_custom_error": "An advanced data limiting configuration is set. To modify click the JSON button. Clear it to use the fields below.","limit_sharing_attribute": "Limit data sharing by asset type attributes","limit_sharing_attribute_selected": "attributes selected","limit_sharing_rate": "Limit the rate of how often attribute value updates are shared",- "limit_sharing_rate_suffix": "minutes interval"+ "limit_sharing_rate_suffix": "minutes interval",+ "assetSyncRulesEnable": "Customize asset synchronization",+ "assetSyncRulesInput": "Synchronization config"},"gatewayTunnel": "Gateway tunnels","gatewayTunnels": {@@ -378,8 +383,6 @@},"tunnels": "tunnels","tunnel": "tunnel",- "connectionDetails": "CONNECTION DETAILS",- "dataSharing": "DATA SHARING","secured": "Secured","clientSecret": "Client secret","clientId": "Client ID",diff --git a/ui/app/shared/locales/es/or.json b/ui/app/shared/locales/es/or.jsonindex c069584cd..a617bec6b 100644--- a/ui/app/shared/locales/es/or.json+++ b/ui/app/shared/locales/es/or.json@@ -254,8 +254,10 @@"GROOVY": "Groovy","JAVASCRIPT": "JavaScript"},- "gatewayConnection": "Interconexión del Manager",- "connectionDetails": "DETALLES DE CONEXIÓN",+ "gateway": {+ "": "Interconexión del Manager",+ "connectionDetails": "DETALLES DE CONEXIÓN"+ },"secured": "Asegurado","clientSecret": "Secreto del cliente","clientId": "ID del cliente",diff --git a/ui/app/shared/locales/fr/or.json b/ui/app/shared/locales/fr/or.jsonindex e199dd897..e331b5431 100644--- a/ui/app/shared/locales/fr/or.json+++ b/ui/app/shared/locales/fr/or.json@@ -254,8 +254,10 @@"GROOVY": "Groovy","JAVASCRIPT": "JavaScript"},- "gatewayConnection": "Interconnexion du Manager",- "connectionDetails": "DÉTAILS DE CONNEXION",+ "gateway": {+ "": "Interconnexion du Manager",+ "connectionDetails": "DÉTAILS DE CONNEXION"+ },"secured": "Sécurisé","clientSecret": "Secret du client","clientId": "ID du client",@@ -469,4 +471,4 @@"attributeValueLabel": "Attribute value","assetTypeDoesNotExist": "Filter : Asset type does not exist"}-}+},diff --git a/ui/app/shared/locales/it/or.json b/ui/app/shared/locales/it/or.jsonindex 508e08444..b4163125f 100644--- a/ui/app/shared/locales/it/or.json+++ b/ui/app/shared/locales/it/or.json@@ -249,8 +249,10 @@"GROOVY": "Groovy","JAVASCRIPT": "JavaScript"},- "gatewayConnection": "Manager del gateway",- "connectionDetails": "DETTAGLI DELLA CONNESSIONE",+ "gateway": {+ "": "Manager del gateway",+ "connectionDetails": "DETTAGLI DELLA CONNESSIONE"+ },"secured": "Assicurato","clientSecret": "Segreto del cliente","clientId": "ID Client",@@ -466,4 +468,4 @@"attributeValueLabel": "Attribute value","assetTypeDoesNotExist": "Filter : Asset type does not exist"}-}+},diff --git a/ui/app/shared/locales/nl/or.json b/ui/app/shared/locales/nl/or.jsonindex 908b0a771..17ceb3920 100644--- a/ui/app/shared/locales/nl/or.json+++ b/ui/app/shared/locales/nl/or.json@@ -347,11 +347,16 @@"gatewayConnection": "Manager interconnect","gateway": {"": "Manager interconnect",+ "connectionDetails": "Connectie details",+ "dataSharing": "Data delen",+ "assetSyncRules": "Asset synchronisatie","limit_sharing_is_custom_error": "Een aangepaste configuratie is ingesteld. Klik op JSON om deze aan te passen. Maak de configuratie leeg om de velden hieronder te gebruiken.","limit_sharing_attribute": "Begrens welke attributen van asset types worden gedeeld","limit_sharing_types_selected": "asset types geselecteerd",- "limit_sharing_rate": "Begrens hoevaak attribuut waarden worden bijgewerkt",- "limit_sharing_rate_suffix": "minuten interval"+ "limit_sharing_rate": "Begrens hoe vaak attribuutwaarden worden bijgewerkt",+ "limit_sharing_rate_suffix": "minuten interval",+ "assetSyncRulesEnable": "Asset synchronisatie aanpassen",+ "assetSyncRulesInput": "Synchronisatie configuratie"},"gatewayTunnel": "Gateway tunnels","gatewayTunnels": {@@ -375,7 +380,6 @@},"tunnels": "tunnels","tunnel": "tunnel",- "connectionDetails": "CONNECTIE DETAILS","secured": "Beveiligd","clientSecret": "Client wachtwoord","clientId": "Client ID",diff --git a/ui/app/shared/locales/pt/or.json b/ui/app/shared/locales/pt/or.jsonindex 877e351f2..f0f6fa522 100644--- a/ui/app/shared/locales/pt/or.json+++ b/ui/app/shared/locales/pt/or.json@@ -252,8 +252,10 @@"GROOVY": "Groovy","JAVASCRIPT": "JavaScript"},- "gatewayConnection": "Manager interconectar",- "connectionDetails": "Detalhes de conexão",+ "gateway": {+ "": "Manager interconectar",+ "connectionDetails": "Detalhes de conexão"+ },"secured": "Seguro","clientSecret": "Segredo do cliente","clientId": "ID do Cliente",@@ -455,4 +457,4 @@"attributeValueLabel": "Attribute value","assetTypeDoesNotExist": "Filter : Asset type does not exist"}-}+},diff --git a/ui/app/shared/locales/ro/or.json b/ui/app/shared/locales/ro/or.jsonindex 155daacc6..807fcc61b 100644--- a/ui/app/shared/locales/ro/or.json+++ b/ui/app/shared/locales/ro/or.json@@ -330,9 +330,10 @@"GROOVY": "Groovy","JAVASCRIPT": "JavaScript"},- "gatewayConnection": "Interconectare manager",- "gateway": "Interconectare manager",- "connectionDetails": "DETALIILE CONEXIUNII",+ "gateway": {+ "": "Interconectare manager",+ "connectionDetails": "DETALIILE CONEXIUNII"+ },"secured": "Securizat","clientSecret": "Codul secret al Clientului","clientId": "ID-ul Clientului",@@ -713,4 +714,4 @@"saveRealmSucceeded": "Domeniul a fost salvat cu succes!","userDisconnected": "Deconectare cu succes!","userDisconnectFailed": "Deconectare eșuată"-}+},diff --git a/ui/app/shared/locales/uk/or.json b/ui/app/shared/locales/uk/or.jsonindex a2ede388a..87b889507 100644--- a/ui/app/shared/locales/uk/or.json+++ b/ui/app/shared/locales/uk/or.json@@ -335,9 +335,10 @@"GROOVY": "Groovy","JAVASCRIPT": "JavaScript"},- "gatewayConnection": "З'єднання з менеджером",- "gateway": "З'єднання з менеджером",- "connectionDetails": "Деталі підключення",+ "gateway": {+ "": "З'єднання з менеджером",+ "connectionDetails": "Деталі підключення"+ },"secured": "Захищено","clientSecret": "Секрет клієнта","clientId": "Client ID",@@ -755,4 +756,4 @@"AVG": "Середнє (середнє значення)","MIN": "Мінімум","MAX": "Максимум"-}+},diff --git a/ui/component/or-components/src/or-panel.ts b/ui/component/or-components/src/or-panel.tsindex 608333070..c7a1a1538 100644--- a/ui/component/or-components/src/or-panel.ts+++ b/ui/component/or-components/src/or-panel.ts@@ -20,7 +20,7 @@ const style = css`--internal-or-panel-heading-color: var(--or-panel-heading-color, var(--or-app-color3, ${unsafeCSS(DefaultColor3)}));--internal-or-panel-heading-font-size: var(--or-panel-heading-font-size, larger);--internal-or-panel-heading-font-weight: var(--or-panel-heading-font-weight, bolder);-+ --internal-or-panel-heading-text-transform: var(--or-panel-heading-text-transform, unset);display: block;}@@ -48,6 +48,7 @@ const style = css`font-size: var(--internal-or-panel-heading-font-size);font-weight: var(--internal-or-panel-heading-font-weight);color: var(--internal-or-panel-heading-color);+ text-transform: var(--internal-or-panel-heading-text-transform);}`;