Created
June 6, 2012 14:12
-
-
Save abelhegedus/2882091 to your computer and use it in GitHub Desktop.
Query-driven soft links examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@QueryBasedFeature(feature = "jobs") | |
pattern ChecklistEntryJobCorrespondence(CLE : ChecklistEntry, Job : Job) = { | |
Job.name(Job,JobName); | |
System.name(System,SysName); | |
Job.runsOn(Job,System); | |
ChecklistEntry.jobPaths(CLE,JobPath); | |
check((JobPath as String).equals((SysName as String).concat('/').concat(JobName as String))); | |
} | |
@QueryBasedFeature(feature = "task") | |
pattern ChecklistEntryTaskCorrespondence(CLE : ChecklistEntry, Task : Task) = { | |
Task.id(Task, TaskId); | |
ChecklistEntry.taskId(CLE,TaskId); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pattern ChecklistEntryJobCorrespondence(CLE : ChecklistEntry, Job : Job) = { | |
Job.name(Job,JobName); | |
System.name(System,SysName); | |
Job.runsOn(Job,System); | |
ChecklistEntry.jobPaths(CLE,JobPath); | |
check((JobPath as String).equals((SysName as String).concat('/').concat(JobName as String))); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@QueryBasedFeature(feature = "process") | |
pattern ChecklistProcessCorrespondence(Checklist : Checklist, Process : Process) = { | |
Process.id(Process,ProcessId); | |
Checklist.processId(Checklist,ProcessId); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private QueryBasedFeatureHandler processHandler; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
*/ | |
public process.Process basicGetProcess() { | |
if (processHandler == null) { | |
processHandler = QueryBasedFeatureHelper.getQueryBasedFeatureHandler (this, | |
OperationPackage.Literals.CHECKLIST__PROCESS, | |
"operation.queries.ChecklistProcessCorrespondence", | |
"Checklist", "Process", FeatureKind.SINGLE_REFERENCE); | |
} | |
return (process.Process) processHandler.getSingleReferenceValue(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@QueryBasedFeature(feature = "readingTask") | |
pattern DataTaskReadCorrespondence(Data : Data, Task : Task) = { | |
Data.readingTaskIds(Data,TaskId); | |
Task.id(Task,TaskId); | |
} | |
@QueryBasedFeature(feature = "writingTask") | |
pattern DataTaskWriteCorrespondence(Data : Data ,Task : Task) = { | |
Data.writingTaskIds(Data,TaskId); | |
Task.id(Task,TaskId); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Constraint(location = "ChecklistEntry", | |
message = "Entry $ChecklistEntry.name$ corresponds to Task $Task.name$ outside of process $Process.name$ defined for the checklist!", | |
severity = "error") | |
pattern IncorrectEntryInChecklist(ChecklistEntry,Task,Process) = { | |
Checklist.entries(Checklist,ChecklistEntry); | |
find ChecklistProcessCorrespondence(Checklist,Process); | |
find ChecklistEntryTaskCorrespondence(ChecklistEntry,Task); | |
neg find TaskInProcess(Task,Process); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@QueryBasedFeature(feature = "tasks") | |
pattern JobTaskCorrespondence(Job : Job, Task : Task) = { | |
Job.taskIds(Job,TaskId); | |
Task.id(Task,TaskId); | |
} | |
@QueryBasedFeature(feature = "info") | |
pattern JobInfoCorrespondence(Job : Job, Info : RuntimeInformation) = { | |
ChecklistEntry.info(CLE, Info); | |
ChecklistEntry.jobs(CLE, Job); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Derived features | |
private QueryBasedFeatureHandler tasksHandler; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
*/ | |
public EList getTasks() { | |
if (tasksHandler == null) { | |
tasksHandler = QueryBasedFeatureHelper.getQueryBasedFeatureHandler(this, | |
SystemPackage.Literals.JOB__TASKS, "system.queries.JobTaskCorrespondence", | |
"Job", "Task", FeatureKind.MANY_REFERENCE); | |
} | |
return tasksHandler.getManyReferenceValueForHandler(this); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pattern JobTaskCorrespondence(Job : Job, Task : Task) = { | |
Job.taskIds(Job,TaskId); | |
Task.id(Task,TaskId); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<extension | |
point="org.eclipse.viatra2.emf.incquery.base.wellbehaving.derived.features"> | |
<wellbehaving-derived-feature | |
package-nsUri="http://operation/1.0"> | |
</wellbehaving-derived-feature> | |
<wellbehaving-derived-feature | |
package-nsUri="http://system/1.0"> | |
</wellbehaving-derived-feature> | |
</extension> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment