diff options
2 files changed, 67 insertions, 53 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend index 69365add..ad950fc8 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend | |||
@@ -19,16 +19,13 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.Insta | |||
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | 20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml |
21 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser | 21 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser |
22 | import hu.bme.mit.inf.dslreasoner.workspace.ProjectWorkspace | 22 | import hu.bme.mit.inf.dslreasoner.workspace.URIBasedWorkspace |
23 | import java.io.File | ||
23 | import java.util.LinkedHashMap | 24 | import java.util.LinkedHashMap |
25 | import java.util.LinkedList | ||
24 | import java.util.Optional | 26 | import java.util.Optional |
25 | import java.util.Scanner | ||
26 | import org.eclipse.core.runtime.IProgressMonitor | 27 | import org.eclipse.core.runtime.IProgressMonitor |
27 | import org.eclipse.emf.common.util.URI | 28 | import org.eclipse.emf.common.util.URI |
28 | import hu.bme.mit.inf.dslreasoner.workspace.URIBasedWorkspace | ||
29 | import java.util.LinkedList | ||
30 | import java.io.File | ||
31 | import org.eclipse.ui.console.ConsolePlugin | ||
32 | 29 | ||
33 | class GenerationTaskExecutor { | 30 | class GenerationTaskExecutor { |
34 | val metamodelLoader = new MetamodelLoader | 31 | val metamodelLoader = new MetamodelLoader |
@@ -228,49 +225,57 @@ class GenerationTaskExecutor { | |||
228 | emfRepresentations += outputWorkspaceForRun.getFile(emfFileName) | 225 | emfRepresentations += outputWorkspaceForRun.getFile(emfFileName) |
229 | 226 | ||
230 | val representation = solution.representation.get(interpretationIndex) | 227 | val representation = solution.representation.get(interpretationIndex) |
231 | if(representation instanceof PartialInterpretation) { | 228 | if(documentationLevel.atLeastNormal) { |
232 | val vis1 = new PartialInterpretation2Gml | 229 | if(representation instanceof PartialInterpretation) { |
233 | val gml = vis1.transform(representation) | 230 | val vis1 = new PartialInterpretation2Gml |
234 | val glmFilename = '''«IF runs>1»«run»_«ENDIF»«interpretationIndex+1».gml''' | 231 | val gml = vis1.transform(representation) |
235 | outputWorkspaceForRun.writeText(glmFilename,gml) | 232 | val glmFilename = '''«IF runs>1»«run»_«ENDIF»«interpretationIndex+1».gml''' |
236 | gmlRepresentations += outputWorkspaceForRun.getFile(glmFilename) | 233 | outputWorkspaceForRun.writeText(glmFilename,gml) |
237 | if(representation.newElements.size + representation.problem.elements.size < 150) { | 234 | gmlRepresentations += outputWorkspaceForRun.getFile(glmFilename) |
238 | val vis2 = new GraphvizVisualiser | 235 | if(representation.newElements.size + representation.problem.elements.size < 150) { |
239 | val dot = vis2.visualiseConcretization(representation) | 236 | val vis2 = new GraphvizVisualiser |
240 | val dotFileName = '''«IF runs>1»«run»_«ENDIF»«interpretationIndex+1».png''' | 237 | val dot = vis2.visualiseConcretization(representation) |
241 | dot.writeToFile(outputWorkspaceForRun,dotFileName) | 238 | val dotFileName = '''«IF runs>1»«run»_«ENDIF»«interpretationIndex+1».png''' |
242 | dotRepresentations += outputWorkspaceForRun.getFile(dotFileName) | 239 | dot.writeToFile(outputWorkspaceForRun,dotFileName) |
243 | } | 240 | dotRepresentations += outputWorkspaceForRun.getFile(dotFileName) |
244 | else { | 241 | } |
242 | else { | ||
243 | dotRepresentations += null | ||
244 | } | ||
245 | } else { | ||
246 | gmlRepresentations += null | ||
245 | dotRepresentations += null | 247 | dotRepresentations += null |
246 | } | 248 | } |
247 | } else { | ||
248 | gmlRepresentations += null | ||
249 | dotRepresentations += null | ||
250 | } | 249 | } |
251 | monitor.worked(100) | 250 | monitor.worked(100) |
252 | } | 251 | } |
253 | console.writeMessage( | 252 | if(!emfRepresentations.empty) { |
254 | '''Models: «FOR f : emfRepresentations»#«ENDFOR»''', | 253 | console.writeMessage( |
255 | "#", | 254 | '''Models: «FOR f : emfRepresentations»#«ENDFOR»''', |
256 | emfRepresentations.map[ | 255 | "#", |
257 | new ScriptConsoleDecorator('''«it.fileRepresentationInConsole»''',it) | 256 | emfRepresentations.map[ |
258 | ] | 257 | new ScriptConsoleDecorator('''«it.fileRepresentationInConsole»''',it) |
259 | ) | 258 | ] |
260 | console.writeMessage( | 259 | ) |
261 | '''Visualisations: «FOR f : gmlRepresentations»#«ENDFOR»''', | 260 | } |
262 | "#", | 261 | if(!gmlRepresentations.empty) { |
263 | gmlRepresentations.map[ | 262 | console.writeMessage( |
264 | new ScriptConsoleDecorator('''«it.fileRepresentationInConsole»''',it) | 263 | '''Visualisations: «FOR f : gmlRepresentations»#«ENDFOR»''', |
265 | ] | 264 | "#", |
266 | ) | 265 | gmlRepresentations.map[ |
267 | console.writeMessage( | 266 | new ScriptConsoleDecorator('''«it.fileRepresentationInConsole»''',it) |
268 | '''Visualisations: «FOR f : dotRepresentations»#«ENDFOR»''', | 267 | ] |
269 | "#", | 268 | ) |
270 | dotRepresentations.map[ | 269 | } |
271 | new ScriptConsoleDecorator('''«it.fileRepresentationInConsole»''',it) | 270 | if(!dotRepresentations.empty) { |
272 | ] | 271 | console.writeMessage( |
273 | ) | 272 | '''Visualisations: «FOR f : dotRepresentations»#«ENDFOR»''', |
273 | "#", | ||
274 | dotRepresentations.map[ | ||
275 | new ScriptConsoleDecorator('''«it.fileRepresentationInConsole»''',it) | ||
276 | ] | ||
277 | ) | ||
278 | } | ||
274 | } else { | 279 | } else { |
275 | monitor.worked(solverConfig.solutionScope.numberOfRequiredSolution*100) | 280 | monitor.worked(solverConfig.solutionScope.numberOfRequiredSolution*100) |
276 | } | 281 | } |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend index 97fff9c6..f373d910 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend | |||
@@ -32,7 +32,7 @@ class StandaloneScriptExecutor { | |||
32 | } | 32 | } |
33 | } | 33 | } |
34 | 34 | ||
35 | def static executeScript(String path){ | 35 | def static loadScript(String path) { |
36 | //Initialise extensions | 36 | //Initialise extensions |
37 | EMFPatternLanguageStandaloneSetup.doSetup | 37 | EMFPatternLanguageStandaloneSetup.doSetup |
38 | ApplicationConfigurationStandaloneSetup.doSetup | 38 | ApplicationConfigurationStandaloneSetup.doSetup |
@@ -49,8 +49,8 @@ class StandaloneScriptExecutor { | |||
49 | try{ | 49 | try{ |
50 | resource = resourceSet.getResource(URI.createURI(path),true) | 50 | resource = resourceSet.getResource(URI.createURI(path),true) |
51 | } catch(Exception e) { | 51 | } catch(Exception e) { |
52 | val message = '''Unable to load Configuration Script!''' | 52 | val message = '''Unable to load Configuration Script! «e.message»''' |
53 | return message | 53 | throw new IllegalArgumentException(message) |
54 | } | 54 | } |
55 | 55 | ||
56 | EcoreUtil::resolveAll(resource) | 56 | EcoreUtil::resolveAll(resource) |
@@ -58,11 +58,10 @@ class StandaloneScriptExecutor { | |||
58 | if(errors.empty) { | 58 | if(errors.empty) { |
59 | val content = resource.contents.head | 59 | val content = resource.contents.head |
60 | if(content instanceof ConfigurationScript) { | 60 | if(content instanceof ConfigurationScript) { |
61 | val executor = new ScriptExecutor | 61 | return content |
62 | executor.executeScript(content,new NullProgressMonitor) | ||
63 | } else { | 62 | } else { |
64 | val message = '''Content is not a Configuration Script! (Found : «content.class.simpleName»)''' | 63 | val message = '''Content is not a Configuration Script! (Found : «content.class.simpleName»)''' |
65 | return message | 64 | throw new IllegalArgumentException(message) |
66 | } | 65 | } |
67 | } else { | 66 | } else { |
68 | val message = ''' | 67 | val message = ''' |
@@ -71,11 +70,21 @@ class StandaloneScriptExecutor { | |||
71 | «"\t"»«error.message» | 70 | «"\t"»«error.message» |
72 | «ENDFOR» | 71 | «ENDFOR» |
73 | ''' | 72 | ''' |
74 | return message | 73 | throw new IllegalArgumentException(message) |
75 | } | 74 | } |
76 | } else { | 75 | } else { |
77 | val message = '''Unsupported file extension: «ext»''' | 76 | throw new IllegalArgumentException('''Unsupported file extension: «ext»''') |
78 | return message | 77 | } |
78 | } | ||
79 | |||
80 | def static executeScript(String path){ | ||
81 | val executor = new ScriptExecutor | ||
82 | try{ | ||
83 | val content = loadScript(path) | ||
84 | executor.executeScript(content,new NullProgressMonitor) | ||
85 | return null | ||
86 | } catch(Exception e) { | ||
87 | return e.message | ||
79 | } | 88 | } |
80 | } | 89 | } |
81 | } \ No newline at end of file | 90 | } \ No newline at end of file |