Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Right behavior of getByTags(Set<String> tags) method #1413

Closed
danchom opened this issue Apr 21, 2016 · 4 comments
Closed

Right behavior of getByTags(Set<String> tags) method #1413

danchom opened this issue Apr 21, 2016 · 4 comments

Comments

@danchom
Copy link
Contributor

danchom commented Apr 21, 2016

ModuleTypeRegistry has a method Collection getByTags(Set tags), which returns all the moduleTypes which have been tagged with one of the tags in the filter.
For example:
modulType1 has tags: tag1, tag2
modulType2 has tags: tag1
At the moment getByTags(Set {"tag1"}) will return collection of moduleType1 and moduleType2. The same result will be returned by getByTags(Set {"tag1", "tag2"}) because they both are tagged as "tag1"

Isn't be better if the method getByTags(Set {"tag1", "tag2"}) returns only module types which have been tagged with both tag1 and tag2?
in that way:
getByTags(Set {"tag1"}) will return collection of moduleType1 and moduleType2. - because they satisfied condition to be tagged as "tag1"
getByTags(Set {"tag1", "tag2"}) will returns only moduleType2 because only it has tags "tag1" and "tag2"

The same can be applied to RuleRegistry and TemplateRegistry

@kaikreuzer
Copy link
Contributor

Yes, makes sense to me.

@danchom
Copy link
Contributor Author

danchom commented Apr 28, 2016

On the other hand if you have a module type is tagged as Celsius and other which is tagged Kelvin
I can expect from the getByTag(Set {"Celsius", "Kelvin", "Temperature"}") to return all the types related to temperature to be returned, but the method will not return anything because there isn't a rule tagged with all the tags.
The question is what will be more usable, to interpret tags as AND or OR

@kaikreuzer
Copy link
Contributor

I think in your case you should only query for the tag "Temperature" and all is fine.

The underlying question of your use case is rather on how we could support hierarchies within tags. This is very much related to #1093 - I think for a start we can live with a "flat list" of tags, but sooner or later we will have to deal with hierarchies as well (so that you can query "all temperature related" module types, independent of whether they deal with Celsius, Fahrenheit or Kelvin).

danchom pushed a commit to danchom/smarthome that referenced this issue May 3, 2016
…#1413

Signed-off-by: Yordan Mihaylov <j.mihailov@prosyst.com>
kaikreuzer pushed a commit that referenced this issue May 4, 2016
Signed-off-by: Yordan Mihaylov <j.mihailov@prosyst.com>
@kaikreuzer
Copy link
Contributor

Implemented with #1456

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants