openhab-core
openhab-core copied to clipboard
Allow managing persistence configurations and enable filters
Depends on #2994
The aim of this PR is to allow managing persistence service configurations via the REST API (UI).
To achieve this
- A
PersistenceServiceConfigurationRegistry
has been introduced. It needs to add an own interface for the change listener because one class can't inherit twoRegistryChangeListener<T>
with different types and the persistence manager needs to listen to both, theItemRegistry
and thePersistenceServiceConfigurationRegistry
. - The
PersistenceManager
interface has been deprecated. To maintain backward compatibility, aLegacyPersistenceServiceConfigurationProvider
has been introduced which implements the deprecated interface. It is in an internal package to prevent usage in new code. - The
PersistenceManagerImpl
has been renamed toPersistenceManager
and makes use of the new registry. - The
PersistenceModelManager
has been refactored to aPersistenceServiceConfigurationProvider
. - A
ManagedPersistenceServiceConfigurationProvider
has been introduced. - The core REST bundle has been extended to allow adding configurations. Unmanaged configurations can also be retrieved.
Signed-off-by: Jan N. Klug [email protected]
@ghys Can you have a look at the REST part and let me know if that is a good design for the UI?
I'll add more extensive test coverage to ensure that my refactoring are all correct.
Since you touch fairly important base - have a look on PersistenceFilter
which is blind interface without use. While it can be referred in persistence service config it plays no role in config itself. I made it an Predicate<Item>
which allows to use it as an exclusion filter for certain items. Obviously there is still a problem of mapping the filters, but that's other thing. Other elephant then would be the xtext part which would need to be provided by someone who knows how to work with it (or omitted as deprecated).
@splatch I enabled the PersistenceFilter
.
@splatch I enabled the
PersistenceFilter
.
Yes, I saw it and see you use it to throttle or limit writes to persistence stuff. It makes a lot of sense cause this can be used when multiple stores are used. My approach so far was focusing on use of profiles which worked for single persistence but not for all.
I think there is still an area for improvement in excluding certain items, cause mapFilter
is currently fairly limited. Its really about use cases reported several times in forums (where I advertised own externalized XML config for that) to serve cases where it is easier to mark item with an tag than create a completely new group without just few members.
Knowing the limit of xtext I think it could be done with a basic instanceof
call to see if ie. incoming filter instance is already compatible with contract and does not require further mapping.
The two filters I added were already defined in the model, that's why I implemented them. If someone knows how to properly extend that, more filters can be added. Maybe something like !itemName
could be used to exclude items. But it's difficult if we need wildcards. This should ne done in a separate PR. I only added the filters here because I needed to figure out how to model them for the REST API.
@J-N-K I'm perfectly fine with your work, my stuff is sitting on OH 3.0.x fork, so I still have plenty of time to fight with 3.3 updates. ;-)
This pull request has been mentioned on openHAB Community. There might be relevant details there:
https://community.openhab.org/t/is-there-a-way-to-limit-the-precision-of-number-items/141006/7
This pull request has been mentioned on openHAB Community. There might be relevant details there:
https://community.openhab.org/t/profiling-results-using-jprofiler/143073/2
This pull request has been mentioned on openHAB Community. There might be relevant details there:
https://community.openhab.org/t/openhab-4-0-wishlist/142388/248
@florian-h05 FYI. This is also lacking UI support and I don't have a good idea how this should look like.
Thanks for the hint, I have also seen https://github.com/openhab/openhab-webui/issues/1463. I am currently super busy wit my final exams (Abitur), but I put this on my UI list 👍
Abitur
May the force be with you !
I am currently super busy wit my final exams (Abitur), but I put this on my UI list 👍
Best of luck!
Other elephant then would be the xtext part which would need to be provided by someone who knows how to work with it (or omitted as deprecated).
@J-N-K : What exactly is missing in current XText for persistence? I can try to add/fix it if I understand what is the problem.
Filters are already enabled (I think we need documentation for that). Currently there are two types of filters: value-based and time-based. If we would add more, then there would also be the need for XText support, but I think currently we are fine.
Fine. I see them in XText syntax.