Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Transforming two model instances into a single model instance(Parameter passing QVTO)
Transforming two model instances into a single model instance [message #1234575] Wed, 22 January 2014 09:43 Go to next message
Ben Haldo is currently offline Ben HaldoFriend
Messages: 6
Registered: October 2013
Junior Member
I am trying to learn model transformation using QVTO. I have two simple source models (VehicleMM , DriverMM )each with a single class and a single attribute. My target metamodel (CarMM )has also one class but has two attributes. I want to transform VehicleMM and DriverMM attributes to the first and the second attributes of MMC.

So far I managed to write a transformation like this:

modeltype CarMM uses ".....";
modeltype VehicleMM uses ".....";
modeltype DriverMM uses ".....";

transformation VehitoCar(in vehiSource:VehicleMM, out carTarget:CarMM);

main() {
vehiSource.rootObjects()[Vehicle] . map vehi2Car( ????? );
}

mapping Vehicle::vehi2Car(driverInst:Driver):Car{

brand := self.brand;
driver := driverInst.drivName;
}

I couldn't figure how to instantiate the Driver model to pass it to the vehi2Car mapping. I mean what kind of construct should be placed in place of ????? Any ideas on how to achieve this?

[Updated on: Wed, 22 January 2014 09:45]

Report message to a moderator

Re: Transforming two model instances into a single model instance [message #1235045 is a reply to message #1234575] Thu, 23 January 2014 12:27 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you have two input models then your transformation should have two
input models.

Your transformation will naturally traverse one model, so tyou will need
to use appropriate queries to locate the corresponding object in the
second model.

Regards

Ed Willink


On 22/01/2014 09:43, Ben Haldo wrote:
> I am trying to learn model transformation using QVTO. I have two
> simple source models (VehicleMM , DriverMM )each with a single class
> and a single attribute. My target metamodel (CarMM )has also one
> class but has two attributes. I want to transform VehicleMM and
> MMDriverMM attributes to the first and the second attributes of MMC.
>
> So far I managed to write a transformation like this:
>
> modeltype CarMM uses ".....";
> modeltype VehicleMM uses ".....";
> modeltype DriverMM uses ".....";
>
> transformation VehitoCar(in vehiSource:VehicleMM, out carTarget:CarMM);
>
> main() {
> vehiSource.rootObjects()[Vehicle] . map vehi2Car( ???? );
> }
> mapping Vehicle::vehi2Car(driverInst:Driver):Car{
>
> brand := self.brand;
> driver := driverInst.drivName;
> }
>
> I couldn't figure how to instantiate the Driver model to pass it to
> the vehi2Car mapping. Any ideas on how to achieve this?
>
Re: Transforming two model instances into a single model instance [message #1235082 is a reply to message #1235045] Thu, 23 January 2014 14:36 Go to previous messageGo to next message
Ben Haldo is currently offline Ben HaldoFriend
Messages: 6
Registered: October 2013
Junior Member
Okay, As you said I have two models, So I create the following query to locate an object in the second model.

query findDriver():Driver{
var aDriver:Driver;
var driverSet:Set(Driver);
driverSet := drivSource.rootObjects()[Driver] ;

return aDriver;
}

Now my problem is dirverSet is of type Set which (as far as I know about OCL types) has no way of accessing individual members. How can I cast a Set to an OrderedSet or to a Sequence so that I can return a specific Driver Object from the query?
Re: Transforming two model instances into a single model instance [message #1235142 is a reply to message #1235082] Thu, 23 January 2014 16:53 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
->asOrderedSet()

but since a Set has no deterministic order the result of asOrderedSet()
will not be determinstic.

If order existed don't lose it.

If order does not exist you need to create it by e.g. ->sortedBy(name)

Regards

Ed Willink


On 23/01/2014 14:36, Ben Haldo wrote:
> Okay, As you said I have two models, So I create the following query
> to locate an object in the second model.
>
> query findDriver():Driver{
> var aDriver:Driver;
> var driverSet:Set(Driver);
> driverSet := drivSource.rootObjects()[Driver] ; return aDriver;
> }
> Now my problem is dirverSet is of type Set which (as far as I know
> about OCL types) has no way of accessing individual members. How can I
> cast a Set to an OrderedSet or to a Sequence so that I can return a
> specific Driver Object from the query?
Previous Topic:Posible enhacements in the QVT code
Next Topic:Setting a configuration property from Java
Goto Forum:
  


Current Time: Thu Apr 18 12:49:34 GMT 2024

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

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

Back to the top