Skip to content

Commit

Permalink
#38 uml integration xform fixes
Browse files Browse the repository at this point in the history
  top elements are placed in correct xtUMLrt model
  only a single IncQueryEngine and xform are used
  • Loading branch information
abelhegedus committed Apr 29, 2015
1 parent be12e1a commit 429dd77
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ class ModelSetSnippet implements IModelSetSnippet {
val transformation = new TransformationQrt

override start(ModelSet modelSet) {
val resourceSet = new ResourceSetImpl
val engine = AdvancedIncQueryEngine.createUnmanagedEngine(new EMFScope(#{modelSet, resourceSet}))

ImmutableList.copyOf(modelSet.resources.filter(UMLResource)).forEach[resource |
if (!resource.contents.filter(Model).empty) {
val mapping = createMapping(resource, modelSet)
val engine = AdvancedIncQueryEngine.createUnmanagedEngine(new EMFScope(#{modelSet, mapping.eResource.resourceSet}))
transformation.initialize(mapping, engine)
transformation.execute
createMapping(resource, modelSet, resourceSet)
}
]

transformation.initialize(engine)
transformation.execute
}

def createMapping(Resource umlResource, ModelSet modelSet) {
val resourceSet = new ResourceSetImpl
def createMapping(Resource umlResource, ModelSet modelSet, ResourceSet resourceSet) {

val xtumlrtModel = CommonFactory.eINSTANCE.createModel
createResource(umlResource, "xtumlrt", xtumlrtModel, modelSet, resourceSet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class IntegrationTest {

val transformation = new TransformationQrt
val engine = AdvancedIncQueryEngine.createUnmanagedEngine(new EMFScope(resourceSet))
transformation.initialize(mapping, engine)
transformation.initialize(engine)
transformation.execute

val rules = getRules(engine)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class QueryResultTraceability extends TransformationWrapper {
override initializeTransformation(RootMapping umlToCommon) {
engine = AdvancedIncQueryEngine.createUnmanagedEngine(new EMFScope(umlToCommon.eResource.resourceSet))
xform = new TransformationQrt
xform.initialize(umlToCommon, engine)
xform.initialize(engine)
}

override executeTransformation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import com.google.common.base.Stopwatch
import com.incquerylabs.emdw.umlintegration.queries.StateMachine
import com.incquerylabs.emdw.umlintegration.queries.Structure
import com.incquerylabs.emdw.umlintegration.queries.Trace
import com.incquerylabs.emdw.umlintegration.trace.RootMapping
import com.incquerylabs.emdw.umlintegration.util.PerJobFixedPriorityConflictResolver
import com.incquerylabs.emdw.umlintegration.util.RuleProvider
import java.util.concurrent.TimeUnit
import org.apache.log4j.Logger
import org.eclipse.incquery.runtime.api.GenericPatternGroup
import org.eclipse.incquery.runtime.api.IncQueryEngine
import org.eclipse.viatra.emf.runtime.transformation.eventdriven.EventDrivenTransformation

import static com.google.common.base.Preconditions.*
import org.eclipse.incquery.runtime.api.GenericPatternGroup
import com.incquerylabs.emdw.umlintegration.util.RuleProvider
import org.eclipse.incquery.runtime.emf.EMFScope

class TransformationQrt {

Expand All @@ -26,16 +24,11 @@ class TransformationQrt {
private var initialized = false;

EventDrivenTransformation transform
RootMapping mapping
IncQueryEngine engine

def initialize(RootMapping mapping, IncQueryEngine engine) {
checkArgument(mapping != null, "Mapping cannot be null!")
checkArgument(mapping.umlRoot != null, "Source not defined in mapping!")
checkArgument(mapping.xtumlrtRoot != null, "Target not defined in mapping!")
def initialize(IncQueryEngine engine) {
checkArgument(engine != null, "Engine cannot be null!")
if (!initialized) {
this.mapping = mapping
this.engine = engine

debug("Preparing queries on engine.")
Expand All @@ -60,7 +53,7 @@ class TransformationQrt {
}

def execute() {
info('''Executing transformation on «mapping.umlRoot.name»''')
info('''Executing transformation''')
debug("Initial execution of transformation rules.")
val watch = Stopwatch.createStarted
transform.executionSchema.startUnscheduledExecution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ abstract class AbstractContainmentMapping<Match extends IPatternMatch, Parent ex
override appeared(Match match) {
val parent = match.findParent
val child = match.findChild
parent.insertChild(child)
logger.debug('''Added containment edge «parent» -> «child»''')
if(parent == null){
logger.debug('''Containment edge for «child» without parent not added''')
} else {
parent.insertChild(child)
logger.debug('''Added containment edge «parent» -> «child»''')
}
}

override protected updated(Match match) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ class XTClassInModelMapping extends AbstractContainmentMapping<XtClassInModelMat
}

override findParent(XtClassInModelMatch match) {
rootMapping.xtumlrtRoot
if(rootMapping.umlRoot == match.model){
rootMapping.xtumlrtRoot
} else {
// XXX known null return since this class is out of scope
null
}
}

override findChild(XtClassInModelMatch match) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ class XTComponentInModelMapping extends AbstractContainmentMapping<XtComponentIn
}

override findParent(XtComponentInModelMatch match) {
rootMapping.xtumlrtRoot
if(rootMapping.umlRoot == match.model){
rootMapping.xtumlrtRoot
} else {
// XXX known null return since this class is out of scope
null
}
}

override findChild(XtComponentInModelMatch match) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.incquerylabs.emdw.umlintegration.rules

import com.incquerylabs.emdw.umlintegration.queries.XtEventTriggerMatch
import org.eclipse.papyrusrt.xtumlrt.common.Transition
import org.eclipse.papyrusrt.xtumlrt.xtuml.XTEventTrigger
import org.eclipse.papyrusrt.xtumlrt.xtuml.XTSignalEvent
import java.util.Set
import org.eclipse.incquery.runtime.api.IncQueryEngine
import org.eclipse.papyrusrt.xtumlrt.common.Transition
import org.eclipse.papyrusrt.xtumlrt.xtuml.XTEvent
import org.eclipse.papyrusrt.xtumlrt.xtuml.XTEventTrigger
import org.eclipse.uml2.uml.SignalEvent
import org.eclipse.uml2.uml.Trigger

Expand Down Expand Up @@ -51,7 +51,7 @@ class XTEventTriggerMapping extends AbstractObjectMapping<XtEventTriggerMatch, T
override updateXtumlrtObject(XTEventTrigger xtumlrtObject, XtEventTriggerMatch match) {
switch event : match.trigger.event {
SignalEvent: {
xtumlrtObject.signal = event.signal.findXtumlrtObject(XTSignalEvent)
xtumlrtObject.signal = event.signal.findXtumlrtObject(XTEvent)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ class XTPackageInModelMapping extends AbstractContainmentMapping<XtPackageInMode
}

override findParent(XtPackageInModelMatch match) {
rootMapping.xtumlrtRoot
if(rootMapping.umlRoot == match.model){
rootMapping.xtumlrtRoot
} else {
// XXX known null return since this class is out of scope
null
}
}

override findChild(XtPackageInModelMatch match) {
Expand Down

0 comments on commit 429dd77

Please sign in to comment.