-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
Allow subscriptions for complete sitemaps (not limited to a single page) #3652
Conversation
12466df
to
537b962
Compare
I will have a look to your proposal. But as this is something we are not recommending at all, first can you confirm that this will not become the default behaviour for existing UIs ? And I would like something added in the javadoc explaining that this is a possible not a recommended usage. |
ce26ee9
to
ac1f2f1
Compare
@lolodomo thank you for giving this PR some support. I split up the methods to create a sitemap-wide subscription and a normal subscription endpoint, and wrote comments on the ones that should not be used. There should be no possibility to unconsciously subscribe to the whole sitemap. The things I did not change apparently contained some nullability issues with the pageId. I did not try to resolve them to not break legacy behaviour. |
f5aa752
to
7fb7a18
Compare
Signed-off-by: Tassilo Karge <[email protected]>
7fb7a18
to
4635625
Compare
Signed-off-by: Tassilo Karge <[email protected]>
additionally refactor the test by removing redundancy Signed-off-by: Tassilo Karge <[email protected]>
@lolodomo the compliance with your request to make sure not the whole sitemap is listened to by default is now also ensured by a regression test. I don´t see any reason why this should not be merged. |
@lolodomo I know everyone is busy and stuff, but now that it´s spring and everything is getting back to life, would you consider reviving your interest in this PR, too? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can simplify the code very much by allowig pageId
to be null (and consider that as "whole sitemap"). You can remove nearly all added methods in this case.
....rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/SitemapSubscriptionService.java
Outdated
Show resolved
Hide resolved
...io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java
Outdated
Show resolved
Hide resolved
....rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/SitemapSubscriptionService.java
Outdated
Show resolved
Hide resolved
I can't find that request in this PR, can you point me to the comment? |
Have I misinterpreted the request to make sure it does not get used accidentally? |
IMO yes, my understanding is that a comment should state "whole sitemap is not recommended" (maybe also in the API documentation, not only in JavaDoc) and that a subscription with page should never result in a subscription to the whole sitemap. But maybe @lolodomo can comment on this. Edit: This only relevant for the |
I will make some simplifications to the private methods, that should reduce code duplication. |
Yes, exactly ,that was my request. |
…bscriptions-signed_off
The reason I split the methods is that the method Lines 346 to 349 in 81f2bd9
|
...io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java
Show resolved
Hide resolved
Signed-off-by: Tassilo Karge <[email protected]>
… subscribing to page or sitemap Signed-off-by: Tassilo Karge <[email protected]>
Signed-off-by: Tassilo Karge <[email protected]>
…ge listener Signed-off-by: Tassilo Karge <[email protected]>
....rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/SitemapSubscriptionService.java
Show resolved
Hide resolved
There is an issue with the tests, can you fix that? I'll nmerge afterwards. Thanks for your patience. |
I have not checked but I will not be surprised that tests are failing due to the change I am commenting in my last message. |
The test fails because the subscriptionService is just a mock, I need to properly instantiate it and mock its itemUIRegistry in the test. |
You can also keep the mocked |
but that would defeat the purpose of the test, since an important part of the logic resides in collectWidgets |
I didn't look at the test, it was more a general comment. |
Signed-off-by: Tassilo Karge <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@J-N-K the test issues have been resolved. |
By renaming method |
Related to openhab/openhab-core#3652 that renamed method setPageId into updateSubscriptionLocation Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab/openhab-core#3652 that renamed method setPageId into updateSubscriptionLocation Signed-off-by: Laurent Garnier <[email protected]>
Thank you very much, I wasn't aware that the method was public api. Maybe I should re-add the legacy method but deprecate it and make it just call the new one, just in case other (plugin) implementations use the method, too? |
I searched in GitHub (including iOS and Android apps) and apparently Basic UI was the unique app calling this method. |
But you could fix javadoc still referencing it Line 63 in 1a89b9e
|
The changes in this PR allow to leave out the pageId in a request for updates from a subscription. The motivation for this was discussed in #3650
Leaving out the pageId in a subscription request makes the event API send events for updates of all widgets within a sitemap. This is accomplished by walking the sitemap tree and collecting all widgets in it when the subscription is created. Previously, only the widgets on the given page were collected at that occasion.
In the issue above, performance issues were discussed. I do not know how to test for them, and would happily accept help with that matter.