Skip to content
Snippets Groups Projects

Resolve "Add processing frequency option for items"

2 files
+ 39
11
Compare changes
  • Side-by-side
  • Inline

Files

@@ -11,34 +11,48 @@ aspect Navigation {
return result;
}
//--- enclosingGroup ---
inh Group Group.enclosingGroup();
inh Group Item.enclosingGroup();
eq Group.getItem().enclosingGroup() = this;
eq Group.getGroup().enclosingGroup() = this;
eq SmartHomeEntityModel.getGroup().enclosingGroup() = null;
eq SmartHomeEntityModel.getActivityItem().enclosingGroup() = null;
inh ItemPerformance Item.relevantItemPerformance();
inh ItemPerformance Group.relevantItemPerformance();
eq Group.getItem(int index).relevantItemPerformance() {
Item item = getItem(index);
// first, use value defined on item itself, if any
if (item.hasItemPerformance()) {
return item.getItemPerformance();
}
// then on this group, if defined
//--- relevantItemPerformance ---
syn ItemPerformance Group.relevantItemPerformance() {
// first, use value defined on group itself, if any
if (this.hasItemPerformance()) {
return this.getItemPerformance();
}
// recursively use enclosing group and use value from there, if any
Group parent = enclosingGroup();
if (parent != null) {
return parent.relevantItemPerformance();
}
// if top-level group without ItemPerformance
return null;
}
syn ItemPerformance Item.relevantItemPerformance() {
// first, use value defined on item itself, if any
if (this.hasItemPerformance()) {
return this.getItemPerformance();
}
inh Group Group.enclosingGroup();
inh Group Item.enclosingGroup();
// use enclosing group and use value from there, if any
Group parent = enclosingGroup();
if (parent != null) {
return parent.relevantItemPerformance();
}
// if top-level item without ItemPerformance
return null;
}
//--- addItems ---
private void SmartHomeEntityModel.addItems(java.util.List<Item> result, JastAddList<Group> groups) {
groups.forEach(group -> group.getItemList().forEach(item -> result.add(item)));
}
@@ -84,4 +98,5 @@ aspect Navigation {
eq Root.getRule().getRoot() = this;
eq Root.getUser().getRoot() = this;
eq Root.getLocation().getRoot() = this;
eq Root.getItemPerformance().getRoot() = this;
}
Loading