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
Location update/refactor. WIP
Michael Rademakerdb4d83dc7d1b
diff --git a/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.javaindex e5fe3d81c..1cdf5171a 100644--- a/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java@@ -19,9 +19,6 @@*/package org.openremote.agent.protocol;-import com.vividsolutions.jts.geom.Coordinate;-import com.vividsolutions.jts.geom.GeometryFactory;-import com.vividsolutions.jts.geom.Point;import org.apache.camel.ProducerTemplate;import org.apache.camel.builder.RouteBuilder;import org.openremote.agent.protocol.filter.MessageFilter;@@ -40,7 +37,9 @@ import org.openremote.model.asset.agent.ConnectionStatus;import org.openremote.model.asset.agent.ProtocolConfiguration;import org.openremote.model.asset.agent.ProtocolDescriptor;import org.openremote.model.attribute.*;-import org.openremote.model.value.*;+import org.openremote.model.value.Value;+import org.openremote.model.value.ValueType;+import org.openremote.model.value.Values;import java.util.*;import java.util.concurrent.TimeUnit;@@ -67,7 +66,7 @@ import static org.openremote.container.concurrent.GlobalLock.withLockReturning;* return ...;* });* }</pre></blockquote>- *+ * <p>* All <code>abstract</code> methods are always called within lock scope. An implementation can rely on this lock* and safely modify internal, protocol-specific shared state. However, if a protocol implementation schedules* an asynchronous task, this task must obtain the lock to call any protocol operations.@@ -112,7 +111,6 @@ public abstract class AbstractProtocol implements Protocol {protected final Map<AttributeRef, AssetAttribute> linkedAttributes = new HashMap<>();protected final Map<AttributeRef, LinkedProtocolInfo> linkedProtocolConfigurations = new HashMap<>();protected final Map<AttributeRef, List<MessageFilter>> linkedAttributeFilters = new HashMap<>();- protected final List<AttributeRef> locationLinkedAttributes = new ArrayList<>();protected MessageBrokerContext messageBrokerContext;protected ProducerTemplate producerTemplate;protected TimerService timerService;@@ -209,17 +207,12 @@ public abstract class AbstractProtocol implements Protocol {linkedAttributeFilters.put(attributeRef, mFilters);});- attribute.getMetaItem(AssetMeta.LOCATION_LINK).ifPresent(metaItem -> {- locationLinkedAttributes.add(attribute.getReferenceOrThrow());- });-try {doLinkAttribute(attribute, protocolConfiguration);} catch (Exception e) {LOG.log(Level.SEVERE, "Failed to link attribute to protocol: " + attribute, e);linkedAttributes.remove(attributeRef);linkedAttributeFilters.remove(attributeRef);- locationLinkedAttributes.remove(attributeRef);}});});@@ -233,7 +226,6 @@ public abstract class AbstractProtocol implements Protocol {AttributeRef attributeRef = attribute.getReferenceOrThrow();linkedAttributes.remove(attributeRef);linkedAttributeFilters.remove(attributeRef);- locationLinkedAttributes.remove(attributeRef);doUnlinkAttribute(attribute, protocolConfiguration);}));@@ -243,7 +235,7 @@ public abstract class AbstractProtocol implements Protocol {* Gets a linked attribute by its attribute ref*/protected AssetAttribute getLinkedAttribute(AttributeRef attributeRef) {- return withLockReturning(getProtocolName() + "::getLinkedAttribute", () -> linkedAttributes.get(attributeRef));+ return withLockReturning(getProtocolName() + "::getLinkedAttribute", () -> linkedAttributes.get(attributeRef));}/**@@ -371,36 +363,6 @@ public abstract class AbstractProtocol implements Protocol {AttributeEvent attributeEvent = new AttributeEvent(state, timestamp);LOG.fine("Sending on sensor queue: " + attributeEvent);producerTemplate.sendBodyAndHeader(SENSOR_QUEUE, attributeEvent, Protocol.SENSOR_QUEUE_SOURCE_PROTOCOL, getProtocolName());-- if (locationLinkedAttributes.contains(state.getAttributeRef())) {-- // Check value type is compatible- Point location = state.getValue().map(value -> {- if (value.getType() != ValueType.ARRAY) {- LOG.warning("Location linked attribute type is not an array");- return null;- }-- Optional<List<NumberValue>> coordinates = Values.getArrayElements((ArrayValue) value, NumberValue.class, false, false);- if (!coordinates.isPresent()- || coordinates.get().size() != 2- || Math.abs(coordinates.get().get(0).getNumber()) > 180- || Math.abs(coordinates.get().get(1).getNumber()) > 90) {- LOG.warning("Location linked attribute value must contain longitude then latitude in a 2 value number array");- return null;- }-- try {- return new GeometryFactory().createPoint(- new Coordinate(coordinates.get().get(0).getNumber(), coordinates.get().get(1).getNumber())- );- } catch (Exception e) {- return null;- }- }).orElse(null);-- updateAssetLocation(state.getAttributeRef().getEntityId(), location);- }});}@@ -412,10 +374,6 @@ public abstract class AbstractProtocol implements Protocol {updateLinkedAttribute(state, timerService.getCurrentTimeMillis());}- final protected void updateAssetLocation(String assetId, Point location) {- withLock(getProtocolName(), () -> assetService.updateAssetLocation(assetId, location));- }-/*** Update a linked protocol configuration; allows protocols to reconfigure their own protocol configurations to* persist changing data e.g. authorization tokens. First this clones the existing protocolConfiguration and callsdiff --git a/agent/src/main/java/org/openremote/agent/protocol/ProtocolAssetService.java b/agent/src/main/java/org/openremote/agent/protocol/ProtocolAssetService.javaindex c2ba46df5..24489ce48 100644--- a/agent/src/main/java/org/openremote/agent/protocol/ProtocolAssetService.java+++ b/agent/src/main/java/org/openremote/agent/protocol/ProtocolAssetService.java@@ -93,13 +93,6 @@ public interface ProtocolAssetService extends ContainerService {*/void updateProtocolConfiguration(AssetAttribute protocolConfiguration);- /**- * Protocols can update an assets location. This is generally to be used for linked attributes- * that also have a {@link AssetMeta#LOCATION_LINK} {@link MetaItem}. Set location to null to- * clear an asset's location.- */- void updateAssetLocation(String assetId, Point location);-/*** Protocols may store assets in the context or update existing assets. A unique identifier* must be set by the protocol implementor, as well as a parent identifier. This operationdiff --git a/client/src/main/java/org/openremote/app/client/assets/asset/AbstractAssetActivity.java b/client/src/main/java/org/openremote/app/client/assets/asset/AbstractAssetActivity.javaindex fe371d91b..b91f31d76 100644--- a/client/src/main/java/org/openremote/app/client/assets/asset/AbstractAssetActivity.java+++ b/client/src/main/java/org/openremote/app/client/assets/asset/AbstractAssetActivity.java@@ -204,9 +204,10 @@ public abstract class AbstractAssetActivity<Vview.getAssetNavigation().setEnabled(assetId != null);view.setName(asset.getName());view.setCreatedOn(asset.getCreatedOn());- view.setLocation(asset.getCoordinates());- view.showDroppedPin(asset.getGeoFeature(20));- view.flyTo(asset.getCoordinates());+ //TODO location update+// view.setLocation(asset.getCoordinates());+// view.showDroppedPin(asset.getGeoFeature(20));+// view.flyTo(asset.getCoordinates());view.setAccessPublicRead(asset.isAccessPublicRead());}diff --git a/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.java b/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.javaindex 5866564ae..b340194f7 100644--- a/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.java+++ b/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.java@@ -461,9 +461,11 @@ public class AssetEditActivitypublic void centerMap() {if (selectedCoordinates != null) {view.flyTo(selectedCoordinates);- } else if (asset.getCoordinates() != null) {- view.flyTo(asset.getCoordinates());}+ //TODO location update+ /*else if (asset.getCoordinates() != null) {+ view.flyTo(asset.getCoordinates());+ }*/}@Override@@ -661,7 +663,8 @@ public class AssetEditActivityasset.setType(view.getType());}if (selectedCoordinates != null) {- asset.setCoordinates(selectedCoordinates);+ //TODO location update+ //asset.setCoordinates(selectedCoordinates);}}diff --git a/client/src/main/java/org/openremote/app/client/assets/asset/AssetViewActivity.java b/client/src/main/java/org/openremote/app/client/assets/asset/AssetViewActivity.javaindex f979f7b6a..1bfbd2449 100644--- a/client/src/main/java/org/openremote/app/client/assets/asset/AssetViewActivity.java+++ b/client/src/main/java/org/openremote/app/client/assets/asset/AssetViewActivity.java@@ -164,7 +164,8 @@ public class AssetViewActivity@Overridepublic void centerMap() {- view.flyTo(asset.getCoordinates());+ //TODO location update+ //view.flyTo(asset.getCoordinates());}@Overridediff --git a/client/src/main/java/org/openremote/app/client/map/MapActivity.java b/client/src/main/java/org/openremote/app/client/map/MapActivity.javaindex 348aef649..924672166 100644--- a/client/src/main/java/org/openremote/app/client/map/MapActivity.java+++ b/client/src/main/java/org/openremote/app/client/map/MapActivity.java@@ -152,11 +152,12 @@ public class MapActivity extends AssetBrowsingActivity<MapPlace> implements MapVsuper.onStop();view.setPresenter(null);- if (asset != null && asset.hasGeoFeature() || dashboardAttributes.size() > 0) {- environment.getEventService().unsubscribe(- AttributeEvent.class- );- }+ //TODO location update+// if (asset != null && asset.hasGeoFeature() || dashboardAttributes.size() > 0) {+// environment.getEventService().unsubscribe(+// AttributeEvent.class+// );+// }}@Override@@ -172,13 +173,14 @@ public class MapActivity extends AssetBrowsingActivity<MapPlace> implements MapVnew AssetViewPlace(assetId)));showAssetOnMap();- if (asset.hasGeoFeature() || dashboardAttributes.size() > 0) {- showAssetInfoItems();- environment.getEventService().subscribe(- AttributeEvent.class,- new AttributeEvent.EntityIdFilter(asset.getId())- );- }+ //TODO location update+// if (asset.hasGeoFeature() || dashboardAttributes.size() > 0) {+// showAssetInfoItems();+// environment.getEventService().subscribe(+// AttributeEvent.class,+// new AttributeEvent.EntityIdFilter(asset.getId())+// );+// }});} else if (realmId != null) {// TODO: Tenant map not implemented@@ -186,11 +188,12 @@ public class MapActivity extends AssetBrowsingActivity<MapPlace> implements MapV}protected void showAssetOnMap() {- if (asset.hasGeoFeature()) {- GeoJSON geoFeature = asset.getGeoFeature(30);- view.showDroppedPin(geoFeature);- view.flyTo(asset.getCoordinates());- }+ //TODO location update+// if (asset.hasGeoFeature()) {+// GeoJSON geoFeature = asset.getGeoFeature(30);+// view.showDroppedPin(geoFeature);+// view.flyTo(asset.getCoordinates());+// }}protected void showAssetInfoItems() {@@ -205,14 +208,15 @@ public class MapActivity extends AssetBrowsingActivity<MapPlace> implements MapV).sorted(Comparator.comparing(MapInfoItem::getLabel)).collect(Collectors.toList());- if (asset.hasGeoFeature()) {- infoItems.add(0, new MapInfoItem(- "map-marker",- environment.getMessages().location(),- null,- Values.create(asset.getCoordinatesLabel())- ));- }+ //TODO location update+// if (asset.hasGeoFeature()) {+// infoItems.add(0, new MapInfoItem(+// "map-marker",+// environment.getMessages().location(),+// null,+// Values.create(asset.getCoordinatesLabel())+// ));+// }view.showInfoItems(infoItems);}diff --git a/manager/src/main/java/org/openremote/manager/agent/AgentResourceImpl.java b/manager/src/main/java/org/openremote/manager/agent/AgentResourceImpl.javaindex d33b7310a..00380eba0 100644--- a/manager/src/main/java/org/openremote/manager/agent/AgentResourceImpl.java+++ b/manager/src/main/java/org/openremote/manager/agent/AgentResourceImpl.java@@ -21,7 +21,6 @@ package org.openremote.manager.agent;import org.openremote.container.timer.TimerService;import org.openremote.manager.asset.AssetStorageService;-import org.openremote.manager.asset.ServerAsset;import org.openremote.manager.security.ManagerIdentityService;import org.openremote.manager.web.ManagerWebResource;import org.openremote.model.asset.agent.AgentResource;@@ -254,8 +253,8 @@ public class AgentResourceImpl extends ManagerWebResource implements AgentResourasset.setId(null);asset.setParent(parentAsset);asset.setRealmId(realmId);- ServerAsset serverAsset = ServerAsset.map(asset, new ServerAsset());- assets[i] = assetStorageService.merge(serverAsset);+ Asset newAsset = Asset.map(asset, new Asset());+ assets[i] = assetStorageService.merge(newAsset);}}}diff --git a/manager/src/main/java/org/openremote/manager/agent/AgentService.java b/manager/src/main/java/org/openremote/manager/agent/AgentService.javaindex 068af1822..ce3652a6f 100644--- a/manager/src/main/java/org/openremote/manager/agent/AgentService.java+++ b/manager/src/main/java/org/openremote/manager/agent/AgentService.java@@ -193,7 +193,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse}AttributeRef protocolRef = protocolConfiguration.getReference().get();- ServerAsset agent = assetStorageService.find(protocolRef.getEntityId(), true);+ Asset agent = assetStorageService.find(protocolRef.getEntityId(), true);if (agent == null || agent.getWellKnownType() != AssetType.AGENT || !agent.hasAttribute(protocolRef.getAttributeName())) {LOG.warning("Protocol configuration doesn't belong to a valid agent: " + protocolConfiguration);return;@@ -212,19 +212,6 @@ public class AgentService extends RouteBuilder implements ContainerService, AsseassetStorageService.merge(agent);}- @Override- public void updateAssetLocation(String assetId, Point location) {- ServerAsset asset = assetStorageService.find(assetId, true);- if (asset == null) {- LOG.warning("Asset with requested ID doesn't exist: " + assetId);- return;- }-- asset.setLocation(location);- LOG.fine("Updating asset location '" + assetId + "': " + Arrays.toString(asset.getCoordinates()));- assetStorageService.merge(asset);- }-@Overridepublic Asset mergeAsset(Asset asset) {Objects.requireNonNull(asset.getId());@@ -237,12 +224,12 @@ public class AgentService extends RouteBuilder implements ContainerService, AsseObjects.requireNonNull(asset.getId());Objects.requireNonNull(asset.getParentId());- ServerAsset updatedAsset = ServerAsset.map(asset, new ServerAsset());+ Asset updatedAsset = Asset.map(asset, new Asset());// Use the unique identifier provided by the protocol, it manages its own identifier spaceupdatedAsset.setId(asset.getId());if (options != null && (options.getIgnoredAttributeNames() != null || options.getIgnoredAttributeKeys() != null)) {- ServerAsset existingAsset = assetStorageService.find(updatedAsset.getId(), true);+ Asset existingAsset = assetStorageService.find(updatedAsset.getId(), true);if (existingAsset != null) {// Check if any attributes except the ignored ones were modifiedList<AssetAttribute> existingAttributes = existingAsset.getAttributesList();@@ -471,7 +458,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse}// Get all assets that have attributes that use this protocol configuration- List<ServerAsset> assets = assetStorageService.findAll(+ List<Asset> assets = assetStorageService.findAll(new AssetQuery().select(new AssetQuery.Select(AssetQuery.Include.ALL)).attributeMeta(@@ -501,7 +488,7 @@ public class AgentService extends RouteBuilder implements ContainerService, AsseAttributeRef protocolAttributeRef = configuration.getReferenceOrThrow();// Get all assets that have attributes that use this protocol configuration- List<ServerAsset> assets = assetStorageService.findAll(+ List<Asset> assets = assetStorageService.findAll(new AssetQuery().select(new AssetQuery.Select(AssetQuery.Include.ALL)).attributeMeta(@@ -627,7 +614,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse*/@Overridepublic boolean processAssetUpdate(EntityManager entityManager,- ServerAsset asset,+ Asset asset,AssetAttribute attribute,Source source) throws AssetProcessingException {if (source == SENSOR) {diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.java b/manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.javaindex 7e208085c..0a96fd4c8 100644--- a/manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.java+++ b/manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.java@@ -22,6 +22,7 @@ package org.openremote.manager.asset;import org.openremote.container.Container;import org.openremote.container.ContainerService;import org.openremote.manager.asset.AssetProcessingException.Reason;+import org.openremote.model.asset.Asset;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.asset.AssetMeta;import org.openremote.model.asset.AssetQuery;@@ -105,7 +106,7 @@ public class AssetAttributeLinkingService implements ContainerService, AssetUpda@Overridepublic boolean processAssetUpdate(EntityManager em,- ServerAsset asset,+ Asset asset,AssetAttribute attribute,Source source) throws AssetProcessingException {if (source == ATTRIBUTE_LINKING_SERVICE) {@@ -231,7 +232,7 @@ public class AssetAttributeLinkingService implements ContainerService, AssetUpdaprotected static Value getCurrentValue(EntityManager em,AssetStorageService assetStorageService,AttributeRef attributeRef) throws NoSuchElementException {- ServerAsset asset = assetStorageService.find(+ Asset asset = assetStorageService.find(em,new AssetQuery().id(attributeRef.getEntityId())diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java b/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.javaindex 69719065c..8189eba9e 100644--- a/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java+++ b/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java@@ -266,7 +266,7 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSer// will see consistent database state and we only commit if no processor failed. This// still won't make this procedure consistent with the message queue from which we consume!persistenceService.doTransaction(em -> {- ServerAsset asset = assetStorageService.find(em, event.getEntityId(), true);+ Asset asset = assetStorageService.find(em, event.getEntityId(), true);if (asset == null)throw new AssetProcessingException(ASSET_NOT_FOUND);@@ -409,7 +409,7 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSer* update, the attribute will be stored in the database.*/protected boolean processAssetUpdate(EntityManager em,- ServerAsset asset,+ Asset asset,AssetAttribute attribute,Source source) throws AssetProcessingException {LOG.fine(">>> Processing start: " + attribute);diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java b/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.javaindex 08e270279..27181edb3 100644--- a/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java+++ b/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java@@ -71,7 +71,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour}if (!isRestrictedUser()) {- List<ServerAsset> result = assetStorageService.findAll(+ List<Asset> result = assetStorageService.findAll(new AssetQuery().parent(new ParentPredicate(true)).tenant(new TenantPredicate().realm(getAuthenticatedRealm()))@@ -79,7 +79,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResourreturn result.toArray(new Asset[result.size()]);}- List<ServerAsset> assets = assetStorageService.findAll(+ List<Asset> assets = assetStorageService.findAll(new AssetQuery().select(new Select(Include.ALL_EXCEPT_PATH_AND_ATTRIBUTES, Access.RESTRICTED_READ)).userId(getUserId())@@ -88,9 +88,9 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour// Filter assets that might have been moved into a different realm and can no longer be accessed by user// TODO: Should we forbid moving assets between realms?Tenant authenticatedTenant = getAuthenticatedTenant();- Iterator<ServerAsset> it = assets.iterator();+ Iterator<Asset> it = assets.iterator();while (it.hasNext()) {- ServerAsset asset = it.next();+ Asset asset = it.next();if (!asset.getRealmId().equals(authenticatedTenant.getId())) {LOG.warning("User '" + getUsername() + "' linked to asset in other realm, skipping: " + asset);it.remove();@@ -100,7 +100,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour// Compress response (the request attribute enables the interceptor)request.setAttribute(HttpHeaders.CONTENT_ENCODING, "gzip");- return assets.toArray(new ServerAsset[assets.size()]);+ return assets.toArray(new Asset[assets.size()]);} catch (IllegalStateException ex) {throw new WebApplicationException(ex, BAD_REQUEST);}@@ -144,7 +144,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResourif (!identityService.getIdentityProvider().isUserInTenant(userId, realmId))throw new WebApplicationException(BAD_REQUEST);- ServerAsset asset;+ Asset asset;if ((asset = assetStorageService.find(assetId)) == null || !asset.getRealmId().equals(realmId)) {throw new WebApplicationException(BAD_REQUEST);}@@ -183,7 +183,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour@Overridepublic Asset get(RequestParams requestParams, String assetId) {try {- ServerAsset asset;+ Asset asset;// Check restrictedif (isRestrictedUser()) {@@ -216,29 +216,28 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour@Overridepublic void update(RequestParams requestParams, String assetId, Asset asset) {try {- ServerAsset serverAsset = assetStorageService.find(assetId, true);- if (serverAsset == null)+ Asset storageAsset = assetStorageService.find(assetId, true);+ if (storageAsset == null)throw new WebApplicationException(NOT_FOUND);// Current and new realm of asset must be accessible- if (!isTenantActiveAndAccessible(serverAsset) || !isTenantActiveAndAccessible(asset)) {- LOG.fine("Current or new tenant not accessible by user '" + getUsername() + "', can't update: " + serverAsset);+ if (!isTenantActiveAndAccessible(storageAsset) || !isTenantActiveAndAccessible(asset)) {+ LOG.fine("Current or new tenant not accessible by user '" + getUsername() + "', can't update: " + storageAsset);throw new WebApplicationException(FORBIDDEN);}boolean isRestrictedUser = isRestrictedUser();// The asset that will ultimately be stored (override/ignore some values for restricted users)- ServerAsset resultAsset = ServerAsset.map(+ Asset resultAsset = storageAsset.map(asset,- serverAsset,- isRestrictedUser ? serverAsset.getName() : null, // TODO We could allow restricted users to update names?- isRestrictedUser ? serverAsset.getRealmId() : null, // Restricted users can not change realm- isRestrictedUser ? serverAsset.getParentId() : null, // Restricted users can not change realm- serverAsset.getType(), // The type an never change- null, // Anybody can set a new location- isRestrictedUser ? serverAsset.isAccessPublicRead() : null, // Restricted user can not change access public flag- isRestrictedUser ? serverAsset.getAttributes() : null // Restricted users need manual attribute merging (see below)+ storageAsset,+ isRestrictedUser ? storageAsset.getName() : null, // TODO We could allow restricted users to update names?+ isRestrictedUser ? storageAsset.getRealmId() : null, // Restricted users can not change realm+ isRestrictedUser ? storageAsset.getParentId() : null, // Restricted users can not change realm+ storageAsset.getType(), // The type an never change+ isRestrictedUser ? storageAsset.isAccessPublicRead() : null, // Restricted user can not change access public flag+ isRestrictedUser ? storageAsset.getAttributes() : null // Restricted users need manual attribute merging (see below));// For restricted users, merge existing and updated attributes depending on write permissions@@ -402,7 +401,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResourthrow new WebApplicationException(FORBIDDEN);}- ServerAsset serverAsset = ServerAsset.map(asset, new ServerAsset());+ Asset newAsset = Asset.map(asset, new Asset());// Allow client to set identifierif (asset.getId() != null) {@@ -411,20 +410,20 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResourLOG.fine("Identifier value must be 22 characters, can't persist asset: " + asset);throw new WebApplicationException(BAD_REQUEST);}- serverAsset.setId(asset.getId());+ newAsset.setId(asset.getId());}AssetModel.getAssetTypeDescriptor(asset.getType()).ifPresent(descriptor -> {- serverAsset.setAccessPublicRead(descriptor.getAccessPublicRead());+ newAsset.setAccessPublicRead(descriptor.getAccessPublicRead());//Add default meta items if not present- serverAsset.getAttributesStream().forEach(serverAssetAttribute ->+ newAsset.getAttributesStream().forEach(AssetAttribute ->descriptor.getDefaultAttributes().filter(defaultAttribute ->- defaultAttribute.getNameOrThrow().equalsIgnoreCase(serverAssetAttribute.getNameOrThrow())+ defaultAttribute.getNameOrThrow().equalsIgnoreCase(AssetAttribute.getNameOrThrow())).findFirst().ifPresent(defaultAttribute -> {- serverAssetAttribute.addMeta(+ AssetAttribute.addMeta(defaultAttribute.getMetaStream().filter(defaultMeta ->- serverAssetAttribute.getMetaStream().noneMatch(serverMeta ->+ AssetAttribute.getMetaStream().noneMatch(serverMeta ->serverMeta.equals(defaultMeta))).toArray(MetaItem[]::new));@@ -432,16 +431,16 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour);//Add missing attributes- serverAsset.addAttributes(descriptor.getDefaultAttributes()+ newAsset.addAttributes(descriptor.getDefaultAttributes().filter(assetAttribute ->- serverAsset.getAttributesStream().noneMatch(serverAttribute ->+ newAsset.getAttributesStream().noneMatch(serverAttribute ->serverAttribute.getNameOrThrow().equalsIgnoreCase(assetAttribute.getNameOrThrow()))).toArray(AssetAttribute[]::new));});- return assetStorageService.merge(serverAsset);+ return assetStorageService.merge(newAsset);} catch (IllegalStateException ex) {throw new WebApplicationException(ex, BAD_REQUEST);@@ -454,7 +453,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResourif (isRestrictedUser()) {throw new WebApplicationException(FORBIDDEN);}- ServerAsset asset = assetStorageService.find(assetId, true);+ Asset asset = assetStorageService.find(assetId, true);if (asset == null)return;@@ -509,7 +508,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResourquery.tenant(new TenantPredicate(tenant.getId()));}- List<ServerAsset> result = assetStorageService.findAll(query);+ List<Asset> result = assetStorageService.findAll(query);// Compress response (the request attribute enables the interceptor)request.setAttribute(HttpHeaders.CONTENT_ENCODING, "gzip");@@ -545,7 +544,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour}try {- List<ServerAsset> result = assetStorageService.findAll(query);+ List<Asset> result = assetStorageService.findAll(query);// Compress response (the request attribute enables the interceptor)request.setAttribute(HttpHeaders.CONTENT_ENCODING, "gzip");diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java b/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.javaindex 2e233e43b..5ab8225b3 100644--- a/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java+++ b/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java@@ -19,7 +19,6 @@*/package org.openremote.manager.asset;-import com.vividsolutions.jts.geom.Point;import net.fortuna.ical4j.filter.PeriodRule;import net.fortuna.ical4j.model.DateTime;import net.fortuna.ical4j.model.Dur;@@ -143,7 +142,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic// If any asset was modified in the database, publish eventsfrom(PERSISTENCE_TOPIC).routeId("AssetPersistenceChanges")- .filter(isPersistenceEventForEntityType(ServerAsset.class))+ .filter(isPersistenceEventForEntityType(Asset.class)).process(exchange -> publishModificationEvents(exchange.getIn().getBody(PersistenceEvent.class)));// React if a client wants to read attribute state@@ -162,7 +161,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic// Superuser can get allif (authContext.isSuperUser()) {- ServerAsset asset = find(event.getAssetId(), true);+ Asset asset = find(event.getAssetId(), true);if (asset != null)replyWithAttributeEvents(sessionKey, asset, event.getAttributeNames());return;@@ -173,7 +172,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServicreturn;}- ServerAsset asset = find(+ Asset asset = find(event.getAssetId(),true,identityService.getIdentityProvider().isRestrictedUser(authContext.getUserId()) ? RESTRICTED_READ : PRIVATE_READ@@ -185,7 +184,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic}- public ServerAsset find(String assetId) {+ public Asset find(String assetId) {if (assetId == null)throw new IllegalArgumentException("Can't query null asset identifier");return find(new AssetQuery().id(assetId));@@ -194,7 +193,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic/*** @param loadComplete If the whole asset data (including path and attributes) should be loaded.*/- public ServerAsset find(String assetId, boolean loadComplete) {+ public Asset find(String assetId, boolean loadComplete) {if (assetId == null)throw new IllegalArgumentException("Can't query null asset identifier");return find(new AssetQuery().select(new Select(loadComplete ? ALL : ALL_EXCEPT_PATH_AND_ATTRIBUTES)).id(assetId));@@ -203,7 +202,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic/*** @param loadComplete If the whole asset data (including path and attributes) should be loaded.*/- public ServerAsset find(EntityManager em, String assetId, boolean loadComplete) {+ public Asset find(EntityManager em, String assetId, boolean loadComplete) {return find(em, assetId, loadComplete, PRIVATE_READ);}@@ -211,18 +210,18 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic* @param loadComplete If the whole asset data (including path and attributes) should be loaded.* @param access The required access permissions of the asset data.*/- public ServerAsset find(String assetId, boolean loadComplete, Access access) {+ public Asset find(String assetId, boolean loadComplete, Access access) {if (assetId == null)throw new IllegalArgumentException("Can't query null asset identifier");return find(new AssetQuery().select(new Select(loadComplete ? ALL : ALL_EXCEPT_PATH_AND_ATTRIBUTES, access)).id(assetId));}- public ServerAsset find(BaseAssetQuery query) {+ public Asset find(BaseAssetQuery query) {return persistenceService.doReturningTransaction(em -> find(em, query));}- public ServerAsset find(EntityManager em, BaseAssetQuery query) {- List<ServerAsset> result = findAll(em, query);+ public Asset find(EntityManager em, BaseAssetQuery query) {+ List<Asset> result = findAll(em, query);if (result.size() == 0)return null;if (result.size() > 1) {@@ -232,7 +231,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic}- public List<ServerAsset> findAll(BaseAssetQuery query) {+ public List<Asset> findAll(BaseAssetQuery query) {return persistenceService.doReturningTransaction(em -> findAll(em, query));}@@ -262,7 +261,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic* @return The current stored asset state.* @throws IllegalArgumentException if the realm or parent is illegal, or other asset constraint is violated.*/- public ServerAsset merge(ServerAsset asset) {+ public Asset merge(Asset asset) {return merge(asset, false);}@@ -271,7 +270,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic* @return The current stored asset state.* @throws IllegalArgumentException if the realm or parent is illegal, or other asset constraint is violated.*/- public ServerAsset merge(ServerAsset asset, boolean overrideVersion) {+ public Asset merge(Asset asset, boolean overrideVersion) {return merge(asset, overrideVersion, null);}@@ -280,7 +279,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic* @return The current stored asset state.* @throws IllegalArgumentException if the realm or parent is illegal, or other asset constraint is violated.*/- public ServerAsset merge(ServerAsset asset, String userName) {+ public Asset merge(Asset asset, String userName) {return merge(asset, false, userName);}@@ -290,7 +289,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic* @return The current stored asset state.* @throws IllegalArgumentException if the realm or parent is illegal, or other asset constraint is violated.*/- public ServerAsset merge(ServerAsset asset, boolean overrideVersion, String userName) {+ public Asset merge(Asset asset, boolean overrideVersion, String userName) {return persistenceService.doReturningTransaction(em -> {// Update all empty attribute timestamps with server-time (a caller which doesn't have a@@ -306,7 +305,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic// Validate parentif (asset.getParentId() != null) {// If this is a not a root asset...- ServerAsset parent = find(em, asset.getParentId(), true);+ Asset parent = find(em, asset.getParentId(), true);// .. the parent must existif (parent == null)throw new IllegalStateException("Parent not found: " + asset.getParentId());@@ -345,7 +344,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic// version, so the detached state always wins and this update will go through and ignore// concurrent updatesif (asset.getId() != null && overrideVersion) {- ServerAsset existing = em.find(ServerAsset.class, asset.getId());+ Asset existing = em.find(Asset.class, asset.getId());if (existing != null) {asset.setVersion(existing.getVersion());}@@ -362,7 +361,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServicLOG.fine("Storing: " + asset);- ServerAsset updatedAsset = em.merge(asset);+ Asset updatedAsset = em.merge(asset);if (user != null) {storeUserAsset(em, new UserAsset(user.getRealmId(), user.getId(), updatedAsset.getId()));@@ -377,9 +376,9 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic*/public boolean delete(String assetId) {return persistenceService.doReturningTransaction(em -> {- Asset asset = em.find(ServerAsset.class, assetId);+ Asset asset = em.find(Asset.class, assetId);if (asset != null) {- List<ServerAsset> children = findAll(em, new AssetQuery()+ List<Asset> children = findAll(em, new AssetQuery().parent(new AssetQuery.ParentPredicate(asset.getId())));if (children.size() > 0)@@ -499,7 +498,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServicvoid acceptStatement(PreparedStatement st) throws SQLException;}- protected ServerAsset find(EntityManager em, String assetId, boolean loadComplete, Access access) {+ protected Asset find(EntityManager em, String assetId, boolean loadComplete, Access access) {if (assetId == null)throw new IllegalArgumentException("Can't query null asset identifier");return find(@@ -510,7 +509,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic);}- protected List<ServerAsset> findAll(EntityManager em, BaseAssetQuery query) {+ protected List<Asset> findAll(EntityManager em, BaseAssetQuery query) {// Use a default projection if it's missingif (query.select == null)@@ -526,18 +525,18 @@ public class AssetStorageService extends RouteBuilder implements ContainerServicPreparedAssetQuery querySql = buildQuery(query);- return em.unwrap(Session.class).doReturningWork(new AbstractReturningWork<List<ServerAsset>>() {+ return em.unwrap(Session.class).doReturningWork(new AbstractReturningWork<List<Asset>>() {@Override- public List<ServerAsset> execute(Connection connection) throws SQLException {+ public List<Asset> execute(Connection connection) throws SQLException {LOG.fine("Executing: " + querySql.querySql);try (PreparedStatement st = connection.prepareStatement(querySql.querySql)) {querySql.apply(st);try (ResultSet rs = st.executeQuery()) {- List<ServerAsset> result = new ArrayList<>();+ List<Asset> result = new ArrayList<>();if (query.calendarEventActive != null) {while (rs.next()) {- ServerAsset asset = mapResultTuple(query, rs);+ Asset asset = mapResultTuple(query, rs);if (calendarEventPredicateMatches(query.calendarEventActive, asset)) {result.add(asset);}@@ -603,7 +602,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServiccase ALL_EXCEPT_PATH_AND_ATTRIBUTES:case ALL_EXCEPT_PATH:case ALL:- sb.append(", A.OBJ_VERSION as OBJ_VERSION, A.LOCATION as LOCATION");+ sb.append(", A.OBJ_VERSION as OBJ_VERSION");sb.append(", P.NAME as PARENT_NAME, P.ASSET_TYPE as PARENT_TYPE");if (!recursive || level == 3) {sb.append(", R.NAME as TENANT_NAME, RA.VALUE as TENANT_DISPLAY_NAME");@@ -808,7 +807,10 @@ public class AssetStorageService extends RouteBuilder implements ContainerServicif (level == 1 && query.location != null) {if (query.location instanceof RadialLocationPredicate) {RadialLocationPredicate location = (RadialLocationPredicate) query.location;- sb.append(" and ST_Distance_Sphere(A.LOCATION, ST_MakePoint(");+ sb.append(" and ST_Distance_Sphere(ST_MakePoint(");+ sb.append("(A.attributes -> 'location' -> 'value' ->> 'latitude')::numeric");+ sb.append("(A.attributes -> 'location' -> 'value' ->> 'longitude')::numeric");+ sb.append(")), ST_MakePoint(");sb.append(location.lng);sb.append(",");sb.append(location.lat);@@ -817,7 +819,10 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic} else if (query.location instanceof RectangularLocationPredicate) {RectangularLocationPredicate location = (RectangularLocationPredicate) query.location;sb.append(location.negated ? " and NOT" : " and");- sb.append(" ST_Within(A.LOCATION,");+ sb.append(" ST_Within(ST_MakePoint(,");+ sb.append("(A.attributes -> 'location' -> 'value' ->> 'latitude')::numeric");+ sb.append("(A.attributes -> 'location' -> 'value' ->> 'longitude')::numeric");+ sb.append(")");sb.append("ST_MakeEnvelope(");sb.append(location.lngMin);sb.append(",");@@ -1174,12 +1179,12 @@ public class AssetStorageService extends RouteBuilder implements ContainerServicreturn attributeBuilder.toString();}- protected ServerAsset mapResultTuple(BaseAssetQuery query, ResultSet rs) throws SQLException {+ protected Asset mapResultTuple(BaseAssetQuery query, ResultSet rs) throws SQLException {switch (query.select.include) {case ONLY_ID_AND_NAME:case ONLY_ID_AND_NAME_AND_ATTRIBUTES:case ONLY_ID_AND_NAME_AND_ATTRIBUTE_NAMES:- ServerAsset asset = new ServerAsset();+ Asset asset = new Asset();asset.setId(rs.getString("ID"));asset.setType(rs.getString("ASSET_TYPE"));asset.setName(rs.getString("NAME"));@@ -1193,12 +1198,16 @@ public class AssetStorageService extends RouteBuilder implements ContainerServiccase ALL_EXCEPT_PATH_AND_ATTRIBUTES:case ALL_EXCEPT_PATH:case ALL:- return new ServerAsset(+ Array path = rs.getArray("PATH");+ String attributes = rs.getString("ATTRIBUTES");+ return new Asset(rs.getString("ID"), rs.getLong("OBJ_VERSION"), rs.getTimestamp("CREATED_ON"), rs.getString("NAME"),rs.getString("ASSET_TYPE"), rs.getBoolean("ACCESS_PUBLIC_READ"),rs.getString("PARENT_ID"), rs.getString("PARENT_NAME"), rs.getString("PARENT_TYPE"),rs.getString("REALM_ID"), rs.getString("TENANT_NAME"), rs.getString("TENANT_DISPLAY_NAME"),- rs.getObject("LOCATION"), rs.getArray("PATH"), rs.getString("ATTRIBUTES"));+ path != null ? (String[]) path.getArray() : null,+ attributes != null && attributes.length() > 0 ? Values.instance().<ObjectValue>parse(attributes).orElse(null)+ : null);default:throw new UnsupportedOperationException("Select include option not supported: " + query.select.include);}@@ -1257,8 +1266,8 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic});}- protected void publishModificationEvents(PersistenceEvent<ServerAsset> persistenceEvent) {- ServerAsset asset = persistenceEvent.getEntity();+ protected void publishModificationEvents(PersistenceEvent<Asset> persistenceEvent) {+ Asset asset = persistenceEvent.getEntity();switch (persistenceEvent.getCause()) {case INSERT:clientEventService.publishEvent(@@ -1307,20 +1316,6 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic);break;}-- // Did the location change?- Point oldLocation = persistenceEvent.getPreviousState("location");- Point newLocation = persistenceEvent.getCurrentState("location");-- if (!(oldLocation == null && newLocation == null)) {- if (oldLocation == null || newLocation == null || !oldLocation.equalsExact(newLocation, 0)) {- clientEventService.publishEvent(- new LocationEvent(asset.getId(),- asset.getCoordinates(),- timerService.getCurrentTimeMillis())- );- }- }break;case DELETE:clientEventService.publishEvent(@@ -1330,7 +1325,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic}}- protected void replyWithAttributeEvents(String sessionKey, ServerAsset asset, String[] attributeNames) {+ protected void replyWithAttributeEvents(String sessionKey, Asset asset, String[] attributeNames) {List<String> names = attributeNames == null ? Collections.emptyList() : Arrays.asList(attributeNames);// Client may want to read a subset or all attributes of the assetdiff --git a/manager/src/main/java/org/openremote/manager/asset/AssetUpdateProcessor.java b/manager/src/main/java/org/openremote/manager/asset/AssetUpdateProcessor.javaindex 0e2fefd66..a9bd9aecd 100644--- a/manager/src/main/java/org/openremote/manager/asset/AssetUpdateProcessor.java+++ b/manager/src/main/java/org/openremote/manager/asset/AssetUpdateProcessor.java@@ -20,6 +20,7 @@package org.openremote.manager.asset;import org.openremote.container.concurrent.GlobalLock;+import org.openremote.model.asset.Asset;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.attribute.AttributeEvent.Source;@@ -43,7 +44,7 @@ public interface AssetUpdateProcessor {* @return <code>true</code> if processing is complete and subsequent processor should be skipped.* @throws AssetProcessingException When processing failed and the update can not continue.*/- boolean processAssetUpdate(EntityManager em, ServerAsset asset, AssetAttribute attribute, Source source) throws AssetProcessingException;+ boolean processAssetUpdate(EntityManager em, Asset asset, AssetAttribute attribute, Source source) throws AssetProcessingException;/* TODO Processors should be transactional, so an exception in one processor can roll back the update in others */// void commit();diff --git a/manager/src/main/java/org/openremote/manager/asset/ServerAsset.java b/manager/src/main/java/org/openremote/manager/asset/ServerAsset.javadeleted file mode 100644index 3913a81a7..000000000--- a/manager/src/main/java/org/openremote/manager/asset/ServerAsset.java+++ /dev/null@@ -1,185 +0,0 @@-/*- * Copyright 2016, OpenRemote Inc.- *- * See the CONTRIBUTORS.txt file in the distribution for a- * full listing of individual contributors.- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <http://www.gnu.org/licenses/>.- */-package org.openremote.manager.asset;--import com.fasterxml.jackson.annotation.JsonIgnore;-import com.vividsolutions.jts.geom.Coordinate;-import com.vividsolutions.jts.geom.GeometryFactory;-import com.vividsolutions.jts.geom.Point;-import org.geolatte.geom.Geometry;-import org.geolatte.geom.jts.JTS;-import org.hibernate.annotations.Check;-import org.hibernate.spatial.dialect.postgis.PGGeometryTypeDescriptor;-import org.openremote.model.asset.Asset;-import org.openremote.model.asset.AssetType;-import org.openremote.model.value.ObjectValue;-import org.openremote.model.value.Values;--import javax.persistence.*;-import javax.validation.constraints.NotNull;-import java.sql.Array;-import java.sql.SQLException;-import java.util.Date;--/**- * This can only be used on the server and offers types (such as- * {@link org.geolatte.geom.Geometry}) which can not be serialized- * or compiled on the client and constructors for query result mapping.- */-@Entity(name = "Asset")-@Table(name = "ASSET")-@Check(constraints = "ID != PARENT_ID")-// TODO Write on-insert/update SQL trigger that validates the asset realm, it must match the parent's realm-public class ServerAsset extends Asset {-- /**- * Easy conversion between types, we copy all properties (not a deep copy!)- */- public static ServerAsset map(Asset asset, ServerAsset serverAsset) {- return map(asset, serverAsset, null, null, null, null, null, null, null);- }-- public static ServerAsset map(Asset asset, ServerAsset serverAsset,- String overrideName,- String overrideRealmId,- String overrideParentId,- String overrideType,- Double[] overrideLocation,- Boolean overrideAccessPublicRead,- ObjectValue overrideAttributes) {- serverAsset.setVersion(asset.getVersion());- serverAsset.setName(overrideName != null ? overrideName : asset.getName());- if (overrideType != null) {- serverAsset.setType(overrideType);- } else {- serverAsset.setType(asset.getType());- }-- serverAsset.setAccessPublicRead(overrideAccessPublicRead != null ? overrideAccessPublicRead : asset.isAccessPublicRead());-- serverAsset.setParentId(overrideParentId != null ? overrideParentId : asset.getParentId());- serverAsset.setParentName(null);- serverAsset.setParentType(null);-- serverAsset.setRealmId(overrideRealmId != null ? overrideRealmId : asset.getRealmId());- serverAsset.setTenantRealm(null);- serverAsset.setTenantDisplayName(null);-- GeometryFactory geometryFactory = new GeometryFactory();-- if (overrideLocation != null) {- serverAsset.setLocation(geometryFactory.createPoint(new Coordinate(- overrideLocation[0],- overrideLocation[1]- )));- } else if (asset.getCoordinates() != null && asset.getCoordinates().length == 2) {- serverAsset.setLocation(geometryFactory.createPoint(new Coordinate(- asset.getCoordinates()[0],- asset.getCoordinates()[1]- )));- } else {- serverAsset.setLocation(null);- }-- serverAsset.setAttributes(overrideAttributes != null ? overrideAttributes : asset.getAttributes());-- return serverAsset;- }-- @Column(name = "LOCATION")- @Access(AccessType.PROPERTY)- @JsonIgnore- protected Point location;-- public ServerAsset() {- }-- @SuppressWarnings("unchecked")- public ServerAsset(String id, long version, Date createdOn, String name, String type, boolean accessPublicRead,- String parentId, String parentName, String parentType,- String realmId, String tenantRealm, String tenantDisplayName,- Object location,- Array path, String attributes) throws SQLException {- super(- id, version, createdOn, name, type, accessPublicRead,- parentId, parentName, parentType,- realmId, tenantRealm, tenantDisplayName,- path != null ? (String[]) path.getArray() : null,- attributes != null && attributes.length() > 0- ? Values.instance().<ObjectValue>parse(attributes).orElse(null)- : null- );-- Point position = null;-- if (location != null) {- Geometry geomPoint = PGGeometryTypeDescriptor.toGeometry(location);- if (geomPoint instanceof org.geolatte.geom.Point) {- position = (Point) JTS.to(geomPoint);- }- }-- setLocation(position);- }-- public ServerAsset(@NotNull String name, @NotNull AssetType type) {- this(name, type, null, null);- }-- public ServerAsset(@NotNull String name, @NotNull String type) {- this(name, type, false, null, null);- }-- public ServerAsset(@NotNull String name, @NotNull AssetType type, Asset parent) {- this(name, type, parent, null);- }-- public ServerAsset(@NotNull String name, @NotNull String type, Asset parent) {- this(name, type, false, parent, null);- }-- public ServerAsset(@NotNull String name, @NotNull AssetType type, Asset parent, String realmId) {- super(name, type, parent, realmId);- }-- public ServerAsset(@NotNull String name, @NotNull String type, boolean accessPublicRead, Asset parent, String realmId) {- super(name, type, accessPublicRead, parent, realmId);- }-- public Point getLocation() {- return location;- }-- public void setLocation(Point location) {- this.location = location;- setCoordinates(this, location);- }-- public static void setCoordinates(Asset asset, Point location) {- if (location == null) {- asset.setCoordinates((double[]) null);- } else {- asset.setCoordinates(- location.getCoordinate().getOrdinate(Coordinate.X),- location.getCoordinate().getOrdinate(Coordinate.Y)- );- }- }-}diff --git a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointResourceImpl.java b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointResourceImpl.javaindex 8ecbb3d33..2fe7339f3 100644--- a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointResourceImpl.java+++ b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointResourceImpl.java@@ -21,9 +21,9 @@ package org.openremote.manager.datapoint;import org.openremote.container.timer.TimerService;import org.openremote.manager.asset.AssetStorageService;-import org.openremote.manager.asset.ServerAsset;import org.openremote.manager.security.ManagerIdentityService;import org.openremote.manager.web.ManagerWebResource;+import org.openremote.model.asset.Asset;import org.openremote.model.datapoint.AssetDatapointResource;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.datapoint.Datapoint;@@ -64,7 +64,7 @@ public class AssetDatapointResourceImpl extends ManagerWebResource implements Asthrow new WebApplicationException(Response.Status.FORBIDDEN);}- ServerAsset asset = assetStorageService.find(assetId, true);+ Asset asset = assetStorageService.find(assetId, true);if (asset == null) {throw new WebApplicationException(Response.Status.NOT_FOUND);diff --git a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.javaindex ced871cbb..f4597ce81 100644--- a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java+++ b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java@@ -10,8 +10,8 @@ import org.openremote.container.web.WebService;import org.openremote.manager.asset.AssetProcessingException;import org.openremote.manager.asset.AssetStorageService;import org.openremote.manager.asset.AssetUpdateProcessor;-import org.openremote.manager.asset.ServerAsset;import org.openremote.manager.security.ManagerIdentityService;+import org.openremote.model.asset.Asset;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.attribute.AttributeEvent.Source;import org.openremote.model.attribute.AttributeRef;@@ -63,7 +63,7 @@ public class AssetDatapointService implements ContainerService, AssetUpdateProce@Overridepublic boolean processAssetUpdate(EntityManager em,- ServerAsset asset,+ Asset asset,AssetAttribute attribute,Source source) throws AssetProcessingException {if (Datapoint.isDatapointsCapable(attribute)diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesService.java b/manager/src/main/java/org/openremote/manager/rules/RulesService.javaindex c193675e1..6f993f6f0 100644--- a/manager/src/main/java/org/openremote/manager/rules/RulesService.java+++ b/manager/src/main/java/org/openremote/manager/rules/RulesService.java@@ -157,7 +157,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse.filter(isPersistenceEventForEntityType(Asset.class)).process(exchange -> {PersistenceEvent persistenceEvent = exchange.getIn().getBody(PersistenceEvent.class);- final ServerAsset eventAsset = (ServerAsset) persistenceEvent.getEntity();+ final Asset eventAsset = (Asset) persistenceEvent.getEntity();processAssetChange(eventAsset, persistenceEvent);});}@@ -190,13 +190,13 @@ public class RulesService extends RouteBuilder implements ContainerService, AssedeployAssetRulesets(rulesetStorageService.findEnabledAssetRulesets());LOG.info("Loading all assets with fact attributes to initialize state of rules engines");- Stream<Pair<ServerAsset, Stream<AssetAttribute>>> assetRuleAttributes = findRuleStateAttributes();+ Stream<Pair<Asset, Stream<AssetAttribute>>> assetRuleAttributes = findRuleStateAttributes();// Push each rule attribute as an asset update through the rule engine chain// that will ensure the insert only happens to the engines in scopeassetRuleAttributes.forEach(pair -> {- ServerAsset asset = pair.key;+ Asset asset = pair.key;pair.value.forEach(ruleAttribute -> {AssetState assetState = new AssetState(asset, ruleAttribute, Source.INTERNAL);updateAssetState(assetState, true, true);@@ -222,7 +222,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse@Overridepublic boolean processAssetUpdate(EntityManager em,- ServerAsset asset,+ Asset asset,AssetAttribute attribute,Source source) throws AssetProcessingException {// We might process two facts for a single attribute update, if that is what the user wants@@ -288,7 +288,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse});}- protected void processAssetChange(ServerAsset asset, PersistenceEvent persistenceEvent) {+ protected void processAssetChange(Asset asset, PersistenceEvent persistenceEvent) {withLock(getClass().getSimpleName() + "::processAssetChange", () -> {// We must load the asset from database (only when required), as the@@ -305,7 +305,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse// Build an update with a fully loaded assetruleStateAttributes.forEach(attribute -> {- ServerAsset loadedAsset = assetStorageService.find(asset.getId(), true);+ Asset loadedAsset = assetStorageService.find(asset.getId(), true);// If the asset is now gone it was deleted immediately after being inserted, nothing more to doif (loadedAsset == null)return;@@ -526,7 +526,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse.stream(activeTenantIds).anyMatch(at -> es.getKey().equals(at))).forEach(es -> {- List<Pair<ServerAsset, List<AssetRuleset>>> tenantAssetAndRules = es.getValue();+ List<Pair<Asset, List<AssetRuleset>>> tenantAssetAndRules = es.getValue();// RT: Not sure we need ordering here for starting engines so removing it// Order rulesets by asset hierarchy within this tenant@@ -678,8 +678,8 @@ public class RulesService extends RouteBuilder implements ContainerService, Assereturn rulesEngines;}- protected Stream<Pair<ServerAsset, Stream<AssetAttribute>>> findRuleStateAttributes() {- List<ServerAsset> assets = assetStorageService.findAll(+ protected Stream<Pair<Asset, Stream<AssetAttribute>>> findRuleStateAttributes() {+ List<Asset> assets = assetStorageService.findAll(new AssetQuery().select(new AssetQuery.Select(AssetQuery.Include.ALL)).attributeMeta(@@ -689,7 +689,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse));return assets.stream()- .map((ServerAsset asset) ->+ .map((Asset asset) ->new Pair<>(asset, asset.getAttributesStream().filter(AssetAttribute::isRuleState)));}diff --git a/manager/src/main/java/org/openremote/manager/rules/facade/AssetsFacade.java b/manager/src/main/java/org/openremote/manager/rules/facade/AssetsFacade.javaindex 0cc593b69..4c910b65b 100644--- a/manager/src/main/java/org/openremote/manager/rules/facade/AssetsFacade.java+++ b/manager/src/main/java/org/openremote/manager/rules/facade/AssetsFacade.java@@ -20,7 +20,6 @@package org.openremote.manager.rules.facade;import org.openremote.manager.asset.AssetStorageService;-import org.openremote.manager.asset.ServerAsset;import org.openremote.manager.rules.RulesEngineId;import org.openremote.model.asset.Asset;import org.openremote.model.asset.BaseAssetQuery;@@ -84,7 +83,7 @@ public class AssetsFacade<T extends Ruleset> extends Assets {@Overridepublic String getResult() {- ServerAsset asset = assetStorageService.find(this);+ Asset asset = assetStorageService.find(this);return asset != null ? asset.getId() : null;}@@ -108,7 +107,7 @@ public class AssetsFacade<T extends Ruleset> extends Assets {);}if (AssetRuleset.class.isAssignableFrom(rulesEngineId.getScope())) {- ServerAsset restrictedAsset = assetStorageService.find(+ Asset restrictedAsset = assetStorageService.find(rulesEngineId.getAssetId().orElseThrow(() -> new IllegalStateException("Asset ID missing: " + rulesEngineId)),true);diff --git a/manager/src/main/java/org/openremote/manager/rules/facade/UsersFacade.java b/manager/src/main/java/org/openremote/manager/rules/facade/UsersFacade.javaindex 588e2b165..0c4b258bb 100644--- a/manager/src/main/java/org/openremote/manager/rules/facade/UsersFacade.java+++ b/manager/src/main/java/org/openremote/manager/rules/facade/UsersFacade.java@@ -20,10 +20,10 @@package org.openremote.manager.rules.facade;import org.openremote.manager.asset.AssetStorageService;-import org.openremote.manager.asset.ServerAsset;import org.openremote.manager.notification.NotificationService;import org.openremote.manager.rules.RulesEngineId;import org.openremote.manager.security.ManagerIdentityService;+import org.openremote.model.asset.Asset;import org.openremote.model.notification.AlertNotification;import org.openremote.model.rules.*;import org.openremote.model.user.UserQuery;@@ -91,7 +91,7 @@ public class UsersFacade<T extends Ruleset> extends Users {}if (AssetRuleset.class.isAssignableFrom(rulesEngineId.getScope())) {String assetId = rulesEngineId.getAssetId().orElseThrow(() -> new IllegalStateException("Asset ID missing: " + rulesEngineId));- ServerAsset restrictedAsset = assetStorageService.find(assetId, true);+ Asset restrictedAsset = assetStorageService.find(assetId, true);if (restrictedAsset == null) {// An asset was deleted in the database, but its ruleset is still deployed. This// can happen while the PersistenceEvent of the deletion is not processed and thediff --git a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.javaindex 5e5c9608a..d62c0a615 100644--- a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java@@ -26,12 +26,12 @@ import org.openremote.agent.protocol.timer.TimerValue;import org.openremote.container.Container;import org.openremote.manager.asset.AssetProcessingService;import org.openremote.manager.asset.AssetStorageService;-import org.openremote.manager.asset.ServerAsset;import org.openremote.manager.concurrent.ManagerExecutorService;import org.openremote.manager.datapoint.AssetDatapointService;import org.openremote.manager.persistence.ManagerPersistenceService;import org.openremote.manager.rules.RulesetStorageService;import org.openremote.manager.security.ManagerIdentityService;+import org.openremote.model.asset.Asset;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.attribute.*;import org.openremote.model.value.Values;@@ -76,9 +76,8 @@ public abstract class AbstractManagerSetup implements Setup {// ################################ Demo apartment with complex scenes ###################################- protected ServerAsset createDemoApartment(ServerAsset parent, String name) {- ServerAsset apartment = new ServerAsset(name, RESIDENCE, parent);- apartment.setLocation(parent.getLocation());+ protected Asset createDemoApartment(Asset parent, String name) {+ Asset apartment = new Asset(name, RESIDENCE, parent);apartment.setAttributes(new AssetAttribute("alarmEnabled", AttributeType.BOOLEAN).setMeta(new Meta(@@ -135,13 +134,12 @@ public abstract class AbstractManagerSetup implements Setup {return apartment;}- protected ServerAsset createDemoApartmentRoom(ServerAsset apartment, String name) {- ServerAsset room = new ServerAsset(name, ROOM, apartment);- room.setLocation(apartment.getLocation());+ protected Asset createDemoApartmentRoom(Asset apartment, String name) {+ Asset room = new Asset(name, ROOM, apartment);return room;}- protected void addDemoApartmentRoomMotionSensor(ServerAsset room, boolean shouldBeLinked, Supplier<MetaItem[]> agentLinker) {+ protected void addDemoApartmentRoomMotionSensor(Asset room, boolean shouldBeLinked, Supplier<MetaItem[]> agentLinker) {room.addAttributes(new AssetAttribute("motionSensor", NUMBER).setMeta(@@ -175,7 +173,7 @@ public abstract class AbstractManagerSetup implements Setup {);}- protected void addDemoApartmentRoomCO2Sensor(ServerAsset room, boolean shouldBeLinked, Supplier<MetaItem[]> agentLinker) {+ protected void addDemoApartmentRoomCO2Sensor(Asset room, boolean shouldBeLinked, Supplier<MetaItem[]> agentLinker) {room.addAttributes(new AssetAttribute("co2Level", CO2_PPM).setMeta(@@ -192,7 +190,7 @@ public abstract class AbstractManagerSetup implements Setup {);}- protected void addDemoApartmentRoomHumiditySensor(ServerAsset room, boolean shouldBeLinked, Supplier<MetaItem[]> agentLinker) {+ protected void addDemoApartmentRoomHumiditySensor(Asset room, boolean shouldBeLinked, Supplier<MetaItem[]> agentLinker) {room.addAttributes(new AssetAttribute("humidity", HUMIDITY_PERCENTAGE).setMeta(@@ -209,7 +207,7 @@ public abstract class AbstractManagerSetup implements Setup {);}- protected void addDemoApartmentRoomThermometer(ServerAsset room,+ protected void addDemoApartmentRoomThermometer(Asset room,boolean shouldBeLinked,Supplier<MetaItem[]> agentLinker) {room.addAttributes(@@ -226,7 +224,7 @@ public abstract class AbstractManagerSetup implements Setup {);}- protected void addDemoApartmentTemperatureControl(ServerAsset room,+ protected void addDemoApartmentTemperatureControl(Asset room,boolean shouldBeLinked,Supplier<MetaItem[]> agentLinker) {room.addAttributes(@@ -242,7 +240,7 @@ public abstract class AbstractManagerSetup implements Setup {);}- protected void addDemoApartmentSmartSwitch(ServerAsset room,+ protected void addDemoApartmentSmartSwitch(Asset room,String switchName,boolean shouldBeLinked,// Integer represents attribute:@@ -301,7 +299,7 @@ public abstract class AbstractManagerSetup implements Setup {);}- protected void addDemoApartmentVentilation(ServerAsset apartment,+ protected void addDemoApartmentVentilation(Asset apartment,boolean shouldBeLinked,Supplier<MetaItem[]> agentLinker) {apartment.addAttributes(@@ -348,13 +346,13 @@ public abstract class AbstractManagerSetup implements Setup {this.targetTemperature = targetTemperature;}- AssetAttribute createMacroAttribute(ServerAsset apartment, ServerAsset... rooms) {+ AssetAttribute createMacroAttribute(Asset apartment, Asset... rooms) {AssetAttribute attribute = initProtocolConfiguration(new AssetAttribute(attributeName), MacroProtocol.PROTOCOL_NAME).addMeta(new MetaItem(LABEL, Values.create(attributeLabel)));attribute.getMeta().add(new MacroAction(new AttributeState(new AttributeRef(apartment.getId(), "alarmEnabled"), Values.create(alarmEnabled))).toMetaItem());- for (ServerAsset room : rooms) {+ for (Asset room : rooms) {if (room.hasAttribute("targetTemperature")) {attribute.getMeta().add(new MacroAction(new AttributeState(new AttributeRef(room.getId(), "targetTemperature"), Values.create(targetTemperature))).toMetaItem()@@ -367,7 +365,7 @@ public abstract class AbstractManagerSetup implements Setup {return attribute;}- AssetAttribute[] createTimerAttributes(ServerAsset apartment) {+ AssetAttribute[] createTimerAttributes(Asset apartment) {List<AssetAttribute> attributes = new ArrayList<>();for (DayOfWeek dayOfWeek : DayOfWeek.values()) {// "MONDAY" => "Monday"@@ -384,9 +382,8 @@ public abstract class AbstractManagerSetup implements Setup {}}- protected ServerAsset createDemoApartmentSceneAgent(ServerAsset apartment, Scene[] scenes, ServerAsset... rooms) {- ServerAsset agent = new ServerAsset("Scene Agent", AGENT, apartment);- agent.setLocation(apartment.getLocation());+ protected Asset createDemoApartmentSceneAgent(Asset apartment, Scene[] scenes, Asset... rooms) {+ Asset agent = new Asset("Scene Agent", AGENT, apartment);for (Scene scene : scenes) {agent.addAttributes(scene.createMacroAttribute(apartment, rooms));}@@ -399,7 +396,7 @@ public abstract class AbstractManagerSetup implements Setup {return agent;}- protected void addDemoApartmentSceneEnableDisableTimer(ServerAsset apartment, ServerAsset agent, Scene[] scenes) {+ protected void addDemoApartmentSceneEnableDisableTimer(Asset apartment, Asset agent, Scene[] scenes) {AssetAttribute enableAllMacro = initProtocolConfiguration(new AssetAttribute("enableSceneTimer"), MacroProtocol.PROTOCOL_NAME).addMeta(new MetaItem(LABEL, Values.create("Enable scene timer")));for (Scene scene : scenes) {@@ -431,7 +428,7 @@ public abstract class AbstractManagerSetup implements Setup {agent.addAttributes(disableAllMacro);}- protected void linkDemoApartmentWithSceneAgent(ServerAsset apartment, ServerAsset agent, Scene[] scenes) {+ protected void linkDemoApartmentWithSceneAgent(Asset apartment, Asset agent, Scene[] scenes) {for (Scene scene : scenes) {apartment.addAttributes(new AssetAttribute(scene.attributeName, AttributeType.STRING, Values.create(AttributeExecuteStatus.READY.name()))diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoAgentSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoAgentSetup.javaindex 31bcf62d0..39f070da5 100644--- a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoAgentSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoAgentSetup.java@@ -23,8 +23,8 @@ import org.openremote.agent.protocol.knx.KNXProtocol;import org.openremote.agent.protocol.upnp.UpnpProtocol;import org.openremote.agent.protocol.velbus.VelbusSerialProtocol;import org.openremote.container.Container;-import org.openremote.manager.asset.ServerAsset;import org.openremote.manager.setup.AbstractManagerSetup;+import org.openremote.model.asset.Asset;import org.openremote.model.security.Tenant;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.attribute.MetaItem;@@ -82,7 +82,7 @@ public class ManagerDemoAgentSetup extends AbstractManagerSetup {Tenant masterTenant = keycloakDemoSetup.masterTenant;masterRealmId = masterTenant.getId();- ServerAsset agent = new ServerAsset("Demo Agent", AGENT);+ Asset agent = new Asset("Demo Agent", AGENT);agent.setRealmId(masterRealmId);agent = assetStorageService.merge(agent);@@ -95,7 +95,7 @@ public class ManagerDemoAgentSetup extends AbstractManagerSetup {new MetaItem(KNXProtocol.META_KNX_LOCAL_IP, Values.create(knxLocalIp))));- ServerAsset knxDevices = new ServerAsset("KNX Devices", THING, agent, masterRealmId);+ Asset knxDevices = new Asset("KNX Devices", THING, agent, masterRealmId);knxDevices = assetStorageService.merge(knxDevices);}@@ -107,13 +107,13 @@ public class ManagerDemoAgentSetup extends AbstractManagerSetup {new MetaItem(VelbusSerialProtocol.META_VELBUS_SERIAL_PORT, Values.create(velbusComPort))));- ServerAsset velbusDevices = new ServerAsset("VELBUS Devices", THING, agent, masterRealmId);+ Asset velbusDevices = new Asset("VELBUS Devices", THING, agent, masterRealmId);velbusDevices = assetStorageService.merge(velbusDevices);}if (upnp) {LOG.info("Enable UPnP demo protocol configuration");- ServerAsset upnpDevices = new ServerAsset("UPnP Devices", THING, agent, masterRealmId);+ Asset upnpDevices = new Asset("UPnP Devices", THING, agent, masterRealmId);upnpDevices = assetStorageService.merge(upnpDevices);agent.addAttributes(initProtocolConfiguration(new AssetAttribute("upnpConfig"), UpnpProtocol.PROTOCOL_NAME)diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.javaindex cf7038300..3d4b96951 100644--- a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java@@ -19,11 +19,10 @@*/package org.openremote.manager.setup.builtin;-import com.vividsolutions.jts.geom.Coordinate;import org.openremote.agent.protocol.simulator.SimulatorProtocol;import org.openremote.container.Container;-import org.openremote.manager.asset.ServerAsset;import org.openremote.manager.setup.AbstractManagerSetup;+import org.openremote.model.asset.Asset;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.asset.AssetMeta;import org.openremote.model.asset.UserAsset;@@ -32,6 +31,7 @@ import org.openremote.model.security.Tenant;import org.openremote.model.simulator.element.ColorSimulatorElement;import org.openremote.model.simulator.element.NumberSimulatorElement;import org.openremote.model.simulator.element.SwitchSimulatorElement;+import org.openremote.model.value.ObjectValue;import org.openremote.model.value.Values;import java.time.LocalDateTime;@@ -101,13 +101,14 @@ public class ManagerDemoSetup extends AbstractManagerSetup {// ################################ Demo assets for 'master' realm ###################################+ ObjectValue locationValue = Values.createObject().put("latitude", 51.44541688237109).put("longitude", 5.460315214821094);- ServerAsset smartOffice = new ServerAsset();+ Asset smartOffice = new Asset();smartOffice.setRealmId(masterTenant.getId());smartOffice.setName("Smart Office");- smartOffice.setLocation(geometryFactory.createPoint(new Coordinate(5.460315214821094, 51.44541688237109)));smartOffice.setType(BUILDING);List<AssetAttribute> smartOfficeAttributes = Arrays.asList(+ new AssetAttribute("location", LOCATION, locationValue),new AssetAttribute("geoStreet", STRING, Values.create("Torenallee 20")).setMeta(new MetaItem(LABEL, Values.create("Street")),@@ -134,23 +135,23 @@ public class ManagerDemoSetup extends AbstractManagerSetup {smartOffice = assetStorageService.merge(smartOffice);smartOfficeId = smartOffice.getId();- ServerAsset groundFloor = new ServerAsset("Ground Floor", FLOOR, smartOffice);- groundFloor.setLocation(smartOffice.getLocation());+ Asset groundFloor = new Asset("Ground Floor", FLOOR, smartOffice)+ .setAttributes(new AssetAttribute("location", LOCATION, locationValue));groundFloor = assetStorageService.merge(groundFloor);groundFloorId = groundFloor.getId();- ServerAsset lobby = new ServerAsset("Lobby", ROOM, groundFloor);- lobby.setLocation(groundFloor.getLocation());+ Asset lobby = new Asset("Lobby", ROOM, groundFloor)+ .setAttributes(new AssetAttribute("location", LOCATION, locationValue));lobby.addAttributes(- new AssetAttribute("location", AttributeType.ARRAY)+ new AssetAttribute("lobbyLocations", AttributeType.ARRAY));lobby = assetStorageService.merge(lobby);lobbyId = lobby.getId();- ServerAsset agent = new ServerAsset("Demo Agent", AGENT, lobby);- agent.setLocation(lobby.getLocation());+ Asset agent = new Asset("Demo Agent", AGENT, lobby);agent.setAttributes(+ new AssetAttribute("location", LOCATION, locationValue),initProtocolConfiguration(new AssetAttribute(agentProtocolConfigName), SimulatorProtocol.PROTOCOL_NAME).addMeta(new MetaItem(@@ -166,8 +167,8 @@ public class ManagerDemoSetup extends AbstractManagerSetup {agent = assetStorageService.merge(agent);agentId = agent.getId();- ServerAsset thing = new ServerAsset("Demo Thing", THING, agent);- thing.setLocation(agent.getLocation());+ Asset thing = new Asset("Demo Thing", THING, agent)+ .setAttributes(new AssetAttribute("location", LOCATION, locationValue));thing.setAttributes(new AssetAttribute(thingLightToggleAttributeName, BOOLEAN, Values.create(true)).setMeta(new Meta(@@ -255,7 +256,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {thingId = thing.getId();// Some sample datapoints- final ServerAsset finalThing = assetStorageService.find(thingId, true);+ final Asset finalThing = assetStorageService.find(thingId, true);ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault());AssetAttribute light1PowerConsumptionAttribute = thing.getAttribute("light1PowerConsumption")@@ -314,12 +315,14 @@ public class ManagerDemoSetup extends AbstractManagerSetup {// ################################ Demo assets for 'customerA' realm ###################################- ServerAsset smartHome = new ServerAsset();+ ObjectValue locationValueA = Values.createObject().put("latitude", 51.438000).put("longitude", 5.470945);++ Asset smartHome = new Asset();smartHome.setRealmId(customerATenant.getId());smartHome.setName("Smart Home");- smartHome.setLocation(geometryFactory.createPoint(new Coordinate(5.470945, 51.438000)));smartHome.setType(BUILDING);smartHome.setAttributes(+ new AssetAttribute("location", LOCATION, locationValueA),new AssetAttribute("geoStreet", STRING, Values.create("Wilhelminaplein 21C")).setMeta(new MetaItem(LABEL, Values.create("Street")),@@ -345,11 +348,12 @@ public class ManagerDemoSetup extends AbstractManagerSetup {smartHomeId = smartHome.getId();// The "Apartment 1" is the demo apartment with complex scenes- ServerAsset apartment1 = createDemoApartment(smartHome, "Apartment 1");+ Asset apartment1 = createDemoApartment(smartHome, "Apartment 1")+ .setAttributes(new AssetAttribute("location", LOCATION, locationValueA));apartment1 = assetStorageService.merge(apartment1);apartment1Id = apartment1.getId();- ServerAsset apartment1ServiceAgent = new ServerAsset("Service Agent (Simulator)", AGENT, apartment1);+ Asset apartment1ServiceAgent = new Asset("Service Agent (Simulator)", AGENT, apartment1);apartment1ServiceAgent.setAttributes(initProtocolConfiguration(new AssetAttribute("apartmentSimulator"), SimulatorProtocol.PROTOCOL_NAME).addMeta(@@ -363,7 +367,8 @@ public class ManagerDemoSetup extends AbstractManagerSetup {/* ############################ ROOMS ############################## */- ServerAsset apartment1Livingroom = createDemoApartmentRoom(apartment1, "Living Room");+ Asset apartment1Livingroom = createDemoApartmentRoom(apartment1, "Living Room")+ .setAttributes(new AssetAttribute("location", LOCATION, locationValueA));addDemoApartmentRoomMotionSensor(apartment1Livingroom, true, () -> new MetaItem[]{new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))@@ -388,7 +393,8 @@ public class ManagerDemoSetup extends AbstractManagerSetup {apartment1Livingroom = assetStorageService.merge(apartment1Livingroom);apartment1LivingroomId = apartment1Livingroom.getId();- ServerAsset apartment1Kitchen = createDemoApartmentRoom(apartment1, "Kitchen");+ Asset apartment1Kitchen = createDemoApartmentRoom(apartment1, "Kitchen")+ .setAttributes(new AssetAttribute("location", LOCATION, locationValueA));addDemoApartmentRoomMotionSensor(apartment1Kitchen, true, () -> new MetaItem[]{new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))@@ -420,7 +426,8 @@ public class ManagerDemoSetup extends AbstractManagerSetup {apartment1Kitchen = assetStorageService.merge(apartment1Kitchen);apartment1KitchenId = apartment1Kitchen.getId();- ServerAsset apartment1Hallway = createDemoApartmentRoom(apartment1, "Hallway");+ Asset apartment1Hallway = createDemoApartmentRoom(apartment1, "Hallway")+ .setAttributes(new AssetAttribute("location", LOCATION, locationValueA));addDemoApartmentRoomMotionSensor(apartment1Hallway, true, () -> new MetaItem[]{new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))@@ -444,18 +451,19 @@ public class ManagerDemoSetup extends AbstractManagerSetup {new Scene("nightScene", "Night scene", "NIGHT", "0 0 22 ? *", true, 19d)};- ServerAsset demoApartmentSceneAgent = createDemoApartmentSceneAgent(+ Asset demoApartmentSceneAgent = createDemoApartmentSceneAgent(apartment1, scenes, apartment1Livingroom, apartment1Kitchen, apartment1Hallway- );+ ).addAttributes(new AssetAttribute("location", LOCATION, locationValueA));+demoApartmentSceneAgent = assetStorageService.merge(demoApartmentSceneAgent);linkDemoApartmentWithSceneAgent(apartment1, demoApartmentSceneAgent, scenes);apartment1 = assetStorageService.merge(apartment1);}- ServerAsset apartment2 = new ServerAsset("Apartment 2", RESIDENCE, smartHome);- apartment2.setLocation(smartHome.getLocation());+ Asset apartment2 = new Asset("Apartment 2", RESIDENCE, smartHome);apartment2.setAttributes(+ new AssetAttribute("location", LOCATION, locationValueA),new AssetAttribute("allLightsOffSwitch", AttributeType.BOOLEAN, Values.create(true)).setMeta(new MetaItem(LABEL, Values.create("All Lights Off Switch")),@@ -467,9 +475,9 @@ public class ManagerDemoSetup extends AbstractManagerSetup {apartment2 = assetStorageService.merge(apartment2);apartment2Id = apartment2.getId();- ServerAsset apartment2Livingroom = new ServerAsset("Living Room", ROOM, apartment2);- apartment2Livingroom.setLocation(apartment2.getLocation());+ Asset apartment2Livingroom = new Asset("Living Room", ROOM, apartment2);apartment2Livingroom.setAttributes(+ new AssetAttribute("location", LOCATION, locationValueA),new AssetAttribute("motionSensor", AttributeType.BOOLEAN, Values.create(false)).setMeta(new MetaItem(LABEL, Values.create("Motion Sensor")),@@ -513,9 +521,9 @@ public class ManagerDemoSetup extends AbstractManagerSetup {apartment2Livingroom = assetStorageService.merge(apartment2Livingroom);apartment2LivingroomId = apartment2Livingroom.getId();- ServerAsset apartment2Bathroom = new ServerAsset("Bathroom", ROOM, apartment2);- apartment2Bathroom.setLocation(apartment2.getLocation());+ Asset apartment2Bathroom = new Asset("Bathroom", ROOM, apartment2);apartment2Bathroom.setAttributes(+ new AssetAttribute("location", LOCATION, locationValueA),new AssetAttribute("motionSensor", AttributeType.BOOLEAN, Values.create(false)).setMeta(new MetaItem(LABEL, Values.create("Motion Sensor")),@@ -550,13 +558,13 @@ public class ManagerDemoSetup extends AbstractManagerSetup {apartment2Bathroom = assetStorageService.merge(apartment2Bathroom);apartment2BathroomId = apartment2Bathroom.getId();- ServerAsset apartment3 = new ServerAsset("Apartment 3", RESIDENCE, smartHome);- apartment3.setLocation(smartHome.getLocation());+ Asset apartment3 = new Asset("Apartment 3", RESIDENCE, smartHome)+ .setAttributes(new AssetAttribute("location", LOCATION, locationValueA));apartment3 = assetStorageService.merge(apartment3);apartment3Id = apartment3.getId();- ServerAsset apartment3Livingroom = new ServerAsset("Living Room", ROOM, apartment3);- apartment3Livingroom.setLocation(apartment3.getLocation());+ Asset apartment3Livingroom = new Asset("Living Room", ROOM, apartment3)+ .setAttributes(new AssetAttribute("location", LOCATION, locationValueA));apartment3Livingroom.addAttributes(new AssetAttribute("lightSwitch", AttributeType.BOOLEAN));diff --git a/manager/src/main/resources/META-INF/persistence.xml b/manager/src/main/resources/META-INF/persistence.xmlindex 33e5e889e..38d5ba968 100644--- a/manager/src/main/resources/META-INF/persistence.xml+++ b/manager/src/main/resources/META-INF/persistence.xml@@ -10,7 +10,7 @@<class>org.openremote.container.persistence</class><class>org.openremote.container.util</class>- <class>org.openremote.manager.asset.ServerAsset</class>+ <class>org.openremote.manager.asset.Asset</class><class>org.openremote.model.notification.DeviceNotificationToken</class><class>org.openremote.model.notification.AlertNotification</class><class>org.openremote.model.notification.AlertAction</class>diff --git a/model/src/main/java/org/openremote/model/asset/Asset.java b/model/src/main/java/org/openremote/model/asset/Asset.javaindex a96f1d0ca..1670e120b 100644--- a/model/src/main/java/org/openremote/model/asset/Asset.java+++ b/model/src/main/java/org/openremote/model/asset/Asset.java@@ -23,19 +23,13 @@ import com.fasterxml.jackson.annotation.JsonIgnore;import org.hibernate.annotations.Formula;import org.openremote.model.IdentifiableEntity;import org.openremote.model.attribute.Attribute;-import org.openremote.model.geo.GeoJSON;-import org.openremote.model.geo.GeoJSONFeature;-import org.openremote.model.geo.GeoJSONGeometry;import org.openremote.model.util.ObservableList;-import org.openremote.model.util.TextUtil;import org.openremote.model.value.ObjectValue;import org.openremote.model.value.Values;import javax.persistence.*;import javax.validation.constraints.NotNull;import javax.validation.constraints.Size;-import java.math.BigDecimal;-import java.math.RoundingMode;import java.util.Arrays;import java.util.Date;import java.util.List;@@ -77,9 +71,6 @@ import static org.openremote.model.asset.AssetAttribute.*;* root asset in the tree. This is a transient property and only resolved and usable when* the asset is loaded from storage and as calculating it is costly, might be empty when* certain optimized loading operations are used.- * <p>- * The {@link #coordinates} are a pair of LNG/LAT values with the location of the asset.- * <p>* An asset may have dynamically-typed {@link #attributes} with an underlying* {@link ObjectValue} model. Use the {@link Attribute} etc. class to work with this API.* This property can be empty when certain optimized loading operations are used.@@ -267,9 +258,6 @@ public class Asset implements IdentifiableEntity {@Transientprotected String tenantDisplayName;- @Transient- protected double[] coordinates;-@Transient@JsonIgnoreprotected ObservableList<AssetAttribute> attributeList;@@ -340,7 +328,6 @@ public class Asset implements IdentifiableEntity {this.attributes = attributes;}-public Asset addAttributes(AssetAttribute... attributes) throws IllegalArgumentException {Arrays.asList(attributes).forEach(attribute -> {@@ -512,18 +499,6 @@ public class Asset implements IdentifiableEntity {this.tenantDisplayName = tenantDisplayName;}- public boolean hasCoordinates() {- return getCoordinates() != null && getCoordinates().length > 0;- }-- public double[] getCoordinates() {- return coordinates;- }-- public void setCoordinates(double... coordinates) {- this.coordinates = coordinates;- }-/*** NOTE: This is a transient and optional property, set only in database query results.* <p>@@ -598,31 +573,6 @@ public class Asset implements IdentifiableEntity {return setAttributes(Arrays.asList(attributes));}- /**- * This assumes {@link #getCoordinates} array index 0 is Lng and index 1 is Lat,- * which is true for PostGIS backend. Because Lat/Lng is the 'right way', we flip- * it here for display. Rounding to 5 decimal places gives us precision of about 1 meter.- */- public String getCoordinatesLabel() {- return- new BigDecimal(getCoordinates()[1]).setScale(5, RoundingMode.HALF_UP) + " " +- new BigDecimal(getCoordinates()[0]).setScale(5, RoundingMode.HALF_UP) + " Lat|Lng";- }-- public boolean hasGeoFeature() {- return getCoordinates() != null && getCoordinates().length == 2;- }-- public GeoJSON getGeoFeature(int maxNameLength) {- if (!hasGeoFeature())- return GeoJSON.EMPTY_FEATURE_COLLECTION;- return new GeoJSON("FeatureCollection").setFeatures(- new GeoJSONFeature("Feature")- .setProperty("id", getId())- .setProperty("title", TextUtil.ellipsize(getName(), maxNameLength))- .setGeometry(new GeoJSONGeometry(getCoordinates()))- );- }@Overridepublic String toString() {@@ -647,7 +597,6 @@ public class Asset implements IdentifiableEntity {", realmId='" + realmId + '\'' +", tenantRealm='" + tenantRealm + '\'' +", tenantDisplayName='" + tenantDisplayName + '\'' +- ", coordinates=" + Arrays.toString(coordinates) +", path=" + Arrays.toString(path) +", attributes=" + attributes +'}';@@ -677,4 +626,38 @@ public class Asset implements IdentifiableEntity {asset.getAttributesList().removeIf(filter);}++ public static Asset map(Asset assetToMap, Asset asset) {+ return map(assetToMap, asset, null, null, null, null, null, null);+ }++ public static Asset map(Asset assetToMap, Asset asset,+ String overrideName,+ String overrideRealmId,+ String overrideParentId,+ String overrideType,+ Boolean overrideAccessPublicRead,+ ObjectValue overrideAttributes) {+ asset.setVersion(assetToMap.getVersion());+ asset.setName(overrideName != null ? overrideName : assetToMap.getName());+ if (overrideType != null) {+ asset.setType(overrideType);+ } else {+ asset.setType(assetToMap.getType());+ }++ asset.setAccessPublicRead(overrideAccessPublicRead != null ? overrideAccessPublicRead : assetToMap.isAccessPublicRead());++ asset.setParentId(overrideParentId != null ? overrideParentId : assetToMap.getParentId());+ asset.setParentName(null);+ asset.setParentType(null);++ asset.setRealmId(overrideRealmId != null ? overrideRealmId : assetToMap.getRealmId());+ asset.setTenantRealm(null);+ asset.setTenantDisplayName(null);++ asset.setAttributes(overrideAttributes != null ? overrideAttributes : assetToMap.getAttributes());++ return asset;+ }}\ No newline at end of filediff --git a/model/src/main/java/org/openremote/model/asset/AssetMeta.java b/model/src/main/java/org/openremote/model/asset/AssetMeta.javaindex fef386a43..d939f295b 100644--- a/model/src/main/java/org/openremote/model/asset/AssetMeta.java+++ b/model/src/main/java/org/openremote/model/asset/AssetMeta.java@@ -76,20 +76,6 @@ public enum AssetMeta implements MetaItemDescriptor {: new ValidationFailure(META_ITEM_VALUE_MISMATCH, AttributeRef.class.getSimpleName()))),- /**- * Links an attribute to the location of the owning {@link Asset}; this is intended to be coupled with- * {@link #AGENT_LINK} to allow protocols to write an {@link Asset}'s location.- */- LOCATION_LINK(- ASSET_META_NAMESPACE + ":locationLink",- ACCESS_PRIVATE,- ValueType.BOOLEAN,- null,- null,- Values.create(true),- true- ),-/*** Links the attribute to another attribute, so an attribute event on the attribute triggers the same attribute* event on the linked attribute.diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeType.java b/model/src/main/java/org/openremote/model/attribute/AttributeType.javaindex 8c1c37fb5..253919f82 100644--- a/model/src/main/java/org/openremote/model/attribute/AttributeType.java+++ b/model/src/main/java/org/openremote/model/attribute/AttributeType.java@@ -100,7 +100,7 @@ public enum AttributeType {TEMPERATURE_CELCIUS("thermometer", ValueType.NUMBER, value -> Values.getNumber(value).filter(n -> n < -273.15).map(n -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_TEMPERATURE_OUT_OF_RANGE)),- new MetaItem(FORMAT, Values.create("%0.1f C")+ new MetaItem(FORMAT, Values.create("%0.1f C"))),@@ -226,7 +226,11 @@ public enum AttributeType {DIRECTION_DECIMAL_DEGREES("compass", ValueType.NUMBER, value -> Optional.empty(),new MetaItem(FORMAT, Values.create("%0.1f deg"))- );+ ),++ LOCATION("map-marker", ValueType.OBJECT, value -> Values.getObject(value)+ .filter(object -> !object.hasKey("latitude") || !object.hasKey("longitude"))+ .map(object -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_INVALID)));public static final String DEFAULT_ICON = "circle-thin";diff --git a/model/src/main/java/org/openremote/model/rules/AssetQueryPredicate.java b/model/src/main/java/org/openremote/model/rules/AssetQueryPredicate.javaindex f93b001e1..7a2a44b6a 100644--- a/model/src/main/java/org/openremote/model/rules/AssetQueryPredicate.java+++ b/model/src/main/java/org/openremote/model/rules/AssetQueryPredicate.java@@ -19,8 +19,11 @@*/package org.openremote.model.rules;+import com.vividsolutions.jts.geom.*;+import com.vividsolutions.jts.util.GeometricShapeFactory;import org.openremote.model.asset.BaseAssetQuery;import org.openremote.model.asset.BaseAssetQuery.*;+import org.openremote.model.value.ObjectValue;import java.util.Arrays;import java.util.Locale;@@ -89,7 +92,7 @@ public class AssetQueryPredicate implements Predicate<AssetState> {// Cannot use JTS libraries here without moving this class into manager module// TODO: decide whether to use JTS lib or do simple approx calcs (e.g. (x - center_x)^2 + (y - center_y)^2 < radius^2)if (query.location instanceof RadialLocationPredicate) {- RadialLocationPredicate radialLocationPredicate = (RadialLocationPredicate)query.location;+ RadialLocationPredicate radialLocationPredicate = (RadialLocationPredicate) query.location;return false;} else if (query.location instanceof RectangularLocationPredicate) {return false;@@ -210,6 +213,31 @@ public class AssetQueryPredicate implements Predicate<AssetState> {&& (predicate.realmId == null || predicate.realmId.equals(assetState.getRealmId()));}+ protected Predicate<Coordinate> asPredicate(LocationPredicate predicate) {+ return coordinate -> {+ if (predicate instanceof RadialLocationPredicate) {+ RadialLocationPredicate radialLocationPredicate = (RadialLocationPredicate) predicate;+ GeometricShapeFactory shapeFactory = new GeometricShapeFactory();+ shapeFactory.setCentre(new Coordinate(radialLocationPredicate.lat, radialLocationPredicate.lng));+ shapeFactory.setSize(radialLocationPredicate.radius * 2);+ Polygon circle = shapeFactory.createCircle();++ GeometryFactory geometryFactory = new GeometryFactory();+ Point point = geometryFactory.createPoint(coordinate);+ return point.within(circle);++ } else if (predicate instanceof RectangularLocationPredicate) {+ RectangularLocationPredicate rectangularLocationPredicate = (RectangularLocationPredicate) predicate;+ Envelope envelope = new Envelope(rectangularLocationPredicate.latMin,+ rectangularLocationPredicate.lngMin,+ rectangularLocationPredicate.latMax,+ rectangularLocationPredicate.lngMax);+ return envelope.contains(coordinate);+ }+ return false;+ };+ }+protected Predicate<AssetState> asPredicate(AttributePredicate predicate) {return assetState -> {if (predicate.name != null && !asPredicate(predicate.name).test(assetState.getAttributeName()))@@ -236,6 +264,14 @@ public class AssetQueryPredicate implements Predicate<AssetState> {NumberPredicate p = (NumberPredicate) predicate.value;return asPredicate(p).test(assetState.getValueAsNumber().orElse(null));+ } else if (predicate.value instanceof BaseAssetQuery.LocationPredicate) {+ LocationPredicate p = (LocationPredicate) predicate.value;+ ObjectValue objectValue = assetState.getValueAsObject().orElse(null);+ if (objectValue != null) {+ Coordinate coordinate = new Coordinate(objectValue.getNumber("latitude").orElse(0d), objectValue.getNumber("longitude").orElse(0d));+ return asPredicate(p).test(coordinate);+ }+ return false;} else {// TODO Implement morethrow new UnsupportedOperationException(diff --git a/model/src/main/java/org/openremote/model/rules/AssetState.java b/model/src/main/java/org/openremote/model/rules/AssetState.javaindex 52891e838..dd5d4bd4a 100644--- a/model/src/main/java/org/openremote/model/rules/AssetState.java+++ b/model/src/main/java/org/openremote/model/rules/AssetState.java@@ -89,8 +89,6 @@ public class AssetState implements Comparable<AssetState> {final protected String tenantRealm;- final protected double[] coordinates;-public AssetState(AssetState that) {this.attributeName = that.attributeName;this.attributeType = that.attributeType;@@ -112,7 +110,6 @@ public class AssetState implements Comparable<AssetState> {this.parentType = that.parentType;this.realmId = that.realmId;this.tenantRealm = that.tenantRealm;- this.coordinates = that.coordinates;}public AssetState(Asset asset, AssetAttribute attribute, AttributeEvent.Source source) {@@ -136,7 +133,6 @@ public class AssetState implements Comparable<AssetState> {this.parentType = asset.getParentWellKnownType();this.realmId = asset.getRealmId();this.tenantRealm = asset.getTenantRealm();- this.coordinates = asset.getCoordinates();}public String getAttributeName() {@@ -219,10 +215,6 @@ public class AssetState implements Comparable<AssetState> {return tenantRealm;}- public double[] getCoordinates() {- return coordinates;- }-public boolean isValueChanged() {return !getValue().equals(Optional.ofNullable(oldValue));}diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetAttributeLinkingTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetAttributeLinkingTest.groovyindex 2eade445e..657b842d8 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetAttributeLinkingTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetAttributeLinkingTest.groovy@@ -2,8 +2,9 @@ package org.openremote.test.assetsimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageService-import org.openremote.manager.asset.ServerAsset+import org.openremote.model.Constants+import org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetAttributeimport org.openremote.model.asset.AssetMetaimport org.openremote.model.asset.AssetType@@ -35,12 +36,12 @@ class AssetAttributeLinkingTest extends Specification implements ManagerContaine}when: "assets are created"- def asset1 = new ServerAsset("Asset 1", AssetType.THING, null, Constants.MASTER_REALM)+ def asset1 = new Asset("Asset 1", AssetType.THING, null, Constants.MASTER_REALM)asset1.setAttributes(new AssetAttribute("button", AttributeType.STRING, Values.create("RELEASED"), getClockTimeOf(container)))asset1 = assetStorageService.merge(asset1)- def asset2 = new ServerAsset("Asset 2", AssetType.THING, null, Constants.MASTER_REALM)+ def asset2 = new Asset("Asset 2", AssetType.THING, null, Constants.MASTER_REALM)asset2.setAttributes(new AssetAttribute("lightOnOff", AttributeType.BOOLEAN, Values.create(false), getClockTimeOf(container)),new AssetAttribute("counter", AttributeType.NUMBER, Values.create(0), getClockTimeOf(container))diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovyindex 3c7741072..8cf6925fe 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy@@ -15,7 +15,7 @@ import org.openremote.app.client.event.SubscriptionFailureEventimport org.openremote.app.client.i18n.ManagerMessagesimport org.openremote.app.client.style.WidgetStyleimport org.openremote.manager.asset.AssetStorageService-import org.openremote.manager.asset.ServerAsset+import org.openremote.manager.security.ManagerIdentityServiceimport org.openremote.manager.setup.AbstractKeycloakSetupimport org.openremote.manager.setup.SetupService@@ -204,7 +204,7 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContainewhen: "an asset is created in the database"collectedSharedEvents.clear()- asset = new ServerAsset("My Test Asset", AssetType.THING, asset)+ asset = new Asset("My Test Asset", AssetType.THING, asset)asset = assetStorageService.merge(asset)then: "a tree modified event should be received from the server"diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovyindex e5e2fdd8f..b6d6ba33d 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy@@ -5,6 +5,7 @@ import org.openremote.manager.asset.*import org.openremote.manager.setup.SetupServiceimport org.openremote.manager.setup.builtin.KeycloakDemoSetupimport org.openremote.manager.setup.builtin.ManagerDemoSetup+import org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetAttributeimport org.openremote.model.asset.AssetMetaimport org.openremote.model.asset.AssetType@@ -91,7 +92,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitAssetUpdateProcessor firstProcessor = new AssetUpdateProcessor() {@Override- boolean processAssetUpdate(EntityManager em, ServerAsset asset, AssetAttribute attribute, AttributeEvent.Source source) throws AssetProcessingException {+ boolean processAssetUpdate(EntityManager em, Asset asset, AssetAttribute attribute, AttributeEvent.Source source) throws AssetProcessingException {updatesPassedStartOfProcessingChain.add(attribute)false}@@ -99,7 +100,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitAssetUpdateProcessor afterAgentServiceProcessor = new AssetUpdateProcessor() {@Override- boolean processAssetUpdate(EntityManager em, ServerAsset asset, AssetAttribute attribute, AttributeEvent.Source source) throws AssetProcessingException {+ boolean processAssetUpdate(EntityManager em, Asset asset, AssetAttribute attribute, AttributeEvent.Source source) throws AssetProcessingException {updatesPassedAgentService.add(attribute)false}@@ -107,7 +108,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitAssetUpdateProcessor afterRulesServiceProcessor = new AssetUpdateProcessor() {@Override- boolean processAssetUpdate(EntityManager em, ServerAsset asset, AssetAttribute attribute, AttributeEvent.Source source) throws AssetProcessingException {+ boolean processAssetUpdate(EntityManager em, Asset asset, AssetAttribute attribute, AttributeEvent.Source source) throws AssetProcessingException {updatesPassedRulesService.add(attribute)false}@@ -115,7 +116,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitAssetUpdateProcessor afterDatapointServiceProcessor = new AssetUpdateProcessor() {@Override- boolean processAssetUpdate(EntityManager em, ServerAsset asset, AssetAttribute attribute, AttributeEvent.Source source) throws AssetProcessingException {+ boolean processAssetUpdate(EntityManager em, Asset asset, AssetAttribute attribute, AttributeEvent.Source source) throws AssetProcessingException {updatesPassedDatapointService.add(attribute)false}@@ -123,7 +124,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitAssetUpdateProcessor afterAttributeLinkingServiceProcessor = new AssetUpdateProcessor() {@Override- boolean processAssetUpdate(EntityManager em, ServerAsset asset, AssetAttribute attribute, AttributeEvent.Source source) throws AssetProcessingException {+ boolean processAssetUpdate(EntityManager em, Asset asset, AssetAttribute attribute, AttributeEvent.Source source) throws AssetProcessingException {updatesPassedAttributeLinkingService.add(attribute)false}@@ -150,7 +151,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitassetProcessingService.processors.add(8, afterAttributeLinkingServiceProcessor)when: "a mock agent that uses the mock protocol is created"- def mockAgent = new ServerAsset()+ def mockAgent = new Asset()mockAgent.setName("Mock Agent")mockAgent.setType(AssetType.AGENT)mockAgent.setAttributes(@@ -160,7 +161,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitmockAgent = assetStorageService.merge(mockAgent)and: "a mock thing asset is created with a valid protocol attribute, an invalid protocol attribute and a plain attribute"- def mockThing = new ServerAsset("Mock Thing Asset", AssetType.THING, mockAgent)+ def mockThing = new Asset("Mock Thing Asset", AssetType.THING, mockAgent)mockThing.setAttributes(new AssetAttribute("light1Toggle", AttributeType.BOOLEAN, Values.create(true)).setMeta(diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovyindex 8d8bf5101..19ed3249e 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy@@ -3,10 +3,11 @@ package org.openremote.test.assetsimport org.openremote.container.Containerimport org.openremote.container.persistence.PersistenceServiceimport org.openremote.manager.asset.AssetStorageService-import org.openremote.manager.asset.ServerAsset+import org.openremote.manager.setup.SetupServiceimport org.openremote.manager.setup.builtin.KeycloakDemoSetupimport org.openremote.manager.setup.builtin.ManagerDemoSetup+import org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetResourceimport org.openremote.model.asset.AssetAttributeimport org.openremote.model.asset.AssetQuery@@ -51,7 +52,7 @@ class AssetPublicQueryTest extends Specification implements ManagerContainerTraipersistenceService = container.getService(PersistenceService.class)assetResource = getClientTarget(serverUri(serverPort), MASTER_REALM).proxy(AssetResource.class)- ServerAsset somePublicAsset = new ServerAsset("Some Public Asset", THING)+ Asset somePublicAsset = new Asset("Some Public Asset", THING)somePublicAsset.setParentId(managerDemoSetup.smartOfficeId)somePublicAsset.setAccessPublicRead(true)somePublicAsset.setAttributes(diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovyindex b9c0c9cd4..2d60a81b3 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy@@ -6,10 +6,11 @@ import org.openremote.container.Containerimport org.openremote.container.persistence.PersistenceServiceimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageService-import org.openremote.manager.asset.ServerAsset+import org.openremote.manager.setup.SetupServiceimport org.openremote.manager.setup.builtin.KeycloakDemoSetupimport org.openremote.manager.setup.builtin.ManagerDemoSetup+import org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetMetaimport org.openremote.model.asset.AssetQueryimport org.openremote.model.asset.AssetType@@ -188,10 +189,10 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {assets[10].id == managerDemoSetup.apartment3LivingroomIdwhen: "an asset is loaded by identifier through JPA"- def asset = persistenceService.doReturningTransaction(new Function<EntityManager, ServerAsset>() {+ def asset = persistenceService.doReturningTransaction(new Function<EntityManager, Asset>() {@Override- ServerAsset apply(EntityManager em) {- em.find(ServerAsset.class, managerDemoSetup.apartment1Id)+ Asset apply(EntityManager em) {+ em.find(Asset.class, managerDemoSetup.apartment1Id)}})diff --git a/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovyindex 3c7dca715..54c368a29 100644--- a/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy@@ -26,7 +26,7 @@ import org.openremote.agent.protocol.filter.SubStringFilterimport org.openremote.manager.agent.AgentServiceimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageService-import org.openremote.manager.asset.ServerAsset+import org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetAttributeimport org.openremote.model.asset.AssetMetaimport org.openremote.model.asset.AssetType@@ -165,7 +165,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,def assetProcessingService = container.getService(AssetProcessingService.class)when: "a mock agent that uses the mock protocol is created with several protocol configurations"- def mockAgent = new ServerAsset()+ def mockAgent = new Asset()mockAgent.setName("Mock Agent")mockAgent.setType(AssetType.AGENT)mockAgent.setAttributes(@@ -205,7 +205,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,}when: "a mock thing asset is created that links to the mock protocol configurations"- def mockThing = new ServerAsset("Mock Thing Asset", AssetType.THING, mockAgent)+ def mockThing = new Asset("Mock Thing Asset", AssetType.THING, mockAgent)mockThing.setAttributes(new AssetAttribute("lightToggle1", AttributeType.BOOLEAN).setMeta(diff --git a/test/src/test/groovy/org/openremote/test/protocol/KNXImportTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/KNXImportTest.groovyindex 468beb6e7..147a2ca73 100644--- a/test/src/test/groovy/org/openremote/test/protocol/KNXImportTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/KNXImportTest.groovy@@ -19,6 +19,8 @@*/package org.openremote.test.protocol+import org.openremote.model.asset.Asset+import static org.openremote.model.Constants.*import static org.openremote.manager.setup.AbstractKeycloakSetup.SETUP_ADMIN_PASSWORDimport static org.openremote.manager.setup.AbstractKeycloakSetup.SETUP_ADMIN_PASSWORD_DEFAULT@@ -29,7 +31,7 @@ import org.openremote.model.asset.agent.ConnectionStatusimport org.openremote.manager.agent.AgentServiceimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageService-import org.openremote.manager.asset.ServerAsset+import org.openremote.model.asset.agent.AgentResourceimport org.openremote.model.Constantsimport org.openremote.model.asset.AssetAttribute@@ -61,7 +63,7 @@ class KNXImportTest extends Specification implements ManagerContainerTrait {def knxProtocol = container.getService(KNXProtocol.class)when: "a KNX agent that uses the KNX protocol is created. to test the import we don't need a valid protocol configuration"- def knxAgent = new ServerAsset()+ def knxAgent = new Asset()knxAgent.setName("KNX Agent")knxAgent.setType(AssetType.AGENT)knxAgent.setAttributes(diff --git a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovyindex 5696c4e07..ed87ebc88 100644--- a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy@@ -19,6 +19,7 @@*/package org.openremote.test.protocol+import org.openremote.model.asset.Assetimport tuwien.auto.calimero.server.knxnetip.DefaultServiceContainerimport static org.openremote.model.asset.AssetMeta.DESCRIPTION@@ -29,7 +30,7 @@ import org.openremote.model.asset.agent.ConnectionStatusimport org.openremote.manager.agent.AgentServiceimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageService-import org.openremote.manager.asset.ServerAsset+import org.openremote.model.Constantsimport org.openremote.model.asset.AssetAttributeimport org.openremote.model.asset.AssetMeta@@ -86,7 +87,7 @@ class KNXProtocolTest extends Specification implements ManagerContainerTrait {when: "a KNX agent that uses the KNX protocol is created with a valid protocol configuration"- def knxAgent = new ServerAsset()+ def knxAgent = new Asset()knxAgent.setName("KNX Agent")knxAgent.setType(AssetType.AGENT)knxAgent.setAttributes(@@ -117,7 +118,7 @@ class KNXProtocolTest extends Specification implements ManagerContainerTrait {when: "a thing asset is created that links it's attributes to the knx protocol configuration"- def knxThing = new ServerAsset("Living Room Assset", AssetType.THING, knxAgent)+ def knxThing = new Asset("Living Room Assset", AssetType.THING, knxAgent)knxThing.setAttributes(new AssetAttribute("light1ToggleOnOff", AttributeType.BOOLEAN).setMeta(diff --git a/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovyindex 4434db0f5..e9003d3c7 100644--- a/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy@@ -4,9 +4,10 @@ import org.openremote.agent.protocol.timer.TimerProtocolimport org.openremote.agent.protocol.timer.TimerValueimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageService-import org.openremote.manager.asset.ServerAsset+import org.openremote.manager.setup.SetupServiceimport org.openremote.manager.setup.builtin.ManagerDemoSetup+import org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetAttributeimport org.openremote.model.asset.AssetQueryimport org.openremote.model.asset.AssetType@@ -35,8 +36,8 @@ class TimerProtocolTest extends Specification implements ManagerContainerTrait {def assetProcessingService = container.getService(AssetProcessingService.class)def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def timerProtocol = container.getService(TimerProtocol.class)- ServerAsset sceneAgent- ServerAsset apartment1+ Asset sceneAgent+ Asset apartment1then: "the container should be running and attributes linked"conditions.eventually {diff --git a/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovyindex 417ab0ea2..7f660eef2 100644--- a/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy@@ -27,8 +27,9 @@ import org.openremote.agent.protocol.http.*import org.openremote.manager.agent.AgentServiceimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageService-import org.openremote.manager.asset.ServerAsset+import org.openremote.model.Constants+import org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetAttributeimport org.openremote.model.asset.AssetMetaimport org.openremote.model.asset.AssetType@@ -297,7 +298,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr}and: "an agent with a HTTP client protocol configuration is created"- def agent = new ServerAsset()+ def agent = new Asset()agent.setRealmId(Constants.MASTER_REALM)agent.setName("Test Agent")agent.setType(AssetType.AGENT)@@ -458,7 +459,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr}when: "an asset is created with attributes linked to the http protocol configuration"- def asset = new ServerAsset("Test Asset", AssetType.THING, agent)+ def asset = new Asset("Test Asset", AssetType.THING, agent)asset.setAttributes(// attribute that sends requests to the server using PUT with dynamic body and custom header to override parentnew AssetAttribute("putRequestWithHeaders", AttributeType.OBJECT)@@ -622,7 +623,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr}when: "attributes are linked to these protocol configurations"- def asset2 = new ServerAsset("Test Asset 2", AssetType.THING, agent)+ def asset2 = new Asset("Test Asset 2", AssetType.THING, agent)asset2.addAttributes(new AssetAttribute("getSuccess", AttributeType.STRING).addMeta(diff --git a/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovyindex 160f5b1f2..5b8d82824 100644--- a/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy@@ -27,7 +27,7 @@ import org.openremote.agent.protocol.http.*import org.openremote.manager.agent.AgentServiceimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageService-import org.openremote.manager.asset.ServerAsset+import org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetAttributeimport org.openremote.model.asset.AssetTypeimport org.openremote.model.attribute.AttributeType@@ -303,7 +303,7 @@ class HttpServerProtocolTest extends Specification implements ManagerContainerTrnull).proxy(TestResource.class)when: "an agent with a test HTTP server protocol configuration is created"- def agent = new ServerAsset()+ def agent = new Asset()agent.setRealmId(MASTER_REALM)agent.setName("Test Agent")agent.setType(AssetType.AGENT)@@ -330,7 +330,7 @@ class HttpServerProtocolTest extends Specification implements ManagerContainerTr}when: "the authenticated test resource is used to post an asset"- def testAsset = new ServerAsset("Test Asset", AssetType.THING)+ def testAsset = new Asset("Test Asset", AssetType.THING)testAsset.setId("12345")testAsset.setAttributes(new AssetAttribute("attribute1", AttributeType.STRING, Values.create("Test"))@@ -344,8 +344,9 @@ class HttpServerProtocolTest extends Specification implements ManagerContainerTrassert testServerProtocol.resource1.postedAssets.get(0).name == "Test Asset"assert testServerProtocol.resource1.postedAssets.get(0).hasTypeWellKnown()assert testServerProtocol.resource1.postedAssets.get(0).wellKnownType == AssetType.THING- assert testServerProtocol.resource1.postedAssets.get(0).coordinates[0] == 1d- assert testServerProtocol.resource1.postedAssets.get(0).coordinates[1] == 2d+ //TODO location update+// assert testServerProtocol.resource1.postedAssets.get(0).coordinates[0] == 1d+// assert testServerProtocol.resource1.postedAssets.get(0).coordinates[1] == 2d}when: "the authenticated test resource is used to get an asset"@@ -354,8 +355,9 @@ class HttpServerProtocolTest extends Specification implements ManagerContainerTrthen: "the asset should match the posted asset"assert asset.name == testAsset.nameassert asset.wellKnownType == testAsset.wellKnownType- assert asset.coordinates[0] == testAsset.coordinates[0]- assert asset.coordinates[1] == testAsset.coordinates[1]+ //TODO location update+// assert asset.coordinates[0] == testAsset.coordinates[0]+// assert asset.coordinates[1] == testAsset.coordinates[1]when: "the un-authenticated test resource is used to post an asset"testResource.postAsset(testAsset)@@ -388,7 +390,7 @@ class HttpServerProtocolTest extends Specification implements ManagerContainerTr}when: "the new test resource is used to post an asset"- testAsset = new ServerAsset("Test Asset 2", AssetType.THING)+ testAsset = new Asset("Test Asset 2", AssetType.THING)testAsset.setId("67890")testAsset.setAttributes(new AssetAttribute("attribute2", AttributeType.STRING, Values.create("Test"))@@ -402,8 +404,9 @@ class HttpServerProtocolTest extends Specification implements ManagerContainerTrassert testServerProtocol.resource1.postedAssets.get(1).name == "Test Asset 2"assert testServerProtocol.resource1.postedAssets.get(1).hasTypeWellKnown()assert testServerProtocol.resource1.postedAssets.get(1).wellKnownType == AssetType.THING- assert testServerProtocol.resource1.postedAssets.get(1).coordinates[0] == 3d- assert testServerProtocol.resource1.postedAssets.get(1).coordinates[1] == 4d+ //TODO location update+// assert testServerProtocol.resource1.postedAssets.get(1).coordinates[0] == 3d+// assert testServerProtocol.resource1.postedAssets.get(1).coordinates[1] == 4d}when: "the new test resource is used to get an asset"@@ -412,8 +415,9 @@ class HttpServerProtocolTest extends Specification implements ManagerContainerTrthen: "the asset should match the posted asset"assert asset.name == testAsset.nameassert asset.wellKnownType == testAsset.wellKnownType- assert asset.coordinates[0] == testAsset.coordinates[0]- assert asset.coordinates[1] == testAsset.coordinates[1]+ //TODO location update+// assert asset.coordinates[0] == testAsset.coordinates[0]+// assert asset.coordinates[1] == testAsset.coordinates[1]when: "a protocol configuration is deleted"agent.removeAttribute("protocolConfig")diff --git a/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovyindex 0680f22a4..eeaf29fa6 100644--- a/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy@@ -9,7 +9,7 @@ import org.openremote.agent.protocol.velbus.VelbusSerialProtocolimport org.openremote.manager.agent.AgentServiceimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageService-import org.openremote.manager.asset.ServerAsset+import org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetAttributeimport org.openremote.model.asset.AssetMetaimport org.openremote.model.asset.AssetType@@ -98,7 +98,7 @@ class VelbusProtocolTest extends Specification implements ManagerContainerTraitdef assetStorageService = container.getService(AssetStorageService.class)and: "a VELBUS agent is created"- def agent = new ServerAsset("VELBUS", AssetType.AGENT)+ def agent = new Asset("VELBUS", AssetType.AGENT)agent.setRealmId(MASTER_REALM)agent.setType(AssetType.AGENT)agent.setAttributes(@@ -108,7 +108,7 @@ class VelbusProtocolTest extends Specification implements ManagerContainerTraitagent = assetStorageService.merge(agent)and: "a device asset is created"- def device = new ServerAsset("VELBUS Demo VMBGPOD", AssetType.THING, agent)+ def device = new Asset("VELBUS Demo VMBGPOD", AssetType.THING, agent)device.setAttributes(new AssetAttribute("ch1State", AttributeType.STRING).setMeta(@@ -159,7 +159,7 @@ class VelbusProtocolTest extends Specification implements ManagerContainerTraitdef velbusProjectFile = IOUtils.toString(velbusProjectFileResource, "UTF-8")and: "a VELBUS agent is created"- def agent = new ServerAsset("VELBUS", AssetType.AGENT)+ def agent = new Asset("VELBUS", AssetType.AGENT)agent.setRealmId(MASTER_REALM)agent.setType(AssetType.AGENT)agent.setAttributes(diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovyindex 528d6af5b..41954804e 100644--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy@@ -3,7 +3,7 @@ package org.openremote.test.rulesimport org.openremote.container.Containerimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageService-import org.openremote.manager.asset.ServerAsset+import org.openremote.manager.rules.RulesEngineimport org.openremote.manager.rules.RulesServiceimport org.openremote.manager.rules.RulesetStorageService@@ -11,6 +11,7 @@ import org.openremote.manager.rules.geofence.GeofenceAssetAdapterimport org.openremote.manager.setup.SetupServiceimport org.openremote.manager.setup.builtin.KeycloakDemoSetupimport org.openremote.manager.setup.builtin.ManagerDemoSetup+import org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetAttributeimport org.openremote.model.asset.AssetMetaimport org.openremote.model.asset.AssetType@@ -215,7 +216,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerwhen: "a Kitchen room asset is inserted into apartment that contains a RULE_STATE = true meta flag"rulesImport.resetRulesFired()def apartment2 = assetStorageService.find(managerDemoSetup.apartment2Id)- def asset = new ServerAsset("Kitchen", AssetType.ROOM, apartment2)+ def asset = new Asset("Kitchen", AssetType.ROOM, apartment2)asset.setRealmId(keycloakDemoSetup.customerATenant.getId())def attributes = [new AssetAttribute("testString", AttributeType.STRING, Values.create("test"))