Class Asset<T extends Asset<?>>

java.lang.Object
org.openremote.model.asset.Asset<T>
All Implemented Interfaces:
AssetInfo, IdentifiableEntity<T>
Direct Known Subclasses:
Agent, CityAsset, ConsoleAsset, DoorAsset, ElectricityAsset, EnergyOptimisationAsset, EnvironmentSensorAsset, GatewayAsset, GroundwaterSensorAsset, GroupAsset, LightAsset, MicrophoneAsset, ParkingAsset, PeopleCounterAsset, PlugAsset, PresenceSensorAsset, RoomAsset, ShipAsset, ThermostatAsset, ThingAsset, UnknownAsset, VentilationAsset, WeatherAsset

@Entity @AssetValid @Valid public abstract class Asset<T extends Asset<?>> extends Object implements IdentifiableEntity<T>, AssetInfo
The main model class of this software.

An asset is an identifiable item in a composite relationship with other assets. This tree of assets can be managed through a null parentId property for root assets, and a valid parent identifier for sub-assets.

An asset is stored in and therefore access-controlled through a realm.

The createdOn value is milliseconds since the Unix epoch.

The getType()} of the asset is the same value as Class.getSimpleName() and should correspond with an AssetDescriptor registered within the running instance. If the corresponding AssetDescriptor cannot be found then the fallback generic ThingAsset.DESCRIPTOR will be assumed.

The id is BASE-62 encoded UUID (22 characters long) and can be supplied or auto generated; by allowing it to be supplied services have a predictable way to find a given asset and can use the UniqueIdentifierGenerator.generateId(String) to generate a constant ID from a given input string.

The path is a list of parent asset identifiers, starting with the identifier of this asset, followed by parent asset identifiers, and ending with the identifier of the 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. An asset may have 0-N attributes; the AssetDescriptor associated with an asset type describes the standard Attributes that can be found and what the value type of these Attributes should be but additional Attributes can also be added but obviously no validation can be performed on such dynamic Attributes. Use the Attribute etc. class to work with this API. This property can be empty when certain optimized loading operations are used.

For more details on restricted access of user-assigned assets, see UserAssetLink.

Example JSON representation of an asset tree:


 {
 "id": "0oI7Gf_kTh6WyRJFUTr8Lg",
 "version": 0,
 "createdOn": 1489042784142,
 "name": "Smart building",
 "type": "urn:openremote:asset:building",
 "accessPublicRead": false,
 "realm": "building",
 "realmDisplayName": "Building",
 "path": [
 "0oI7Gf_kTh6WyRJFUTr8Lg"
 ],
 "coordinates": [
 5.469751699216005,
 51.44760787406028
 ]
 }
 

 {
 "id": "B0x8ZOqZQHGjq_l0RxAJBA",
 "version": 0,
 "createdOn": 1489042784148,
 "name": "Apartment 1",
 "type": "urn:openremote:asset:residence",
 "accessPublicRead": false,
 "parentId": "0oI7Gf_kTh6WyRJFUTr8Lg",
 "parentName": "Smart building",
 "parentType": "urn:openremote:asset:building",
 "realm": "building",
 "path": [
 "B0x8ZOqZQHGjq_l0RxAJBA",
 "0oI7Gf_kTh6WyRJFUTr8Lg"
 ],
 "coordinates": [
 5.469751699216005,
 51.44760787406028
 ]
 }
 

 {
 "id": "bzlRiJmSSMCl8HIUt9-lMg",
 "version": 0,
 "createdOn": 1489042784157,
 "name": "Living Room",
 "type": "urn:openremote:asset:room",
 "accessPublicRead": false,
 "parentId": "B0x8ZOqZQHGjq_l0RxAJBA",
 "parentName": "Apartment 1",
 "parentType": "urn:openremote:asset:residence",
 "realm": "building",
 "path": [
 "bzlRiJmSSMCl8HIUt9-lMg",
 "B0x8ZOqZQHGjq_l0RxAJBA",
 "0oI7Gf_kTh6WyRJFUTr8Lg"
 ],
 "coordinates": [
 5.469751699216005,
 51.44760787406028
 ]
 }
 

 {
 "id": "W7GV_lFeQVyHLlgHgE3dEQ",
 "version": 0,
 "createdOn": 1489042784164,
 "name": "Living Room Thermostat",
 "type": "urn:openremote:asset:thing",
 "accessPublicRead": false,
 "parentId": "bzlRiJmSSMCl8HIUt9-lMg",
 "parentName": "Living Room",
 "parentType": "urn:openremote:asset:room",
 "realm": "building",
 "path": [
 "W7GV_lFeQVyHLlgHgE3dEQ",
 "bzlRiJmSSMCl8HIUt9-lMg",
 "B0x8ZOqZQHGjq_l0RxAJBA",
 "0oI7Gf_kTh6WyRJFUTr8Lg"
 ],
 "coordinates": [
 5.460315214821094,
 51.44541688237109
 ],
 "attributes": {
 "currentTemperature": {
 "meta": [
 {
 "name": "urn:openremote:asset:meta:label",
 "value": "Current Temp"
 },
 {
 "name": "urn:openremote:asset:meta:accessRestrictedRead",
 "value": true
 },
 {
 "name": "urn:openremote:asset:meta:readOnly",
 "value": true
 },
 {
 "name": "urn:openremote:foo:bar",
 "value": "FOO"
 },
 {
 "name": "urn:thirdparty:bar",
 "value": "BAR"
 }
 ],
 "type": "Decimal",
 "value": 19.2,
 "valueTimestamp": 1.489670166115E12
 },
 "somethingPrivate": {
 "type": "String",
 "value": "Foobar",
 "valueTimestamp": 1.489670156115E12
 }
 }
 }
 
  • Field Details

    • LOCATION

      public static final AttributeDescriptor<GeoJSONPoint> LOCATION
    • EMAIL

      public static final AttributeDescriptor<String> EMAIL
    • TAGS

      public static final AttributeDescriptor<String[]> TAGS
    • NOTES

      public static final AttributeDescriptor<String> NOTES
    • MANUFACTURER

      public static final AttributeDescriptor<String> MANUFACTURER
    • MODEL

      public static final AttributeDescriptor<String> MODEL
    • id

      @Pattern(regexp="^[0-9A-Za-z]{22}$", message="{Asset.id.Pattern}") protected @Pattern(regexp="^[0-9A-Za-z]{22}$",message="{Asset.id.Pattern}") String id
    • version

      @Min(value=0L, message="{Asset.version.Min}") protected @jakarta.validation.constraints.Min(value=0L, message="{Asset.version.Min}") long version
    • createdOn

      protected Date createdOn
    • name

      @NotBlank(message="{Asset.name.NotBlank}") @Size(min=1, max=1023, message="{Asset.name.Size}") protected @NotBlank(message="{Asset.name.NotBlank}") @Size(min=1,max=1023,message="{Asset.name.Size}") String name
    • accessPublicRead

      protected boolean accessPublicRead
    • parentId

      @Pattern(regexp="^[0-9A-Za-z]{22}$", message="{Asset.parentId.Pattern}") protected @Pattern(regexp="^[0-9A-Za-z]{22}$",message="{Asset.parentId.Pattern}") String parentId
    • realm

      @NotBlank(message="{Asset.realm.NotBlank}") @Size(min=1, max=255, message="{Asset.realm.Size}") protected @NotBlank(message="{Asset.realm.NotBlank}") @Size(min=1,max=255,message="{Asset.realm.Size}") String realm
    • type

      protected String type
    • path

      protected String[] path
    • attributes

      @Valid protected @Valid AttributeMap attributes
  • Constructor Details

    • Asset

      protected Asset()
      For use by hydrators (i.e. JPA/Jackson)
    • Asset

      protected Asset(String name)
  • Method Details