aboutsummaryrefslogtreecommitdiffstats
path: root/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScopeLoader.xtend
diff options
context:
space:
mode:
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScopeLoader.xtend')
-rw-r--r--Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScopeLoader.xtend83
1 files changed, 83 insertions, 0 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScopeLoader.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScopeLoader.xtend
new file mode 100644
index 00000000..ee1a92f0
--- /dev/null
+++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScopeLoader.xtend
@@ -0,0 +1,83 @@
1package hu.bme.mit.inf.dslreasoner.application.execution
2
3import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ClassTypeScope
4import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ExactNumber
5import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.IntEnumberation
6import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.IntegerTypeScope
7import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.IntervallNumber
8import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ObjectTypeScope
9import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.RealEnumeration
10import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.RealTypeScope
11import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ScopeSpecification
12import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.StringEnumeration
13import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.StringTypeScope
14import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic
15import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
16import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes
17import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
18import org.eclipse.emf.ecore.EClass
19
20class ScopeLoader {
21 def TypeScopes loadScope(ScopeSpecification specification, LogicProblem problem, Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
22 val res = new TypeScopes
23 for(scopeSpecification : specification.scopes) {
24 setSpecification(scopeSpecification,res,ecore2Logic,trace)
25 }
26 return res
27 }
28
29 def dispatch setSpecification(ObjectTypeScope scope, TypeScopes aggregated, Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
30 //val existingObjects =
31 aggregated.minNewElements = getLowerLimit(scope.number)
32 aggregated.maxNewElements = getUpperLimit(scope.number)
33 }
34 def dispatch setSpecification(ClassTypeScope scope, TypeScopes aggregated, Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
35 val target = scope.type.element
36 if(target.feature != null) {
37 throw new IllegalArgumentException('''Feature scopes are not supported: "«target.feature.name»"!''')
38 } else {
39 val targetClassifier = target.classifier
40 if(targetClassifier instanceof EClass) {
41 val type = ecore2Logic.TypeofEClass(trace,targetClassifier)
42 aggregated.minNewElementsByType.put(type,getLowerLimit(scope.number))
43 aggregated.maxNewElementsByType.put(type,getUpperLimit(scope.number))
44 } else {
45 throw new IllegalArgumentException('''Non-EClass scopes are not supported: "«targetClassifier.name»"!''')
46 }
47 }
48 }
49 def dispatch setSpecification(IntegerTypeScope scope, TypeScopes aggregated, Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
50 aggregated.minNewIntegers = scope.number.lowerLimit
51 aggregated.maxNewIntegers = scope.number.upperLimit
52 }
53 def dispatch setSpecification(RealTypeScope scope, TypeScopes aggregated, Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
54 aggregated.minNewReals = scope.number.lowerLimit
55 aggregated.maxNewReals = scope.number.upperLimit
56 }
57 def dispatch setSpecification(StringTypeScope scope, TypeScopes aggregated, Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
58 aggregated.minNewStrings = scope.number.lowerLimit
59 aggregated.maxNewStrings = scope.number.upperLimit
60 }
61
62 def dispatch getLowerLimit(IntervallNumber specification) {
63 return specification.min
64 }
65 def dispatch getLowerLimit(ExactNumber specification) {
66 if(specification.isExactUnlimited) return 0
67 else return specification.exactNumber
68 }
69 def dispatch getLowerLimit(IntEnumberation specification) { 0 }
70 def dispatch getLowerLimit(RealEnumeration specification) { 0 }
71 def dispatch getLowerLimit(StringEnumeration specification) { 0 }
72 def dispatch getUpperLimit(IntervallNumber specification) {
73 if(specification.isMaxUnlimited) return -1
74 else return specification.maxNumber
75 }
76 def dispatch getUpperLimit(ExactNumber specification) {
77 if(specification.isExactUnlimited) return -1
78 else return specification.exactNumber
79 }
80 def dispatch getUpperLimit(IntEnumberation specification) { 0 }
81 def dispatch getUpperLimit(RealEnumeration specification) { 0 }
82 def dispatch getUpperLimit(StringEnumeration specification) { 0 }
83} \ No newline at end of file