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