diff options
Diffstat (limited to 'Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill')
-rw-r--r-- | Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/examples/CSERposterSample.xtend | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/examples/CSERposterSample.xtend b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/examples/CSERposterSample.xtend new file mode 100644 index 00000000..44aad755 --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/examples/CSERposterSample.xtend | |||
@@ -0,0 +1,80 @@ | |||
1 | package ca.mcgill.ecse.dslreasoner.realistic.metrics.examples | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration | ||
6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2PartialInterpretation | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2ImmutableTypeLattice | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | ||
10 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace | ||
11 | import java.util.Collections | ||
12 | import org.eclipse.emf.ecore.EClass | ||
13 | import org.eclipse.emf.ecore.EEnum | ||
14 | import org.eclipse.emf.ecore.EObject | ||
15 | import org.eclipse.emf.ecore.resource.Resource | ||
16 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
17 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine | ||
18 | import java.io.PrintWriter | ||
19 | import linkedList.LinkedListPackage | ||
20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.Neighbourhood2Gml | ||
21 | import simpleStatechart.SimpleStatechartPackage | ||
22 | |||
23 | class CSERposterSample { | ||
24 | static val partialInterpretation2Logic = new InstanceModel2PartialInterpretation | ||
25 | static val neighbourhoodComputer = new PartialInterpretation2ImmutableTypeLattice | ||
26 | static val Ecore2Logic ecore2Logic = new Ecore2Logic | ||
27 | static val partialVisualizer = new PartialInterpretation2Gml | ||
28 | static val neighbourhoodVisualizer = new Neighbourhood2Gml | ||
29 | static val depth = 1 | ||
30 | static val REALISTIC = "simpleSCRealistic" | ||
31 | static val IRREALISTIC = "simpleSCIrrealistic" | ||
32 | |||
33 | def static void main(String[] args) { | ||
34 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("*", new XMIResourceFactoryImpl) | ||
35 | YakindummPackage.eINSTANCE.eClass | ||
36 | LinkedListPackage.eINSTANCE.eClass | ||
37 | SimpleStatechartPackage.eINSTANCE.eClass | ||
38 | ReteEngine.getClass | ||
39 | |||
40 | val outputs = "outputs" | ||
41 | val instModName = REALISTIC | ||
42 | val workspace = new FileSystemWorkspace('''resources''', "") | ||
43 | val model = workspace.readModel(EObject, instModName+".xmi") | ||
44 | |||
45 | val pckg = model.eClass.EPackage | ||
46 | val metamodel = new EcoreMetamodelDescriptor( | ||
47 | pckg.EClassifiers.filter(EClass).toList, | ||
48 | Collections::emptySet, | ||
49 | false, | ||
50 | pckg.EClassifiers.filter(EEnum).toList, | ||
51 | pckg.EClassifiers.filter(EEnum).map[ELiterals].flatten.toList, | ||
52 | pckg.EClassifiers.filter(EClass).map[EReferences].flatten.toList, | ||
53 | pckg.EClassifiers.filter(EClass).map[EAttributes].flatten.toList | ||
54 | ) | ||
55 | val metamodelTransformationOutput = ecore2Logic.transformMetamodel(metamodel, new Ecore2LogicConfiguration) | ||
56 | |||
57 | val partialModelOutput = partialInterpretation2Logic.transform(metamodelTransformationOutput, model.eResource, false) | ||
58 | |||
59 | val writer = new PrintWriter(outputs+"//"+instModName+"MODEL.gml") | ||
60 | |||
61 | writer.print(partialVisualizer.transform(partialModelOutput)) | ||
62 | |||
63 | writer.close | ||
64 | |||
65 | val hood = neighbourhoodComputer.createRepresentation(partialModelOutput, depth, Integer.MAX_VALUE, Integer.MAX_VALUE) | ||
66 | |||
67 | val w2 = new PrintWriter(outputs+"/"+instModName+depth+"NEIGHBOURHOOD.gml") | ||
68 | |||
69 | w2.print(neighbourhoodVisualizer.transform(hood, partialModelOutput)) | ||
70 | |||
71 | w2.close | ||
72 | |||
73 | println("visualization done") | ||
74 | |||
75 | // partialModelOutput.openWorldElements | ||
76 | //RESULTS | ||
77 | // print(hood) | ||
78 | |||
79 | } | ||
80 | } | ||