Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[persistence] Don't require relative, inverted and unit fields for filter configuration over REST #3681

Closed
wants to merge 1 commit into from

Conversation

florian-h05
Copy link
Contributor

While creating the persistence edit page, I noticed that PUT /rest/persistence/{serviceId} requests fail when the boolean properties inverted and relative of some persistence filters are not set. First, I ensured that they are set when the UI saves the persistence configuration, however IMO this should be in core.
Setting up a treshold filter with the UI, it did not work because the unit field was blank (I got an NPE from PersistenceTresholdFilter, and the PersistenceIncludeFilter would also throw a NPE.

This PR sets reasonable defaults for those fields that are required by core, but not neccassarily set by the user.

/cc @J-N-K

…tive, inverted if those are null

This allows MainUI to send requests without ensuring that these fields are set.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05 florian-h05 requested a review from a team as a code owner July 3, 2023 12:39
florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Jul 3, 2023
Depends on openhab/openhab-core#3681.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05 florian-h05 changed the title [persistence] Don't require relative, inverted and unit fields in REST request [persistence] Don't require relative, inverted and unit fields for filter configuration over REST Jul 3, 2023
@J-N-K
Copy link
Member

J-N-K commented Jul 4, 2023

I'm not sure this is the best way. IMO it would better to make the constructors accept a null value and set the default in the filter class. That makes it much clearer what the default is and also works in other places. WDYT?

@splatch
Copy link
Contributor

splatch commented Jul 4, 2023

Isn't it better to make this particular DTO mapper non-static? It seems to be that PersistenceFilters have rather a dynamic nature and mapping of them in such tied way will always lead to troubles.

@florian-h05
Copy link
Contributor Author

That makes it much clearer what the default is and also works in other places. WDYT?

I will try that.

@florian-h05
Copy link
Contributor Author

I am currently on holiday in France, so I won’t be able to work on this soon. Let’s postpone it for openHAB 4.1, since the feature freeze will start on Sunday.

florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Jul 14, 2023
Depends on openhab/openhab-core#3681.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Jul 18, 2023
Depends on openhab/openhab-core#3681.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05 florian-h05 marked this pull request as draft July 20, 2023 11:39
florian-h05 added a commit to florian-h05/openhab-core that referenced this pull request Jul 20, 2023
Setting up a treshold filter with the UI, it did not work because the unit field was blank.
I got an NPE from PersistenceTresholdFilter, and the PersistenceIncludeFilter would also throw a NPE in that case.
For PersistenceTimeFilter, defaulting to "s" is just cosmetic.

Picks-up PR openhab#3681 and should be merged for the 4.0 release, because the UI does not prevent the unit field from being null.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
J-N-K pushed a commit that referenced this pull request Jul 20, 2023
Setting up a treshold filter with the UI, it did not work because the unit field was blank.
I got an NPE from PersistenceTresholdFilter, and the PersistenceIncludeFilter would also throw a NPE in that case.
For PersistenceTimeFilter, defaulting to "s" is just cosmetic.

Picks-up PR #3681 and should be merged for the 4.0 release, because the UI does not prevent the unit field from being null.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@J-N-K J-N-K closed this Jul 20, 2023
@florian-h05 florian-h05 deleted the persistence-filters branch July 24, 2023 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants