M-to-N model transformations

7 views
Skip to first unread message

RFR

unread,
Sep 11, 2007, 7:45:04 AM9/11/07
to Tefkat
Hello,

When specifying more than one input model, only the first one will be
considered for pattern matching (if the extends are not referenced via
@extend directly). For some use cases I have a large number of small
input models which share the same metamodel. Is there a possibility to
consider them all for pattern matching without addressing each one
directly?

Sometimes it would be even useful to put various models (with the same
metamodel) in one single extend. For my scenario I would like to put
all physical separated models in this logical extend. This way I could
deal easier with a dynamic number of input models (which is the case
for my scenario).

Best regards
René

michael lawley

unread,
Sep 11, 2007, 9:10:50 AM9/11/07
to Tef...@googlegroups.com

Hi again René,

More interesting questions. In theory, the single-extent solution is
possible and the foundation to support it does exist, however...

At the moment you can only do this if you invoke Tefkat
programmatically -- you create an instance of
tefkat.model.impl.RefereceExtentImpl and add your
org.eclipse.emf.ecore.resource.Resource objects to its multi-valued
resources attribute, then you invoke transform(Resource
transformation, Extent[] srcs, Extent[] tgts, Extent trackingExtent,
boolean force) on an instance of tefkat.engine.Tefkat. The problem
then is that this is not a public method :-(

Fixing this is something we can do in the short term.

To answer your first question, if you want a single rule to match
across some number of input models, then you should be able to write
something like:

TRANSFORMATION t: s1, s2, s3, s4, s5 -> t

// s1, s2, and s3 share the same metamodel and we
// want to consider them together.
//
PATTERN sourceGroup(s)
WHERE s = s1 OR s = s2 OR s = s3;

RULE rule
FORALL Foo@s f
WHERE sourceGroup(s) AND f.attr = "value"
MAKE Bar b
;

This is because extent variables are just ordinary variables that
happen to be bound to Extent objects (if they aren't then using them
in @extent will fail).

I hope this helps,

michael

RFR

unread,
Sep 11, 2007, 9:43:24 AM9/11/07
to Tefkat
Hi Michael,

Thanks a lot again.

The idea with the PATTERN for a source group helps indeed. The only
problem which remains is that the number of input models is still
static. Since I would prefer programmatical invokation of a
transformation run anyway, access to the yet private method would
solve this, too.

Is a transformation run involving two extends with different
metamodels and multiple resources for each extend also possible this
way?

Regards
René

On 11 Sep., 15:10, "michael lawley" <mich...@lawley.id.au> wrote:

RFR

unread,
Sep 17, 2007, 8:58:13 AM9/17/07
to Tefkat
> At the moment you can only do this if you invoke Tefkat
> programmatically -- you create an instance of
> tefkat.model.impl.RefereceExtentImpl and add your
> org.eclipse.emf.ecore.resource.Resource objects to its multi-valued
> resources attribute, then you invoke transform(Resource
> transformation, Extent[] srcs, Extent[] tgts, Extent trackingExtent,
> boolean force) on an instance of tefkat.engine.Tefkat. The problem
> then is that this is not a public method :-(
>
> Fixing this is something we can do in the short term.

Hi Michael,

Will this be fixed for a new release or do I have to fix it on the
basis of the CVS version?
Is the CVS version as stable as the release?

Regards
René

michael lawley

unread,
Sep 17, 2007, 10:10:35 AM9/17/07
to Tef...@googlegroups.com
Hi,

I have a new version in the works. Stay tuned!

michael

michael lawley

unread,
Sep 18, 2007, 7:16:16 PM9/18/07
to Tef...@googlegroups.com
Hi René,

There is a new release available (build 2.1.0.lawley235) that supports
multiple Resources per (source) Extent.

Quoting the FAQ <http://tefkat.sourceforge.net/FAQ.html>

"...specify the name of the source extent variable as the Var Group
property in the tefkat config file. For example, if there are two
source models, file:foo.xmi and file:bar.xmi and the transformation is
specified as TRANSFORMATION example: src -> tgt then you would add two
SourceModels to the TransformationTask, one with Location Uri =
file:foo.xmi and one with file:bar.xmi but set the Var Group of both
to src."

michael

RFR

unread,
Sep 19, 2007, 8:10:39 AM9/19/07
to Tefkat
Great,

nice to have that integrated into the UI launching method.

Anyway, is there also a solution for the situation, when the numper of
models is dynamic. Best solution would be to generate a tefkat.xml
dynamically and launch the engine programatically. Is such an
interface available (run (TKConfiguration))?

Regards René

michael lawley

unread,
Sep 19, 2007, 9:21:11 AM9/19/07
to Tef...@googlegroups.com
Yes, you can create a tefkat.config.TefkatConfig.TransformationTask
programmatically (no need to serialise it to tefkat.xmi) and call new
Tefkat().transform(transformationTask, true, false) The other
parameters mean yes, please save the resulting models and no, don't
continue after an error.

Alternatively, you can call tefkat.engine.Main.main(String[] args)
with appropriate arguments:

[-quiet] [-debug] [-force] [-fixpoint] [-statistics] [-save]
[-layout] [-vis mtsT] [-mapURI from to]
[-conf configURI |
-transformation mappingURI
[-source srcURI | -sourceVar var=srcURI]*
[-target targetURI]*
[-trace traceURI]
]

For example,

String[] args = {
"-save",
"-transformation", "file:transform.qvt",
"-sourceVar", "src=file:foo.xmi",
"-sourceVar", "src=file:bar.xmi",
"-target", "file:result.xmi"
};

michael

Reply all
Reply to author
Forward
0 new messages