Skip to content

Commit

Permalink
[HABot] Use SemanticsService to search for label/synonyms of a tag cl…
Browse files Browse the repository at this point in the history
…ass (#1916)

Depends on openhab/openhab-core#3636

Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo authored Jun 17, 2023
1 parent e75f001 commit 81e12f5
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Stream<Item> getMatchingItems(String object, String location) {
}

if (object != null) {
List<Class<? extends Tag>> semanticTagTypes = SemanticTags.getByLabelOrSynonym(object, currentLocale);
List<Class<? extends Tag>> semanticTagTypes = semanticsService.getByLabelOrSynonym(object, currentLocale);
if (!semanticTagTypes.isEmpty()
&& semanticTagTypes.stream().noneMatch(t -> Location.class.isAssignableFrom(t))) {
Predicate<Item> tagsPredicate = null;
Expand Down Expand Up @@ -116,14 +116,14 @@ public Map<Item, Set<ItemNamedAttribute>> getAllItemNamedAttributes() throws Uns
itemAttributes.add(new ItemNamedAttribute(attributeType, item.getLabel(), AttributeSource.LABEL));

// Add the primary type's label and synonyms
for (String tagLabel : SemanticTags.getLabelAndSynonyms(semanticType, currentLocale)) {
for (String tagLabel : semanticsService.getLabelAndSynonyms(semanticType, currentLocale)) {
itemAttributes.add(new ItemNamedAttribute(attributeType, tagLabel, AttributeSource.TAG));
}

// Add the related property's label and synonyms
Class<? extends Property> relatedProperty = SemanticTags.getProperty(item);
if (relatedProperty != null) {
for (String propertyLabel : SemanticTags.getLabelAndSynonyms(relatedProperty, currentLocale)) {
for (String propertyLabel : semanticsService.getLabelAndSynonyms(relatedProperty, currentLocale)) {
itemAttributes.add(new ItemNamedAttribute("object", propertyLabel, AttributeSource.TAG));
}
}
Expand Down

0 comments on commit 81e12f5

Please sign in to comment.