From 6b2cbbe534b51951d3a9b600f9f5a59a3660ae1e Mon Sep 17 00:00:00 2001 From: OszkarSemerath Date: Tue, 28 Aug 2018 16:32:24 +0200 Subject: Separated the loading and executing of a script. --- .../execution/StandaloneScriptExecutor.xtend | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 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 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 { } } - def static executeScript(String path){ + def static loadScript(String path) { //Initialise extensions EMFPatternLanguageStandaloneSetup.doSetup ApplicationConfigurationStandaloneSetup.doSetup @@ -49,8 +49,8 @@ class StandaloneScriptExecutor { try{ resource = resourceSet.getResource(URI.createURI(path),true) } catch(Exception e) { - val message = '''Unable to load Configuration Script!''' - return message + val message = '''Unable to load Configuration Script! «e.message»''' + throw new IllegalArgumentException(message) } EcoreUtil::resolveAll(resource) @@ -58,11 +58,10 @@ class StandaloneScriptExecutor { if(errors.empty) { val content = resource.contents.head if(content instanceof ConfigurationScript) { - val executor = new ScriptExecutor - executor.executeScript(content,new NullProgressMonitor) + return content } else { val message = '''Content is not a Configuration Script! (Found : «content.class.simpleName»)''' - return message + throw new IllegalArgumentException(message) } } else { val message = ''' @@ -71,11 +70,21 @@ class StandaloneScriptExecutor { «"\t"»«error.message» «ENDFOR» ''' - return message + throw new IllegalArgumentException(message) } } else { - val message = '''Unsupported file extension: «ext»''' - return message + throw new IllegalArgumentException('''Unsupported file extension: «ext»''') + } + } + + def static executeScript(String path){ + val executor = new ScriptExecutor + try{ + val content = loadScript(path) + executor.executeScript(content,new NullProgressMonitor) + return null + } catch(Exception e) { + return e.message } } } \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 21e61d4642c89a764a2fbcb01903aea5bf4df128 Mon Sep 17 00:00:00 2001 From: OszkarSemerath Date: Tue, 28 Aug 2018 16:33:05 +0200 Subject: Models are not visualized if the documentation level is above NORMAL --- .../execution/GenerationTaskExecutor.xtend | 93 ++++++++++++---------- 1 file changed, 49 insertions(+), 44 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 import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser -import hu.bme.mit.inf.dslreasoner.workspace.ProjectWorkspace +import hu.bme.mit.inf.dslreasoner.workspace.URIBasedWorkspace +import java.io.File import java.util.LinkedHashMap +import java.util.LinkedList import java.util.Optional -import java.util.Scanner import org.eclipse.core.runtime.IProgressMonitor import org.eclipse.emf.common.util.URI -import hu.bme.mit.inf.dslreasoner.workspace.URIBasedWorkspace -import java.util.LinkedList -import java.io.File -import org.eclipse.ui.console.ConsolePlugin class GenerationTaskExecutor { val metamodelLoader = new MetamodelLoader @@ -228,49 +225,57 @@ class GenerationTaskExecutor { emfRepresentations += outputWorkspaceForRun.getFile(emfFileName) val representation = solution.representation.get(interpretationIndex) - if(representation instanceof PartialInterpretation) { - val vis1 = new PartialInterpretation2Gml - val gml = vis1.transform(representation) - val glmFilename = '''«IF runs>1»«run»_«ENDIF»«interpretationIndex+1».gml''' - outputWorkspaceForRun.writeText(glmFilename,gml) - gmlRepresentations += outputWorkspaceForRun.getFile(glmFilename) - if(representation.newElements.size + representation.problem.elements.size < 150) { - val vis2 = new GraphvizVisualiser - val dot = vis2.visualiseConcretization(representation) - val dotFileName = '''«IF runs>1»«run»_«ENDIF»«interpretationIndex+1».png''' - dot.writeToFile(outputWorkspaceForRun,dotFileName) - dotRepresentations += outputWorkspaceForRun.getFile(dotFileName) - } - else { + if(documentationLevel.atLeastNormal) { + if(representation instanceof PartialInterpretation) { + val vis1 = new PartialInterpretation2Gml + val gml = vis1.transform(representation) + val glmFilename = '''«IF runs>1»«run»_«ENDIF»«interpretationIndex+1».gml''' + outputWorkspaceForRun.writeText(glmFilename,gml) + gmlRepresentations += outputWorkspaceForRun.getFile(glmFilename) + if(representation.newElements.size + representation.problem.elements.size < 150) { + val vis2 = new GraphvizVisualiser + val dot = vis2.visualiseConcretization(representation) + val dotFileName = '''«IF runs>1»«run»_«ENDIF»«interpretationIndex+1».png''' + dot.writeToFile(outputWorkspaceForRun,dotFileName) + dotRepresentations += outputWorkspaceForRun.getFile(dotFileName) + } + else { + dotRepresentations += null + } + } else { + gmlRepresentations += null dotRepresentations += null } - } else { - gmlRepresentations += null - dotRepresentations += null } monitor.worked(100) } - console.writeMessage( - '''Models: «FOR f : emfRepresentations»#«ENDFOR»''', - "#", - emfRepresentations.map[ - new ScriptConsoleDecorator('''«it.fileRepresentationInConsole»''',it) - ] - ) - console.writeMessage( - '''Visualisations: «FOR f : gmlRepresentations»#«ENDFOR»''', - "#", - gmlRepresentations.map[ - new ScriptConsoleDecorator('''«it.fileRepresentationInConsole»''',it) - ] - ) - console.writeMessage( - '''Visualisations: «FOR f : dotRepresentations»#«ENDFOR»''', - "#", - dotRepresentations.map[ - new ScriptConsoleDecorator('''«it.fileRepresentationInConsole»''',it) - ] - ) + if(!emfRepresentations.empty) { + console.writeMessage( + '''Models: «FOR f : emfRepresentations»#«ENDFOR»''', + "#", + emfRepresentations.map[ + new ScriptConsoleDecorator('''«it.fileRepresentationInConsole»''',it) + ] + ) + } + if(!gmlRepresentations.empty) { + console.writeMessage( + '''Visualisations: «FOR f : gmlRepresentations»#«ENDFOR»''', + "#", + gmlRepresentations.map[ + new ScriptConsoleDecorator('''«it.fileRepresentationInConsole»''',it) + ] + ) + } + if(!dotRepresentations.empty) { + console.writeMessage( + '''Visualisations: «FOR f : dotRepresentations»#«ENDFOR»''', + "#", + dotRepresentations.map[ + new ScriptConsoleDecorator('''«it.fileRepresentationInConsole»''',it) + ] + ) + } } else { monitor.worked(solverConfig.solutionScope.numberOfRequiredSolution*100) } -- cgit v1.2.3-70-g09d2