blob: e79a6261f981f53b7532f68485bb5b963e71efd7 (
plain) (
blame)
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
|
package hu.bme.mit.inf.dslreasoner.run
import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethodBasedGlobalConstraint
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod
import org.eclipse.viatra.dse.base.ThreadContext
class FileSystemInconsistencyDetector extends ModelGenerationMethodBasedGlobalConstraint {
var PartialInterpretation partialInterpretation
//unfinishedLowerMultiplicity_root_reference_FileSystem
//unfinishedLowerMultiplicity_filesystems_reference_Model
var ViatraQueryMatcher<?> filesystem
var ViatraQueryMatcher<?> root
new(ModelGenerationMethod method) {
super(method)
}
override init(ThreadContext context) {
partialInterpretation = context.model as PartialInterpretation
try{
this.filesystem = method.allPatterns.filter[
it.fullyQualifiedName.equals("unfinishedLowerMultiplicity_root_reference_FileSystem")
].head.getMatcher(context.queryEngine)
this.root = method.allPatterns.filter[
it.fullyQualifiedName.equals("unfinishedLowerMultiplicity_filesystems_reference_Model")
].head.getMatcher(context.queryEngine)
} catch(Exception e) { }
}
override checkGlobalConstraint(ThreadContext context) {
var requiredNewObjects =
filesystem.countMatches*2 +
root.countMatches
val availableNewObjects = partialInterpretation.maxNewElements
val res = availableNewObjects >= requiredNewObjects
//println('''[«availableNewObjects» >= «requiredNewObjects»] = «res»''')
return res
}
override createNew() {
return new FileSystemInconsistencyDetector(this.method)
}
override getName() {
this.class.simpleName
}
}
|