diff options
author | OszkarSemerath <oszkar.semerath@gmail.com> | 2018-08-27 18:29:20 +0200 |
---|---|---|
committer | OszkarSemerath <oszkar.semerath@gmail.com> | 2018-08-27 18:29:20 +0200 |
commit | 6c75bf0854c6d9e9a46fbe38500682e8198675a9 (patch) | |
tree | 8b31e1f5a98cdd68ae3428102fd049ba7704e83e /Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend | |
parent | Application puts hyperlinks of the generated files to the console (diff) | |
download | VIATRA-Generator-6c75bf0854c6d9e9a46fbe38500682e8198675a9.tar.gz VIATRA-Generator-6c75bf0854c6d9e9a46fbe38500682e8198675a9.tar.zst VIATRA-Generator-6c75bf0854c6d9e9a46fbe38500682e8198675a9.zip |
ScriptConsole to redirects console output to STDOUT in java applications
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend')
-rw-r--r-- | Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend | 17 |
1 files changed, 12 insertions, 5 deletions
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 825bfdcc..97fff9c6 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 | |||
@@ -22,7 +22,9 @@ class StandaloneScriptExecutor { | |||
22 | def static void main(String[] args) { | 22 | def static void main(String[] args) { |
23 | if(args.size == 1) { | 23 | if(args.size == 1) { |
24 | val message = executeScript(args.head) | 24 | val message = executeScript(args.head) |
25 | println(message) | 25 | if(message !== null) { |
26 | println(message) | ||
27 | } | ||
26 | } else if(args.size == 0){ | 28 | } else if(args.size == 0){ |
27 | println('''Run generator with script file path as parameter!''') | 29 | println('''Run generator with script file path as parameter!''') |
28 | } else { // args.size > 1 | 30 | } else { // args.size > 1 |
@@ -36,6 +38,7 @@ class StandaloneScriptExecutor { | |||
36 | ApplicationConfigurationStandaloneSetup.doSetup | 38 | ApplicationConfigurationStandaloneSetup.doSetup |
37 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi",new XMIResourceFactoryImpl) | 39 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi",new XMIResourceFactoryImpl) |
38 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("logicproblem",new XMIResourceFactoryImpl) | 40 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("logicproblem",new XMIResourceFactoryImpl) |
41 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("partialmodel",new XMIResourceFactoryImpl) | ||
39 | ReteEngine.getClass | 42 | ReteEngine.getClass |
40 | 43 | ||
41 | val ext = path.split("\\.").last | 44 | val ext = path.split("\\.").last |
@@ -46,7 +49,8 @@ class StandaloneScriptExecutor { | |||
46 | try{ | 49 | try{ |
47 | resource = resourceSet.getResource(URI.createURI(path),true) | 50 | resource = resourceSet.getResource(URI.createURI(path),true) |
48 | } catch(Exception e) { | 51 | } catch(Exception e) { |
49 | return '''Unable to load Configuration Script!''' | 52 | val message = '''Unable to load Configuration Script!''' |
53 | return message | ||
50 | } | 54 | } |
51 | 55 | ||
52 | EcoreUtil::resolveAll(resource) | 56 | EcoreUtil::resolveAll(resource) |
@@ -57,18 +61,21 @@ class StandaloneScriptExecutor { | |||
57 | val executor = new ScriptExecutor | 61 | val executor = new ScriptExecutor |
58 | executor.executeScript(content,new NullProgressMonitor) | 62 | executor.executeScript(content,new NullProgressMonitor) |
59 | } else { | 63 | } else { |
60 | return('''Content is not a Configuration Script! (Found : «content.class.simpleName»)''') | 64 | val message = '''Content is not a Configuration Script! (Found : «content.class.simpleName»)''' |
65 | return message | ||
61 | } | 66 | } |
62 | } else { | 67 | } else { |
63 | return ''' | 68 | val message = ''' |
64 | The Configuration Script contains «errors.size» error«IF errors.size>1»s«ENDIF»: | 69 | The Configuration Script contains «errors.size» error«IF errors.size>1»s«ENDIF»: |
65 | «FOR error : errors» | 70 | «FOR error : errors» |
66 | «"\t"»«error.message» | 71 | «"\t"»«error.message» |
67 | «ENDFOR» | 72 | «ENDFOR» |
68 | ''' | 73 | ''' |
74 | return message | ||
69 | } | 75 | } |
70 | } else { | 76 | } else { |
71 | return '''Unsupported file extension: «ext»''' | 77 | val message = '''Unsupported file extension: «ext»''' |
78 | return message | ||
72 | } | 79 | } |
73 | } | 80 | } |
74 | } \ No newline at end of file | 81 | } \ No newline at end of file |