Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
eraser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenLicht
eraser
Commits
657b6eeb
Commit
657b6eeb
authored
4 years ago
by
René Schöne
Browse files
Options
Downloads
Patches
Plain Diff
fix ItemPerformance resolving and attribute relevantItemPerformance
parent
ee3a6325
No related branches found
No related tags found
2 merge requests
!12
Resolve "Cleanup parser"
,
!11
Resolve "Add processing frequency option for items"
Pipeline
#9769
passed
4 years ago
Stage: build
Stage: test
Stage: report
Stage: ragdoc_build
Stage: ragdoc_view
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
eraser-base/src/main/jastadd/Navigation.jrag
+26
-11
26 additions, 11 deletions
eraser-base/src/main/jastadd/Navigation.jrag
eraser-base/src/main/jastadd/Resolving.jrag
+13
-0
13 additions, 0 deletions
eraser-base/src/main/jastadd/Resolving.jrag
with
39 additions
and
11 deletions
eraser-base/src/main/jastadd/Navigation.jrag
+
26
−
11
View file @
657b6eeb
...
...
@@ -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;
}
This diff is collapsed.
Click to expand it.
eraser-base/src/main/jastadd/Resolving.jrag
+
13
−
0
View file @
657b6eeb
...
...
@@ -98,9 +98,22 @@ aspect Resolving {
return java.util.Optional.empty();
}
syn java.util.Optional<ItemPerformance> Root.resolveItemPerformance(String performanceId) {
for (ItemPerformance performance : getItemPerformanceList()) {
if (performance.getLabel().equals(performanceId)) {
return java.util.Optional.of(performance);
}
}
return java.util.Optional.empty();
}
// implementing resolving for relations
refine RefResolverStubs eq StateSyncGroup.resolveTargetItemByToken(String id, int position) {
return getRoot().getSmartHomeEntityModel().resolveItem(id).orElseThrow(() -> new RuntimeException("Item '" + id + "' not found!"));
}
refine RefResolverStubs eq ASTNode.globallyResolveItemPerformanceByToken(String id) {
return getRoot().resolveItemPerformance(id).orElseThrow(() -> new RuntimeException("ItemPerformance '" + id + "' not found!"));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment