Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Couple of beginner questions
[QVTO] Couple of beginner questions [message #500318] Wed, 25 November 2009 16:11 Go to next message
PBarendrecht is currently offline PBarendrechtFriend
Messages: 36
Registered: November 2009
Location: Eindhoven, Netherlands
Member
Hi all,
I recently started with a project about model transformations, but I'm all new to M2M and QVTO (that's the language I chose to work with).

The first step I took was to create two metamodels (.ecore files). Next I tried to write a qvt transformation (.qvto file), but I'm not sure what I should write inside the main() part.
For now I just copied something out of a book I borrowed (Eclipse Modeling Project, A DSL Toolkit), but I don't fully understand what it does - in other documentation different commands are used.

main() {
  modelin.rootObjects()[Model]->map toNew();
}


I do understand that this part links to my function toNew(),

mapping MM1::Model::toNew() : MM2::Model {
	Name := self.Name;
}


But after this function is executed, what is next? How does QVT know which mapping to do next?

It looks like the .qvto file would work (no warning symbols in the editor any more), but I don't know how to test it. The metamodels represent some kind of automaton (actually, a model consisting of automata).

I hope somebody can explain these things to me Smile
One other thing, I'm looking for examples with a step-by-step description. Any idea where to find them? I already downloaded the M2M-QVTO.pdf file.
Re: [QVTO] Couple of beginner questions [message #500346 is a reply to message #500318] Wed, 25 November 2009 17:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dvorak.radek.gmail.com

Hi,

Comments, in-lined.

Regards,
/Radek

On Wed, 25 Nov 2009 17:11:16 +0100, PBarendrecht <pieter@redpanda.nl>
wrote:

> Hi all,
> I recently started with a project about model transformations, but I'm
> all new to M2M and QVTO (that's the language I chose to work with).
>
> The first step I took was to create two metamodels (.ecore files). Next
> I tried to write a qvt transformation (.qvto file), but I'm not sure
> what I should write inside the main() part. For now I just copied
> something out of a book I borrowed (Eclipse Modeling Project, A DSL
> Toolkit), but I don't fully understand what it does - in other
> documentation different commands are used.

No problem, AFAIK, the book was not intended for learning QVT in depth and
should rather give an overview of how to combine a couple of modeling
technologies
in a bigger picture.
You are at the right place for the rest on QVT ;).

>
> main() {
> modelin.rootObjects()[Model]->map toNew();
> }
>
> I do understand that this part links to my function toNew(),
>
> mapping MM1::Model::toNew() : MM2::Model {
> Name := self.Name;
> }
>
> But after this function is executed, what is next? How does QVT know
> which mapping to do next?

Simply nothing else is executed. By this code you would just take all root
objects from the input and transform them into instances of the target
metamodel classes
of your choice.

In order to continue, you can certainly see that your root input objects
have some references to other objects. Just go ahead and create another
mapping that transforms those referenced objects to something else that
makes
sense in the target model.

Let's assume your meta-models might look like this:

MM1::Model {
...
p : Package [*];
...
}

MM2::Model {
targetP : TargetPackage [*]
}

// complement your original mapping
mapping MM1::Model::toNew() : MM2::Model {
Name := self.Name;
// follow the hierarchy
// left side creates the target objects which are assigned
// to the target object via the target reference
targetP := p->map toTargetPackage();
}


mapping MM1::Package::toTargetPackage() : MM2::TargetPackage {
// populate data, eventually call further mappings on referenced objects
}


This is a very simplified case, you can do a lot of complex techniques
like disjuct, merge, inherit etc.
This should only help to get understanding of how it works.
IOW, similar to Java coding, but more efficient.

>
> It looks like the .qvto file would work (no warning symbols in the
> editor any more), but I don't know how to test it. The metamodels
> represent some kind of automaton (actually, a model consisting of
> automata). I hope somebody can explain these things to me :)
> One other thing, I'm looking for examples with a step-by-step
> description. Any idea where to find them? I already downloaded the
> M2M-QVTO.pdf file.

You may checkout the following CVS location as project
dev.eclipse.org:/cvsroot/modeling
org.eclipse.m2m/org.eclipse.m2m.qvt.oml/examples/org.eclipse .m2m.qvt.oml.econ2009.tutorial/projects/qvto.ecore2uml

Use wizard 'Examples/Operational QVT Transformation'.

Both examples contain launch configurations to run your transf.

Another option is Ant tasks, search help for "Ant tasks support".

Finally, http://www.omg.org/spec/QVT/1.0 is useful too ;).
Re: [QVTO] Couple of beginner questions [message #500375 is a reply to message #500318] Wed, 25 November 2009 19:46 Go to previous messageGo to next message
PBarendrecht is currently offline PBarendrechtFriend
Messages: 36
Registered: November 2009
Location: Eindhoven, Netherlands
Member
Thanks for your quick reply Radek, the mapping and references are more clear now.

Where can I find the examples you speak of? I cannot find them on my system, and I don't know what a CVS location is Smile
If I understand it correctly, there is no step-by-step tutorial available?

I looked at some other .qvto files, they sometimes have things like "query" and "constructor"; could you concisely explain what these terms do?

Furthermore I searched for more info about QVTO, and found out about a German book about the subject: QVT - Operational Mappings, by Siegfried Nolte. Looking at the table of contents, it explains QVT step by step, and even provides some examples of mapping. Are you familiar with this book, and do you recommend it?
Re: [QVTO] Couple of beginner questions [message #501430 is a reply to message #500375] Wed, 02 December 2009 10:13 Go to previous messageGo to next message
Siegfried Nolte is currently offline Siegfried NolteFriend
Messages: 45
Registered: August 2009
Member
Hello Pieter,

it's me, the "QVT-book-Siegfried". As far as I can see, you leaped deep into QVT now. As you know, my books are in German and I want to reach QVT folks with some German knowledge. At least there are several samples I worked out and published on my book-project web site: "http://www.siegfried-nolte.de/forum/mda/mdaproject/mda.html". They are described in English (at least I hope it). If you start with the famous HelloWorld and go to UML2EJB over UML2RDBM, you will have some step to step, I think. And I would like to have some feedback, because I want to keep the samples being understandable.

So have fun with QVT,
Siegfried
Re: [QVTO] Couple of beginner questions [message #501640 is a reply to message #500375] Thu, 03 December 2009 08:44 Go to previous messageGo to next message
Albert Hofkamp is currently offline Albert HofkampFriend
Messages: 41
Registered: August 2009
Member
PBarendrecht wrote on Wed, 25 November 2009 20:46
Where can I find the examples you speak of? I cannot find them on my system, and I don't know what a CVS location is Smile
CVS access is explained at
http://wiki.eclipse.org/index.php/CVS_Howto
Re: [QVTO] Couple of beginner questions [message #501714 is a reply to message #500318] Thu, 03 December 2009 15:08 Go to previous messageGo to next message
Patrick is currently offline PatrickFriend
Messages: 48
Registered: July 2009
Member
Hello! Smile

I'm trying to get to know modeling a bit better too... So i hope nobody if i'm asking my beginner questions in this thread.

I trying to transform one Ecore Model into another one. Right now Eclipse shows some funny behavior, in the transformation file (.qvto). Both modeltypes, i create :

modeltype contracts "strict" uses 'platform:/resource/contractsForAlarmSystems/model/contracts.ecore';
modeltype components "strict" uses 'platform:/resource/MyAlarmSystem/model/components.ecore';


are both recognized as the same. When i hover with the mouse over them, the tooltip's show both "contracts - platform:/resource/contractsForAlarmSystems/model/contracts. ecore ".

Also in the main entry point, when i try something like this
transformation ComponentsToContracts(in inModel:components, out outModel:contracts);

main() {
	inModel.rootObjects()[components:] ->map toContractModel();
}

And hit space + ctrl after components:, only elements from the contracts model are shown.

Is this a bug or did i make a mistake?
Re: [QVTO] Couple of beginner questions [message #501734 is a reply to message #501714] Thu, 03 December 2009 15:56 Go to previous message
Eclipse UserFriend
Originally posted by: dvorak.radek.gmail.com

Hi P.R2,

Refer to your metamodels by identity (nsURI), not by location in order to
make your transformation runnable from workspace at development time as
well as when deployed in platform.

See
http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg03903.html
for details.

PS: You can use the "model type" code assist template in teh QVT Editor,
which allows you to pick an ecore file from the workspace and performs
registration on the fly.
Just press [Ctrl+Space] in the metamodel proposal popup to reveal
workspace located
metamodels.

Regards,
/Radek


On Thu, 03 Dec 2009 16:08:12 +0100, <P.R2@gmx.de> wrote:

> Hello! :) I'm trying to get to know modeling a bit better too... So i
> hope nobody if i'm asking my beginner questions in this thread. I trying
> to transform one Ecore Model into another one. Right now Eclipse shows
> some funny behavior, in the transformation file (.qvto). Both
> modeltypes, i create :
> modeltype contracts "strict" uses
> 'platform:/resource/contractsForAlarmSystems/model/contracts .ecore';
> modeltype components "strict" uses
> 'platform:/resource/MyAlarmSystem/model/components.ecore';
>
>
> are both recognized as the same. When i hover with the mouse over them,
> the tooltip's show both "contracts -
> platform:/resource/contractsForAlarmSystems/model/contracts. ecore ".
> Also in the main entry point, when i try something like this
>
> transformation ComponentsToContracts(in inModel:components, out
> outModel:contracts);
>
> main() {
> inModel.rootObjects()[components:] ->map toContractModel();
> }
>
> And hit space + ctrl after components:, only elements from the contracts
> model are shown. Is this a bug or did i make a mistake?
Previous Topic:[ATL] how to add a xsi:schemaLocation in the generated model automatically?
Next Topic:[ATL] Release of AML a model matching tool
Goto Forum:
  


Current Time: Thu Aug 22 11:36:07 GMT 2019

Powered by FUDForum. Page generated in 0.03097 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top