diff options
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend')
-rw-r--r-- | Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend index 37e64d98..d8a37184 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend | |||
@@ -26,6 +26,9 @@ import java.util.LinkedHashMap | |||
26 | import java.util.Optional | 26 | import java.util.Optional |
27 | import org.eclipse.emf.common.util.URI | 27 | import org.eclipse.emf.common.util.URI |
28 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.DocumentLevelSpecification | 28 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.DocumentLevelSpecification |
29 | import org.eclipse.core.runtime.jobs.Job | ||
30 | import org.eclipse.core.runtime.IProgressMonitor | ||
31 | import org.eclipse.core.runtime.Status | ||
29 | 32 | ||
30 | class ScriptExecutor { | 33 | class ScriptExecutor { |
31 | val parser = new ApplicationConfigurationParser | 34 | val parser = new ApplicationConfigurationParser |
@@ -37,15 +40,30 @@ class ScriptExecutor { | |||
37 | * Executes a script | 40 | * Executes a script |
38 | */ | 41 | */ |
39 | public def executeScript(URI uri) { | 42 | public def executeScript(URI uri) { |
40 | val script = parser.parse(uri) | 43 | val job = new Job('''Model Generation: «uri.lastSegment»''') { |
41 | script.executeScript | 44 | override protected run(IProgressMonitor monitor) { |
45 | try{ | ||
46 | monitor.subTask('''Loading script''') | ||
47 | val script = parser.parse(uri) | ||
48 | script.executeScript(monitor) | ||
49 | return Status.OK_STATUS; | ||
50 | } catch(Exception e) { | ||
51 | return Status.OK_STATUS | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | job.setUser(true); | ||
56 | job.schedule(); | ||
42 | } | 57 | } |
43 | 58 | ||
44 | public def executeScript(ConfigurationScript script) { | 59 | public def executeScript(ConfigurationScript script, IProgressMonitor monitor) { |
45 | script.activateAllEPackageReferences | 60 | script.activateAllEPackageReferences |
46 | val tasks = script.commands.filter(Task) | 61 | val tasks = script.commands.filter(Task) |
47 | for(task : tasks.filterNull) { | 62 | |
48 | task.execute | 63 | for(taskIndex : 0..<tasks.size) { |
64 | val task = tasks.get(taskIndex) | ||
65 | monitor.beginTask('''Executing task«IF tasks.size>1» «taskIndex+1»«ENDIF»: «task.name»''',task.totalWork) | ||
66 | task.execute(monitor) | ||
49 | } | 67 | } |
50 | } | 68 | } |
51 | 69 | ||
@@ -75,12 +93,33 @@ class ScriptExecutor { | |||
75 | // } | 93 | // } |
76 | } | 94 | } |
77 | 95 | ||
78 | def public dispatch execute(GenerationTask task) { | 96 | def public dispatch execute(GenerationTask task, IProgressMonitor monitor) { |
79 | val generationTaskExecutor = new GenerationTaskExecutor | 97 | val generationTaskExecutor = new GenerationTaskExecutor |
80 | generationTaskExecutor.executeGenerationTask(task,this) | 98 | generationTaskExecutor.executeGenerationTask(task,this,monitor) |
99 | } | ||
100 | |||
101 | def public dispatch execute(Task task, IProgressMonitor monitor) { | ||
102 | throw new IllegalArgumentException('''Unsupported task type: «task.class.simpleName»!''') | ||
81 | } | 103 | } |
82 | 104 | ||
83 | def public dispatch execute(Task task) { | 105 | /** |
106 | * Mapping time = 100 | ||
107 | * Solving = 1000 * runs | ||
108 | * Visualisation = runs * number * 100 | ||
109 | */ | ||
110 | def protected dispatch getTotalWork(GenerationTask task) { | ||
111 | val runs = if(task.runSpecified) { task.runs } else { 1 } | ||
112 | val number = if(task.numberSpecified) { task.number } else { 1 } | ||
113 | return 100 + runs*1000 +runs*number*100 | ||
114 | } | ||
115 | def protected dispatch getTotalWork(Task task) { | ||
116 | throw new IllegalArgumentException('''Unsupported task type: «task.class.simpleName»!''') | ||
117 | } | ||
118 | |||
119 | def protected dispatch getName(GenerationTask task) { | ||
120 | '''Model Generation''' | ||
121 | } | ||
122 | def protected dispatch getName(Task task) { | ||
84 | throw new IllegalArgumentException('''Unsupported task type: «task.class.simpleName»!''') | 123 | throw new IllegalArgumentException('''Unsupported task type: «task.class.simpleName»!''') |
85 | } | 124 | } |
86 | 125 | ||