Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Specifying concrete output model
Specifying concrete output model [message #987182] Sat, 24 November 2012 08:42 Go to next message
Martin Lukes is currently offline Martin LukesFriend
Messages: 4
Registered: November 2012
Junior Member
In our project we are using QVT transformation to create some output models. Two of them has the same type and there is a problem. Is there a way how to specify addition created object to concrete output model? If the models are "inout" instead of output it is possible to get refference of the rootObject but when the models are outputs created objects (even rootObjects) are stored into first model and the second is empty.

Thanks in advance.
Re: Specifying concrete output model [message #987204 is a reply to message #987182] Sat, 24 November 2012 12:50 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

QVTo ensures that only one object is created per mapping per tuple of
identical inputs. If you want multiples then you need to introduce an
extra disambiguating prameter to the generating mapping, so that the
multiple ciopies have an extra distinct value in each tuple. For
instance pass an integer such as 1 or 2 to the mapping to identify the
first or second model.

Regards

Ed Willink


On 24/11/2012 12:36, Martin Lukes wrote:
> In our project we are using QVT transformation to create some output
> models. Two of them has the same type and there is a problem. Is there
> a way how to specify addition created object to concrete output model?
> If the models are "inout" instead of output it is possible to get
> refference of the rootObject but when the models are outputs created
> objects (even rootObjects) are stored into first model and the second
> is empty.
>
> Thanks in advance.
Re: Specifying concrete output model [message #987220 is a reply to message #987204] Sat, 24 November 2012 16:09 Go to previous messageGo to next message
Martin Lukes is currently offline Martin LukesFriend
Messages: 4
Registered: November 2012
Junior Member
I know about creating only one model per tuple of identical inputs that is not an problem.

I will try to illustrate problem on the example code:

modeltype OUTMODEL uses 'http://www.eclipse.org/mm/outmodel';
modeltype INMODEL uset 'http://www.eclipse.org/mm/inmodel';

transformation perform_process(in inputModel : INMODEL, out firstOutModel : OUTMODEL, out secondOutModel : OUTMODEL);

main() {
   var inRoot : Letter := inputModel.rootObjects()![Letter];
   inRoot.map toFirstOut(firstOutModel);
   inRoot.map toSecondOut(secondOutModel);
}

mapping Letter : toFirstOut(inout outM : OUTMODEL ){
	object Person{ name:= self.name};
}

mapping Letter : toSecondOut(inout outM : OUTMODEL){
	object Person{ name:= self.name + " Lukes"};
}

Let's have this code. I want to map inputModel to two outputs firstOutModel and secondOutModel. Let's INMODEL has rootObject Letter and OUTMODEL has rootObject Person. There are two mapping with different names - so both should be executed ones. Mapping toFirstOut maps Letter object to object Person with name equal to attribut Letter.name and second mapping toSecondOut maps Letter object to object Person with name equal to atribute Letter.name concatenated with String " Lukes". Problem is that both Person are stored in firstOutModel. How should be code modified to store object object Person{ name:= self.name} to firstOutModel and object Person{ name:= self.name + " Lukes"} to secondOutModel?
Re: Specifying concrete output model [message #987221 is a reply to message #987220] Sat, 24 November 2012 16:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I don't know the answer but I can make some suggestions.
>
> transformation perform_process(in inputModel : INMODEL, out
> firstOutModel : OUTMODEL, out secondOutModel : OUTMODEL);
>
> main() {
> var inRoot : Letter := inputModel.rootObjects()![Letter];
> inRoot.map toFirstOut(firstOutModel);
> inRoot.map toSecondOut(secondOutModel);
> }
provides no indication that you want the two models to be separated, so
they aren't.

I can see no obvious syntax that allows you to define alternate default
roots, so I suspect that you may need to disambiguate it by defining
distinct output meta-models, OUTMODEL1 and OUTMODEL2 that happen to use
the same meta-model.

Regards

Ed Willink
Re: Specifying concrete output model [message #987224 is a reply to message #987221] Sat, 24 November 2012 18:15 Go to previous messageGo to next message
Martin Lukes is currently offline Martin LukesFriend
Messages: 4
Registered: November 2012
Junior Member
modeltype OUTMODEL1 uses 'http://www.eclipse.org/mm/outmodel';
modeltype OUTMODEL2 uses 'http://www.eclipse.org/mm/outmodel';

this was interesting suggestion, but not working. For our project there is alternative to divide metamodel OUTMODEL into two but some team members were annoyed by growing model amount and I was curious if there is solution for two same models that cannot be splitted.
Re: Specifying concrete output model [message #987226 is a reply to message #987224] Sat, 24 November 2012 19:03 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

looking further at your example

mapping Letter : toSecondOut(inout outM : OUTMODEL){
object Person{ name:= self.name + " Lukes"};
}

does not use outM, so you are relying on the default behaviour whereby
all orphan outputs are assigned to the first.

Try assigning your outputs to output properties.

Regards

Ed Willink



On 24/11/2012 18:15, Martin Lukes wrote:
> modeltype OUTMODEL1 uses 'http://www.eclipse.org/mm/outmodel';
> modeltype OUTMODEL2 uses 'http://www.eclipse.org/mm/outmodel';
> this was interesting suggestion, but not working. For our project
> there is alternative to divide metamodel OUTMODEL into two but some
> team members were annoyed by growing model amount and I was curious if
> there is solution for two same models that cannot be splitted.
Re: Specifying concrete output model [message #987232 is a reply to message #987226] Sat, 24 November 2012 19:56 Go to previous messageGo to next message
Martin Lukes is currently offline Martin LukesFriend
Messages: 4
Registered: November 2012
Junior Member
I can assign objects to a nonroot property, but I can't assign rootObject to Model. I can create model before transformation and make it inout but it is little weird solution.

[Updated on: Sat, 24 November 2012 20:25]

Report message to a moderator

Re: Specifying concrete output model [message #987262 is a reply to message #987232] Sun, 25 November 2012 11:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Without seeing your solution, I cannot comment on how weird it is or
whether there is a better way.

Regards

Ed Willink


On 24/11/2012 19:56, Martin Lukes wrote:
> I can assign objects to a nonroot property, but I can't assign
> rootObject to Model. I can create model and make it inout but it is
> little weird solution.
Re: Specifying concrete output model [message #987584 is a reply to message #987262] Tue, 27 November 2012 09:24 Go to previous messageGo to next message
Pavel Moravec is currently offline Pavel MoravecFriend
Messages: 1
Registered: November 2012
Junior Member
Hi,

here is a solution (not really nice but working for me).
Comments in the source code.

Pavel

File 1: outer.qvto
import inner;

modeltype ECORE uses "http://www.eclipse.org/emf/2002/Ecore";

transformation outer(out outModel : ECORE, out outModel2 : ECORE);

main() {
	/* Executes inner transformation which creates root element in outModel2.
         * Consider using .transform().failed() to check if the transformation has
         * finished properly. */
	new inner(outModel2).transform();

	/* Creates new EPackage to outModel */
	object EPackage { name := "outer" };
	
	/* Objects from outModel2 can be further updated... */ 
	var innerPackage : EPackage = outModel2.rootObjects()![EPackage]; 
	innerPackage.name := "updated inner";

	/* ... and new instances can be placed into the model as well. */	
	innerPackage.eSubpackages += object EPackage { name := "inner, inner" }
}


File 2: inner.qvto
modeltype ECORE uses "http://www.eclipse.org/emf/2002/Ecore";

transformation inner(out outModel : ECORE);

main() {
	object EPackage { name := "inner" };
}
Re: Specifying concrete output model [message #988288 is a reply to message #987584] Thu, 29 November 2012 09:48 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Thanks for sharing this solution; not very nice but a simple workaround.
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=395357 raised).

Superficially it seems to be that there is a bug in that 'outmodel2' is
not in the environment for use as an output side label such as

outmodel2 := ...

or perhaps

outmodel2.rootObjects() += ...

Regards

Ed Willink


On 27/11/2012 13:05, Pavel Moravec wrote:
> Hi,
>
> here is a solution (not really nice but working for me).
> Comments in the source code.
>
> Pavel
>
> File 1: outer.qvto
>
> import inner;
>
> modeltype ECORE uses "http://www.eclipse.org/emf/2002/Ecore";
>
> transformation outer(out outModel : ECORE, out outModel2 : ECORE);
>
> main() {
> /* Executes inner transformation which creates root element in
> outModel2.
> * Consider using .transform().failed() to check if the
> transformation has
> * finished properly. */
> new inner(outModel2).transform();
>
> /* Creates new EPackage to outModel */
> object EPackage { name := "outer" };
>
> /* Objects from outModel2 can be further updated... */ var
> innerPackage : EPackage = outModel2.rootObjects()![EPackage];
> innerPackage.name := "updated inner";
>
> /* ... and new instances can be placed into the model as well. */
> innerPackage.eSubpackages += object EPackage { name := "inner,
> inner" }
> }
>
>
> File 2: inner.qvto
>
> modeltype ECORE uses "http://www.eclipse.org/emf/2002/Ecore";
>
> transformation inner(out outModel : ECORE);
>
> main() {
> object EPackage { name := "inner" };
> }
>
Re: Specifying concrete output model [message #1008044 is a reply to message #988288] Fri, 08 February 2013 15:59 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The solution is to use the @modelExtent operator as noted in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=395357.

Regards

Ed Willink
Previous Topic:[Announce] Eclipse QVT Operational 3.3.0 (Kepler M5) is now available
Next Topic:Access values between tags via qvto
Goto Forum:
  


Current Time: Fri Mar 29 08:39:05 GMT 2024

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

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

Back to the top