Skip to content

Commit

Permalink
ATOL - apply transformation in an incremental way
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLeCalvar committed May 26, 2023
1 parent 8800ed6 commit 4817053
Showing 1 changed file with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ package atol.example.transformation
import atl.research.AbstractDriver
import atl.research.class_.Class
import atl.research.class_.DataType
import fr.eseo.aof.extensions.AOFExtensions
import io.github.atlresearch.emfmodelfuzzer.SimpleEMFModelFuzzer
import org.eclipse.emf.ecore.EObject
import org.eclipse.papyrus.aof.core.impl.utils.DefaultObserver


class Run extends AbstractDriver {
class Run extends AbstractDriver implements AOFExtensions {
var Class2Relational transformation

static def void main(String[] args) {
Expand All @@ -34,16 +35,31 @@ class Run extends AbstractDriver {
}

override void applyTransformation() {
for(EObject e : source.contents) {
if(e instanceof Class) {
val res = this.transformation.Class2Table(e)._out
target.contents.add(res)
val res = source.<EObject>allContents(null).collect[ e |
val r = switch (e) {
Class: this.transformation.Class2Table(e)._out
DataType: this.transformation.DataType2Type(e)._out
}
else if (e instanceof DataType) {
val res = this.transformation.DataType2Type(e)._out
target.contents.add(res)
r as EObject
].select[ e | e !== null ]
res.addObserver(new DefaultObserver<EObject> {
override added(int index, EObject element) {
target.contents.add(element)
}
}
override moved(int newIndex, int oldIndex, EObject element) {
// no impact
}
override removed(int index, EObject element) {
target.contents.remove(element)
}
override replaced(int index, EObject newElement, EObject oldElement) {
removed(index, oldElement)
added(index, newElement)
}
})
res.forEach[ e |
target.contents.add(e)
]
}

def fuzzerExample() {
Expand Down

0 comments on commit 4817053

Please sign in to comment.