goal for new objects in a transformation [message #1214821] |
Wed, 27 November 2013 21:41 |
Rudolf Weber 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
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04875 seconds