Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » goal for new objects in a transformation
icon5.gif  goal for new objects in a transformation [message #1214821] Wed, 27 November 2013 21:41 Go to next message
Rudolf Weber is currently offline Rudolf WeberFriend
Messages: 11
Registered: February 2013
Junior Member
Hello,

I want to create Objects in the modelpackage itself.
The Objects are created directly in the xmi-Model at first level, and not as childs in a package.

The following QVTo transforms a Component Diagramm in a special Class Diagramm, with an Administration class and a Monitoring-Class for each component and each port
and shows the Problem:
modeltype UML uses "http://www.eclipse.org/uml2/4.0.0/UML";

transformation kompo2administration(in Compo: UML, out decomp: UML);

property curadminclass : UML::Class = null;
property curmonitorclass : UML::Class = null;
property model : UML::Model = null;

main() 
{
    model = object Model { name='model' };
    Compo.objectsOfType(Component) -> map toAdminDecomp();
}

mapping Component::toAdminDecomp() : a: Class, m:Class
{
   object a: Class
   {
	  name := "Administation_"+self.name;
   };
   
   object m: Class
   {
   	   name := "Monitoring_"+self.name;
   };
   curadminclass := a;
   curmonitorclass := m;   
   model.ownedType += a; // Try: add to the model, but in the result,
                         // the model remain empty 
   model.ownedType += m; // this too
   self.ownedPort-> map toAdmin();
}

mapping Port::toAdmin() : a: Class, m:Class
{
   object a: Class
   {
	  name := "Administation_".concat(self.name);
   };
   
   object m: Class
   {
   	   name := "Monitoring_"+self.name;
   };
   
   var pa = object Property
   {
      name := self.name;
      aggregation := uml::AggregationKind::composite;
      type := a;
      lower := 1;
      upper := 1;
   };

   curadminclass.ownedAttribute += pa;
   
   var pm = object Property
   {
      name := self.name;
      aggregation := uml::AggregationKind::composite;
      type := a;
      lower := 1;
      upper := 1;
   };
   curmonitorclass.ownedAttribute += pm;
}


The result is:
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML">
  <uml:Model xmi:id="_4LFAoFelEeOXFqUo7lQK7Q"/>
  <uml:Class xmi:id="_4LFAoVelEeOXFqUo7lQK7Q" name="Administation_ISP">
    <ownedAttribute xmi:id="_4LFAolelEeOXFqUo7lQK7Q" name="Gateway" type="_4LFAr1elEeOXFqUo7lQK7Q" aggregation="composite">
      <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_4LFAo1elEeOXFqUo7lQK7Q" value="1"/>
      <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_4LFApFelEeOXFqUo7lQK7Q" value="1"/>
    </ownedAttribute>
    <ownedAttribute xmi:id="_4LFApVelEeOXFqUo7lQK7Q" name="AccessRouter" type="_4LFAsVelEeOXFqUo7lQK7Q" aggregation="composite">
      <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_4LFAplelEeOXFqUo7lQK7Q" value="1"/>
      <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_4LFAp1elEeOXFqUo7lQK7Q" value="1"/>
    </ownedAttribute>
  </uml:Class>

  

you see, the generated Objekts are in the first level.
and not as I expect, the Objekts should be ownedTypes in the Model:
<xmi:XMI xmi:version="20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML">
  <uml:Model xmi:id="_4LFAoFelEeOXFqUo7lQK7Q">
  <uml:packagedElement xmi:type="uml:Class" xmi:id="_4LFAoVelEeOXFqUo7lQK7Q" name="Administation_ISP">
    <ownedAttribute xmi:id="_4LFAolelEeOXFqUo7lQK7Q" name="Gateway" type="_4LFAr1elEeOXFqUo7lQK7Q" aggregation="composite">
      <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_4LFAo1elEeOXFqUo7lQK7Q" value="1"/>
      <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_4LFApFelEeOXFqUo7lQK7Q" value="1"/>
    </ownedAttribute>
    <ownedAttribute xmi:id="_4LFApVelEeOXFqUo7lQK7Q" name="AccessRouter" type="_4LFAsVelEeOXFqUo7lQK7Q" aggregation="composite">
      <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_4LFAplelEeOXFqUo7lQK7Q" value="1"/>
      <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_4LFAp1elEeOXFqUo7lQK7Q" value="1"/>
    </ownedAttribute>
  </uml:PackagedElement>
  <uml:Packagedlement xmi:typ="uml:Class" xmi:id="_4LFAqFelEeOXFqUo7lQK7Q" name="Monitoring_ISP">
    <ownedAttribute xmi:id="_4LFAqVelEeOXFqUo7lQK7Q" name="Gateway" type="_4LFAr1elEeOXFqUo7lQK7Q" aggregation="composite">
     </uml:PackagedElement>
   </uml:Model>


Thank you very much
Rudolf Weber, Germany
Re: goal for new objects in a transformation [message #1215935 is a reply to message #1214821] Thu, 28 November 2013 08:52 Go to previous messageGo to next message
Matteo M. is currently offline Matteo M.Friend
Messages: 40
Registered: May 2012
Member
Quote:

model.ownedType += a; // Try: add to the model, but in the result,
                      // the model remain empty
model.ownedType += m; // this too



try this:

model.packagedElement += a;
icon5.gif  Re: goal for new objects in a transformation [message #1219434 is a reply to message #1215935] Tue, 03 December 2013 20:36 Go to previous messageGo to next message
Rudolf Weber is currently offline Rudolf WeberFriend
Messages: 11
Registered: February 2013
Junior Member
I changed it, but the effect is the same.

I added simple objects
main() 
{
    model = object Model { name='model' };
    model.packagedElement += object Class { name :='Packman'; };
    model.ownedType += object Class { name :='Type'; };


This has nothing to do with my mapping - but the effect is the same:

'model', 'Packman',and 'Type' are in the same level, and not packaged in model.

What is the problem ?

Thank you very much

Rudolf
Re: goal for new objects in a transformation [message #1220027 is a reply to message #1219434] Mon, 09 December 2013 08:56 Go to previous messageGo to next message
Christopher Gerking is currently offline Christopher GerkingFriend
Messages: 115
Registered: April 2011
Senior Member
Your problem is that "=" is not an assignment operator. That's why in your code, the model variable remains unassigned. Consequently, it is not possible to populate your model. Instead, all created objects will be top-level.

Just try
model := object Model { name='model' };
i.e. replace '=' by ':='.

As of QVTo 3.4.0, there will be a warning message printed in this situation.
Re: goal for new objects in a transformation [message #1222215 is a reply to message #1220027] Thu, 19 December 2013 22:59 Go to previous messageGo to next message
Rudolf Weber is currently offline Rudolf WeberFriend
Messages: 11
Registered: February 2013
Junior Member
Thank you for the answers, the answer of Christopher Gerking helped:
modeltype UML uses "http://www.eclipse.org/uml2/4.0.0/UML";

transformation kompo2administration(in Compo: UML, out decomp: UML);

property curadminclass : UML::Class = null;
property curmonitorclass : UML::Class = null;
property model : UML::Model = null;

main() 
{
    model := object Model { name='model' };
    // excercise polulating the model
    model.packagedElement += object Class { name :='Packman'; };
    model.ownedType += object Class { name :='Type'; };
    // The transformation
    Compo.objectsOfType(Component) -> map toAdminDecomp();
}

mapping Component::toAdminDecomp() : a: Class, m:Class
{
   object a: Class
   {
	  name := "Administation_"+self.name;
   };
   
   object m: Class
   {
   	   name := "Monitoring_"+self.name;
   };
   curadminclass := a;
   curmonitorclass := m;   
   model.ownedType += a;
   model.ownedType += m;
   self.ownedPort-> map toAdmin();
}

mapping Port::toAdmin() : a: Class, m:Class
{
   object a: Class
   {
	  name := "Administation_".concat(self.name);
   };
   
   object m: Class
   {
   	   name := "Monitoring_"+self.name;
   };
  
   model.ownedType += a;
   model.ownedType += m;
    
   var pa = object Property
   {
      name := self.name;
      aggregation := uml::AggregationKind::composite;
      type := a;
      lower := 1;
      upper := 1;
   };

   curadminclass.ownedAttribute += pa;
  
   
   var pm = object Property
   {
      name := self.name;
      aggregation := uml::AggregationKind::composite;
      type := a;
      lower := 1;
      upper := 1;
   };
   curmonitorclass.ownedAttribute += pm;
}


The solution was
* using := as assignment populates the model
* The created objects are added explicitly to the model.

But I still don't understand:
* is the model the output-Model which is referred in the output parameter decomp ?
* why I need the allocaton of a model ? (first line in main() in the above code)
* (Ok, I have a manual model, and I have to explicitly add the objects)

Greetings
Rudolf
Re: goal for new objects in a transformation [message #1223208 is a reply to message #1222215] Sun, 22 December 2013 19:32 Go to previous messageGo to next message
Christopher Gerking is currently offline Christopher GerkingFriend
Messages: 115
Registered: April 2011
Senior Member
Rudolf Weber wrote on Thu, 19 December 2013 17:59

* is the model the output-Model which is referred in the output parameter decomp ?


No. I'm not familiar with the UML meta model, but it seems as if every model requires an explicit instance of class Model, maybe as a root container.

Rudolf Weber wrote on Thu, 19 December 2013 17:59

* why I need the allocaton of a model ? (first line in main() in the above code)


Because Model is just a class in your meta model, and you need an instance of this class to accommodate other model objects. As stated above, this seems to be a particularity with the UML meta model.
Re: goal for new objects in a transformation [message #1226613 is a reply to message #1223208] Thu, 02 January 2014 07:44 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Model is a derivation of Package and it is conventional for the root of
UML models to be a Model rather than a Package. This provides a single
root for potentially diverse contents.

However you could have a "http://www.eclipse.org/uml2/4.0.0/UML" model
whoose root was a Comment.

As you discovered from the accidental comparison rather than assignment,
everything that lacks a parent is placed at the root.

Beware that QVTo provides a built-in Model class too. This doesn't seem
to have caused you a problem; yet.

Regards

Ed Willink


On 22/12/2013 19:32, Christopher Gerking wrote:
> Rudolf Weber wrote on Thu, 19 December 2013 17:59
>> * is the model the output-Model which is referred in the output
>> parameter decomp ?
>
>
> No. I'm not familiar with the UML meta model, but it seems as if every
> model requires an explicit instance of class Model, maybe as a root
> container.
>
> Rudolf Weber wrote on Thu, 19 December 2013 17:59
>> * why I need the allocaton of a model ? (first line in main() in the
>> above code)
>
>
> Because Model is just a class in your meta model, and you need an
> instance of this class to accommodate other model objects. As stated
> above, this seems to be a particularity with the UML meta model.
>
Previous Topic:Execute native OCL query in qvt-o code
Next Topic:Plz help me [ QVT Relational]
Goto Forum:
  


Current Time: Fri Apr 19 23:24:47 GMT 2024

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

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

Back to the top