aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend
diff options
context:
space:
mode:
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend')
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend99
1 files changed, 77 insertions, 22 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend
index f74c2ab4..1e2bbe6d 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend
@@ -25,6 +25,8 @@ import org.eclipse.emf.ecore.EObject
25import org.eclipse.emf.ecore.resource.Resource 25import org.eclipse.emf.ecore.resource.Resource
26 26
27import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* 27import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
28import org.eclipse.emf.ecore.EClass
29import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
28 30
29class InstanceModel2PartialInterpretation { 31class InstanceModel2PartialInterpretation {
30 val extension LogiclanguageFactory factory = LogiclanguageFactory.eINSTANCE 32 val extension LogiclanguageFactory factory = LogiclanguageFactory.eINSTANCE
@@ -123,26 +125,31 @@ class InstanceModel2PartialInterpretation {
123 // Transforming the attributes 125 // Transforming the attributes
124 for(attribute : source.eClass.EAllAttributes.filter[attributesUsed.contains(it) && !it.derived]) { 126 for(attribute : source.eClass.EAllAttributes.filter[attributesUsed.contains(it) && !it.derived]) {
125 val isIgnored = checkIfIgnored(source, attribute, ignoredAttribs) 127 val isIgnored = checkIfIgnored(source, attribute, ignoredAttribs)
126 if (!isIgnored) { 128 val type = ecore2Logic.relationOfAttribute(ecore2LogicTrace, attribute)
127 val type = ecore2Logic.relationOfAttribute(ecore2LogicTrace,attribute) 129 val interpretation = type.lookup(partialInterpretationTrace.relation2Interpretation)
128 val interpretation = type.lookup(partialInterpretationTrace.relation2Interpretation) 130 val sourceElement = source.lookup(object2DefinedElement)
129 val sourceElement = source.lookup(object2DefinedElement) 131 if (attribute.isMany) {
130 if(attribute.isMany) { 132 val listOfTargets = source.eGet(attribute) as List<? extends EObject>
131 val listOfTargets = source.eGet(attribute) as List<? extends EObject> 133 for (target : listOfTargets) {
132 for(target : listOfTargets) { 134 var DefinedElement value = null
133 val value = translateValue(target,ecore2LogicTrace,partialInterpretationTrace) 135 if (!isIgnored) value = translateValue(target, ecore2LogicTrace, partialInterpretationTrace)
134 if(value !== null) { 136 else value = createUnknownElement(partialInterpretation, target)
135 translateLink(interpretation,sourceElement,value) 137 if (value !== null) {
136 } 138 translateLink(interpretation, sourceElement, value)
137 } 139 }
138 } else { 140 }
139 val target = source.eGet(attribute) 141 } else {
140 if(target !== null) { 142 val target = source.eGet(attribute)
141 val value = translateValue(target,ecore2LogicTrace,partialInterpretationTrace) 143 if (target !== null) {
142 if(value !== null) { 144 if (!isIgnored) {
143 translateLink(interpretation,sourceElement,value) 145 val value = translateValue(target, ecore2LogicTrace, partialInterpretationTrace)
146 if (value !== null) {
147 translateLink(interpretation, sourceElement, value)
144 } 148 }
145 } 149 }
150 else translateLink(interpretation, sourceElement, createUnknownElement(partialInterpretation, target))
151// else value = null
152
146 } 153 }
147 } 154 }
148 } 155 }
@@ -190,11 +197,18 @@ class InstanceModel2PartialInterpretation {
190 ) { 197 ) {
191 val classInIgnored = ignoredAttribs.get(object.eClass.name) 198 val classInIgnored = ignoredAttribs.get(object.eClass.name)
192 val mayIgnored = ( 199 val mayIgnored = (
200 classInIgnored !== null && classInIgnored.containsKey("*")
201 ||
193 classInIgnored !== null && classInIgnored.containsKey(attribute.name)) 202 classInIgnored !== null && classInIgnored.containsKey(attribute.name))
194 203
195 var isIgnored = false 204 var isIgnored = false
196 if (mayIgnored) { 205 if (mayIgnored) {
197 val specificIgnoredValue = classInIgnored.get(attribute.name) 206 var String specificIgnoredValue = null
207 if (classInIgnored.containsKey("*"))
208 specificIgnoredValue = classInIgnored.get("*")
209 else
210 specificIgnoredValue = classInIgnored.get(attribute.name)
211
198 if (specificIgnoredValue.equals("*")) 212 if (specificIgnoredValue.equals("*"))
199 isIgnored = true 213 isIgnored = true
200 else { 214 else {
@@ -208,10 +222,10 @@ class InstanceModel2PartialInterpretation {
208 } 222 }
209 // DEBUG 223 // DEBUG
210 if (isIgnored) { 224 if (isIgnored) {
211 println("IGNORED") 225// println("IGNORED")
212 println(object) 226// println(object)
213 println(attribute) 227// println(attribute)
214 println(object.eGet(attribute)) 228// println(object.eGet(attribute))
215 } 229 }
216 // END DEBUG 230 // END DEBUG
217 return isIgnored 231 return isIgnored
@@ -276,4 +290,45 @@ class InstanceModel2PartialInterpretation {
276 dispatch protected def translateValue(String value, Ecore2Logic_Trace ecore2LogicTrace, Problem2PartialInterpretationTrace partialInterpretationTrace) { 290 dispatch protected def translateValue(String value, Ecore2Logic_Trace ecore2LogicTrace, Problem2PartialInterpretationTrace partialInterpretationTrace) {
277 value.lookup(partialInterpretationTrace.primitiveValues.stringMap) 291 value.lookup(partialInterpretationTrace.primitiveValues.stringMap)
278 } 292 }
293
294 dispatch protected def createUnknownElement(PartialInterpretation p, Enumerator value) {
295 throw new UnsupportedOperationException("Currently we do not support ignored Enums")
296 //TODO Unsure about this
297 }
298
299 dispatch protected def createUnknownElement(PartialInterpretation p, Boolean value) {
300 val e = createBooleanElement => [valueSet = false]
301 p.newElements += e
302 return e
303 }
304
305 dispatch protected def createUnknownElement(PartialInterpretation p, Integer value) {
306 val e = createIntegerElement => [valueSet = false]
307 p.newElements += e
308 return e
309 }
310
311 dispatch protected def createUnknownElement(PartialInterpretation p, Short value) {
312 val e = createIntegerElement => [valueSet = false]
313 p.newElements += e
314 return e
315 }
316
317 dispatch protected def createUnknownElement(PartialInterpretation p, Double value) {
318 val e = createRealElement => [it.valueSet = false]
319 p.newElements += e
320 return e
321 }
322
323 dispatch protected def createUnknownElement(PartialInterpretation p, Float value) {
324 val e = createRealElement => [valueSet = false]
325 p.newElements += e
326 return e
327 }
328
329 dispatch protected def createUnknownElement(PartialInterpretation p, String value) {
330 val e = createStringElement => [valueSet = false]
331 p.newElements += e
332 return e
333 }
279} \ No newline at end of file 334} \ No newline at end of file