Package org.openhab.core.persistence
Interface QueryablePersistenceService
- All Superinterfaces:
PersistenceService
- All Known Subinterfaces:
ModifiablePersistenceService
A queryable persistence service which can be used to store and retrieve
data from openHAB. This is most likely some kind of database system.
- Author:
- Kai Kreuzer - Initial contribution, Chris Jackson - Added getItems method, Mark Herwege - Added methods to retrieve lastUpdate, lastChange and lastState from persistence, Mark Herwege - Implement aliases
-
Method Summary
Modifier and TypeMethodDescriptionReturns a set ofPersistenceItemInfo
about items that are stored in the persistence service.default @Nullable PersistedItem
persistedItem
(String itemName, @Nullable String alias) Returns aPersistedItem
representing the persisted state, last update and change timestamps and previous persisted state.query
(FilterCriteria filter) Queries thePersistenceService
for historic data with a givenFilterCriteria
.default Iterable
<HistoricItem> query
(FilterCriteria filter, @Nullable String alias) Queries thePersistenceService
for historic data with a givenFilterCriteria
.Methods inherited from interface org.openhab.core.persistence.PersistenceService
getDefaultStrategies, getId, getLabel, store, store
-
Method Details
-
query
Queries thePersistenceService
for historic data with a givenFilterCriteria
. If the persistence service implementing this class supports using aliases for item names, the default implementation ofquery(FilterCriteria, String)
should be overridden as well.- Parameters:
filter
- the filter to apply to the query- Returns:
- a time series of items
-
query
Queries thePersistenceService
for historic data with a givenFilterCriteria
. If the persistence service implementing this interface supports aliases and relies on item registry lookups, the default implementation should be overridden to query the database with the aliased name.- Parameters:
filter
- the filter to apply to the queryalias
- for item name in database- Returns:
- a time series of items
-
getItemInfo
Set<PersistenceItemInfo> getItemInfo()Returns a set ofPersistenceItemInfo
about items that are stored in the persistence service. This allows the persistence service to return information about items that are no long available as anItem
in openHAB. If it is not possible to retrieve the information an empty set should be returned. Note that implementations for method callers that this method may return an alias for an existing item if the database does not store the mapping between item name and alias or the reverse mapping is not implemented in the persistence service.- Returns:
- a set of information about the persisted items
-
persistedItem
Returns aPersistedItem
representing the persisted state, last update and change timestamps and previous persisted state. This can be used to restore the full state of an item. The default implementation queries the service and iterates backward to find the last change and previous persisted state. Persistence services can override this default implementation with a more specific or efficient algorithm.- Parameters:
itemName
- name of itemalias
- alias of item- Returns:
- a
PersistedItem
or null if the item has not been persisted
-