openhab-core icon indicating copy to clipboard operation
openhab-core copied to clipboard

Allow managing persistence configurations and enable filters

Open J-N-K opened this issue 2 years ago • 7 comments

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 two RegistryChangeListener<T> with different types and the persistence manager needs to listen to both, the ItemRegistry and the PersistenceServiceConfigurationRegistry.
  • The PersistenceManager interface has been deprecated. To maintain backward compatibility, a LegacyPersistenceServiceConfigurationProvider 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 to PersistenceManager and makes use of the new registry.
  • The PersistenceModelManager has been refactored to a PersistenceServiceConfigurationProvider.
  • 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]

J-N-K avatar Mar 25 '22 19:03 J-N-K

@ghys Can you have a look at the REST part and let me know if that is a good design for the UI?

J-N-K avatar Mar 26 '22 10:03 J-N-K

I'll add more extensive test coverage to ensure that my refactoring are all correct.

J-N-K avatar Mar 26 '22 17:03 J-N-K

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 avatar Apr 07 '22 22:04 splatch

@splatch I enabled the PersistenceFilter.

J-N-K avatar Apr 22 '22 16:04 J-N-K

@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.

splatch avatar Apr 22 '22 17:04 splatch

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 avatar Apr 22 '22 17:04 J-N-K

@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. ;-)

splatch avatar Apr 22 '22 17:04 splatch

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

openhab-bot avatar Nov 14 '22 17:11 openhab-bot

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

openhab-bot avatar Jan 07 '23 19:01 openhab-bot

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

openhab-bot avatar Jan 10 '23 11:01 openhab-bot

@florian-h05 FYI. This is also lacking UI support and I don't have a good idea how this should look like.

J-N-K avatar Apr 07 '23 19:04 J-N-K

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 👍

florian-h05 avatar Apr 18 '23 08:04 florian-h05

Abitur

May the force be with you !

clinique avatar Apr 18 '23 10:04 clinique

I am currently super busy wit my final exams (Abitur), but I put this on my UI list 👍

Best of luck!

J-N-K avatar Apr 18 '23 10:04 J-N-K

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.

lolodomo avatar May 18 '23 11:05 lolodomo

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.

J-N-K avatar May 18 '23 11:05 J-N-K

Fine. I see them in XText syntax.

lolodomo avatar May 18 '23 11:05 lolodomo