Class Asset<T extends Asset<?>>
- 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
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 Attribute
s that can be found and what
the value type of these Attribute
s should be but additional Attribute
s can also be added but
obviously no validation can be performed on such dynamic Attribute
s. 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 } } }
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The purpose of this is to provideAttribute.AttributeDeserializer
access to the asset type so theAttributeDescriptor
can be looked up to control value deserialization; this isn't used when hydrating from the DB as JPA uses its' own hydration mechanism so we also have a lazy loading of attribute value mechanism. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected @Valid AttributeMap
protected Date
static final AttributeDescriptor
<String> protected @Pattern(regexp="^[0-9A-Za-z]{22}$",message="{Asset.id.Pattern}") String
static final AttributeDescriptor
<GeoJSONPoint> static final AttributeDescriptor
<String> static final AttributeDescriptor
<String> protected @NotBlank(message="{Asset.name.NotBlank}") @Size(min=1,max=1023,message="{Asset.name.Size}") String
static final AttributeDescriptor
<String> protected @Pattern(regexp="^[0-9A-Za-z]{22}$",message="{Asset.parentId.Pattern}") String
protected String[]
protected @NotBlank(message="{Asset.realm.NotBlank}") @Size(min=1,max=255,message="{Asset.realm.Size}") String
static final AttributeDescriptor
<String[]> protected String
protected @jakarta.validation.constraints.Min(value=0L, message="{Asset.version.Min}") long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAttributes
(Attribute<?>... attributes) addOrReplaceAttributes
(Attribute<?>... attributes) boolean
getAttribute
(String attributeName) getAttribute
(AttributeDescriptor<T> descriptor) String[]
protected String
getEmail()
getId()
protected String
getMetaString
(MetaMap meta) getModel()
getName()
getNotes()
String[]
getPath()
NOTE: This is a transient and optional property, set only in database query results.getRealm()
getTags()
getType()
long
boolean
hasAttribute
(String attributeName) boolean
hasAttribute
(AttributeDescriptor<?> attributeDescriptor) int
hashCode()
boolean
boolean
pathContains
(String assetId) protected void
setAccessPublicRead
(boolean accessPublicRead) setAttributes
(Collection<Attribute<?>> attributes) Asset
<?> setAttributes
(Attribute<?>... attributes) setAttributes
(AttributeMap attributes) setCreatedOn
(Date createdOn) setLocation
(GeoJSONPoint location) setManufacturer
(String manufacturer) setParentId
(String parentId) setVersion
(long version) toString()
-
Field Details
-
LOCATION
-
EMAIL
-
TAGS
-
NOTES
-
MANUFACTURER
-
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
-
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
-
path
-
attributes
-
-
Constructor Details
-
Asset
protected Asset()For use by hydrators (i.e. JPA/Jackson) -
Asset
-
-
Method Details
-
getId
-
setId
- Specified by:
setId
in interfaceIdentifiableEntity<T extends Asset<?>>
-
getVersion
public long getVersion() -
setVersion
-
getCreatedOn
- Specified by:
getCreatedOn
in interfaceAssetInfo
-
setCreatedOn
-
getName
-
getAssetName
- Specified by:
getAssetName
in interfaceAssetInfo
-
setName
- Throws:
IllegalArgumentException
-
getType
-
isAccessPublicRead
public boolean isAccessPublicRead() -
setAccessPublicRead
-
setParent
-
getParentId
- Specified by:
getParentId
in interfaceAssetInfo
-
setParentId
-
getRealm
-
setRealm
-
getPath
NOTE: This is a transient and optional property, set only in database query results.The identifiers of all parents representing the path in the tree. The first element is the identifier of this instance, the last is the root asset without a parent.
-
pathContains
-
getAttributes
-
setAttributes
-
setAttributes
-
setAttributes
-
getAttribute
-
getAttribute
-
hasAttribute
-
hasAttribute
-
addAttributes
-
addOrReplaceAttributes
-
getAttributeNames
- Specified by:
getAttributeNames
in interfaceAssetInfo
-
getAssetType
- Specified by:
getAssetType
in interfaceAssetInfo
-
getAssetClass
- Specified by:
getAssetClass
in interfaceAssetInfo
-
toString
-
toStringAll
-
getAttributesString
-
getMetaString
-
getLocation
-
setLocation
-
getTags
-
setTags
-
getEmail
-
setEmail
-
getNotes
-
setNotes
-
getManufacturer
-
setManufacturer
-
getModel
-
setModel
-
postLoadCallback
protected void postLoadCallback() -
equals
-
hashCode
public int hashCode()
-