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

Commit

Permalink
Transition to metadata & semantic tags understanding (#16)
Browse files Browse the repository at this point in the history
Transition to metadata & semantic tags understanding

This introduces BREAKING CHANGES!

You'll have to re-tag your items with tags from the ESH semantic tag library, or use metadata.
Review the updating README and adapt your items configuration accordingly.

Signed-off-by: Yannick Schaus <[email protected]>
  • Loading branch information
ghys authored Jun 19, 2018
1 parent c3de12d commit 6bb5560
Show file tree
Hide file tree
Showing 49 changed files with 1,392 additions and 439 deletions.
142 changes: 83 additions & 59 deletions README.md

Large diffs are not rendered by default.

125 changes: 121 additions & 4 deletions src/main/java/org/openhab/ui/habot/card/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class Card extends Component implements Identifiable<String> {
String title;
String subtitle;

Set<String> objects = new HashSet<String>();
Set<String> locations = new HashSet<String>();

Set<String> tags = new HashSet<String>();

boolean bookmarked;
Expand Down Expand Up @@ -117,6 +120,24 @@ public Set<String> getTags() {
return tags;
}

/**
* Gets the set of object attributes attached to the card
*
* @return the card object attributes
*/
public Set<String> getObjectAttributes() {
return objects;
}

/**
* Gets the set of location attributes attached to the card
*
* @return the card location attributes
*/
public Set<String> getLocationAttributes() {
return tags;
}

/**
* Returns whether the card is bookmarked (appears on a dedicated "bookmarks" page)
*
Expand Down Expand Up @@ -199,7 +220,7 @@ public void setEphemeral(boolean ephemeral) {
* @return the timestamp
*/
public Date getTimestamp() {
return this.timestamp;
return timestamp;
}

/**
Expand Down Expand Up @@ -234,7 +255,7 @@ public boolean hasTag(String tag) {
* @param tag the tag to add
*/
public void addTag(String tag) {
tags.add(tag);
this.tags.add(tag);
}

/**
Expand All @@ -261,14 +282,110 @@ public void addTags(String... tags) {
* @param tag the tag to remove
*/
public void removeTag(String tag) {
tags.remove(tag);
this.tags.remove(tag);
}

/**
* Removes all tags on the card
*/
public void removeAllTags() {
tags.clear();
this.tags.clear();
}

/**
* Adds an object attribute to the card
*
* @param tag the tag to add
*/
public void addObjectAttribute(String object) {
this.objects.add(object);
}

/**
* Adds several object attributes to the card
*
* @param tags the tags to add
*/
public void addObjectAttributes(Collection<String> objects) {
this.objects.addAll(objects);
}

/**
* Adds several object attributes to the card
*
* @param tags the tags to add
*/
public void addObjectAttributes(String... objects) {
this.objects.addAll(Arrays.asList(objects));
}

/**
* Removes an object attribute on a card
*
* @param tag the tag to remove
*/
public void removeObjectAttribute(String object) {
this.objects.remove(object);
}

/**
* Returns whether the card has the specified object attribute (case insensitive)
*
* @param object
*/
public boolean hasObjectAttribute(String object) {
if (this.objects == null || object == null || object.isEmpty()) {
return false;
}
return this.objects.stream().anyMatch(o -> o.equalsIgnoreCase(object));
}

/**
* Adds an location attribute to the card
*
* @param tag the tag to add
*/
public void addLocationAttribute(String location) {
this.locations.add(location);
}

/**
* Adds several object attributes to the card
*
* @param tags the tags to add
*/
public void addLocationAttributes(Collection<String> locations) {
this.locations.addAll(locations);
}

/**
* Adds several object attributes to the card
*
* @param tags the tags to add
*/
public void addLocationAttributes(String... locations) {
this.locations.addAll(Arrays.asList(locations));
}

/**
* Removes an object attribute on a card
*
* @param tag the tag to remove
*/
public void removeLocationAttribute(String location) {
this.locations.remove(location);
}

/**
* Returns whether the card has the specified location attribute
*
* @param object
*/
public boolean hasLocationAttribute(String location) {
if (this.locations == null || location == null || location.isEmpty()) {
return false;
}
return this.locations.stream().anyMatch(o -> o.equalsIgnoreCase(location));
}

@Override
Expand Down
Loading

0 comments on commit 6bb5560

Please sign in to comment.