Package de.fraunhofer.iosb.ilt.sta.dao
Interface Dao<T extends Entity<T>>
-
- Type Parameters:
T
- the entity's type
- All Known Implementing Classes:
ActuatorDao
,BaseDao
,DatastreamDao
,FeatureOfInterestDao
,HistoricalLocationDao
,LocationDao
,MultiDatastreamDao
,ObservationDao
,ObservedPropertyDao
,SensorDao
,TaskDao
,TaskingCapabilityDao
,ThingDao
public interface Dao<T extends Entity<T>>
CRUD operations for data access objects (Daos).- Author:
- Nils Sommer, Hylke van der Schaaf, Michael Jacoby
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
create(T entity)
Create a new entity.void
delete(T entity)
Delete an entity.T
find(Entity<?> parent)
Find the entity related to the given parent, like the Thing for a Datastream.T
find(Id id)
Find an entity.T
find(Id id, Expansion expansion)
Find an entity including referenced entities from expansion.T
find(URI uri)
Find an entity.void
patch(T entity, List<com.github.fge.jsonpatch.JsonPatchOperation> patch)
Update the given entity with the given patch.Query<T>
query()
Start a query to find an entity collection.MqttSubscription
subscribe(Consumer<T> handler)
Starts an MQTT subscription.MqttSubscription
subscribe(Consumer<T> handler, EntityProperty... properties)
Starts an MQTT subscription.MqttSubscription
subscribe(Predicate<T> filter, Consumer<T> handler)
Starts an MQTT subscription.MqttSubscription
subscribe(Predicate<T> filter, Consumer<T> handler, EntityProperty... properties)
Starts an MQTT subscription.void
unsubscribe()
Stops all MQTT subscriptions.void
unsubscribe(MqttSubscription subscription)
Stops an MQTT subscription.void
update(T entity)
Update an entity.
-
-
-
Method Detail
-
create
void create(T entity) throws ServiceFailureException
Create a new entity.- Parameters:
entity
- the entity to create- Throws:
ServiceFailureException
- the operation failed
-
find
T find(Entity<?> parent) throws ServiceFailureException
Find the entity related to the given parent, like the Thing for a Datastream.- Parameters:
parent
- The parent to find the singular entity for.- Returns:
- the singular entity linked from the parent.
- Throws:
ServiceFailureException
- the operation failed
-
find
T find(Id id) throws ServiceFailureException
Find an entity.- Parameters:
id
- the entity's unique id- Returns:
- the entity
- Throws:
ServiceFailureException
- the operation failed
-
find
T find(URI uri) throws ServiceFailureException
Find an entity.- Parameters:
uri
- the entity's URI- Returns:
- the entity
- Throws:
ServiceFailureException
- the operation failed
-
find
T find(Id id, Expansion expansion) throws ServiceFailureException
Find an entity including referenced entities from expansion.- Parameters:
id
- the entity's unique idexpansion
- the expansion containing which referenced entities to fetch- Returns:
- the entity
- Throws:
ServiceFailureException
- the operation failed
-
update
void update(T entity) throws ServiceFailureException
Update an entity.- Parameters:
entity
- the entity to update- Throws:
ServiceFailureException
- the operation failed
-
patch
void patch(T entity, List<com.github.fge.jsonpatch.JsonPatchOperation> patch) throws ServiceFailureException
Update the given entity with the given patch. Does not update the entity object itself. To see the result, fetch it anew from the server.- Parameters:
entity
- The entity to update on the server.patch
- The patch to apply to the entity.- Throws:
ServiceFailureException
- the operation failed
-
delete
void delete(T entity) throws ServiceFailureException
Delete an entity.- Parameters:
entity
- the entity to delete- Throws:
ServiceFailureException
- the operation failed
-
subscribe
MqttSubscription subscribe(Consumer<T> handler) throws MqttException
Starts an MQTT subscription.- Parameters:
handler
- a handler that is called upon received messages- Returns:
- object containing information about new MQTT subscription
- Throws:
MqttException
- when subscription failed
-
subscribe
MqttSubscription subscribe(Predicate<T> filter, Consumer<T> handler) throws MqttException
Starts an MQTT subscription.- Parameters:
filter
- predicate to further filter returned entitieshandler
- a handler that is called upon received messages- Returns:
- object containing information about new MQTT subscription
- Throws:
MqttException
- when subscription failed
-
subscribe
MqttSubscription subscribe(Consumer<T> handler, EntityProperty... properties) throws MqttException
Starts an MQTT subscription.- Parameters:
handler
- a handler that is called upon received messagesproperties
- properties to select, must be presten for entity type T- Returns:
- object containing information about new MQTT subscription
- Throws:
MqttException
- when subscription failed
-
subscribe
MqttSubscription subscribe(Predicate<T> filter, Consumer<T> handler, EntityProperty... properties) throws MqttException
Starts an MQTT subscription.- Parameters:
filter
- predicate to further filter returned entitieshandler
- a handler that is called upon received messagesproperties
- properties to select, must be presten for entity type T- Returns:
- object containing information about new MQTT subscription
- Throws:
MqttException
- when subscription failed
-
unsubscribe
void unsubscribe(MqttSubscription subscription) throws MqttException
Stops an MQTT subscription.- Parameters:
subscription
- contains information on subscription- Throws:
MqttException
- when unsubscribing failed
-
unsubscribe
void unsubscribe() throws MqttException
Stops all MQTT subscriptions.- Throws:
MqttException
- when unsubscribing failed
-
-