diff options
author | 2019-06-08 19:17:34 -0400 | |
---|---|---|
committer | 2019-06-08 19:17:34 -0400 | |
commit | b21af04ea821c3daa9ce8a6d26c63e9cd198f9a5 (patch) | |
tree | 4be566b25415ca97cb007b5da7d89f216ef515b2 /Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend | |
parent | Merge remote-tracking branch 'origin/master' into kris (diff) | |
download | VIATRA-Generator-b21af04ea821c3daa9ce8a6d26c63e9cd198f9a5.tar.gz VIATRA-Generator-b21af04ea821c3daa9ce8a6d26c63e9cd198f9a5.tar.zst VIATRA-Generator-b21af04ea821c3daa9ce8a6d26c63e9cd198f9a5.zip |
Trying to simplify Satellite case study
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend')
-rw-r--r-- | Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend new file mode 100644 index 00000000..c5a30f94 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend | |||
@@ -0,0 +1,52 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo | ||
2 | |||
3 | import java.io.BufferedReader | ||
4 | import java.io.BufferedWriter | ||
5 | import java.io.FileReader | ||
6 | import java.io.FileWriter | ||
7 | import java.util.Map | ||
8 | import org.eclipse.emf.ecore.EPackage | ||
9 | import org.eclipse.emf.ecore.resource.Resource | ||
10 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
11 | import satellite.SatellitePackage | ||
12 | import uk.ac.kcl.inf.mdeoptimiser.languages.MoptStandaloneSetup | ||
13 | |||
14 | class SatelliteMdeOptimiserMain { | ||
15 | static val PROJECT_PATH = "." | ||
16 | static val MOPT_PATH = "src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt" | ||
17 | |||
18 | private new() { | ||
19 | new IllegalStateException("This is a static utility class and should not be instantiated directly.") | ||
20 | } | ||
21 | |||
22 | public static def void main(String[] args) { | ||
23 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, | ||
24 | new XMIResourceFactoryImpl) | ||
25 | EPackage.Registry.INSTANCE.put(SatellitePackage.eNS_URI, SatellitePackage.eINSTANCE) | ||
26 | fixupHenshinModel("model/satellite.henshin", "model/satellite_fixup.henshin", | ||
27 | #{"satellite.ecore" -> SatellitePackage.eNS_URI}) | ||
28 | val injector = new MoptStandaloneSetup().createInjectorAndDoEMFRegistration(); | ||
29 | injector.getInstance(ExcludedRun).run(PROJECT_PATH, MOPT_PATH) | ||
30 | } | ||
31 | |||
32 | private def static void fixupHenshinModel(String originalPath, String outputPath, Map<String, String> remapMap) { | ||
33 | val reader = new BufferedReader(new FileReader(originalPath)) | ||
34 | try { | ||
35 | val writer = new BufferedWriter(new FileWriter(outputPath)) | ||
36 | try { | ||
37 | var String line | ||
38 | while ((line = reader.readLine) !== null) { | ||
39 | for (entry : remapMap.entrySet) { | ||
40 | line = line.replace(entry.key, entry.value) | ||
41 | } | ||
42 | writer.write(line) | ||
43 | writer.write("\n") | ||
44 | } | ||
45 | } finally { | ||
46 | writer.close | ||
47 | } | ||
48 | } finally { | ||
49 | reader.close | ||
50 | } | ||
51 | } | ||
52 | } | ||