diff options
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit')
2 files changed, 127 insertions, 0 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/ApplicationConfigurationStandaloneRuntimeModule.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/ApplicationConfigurationStandaloneRuntimeModule.xtend new file mode 100644 index 00000000..2738dfff --- /dev/null +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/ApplicationConfigurationStandaloneRuntimeModule.xtend | |||
@@ -0,0 +1,53 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application | ||
2 | |||
3 | import com.google.inject.Binder | ||
4 | import com.google.inject.multibindings.Multibinder | ||
5 | import hu.bme.mit.inf.dslreasoner.application.linking.ApplicationConfigurationLinkingService | ||
6 | import hu.bme.mit.inf.dslreasoner.application.valueconverter.ApplicationConfigurationValueConverterService | ||
7 | import org.apache.log4j.Logger | ||
8 | import org.eclipse.viatra.query.patternlanguage.emf.GenmodelExtensionLoader | ||
9 | import org.eclipse.viatra.query.patternlanguage.emf.IGenmodelMappingLoader | ||
10 | import org.eclipse.viatra.query.patternlanguage.emf.scoping.CompoundMetamodelProviderService | ||
11 | import org.eclipse.viatra.query.patternlanguage.emf.scoping.IMetamodelProvider | ||
12 | import org.eclipse.viatra.query.patternlanguage.emf.scoping.IMetamodelProviderInstance | ||
13 | import org.eclipse.viatra.query.patternlanguage.emf.scoping.MetamodelProviderService | ||
14 | import org.eclipse.viatra.query.patternlanguage.emf.scoping.ResourceSetMetamodelProviderService | ||
15 | import org.eclipse.viatra.query.tooling.core.targetplatform.ITargetPlatformMetamodelLoader | ||
16 | import org.eclipse.viatra.query.tooling.core.targetplatform.TargetPlatformMetamodelProviderService | ||
17 | import org.eclipse.viatra.query.tooling.core.targetplatform.TargetPlatformMetamodelsIndex | ||
18 | |||
19 | /** | ||
20 | * Use this class to register components to be used at runtime / without the Equinox extension registry. | ||
21 | */ | ||
22 | class ApplicationConfigurationStandaloneRuntimeModule extends AbstractApplicationConfigurationRuntimeModule { | ||
23 | override bindILinkingService() { | ||
24 | ApplicationConfigurationLinkingService | ||
25 | } | ||
26 | |||
27 | def configureLoggerImplementation(Binder binder) { | ||
28 | binder.bind(Logger).toInstance(Logger.getLogger(ApplicationConfigurationStandaloneRuntimeModule)) | ||
29 | } | ||
30 | |||
31 | def Class<? extends IMetamodelProvider> bindIMetamodelProvider() { | ||
32 | CompoundMetamodelProviderService | ||
33 | } | ||
34 | |||
35 | def configureMetamodelProviderInstance(Binder binder) { | ||
36 | val metamodelProviderBinder = Multibinder.newSetBinder(binder, IMetamodelProviderInstance) | ||
37 | metamodelProviderBinder.addBinding.to(MetamodelProviderService) | ||
38 | metamodelProviderBinder.addBinding.to(ResourceSetMetamodelProviderService) | ||
39 | //metamodelProviderBinder.addBinding.to(TargetPlatformMetamodelProviderService) | ||
40 | } | ||
41 | |||
42 | |||
43 | |||
44 | override bindIValueConverterService() { | ||
45 | ApplicationConfigurationValueConverterService | ||
46 | } | ||
47 | def Class<? extends IGenmodelMappingLoader> bindIGenmodelMappingLoader() { | ||
48 | GenmodelExtensionLoader | ||
49 | } | ||
50 | // def Class<? extends ITargetPlatformMetamodelLoader> bindITargetPlatformMetamodelLoader() { | ||
51 | // TargetPlatformMetamodelsIndex | ||
52 | // } | ||
53 | } \ No newline at end of file | ||
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 new file mode 100644 index 00000000..825bfdcc --- /dev/null +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend | |||
@@ -0,0 +1,74 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.execution | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.application.ApplicationConfigurationStandaloneSetup | ||
4 | import org.eclipse.emf.common.util.URI | ||
5 | import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl | ||
6 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript | ||
7 | import org.eclipse.core.runtime.NullProgressMonitor | ||
8 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup | ||
9 | import org.eclipse.emf.ecore.util.EcoreUtil | ||
10 | import java.io.FileNotFoundException | ||
11 | import org.eclipse.emf.ecore.resource.Resource | ||
12 | import java.io.IOException | ||
13 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
14 | import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactoryProvider | ||
15 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactoryProvider | ||
16 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint | ||
18 | import org.eclipse.viatra.query.runtime.rete.util.ReteHintOptions | ||
19 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine | ||
20 | |||
21 | class StandaloneScriptExecutor { | ||
22 | def static void main(String[] args) { | ||
23 | if(args.size == 1) { | ||
24 | val message = executeScript(args.head) | ||
25 | println(message) | ||
26 | } else if(args.size == 0){ | ||
27 | println('''Run generator with script file path as parameter!''') | ||
28 | } else { // args.size > 1 | ||
29 | println('''Multiple arguments are not supported! Run generator with script file path as parameter!''') | ||
30 | } | ||
31 | } | ||
32 | |||
33 | def static executeScript(String path){ | ||
34 | //Initialise extensions | ||
35 | EMFPatternLanguageStandaloneSetup.doSetup | ||
36 | ApplicationConfigurationStandaloneSetup.doSetup | ||
37 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi",new XMIResourceFactoryImpl) | ||
38 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("logicproblem",new XMIResourceFactoryImpl) | ||
39 | ReteEngine.getClass | ||
40 | |||
41 | val ext = path.split("\\.").last | ||
42 | if(ext.equals("vsconfig")) { | ||
43 | val resourceSet = new ResourceSetImpl | ||
44 | var Resource resource | ||
45 | |||
46 | try{ | ||
47 | resource = resourceSet.getResource(URI.createURI(path),true) | ||
48 | } catch(Exception e) { | ||
49 | return '''Unable to load Configuration Script!''' | ||
50 | } | ||
51 | |||
52 | EcoreUtil::resolveAll(resource) | ||
53 | val errors = resource.errors | ||
54 | if(errors.empty) { | ||
55 | val content = resource.contents.head | ||
56 | if(content instanceof ConfigurationScript) { | ||
57 | val executor = new ScriptExecutor | ||
58 | executor.executeScript(content,new NullProgressMonitor) | ||
59 | } else { | ||
60 | return('''Content is not a Configuration Script! (Found : «content.class.simpleName»)''') | ||
61 | } | ||
62 | } else { | ||
63 | return ''' | ||
64 | The Configuration Script contains «errors.size» error«IF errors.size>1»s«ENDIF»: | ||
65 | «FOR error : errors» | ||
66 | «"\t"»«error.message» | ||
67 | «ENDFOR» | ||
68 | ''' | ||
69 | } | ||
70 | } else { | ||
71 | return '''Unsupported file extension: «ext»''' | ||
72 | } | ||
73 | } | ||
74 | } \ No newline at end of file | ||