-
Notifications
You must be signed in to change notification settings - Fork 787
the returned StateDescription combines values from GenericItemProvide… #4428
the returned StateDescription combines values from GenericItemProvide… #4428
Conversation
…r and ChannelStateDescriptionProvider Signed-off-by: Lyubomir V. Papazov <lyubomir.papazov@MUSALA.COM>
85db958
to
2f6e79f
Compare
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.
If we want to go further into merging several state descriptions into a single result, I think we should cover all its properties (i.e. also min/max, etc.)
I am not yet completely sure if this is what we want in the end or if we are overlooking some issues that can come up by such a merged description.
@lolodomo @SJKA @maggu2810 Any opinions here?
@@ -408,6 +408,11 @@ public StateDescription getStateDescription(Locale locale) { | |||
result = stateDescription; | |||
} | |||
|
|||
if (result != null && stateDescription != null) { |
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.
You are here in any case overwriting a previous readOnly information, I don't think this is a valid approach.
We had a similar discussion once in #2729. The outcome was that only the state description options where taken from the One solution would be to take all properties from the |
Could you elaborate on why you do not like it? Taking the info from the first (ordered by prio) provider that serves a value (and not null), sounds to me like a valid approach (but as stated above, I have the feeling that I am missing something, so your answer to this question might help on this...) |
My reasons for dislike for a conventional "merging" of two or more StateDescriptionProviders:
|
What if getStateDescription was modified to also pass the current (from the previous provider iterated) state description, so the queried provider can modify just he parameters it cares about and keep the others intact? This would be kind of distributed merging, would not break the API used by the bindings and need modifications of the providers only. |
@ppieczul what I like about the 'distributed merging' idea is the fact that we don´t have to come up with one algorithm now which will then be hard to modify in the future but leave the decision to every single implementation. It will although also be API breaking since StateDescriptionProviders would have to incorporate the new behaviour. |
Maybe we can gather more brain power, ideas and comments: From a framework perspective we could also factor out some StateDescriptionMergingService and do a default implementation which does a most "simple" in place merging (see #4428 (comment)) but leave flexibility for solutions to define their own behaviour. @kaikreuzer wdyt? /cc @SJKA & @maggu2810 |
On my side, I was in favor of a merge because it is required to fix a current bug we have to get the right label. This was my reason to initially implement the merge solution. |
If the We could also keep the method as it is and create a @htreu Does this fit to your suggestion? Keeping the |
@maggu2810 yes that was also my intention. The current |
The idea about a StateDescriptionMergingService seems great. I will try to implement one and create another PR within the next week. |
Yes, I forgot to mention it in #4882 but this one should be closed. |
Fix for issue 2267.
This fix relies on the fact that ChannelStateDescriptionProvider has service ranking -1 and therefore when iterating through the stateDescriptionProviders in the getStateDescription method, ChannelStateDescriptionProvider will come after GenericItemProvider.
If an item that is provided from the .items file and has a custom pattern, then the GenericItemProvider will provide a non null StateDescription and on the next iteration, the result will take the isReadOnly value from the ChannelStateDescriptionProvider.