Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] resolve issue with nested mappings
[QVTO] resolve issue with nested mappings [message #490740] Fri, 09 October 2009 23:48 Go to next message
Eclipse UserFriend
Originally posted by: vanbeerst.gmail.com

This is a multi-part message in MIME format.
--------------020308010005040200000305
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I'm having trouble using the resolveone command. I have a mapping which
calls a resolveone on an element and if this gives back null, it does a
mapping on that element so it is actually mapped. After that, I call
resolveone again, but this seems to give back null again.
So in short, I have a nested mapping B inside a mapping A, but the
resolveone does not give the mapped result inside mapping A. Is this
normal, or did I make a mistake somewhere, and if this is normal what
can I do to solve this issue?

I think this might be the normal result, because the trace file shows
first the mapping A and then mapping B, even though mapping B is called
from within mapping A and thus finished before mapping A.

I added the qvto - file (agencyguard.qvto), a sample model (agency.uml)
and the trace file (AgencyGuardPattern.qvtotrace). The transformation is
meant to apply the Agency Guard pattern to a UML model. The nested
mappings are as follows : mapping A would be mapping 'applyPattern' and
mapping B would be 'createGuardIface'. The problem is visible inside the
'getGuardIface' helper function, where I put two log messages, this is
the output of the log :

getGuardIface :: mapped targetIface to guardIface
getGuardIface :: guardIface =
'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1b3a7116 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@19d66951 (name: Invalid_Class)
(instanceClassName: null) (abstract: false, interface: false))'
getGuardIface :: mapped targetIface to guardIface
getGuardIface :: guardIface =
'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1b3a7116 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@19d66951 (name: Invalid_Class)
(instanceClassName: null) (abstract: false, interface: false))'


If necessary I am willing to make a simpler toy example for this issue,
but unfortunately I don't have the time for that right now.

Regards,
Tony.

--------------020308010005040200000305
Content-Type: text/xml;
name="agency.uml"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="agency.uml"

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML">
<uml:Usage xmi:id="_h6WoMLUtEd6_9tIgre28dA" name="Iface1_Agent1" client="_QxaqwLUAEd6_9tIgre28dA"/>
<uml:Usage xmi:id="_h6WoMbUtEd6_9tIgre28dA" name="Iface2_Agent1" client="_QxaqwLUAEd6_9tIgre28dA"/>
<uml:Package xmi:id="_zVNEYbT_Ed6_9tIgre28dA" name="agency">
<elementImport xmi:id="_zZ2T0LT_Ed6_9tIgre28dA">
<importedElement xmi:type="uml:PrimitiveType" href=" pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Boolea n"/>
</elementImport>
<elementImport xmi:id="_zZ9okLT_Ed6_9tIgre28dA">
<importedElement xmi:type="uml:PrimitiveType" href=" pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String"/>
</elementImport>
<elementImport xmi:id="_zZ9okbT_Ed6_9tIgre28dA">
<importedElement xmi:type="uml:PrimitiveType" href=" pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Unlimi tedNatural"/>
</elementImport>
<elementImport xmi:id="_zZ9okrT_Ed6_9tIgre28dA">
<importedElement xmi:type="uml:PrimitiveType" href=" pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Intege r"/>
</elementImport>
<packagedElement xmi:type="uml:Package" xmi:id="_ACku4LUAEd6_9tIgre28dA" name="agency1">
<packagedElement xmi:type="uml:Component" xmi:id="_H4GgsLUAEd6_9tIgre28dA" name="&lt;AgencyResource>Agency1Resource1" clientDependency="_i7PW4LUAEd6_9tIgre28dA">
<interfaceRealization xmi:id="_i7PW4LUAEd6_9tIgre28dA" name="Agency1Resource1_Iface1" supplier="_nwdZYLUAEd6_9tIgre28dA" client="_H4GgsLUAEd6_9tIgre28dA"/>
</packagedElement>
<packagedElement xmi:type="uml:Component" xmi:id="_Ufp3ELUAEd6_9tIgre28dA" name="Agent2" clientDependency="_bOT1gLUCEd6_9tIgre28dA _bQNWILUGEd6_9tIgre28dA"/>
<packagedElement xmi:type="uml:Interface" xmi:id="_nwdZYLUAEd6_9tIgre28dA" name="Iface1"/>
<packagedElement xmi:type="uml:Usage" xmi:id="_bOT1gLUCEd6_9tIgre28dA" name="Iface1_Agent2" supplier="_nwdZYLUAEd6_9tIgre28dA" client="_Ufp3ELUAEd6_9tIgre28dA"/>
<packagedElement xmi:type="uml:Usage" xmi:id="_bQNWILUGEd6_9tIgre28dA" name="Iface2_Agent2" supplier="_ODF0kLUGEd6_9tIgre28dA" client="_Ufp3ELUAEd6_9tIgre28dA"/>
<packagedElement xmi:type="uml:Interface" xmi:id="_h5lMILUtEd6_9tIgre28dA" name="guarded_Iface1"/>
<packagedElement xmi:type="uml:Component" xmi:id="_h5lMIrUtEd6_9tIgre28dA" name="agency1AgencyGuard" clientDependency="_h5lMI7UtEd6_9tIgre28dA _h5lMIbUtEd6_9tIgre28dA">
<interfaceRealization xmi:id="_h5lMI7UtEd6_9tIgre28dA" supplier="_h5lMILUtEd6_9tIgre28dA" client="_h5lMIrUtEd6_9tIgre28dA"/>
</packagedElement>
<packagedElement xmi:type="uml:Usage" xmi:id="_h5lMIbUtEd6_9tIgre28dA" name="forward_Iface1" supplier="_nwdZYLUAEd6_9tIgre28dA" client="_h5lMIrUtEd6_9tIgre28dA"/>
</packagedElement>
<packagedElement xmi:type="uml:Package" xmi:id="_Ccho0LUAEd6_9tIgre28dA" name="agency2">
<packagedElement xmi:type="uml:Component" xmi:id="_WtBtkLUAEd6_9tIgre28dA" name="Agent3"/>
<packagedElement xmi:type="uml:Component" xmi:id="_HmpVkLUGEd6_9tIgre28dA" name="&lt;AgencyResource>Agency2Resource1" clientDependency="_TPExQLUGEd6_9tIgre28dA">
<interfaceRealization xmi:id="_TPExQLUGEd6_9tIgre28dA" name="Agency2Resource1_Iface2" supplier="_ODF0kLUGEd6_9tIgre28dA" client="_HmpVkLUGEd6_9tIgre28dA"/>
</packagedElement>
<packagedElement xmi:type="uml:Interface" xmi:id="_ODF0kLUGEd6_9tIgre28dA" name="Iface2"/>
<packagedElement xmi:type="uml:Interface" xmi:id="_h6VaELUtEd6_9tIgre28dA" name="guarded_Iface2"/>
<packagedElement xmi:type="uml:Component" xmi:id="_h6VaErUtEd6_9tIgre28dA" name="agency2AgencyGuard" clientDependency="_h6VaE7UtEd6_9tIgre28dA _h6VaEbUtEd6_9tIgre28dA">
<interfaceRealization xmi:id="_h6VaE7UtEd6_9tIgre28dA" supplier="_h6VaELUtEd6_9tIgre28dA" client="_h6VaErUtEd6_9tIgre28dA"/>
</packagedElement>
<packagedElement xmi:type="uml:Usage" xmi:id="_h6VaEbUtEd6_9tIgre28dA" name="forward_Iface2" supplier="_ODF0kLUGEd6_9tIgre28dA" client="_h6VaErUtEd6_9tIgre28dA"/>
</packagedElement>
<packagedElement xmi:type="uml:Component" xmi:id="_QxaqwLUAEd6_9tIgre28dA" name="Agent1" clientDependency="_h6WoMLUtEd6_9tIgre28dA _h6WoMbUtEd6_9tIgre28dA"/>
</uml:Package>
</xmi:XMI>

--------------020308010005040200000305
Content-Type: text/plain;
name="agencyguard.qvto"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="agencyguard.qvto"

modeltype UML "strict" uses uml('http://www.eclipse.org/uml2/3.0.0/UML');

transformation AgencyGuardPattern(inout model : UML);

main() {
var agencyInterfaces : List (Interface);
model.objectsOfType(Component)-> getAgencyInterfaces(agencyInterfaces);
model.objectsOfType(Usage)->map applyPattern(agencyInterfaces);
}

helper Component::getAgencyInterfaces(inout list : List (Interface)){
if(self.name.startsWith("<AgencyResource>"))
then
{
//log("component '" + self.name + "' is an agency resource");
self.provided->forEach(i)
{
//log("provided interface : ", i);
list->add(i);
}
}
endif;
}

helper Usage::usesAgencyInterface(in ifaces : List(Interface)) : Boolean
{
var b : Boolean;
b := true;
self.target->forEach(t)
{
if(t.oclIsTypeOf(Interface))
then
{
if(not ifaces->includes(t.oclAsType(Interface)))
then
{
b := false;
break;
}
endif;
}
else
{
b := false;
break;
}
endif;
};

return b;
}

mapping inout Package::createAgencyGuard() : Component
{
init
{
object result:Component
{
name := self.name + "AgencyGuard";
}
}

self.packagedElement += result;
}

mapping inout Interface::createGuardIface() : ifaceUsage : Usage, guardIface : Interface, realisation : InterfaceRealization
{
init
{
object guardIface : Interface
{
name := "guarded_" + self.name;
_package := self._package;
};

object ifaceUsage : Usage
{
name := "forward_" + self.name;
};

object realisation : InterfaceRealization
{
}
}

var guard := self._package.resolveone(Component);
if(guard = null)
then
{
self._package->map createAgencyGuard();
guard := self._package.resolveone(Component);
}
endif;

realisation.supplier += guardIface;
realisation.client += guard;

ifaceUsage.supplier += self;
ifaceUsage.client += guard;
self._package.packagedElement += ifaceUsage;

guardIface._package := self._package;
guard.interfaceRealization += realisation;

//log("createGuardIface :: guardIface = '" + guardIface.name + "'");
}

helper Usage::getGuardIface() : Interface
{
var targetIface := self.target->any(true).oclAsType(Interface);
//log("getGuardIface :: targetIface = '" + targetIface.name + "'");
var guardIface := targetIface.resolveone(Interface);
//log("getGuardIface :: targetIface = '" + guardIface.name + "'");
if(guardIface = null)
then
{
targetIface->map createGuardIface();
log("getGuardIface :: mapped targetIface to guardIface");
guardIface = targetIface.resolveone(Interface);
log("getGuardIface :: guardIface = '" + guardIface.name + "'");
}
endif;

return guardIface;
}

mapping Usage::applyPattern(in ifaces : List(Interface)) : Usage
when {
self.client->any(true).oclAsType(Component)._package <> ifaces->any(true)._package
and
self.usesAgencyInterface(ifaces)
}
{
var targetIface := self.getGuardIface();

//log("applyPattern :: targetIface = '" + targetIface.name + "'");
object result:Usage
{
name := self.name;
client := self.client;
};

result.supplier += targetIface;

if(self.ownedElement->any(Package) <> null)
then
{
self.ownedElement->any(Package).oclAsType(Package).packagedElement += result;
}
endif;

model.removeElement(self);
}

--------------020308010005040200000305
Content-Type: text/xml;
name="AgencyGuardPattern.qvtotrace"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="AgencyGuardPattern.qvtotrace"

<?xml version="1.0" encoding="UTF-8"?>
<trace:Trace xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:trace="http:///www.eclipse.org/m2m/qvt/operational/trace.ecore" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML">
<traceRecords>
<mappingOperation name="applyPattern" package="AgencyGuardPattern" module="AgencyGuardPattern">
<runtimeMappingOperation href="qvto:/module.env#//applyPattern"/>
</mappingOperation>
<context>
<context name="self" type="Usage">
<value modelElement=" //@traceRecords.0/@context/@context/@value/@intermediateElem ent ">
<intermediateElement xsi:type="uml:Usage" name="Iface1_Agent1">
<supplier xsi:type="uml:Interface" href=" platform:/resource/EMFFirst/model/agency.uml#_nwdZYLUAEd6_9t Igre28dA "/>
</intermediateElement>
</value>
</context>
</context>
<parameters>
<parameters name="ifaces" type="List(Interface)">
<value collectionType="OclCollection">
<collection>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_nwdZYLUAEd6_9t Igre28dA "/>
</collection>
<collection>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_ODF0kLUGEd6_9t Igre28dA "/>
</collection>
</value>
</parameters>
</parameters>
<result>
<result kind="OUT" name="result" type="Usage">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_h6WoMLUtEd6_9t Igre28dA "/>
</value>
</result>
</result>
</traceRecords>
<traceRecords>
<mappingOperation name="createGuardIface" package="AgencyGuardPattern" module="AgencyGuardPattern">
<runtimeMappingOperation href="qvto:/module.env#//createGuardIface"/>
</mappingOperation>
<context>
<context kind="INOUT" name="self" type="Interface">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_nwdZYLUAEd6_9t Igre28dA "/>
</value>
</context>
</context>
<parameters/>
<result>
<result kind="OUT" name="ifaceUsage" type="Usage">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_h5lMIbUtEd6_9t Igre28dA "/>
</value>
</result>
<result kind="OUT" name="guardIface" type="Interface">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_h5lMILUtEd6_9t Igre28dA "/>
</value>
</result>
<result kind="OUT" name="realisation" type="InterfaceRealization">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_h5lMI7UtEd6_9t Igre28dA "/>
</value>
</result>
</result>
</traceRecords>
<traceRecords>
<mappingOperation name="createAgencyGuard" package="AgencyGuardPattern" module="AgencyGuardPattern">
<runtimeMappingOperation href="qvto:/module.env#//createAgencyGuard"/>
</mappingOperation>
<context>
<context kind="INOUT" name="self" type="Package">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_ACku4LUAEd6_9t Igre28dA "/>
</value>
</context>
</context>
<parameters/>
<result>
<result kind="OUT" name="result" type="Component">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_h5lMIrUtEd6_9t Igre28dA "/>
</value>
</result>
</result>
</traceRecords>
<traceRecords>
<mappingOperation name="applyPattern" package="AgencyGuardPattern" module="AgencyGuardPattern">
<runtimeMappingOperation href="qvto:/module.env#//applyPattern"/>
</mappingOperation>
<context>
<context name="self" type="Usage">
<value modelElement=" //@traceRecords.3/@context/@context/@value/@intermediateElem ent ">
<intermediateElement xsi:type="uml:Usage" name="Iface2_Agent1">
<supplier xsi:type="uml:Interface" href=" platform:/resource/EMFFirst/model/agency.uml#_ODF0kLUGEd6_9t Igre28dA "/>
</intermediateElement>
</value>
</context>
</context>
<parameters>
<parameters name="ifaces" type="List(Interface)">
<value collectionType="OclCollection">
<collection>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_nwdZYLUAEd6_9t Igre28dA "/>
</collection>
<collection>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_ODF0kLUGEd6_9t Igre28dA "/>
</collection>
</value>
</parameters>
</parameters>
<result>
<result kind="OUT" name="result" type="Usage">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_h6WoMbUtEd6_9t Igre28dA "/>
</value>
</result>
</result>
</traceRecords>
<traceRecords>
<mappingOperation name="createGuardIface" package="AgencyGuardPattern" module="AgencyGuardPattern">
<runtimeMappingOperation href="qvto:/module.env#//createGuardIface"/>
</mappingOperation>
<context>
<context kind="INOUT" name="self" type="Interface">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_ODF0kLUGEd6_9t Igre28dA "/>
</value>
</context>
</context>
<parameters/>
<result>
<result kind="OUT" name="ifaceUsage" type="Usage">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_h6VaEbUtEd6_9t Igre28dA "/>
</value>
</result>
<result kind="OUT" name="guardIface" type="Interface">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_h6VaELUtEd6_9t Igre28dA "/>
</value>
</result>
<result kind="OUT" name="realisation" type="InterfaceRealization">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_h6VaE7UtEd6_9t Igre28dA "/>
</value>
</result>
</result>
</traceRecords>
<traceRecords>
<mappingOperation name="createAgencyGuard" package="AgencyGuardPattern" module="AgencyGuardPattern">
<runtimeMappingOperation href="qvto:/module.env#//createAgencyGuard"/>
</mappingOperation>
<context>
<context kind="INOUT" name="self" type="Package">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_Ccho0LUAEd6_9t Igre28dA "/>
</value>
</context>
</context>
<parameters/>
<result>
<result kind="OUT" name="result" type="Component">
<value>
<modelElement href=" platform:/resource/EMFFirst/model/agency.uml#_h6VaErUtEd6_9t Igre28dA "/>
</value>
</result>
</result>
</traceRecords>
</trace:Trace>

--------------020308010005040200000305--
Re: [QVTO] resolve issue with nested mappings [message #490769 is a reply to message #490740] Sat, 10 October 2009 12:49 Go to previous message
Eclipse UserFriend
Originally posted by: vanbeerst.gmail.com

Solved the issue, which clearly was not an issue but a dumb fault of my
own (which was expected). I used = as an assignment instead of := (a
fault I keep making.. :( ).

On 10/10/2009 01:48 AM, Tony Van Beers wrote:
> Hi,
>
> I'm having trouble using the resolveone command. I have a mapping which
> calls a resolveone on an element and if this gives back null, it does a
> mapping on that element so it is actually mapped. After that, I call
> resolveone again, but this seems to give back null again.
> So in short, I have a nested mapping B inside a mapping A, but the
> resolveone does not give the mapped result inside mapping A. Is this
> normal, or did I make a mistake somewhere, and if this is normal what
> can I do to solve this issue?
>
> I think this might be the normal result, because the trace file shows
> first the mapping A and then mapping B, even though mapping B is called
> from within mapping A and thus finished before mapping A.
>
> I added the qvto - file (agencyguard.qvto), a sample model (agency.uml)
> and the trace file (AgencyGuardPattern.qvtotrace). The transformation is
> meant to apply the Agency Guard pattern to a UML model. The nested
> mappings are as follows : mapping A would be mapping 'applyPattern' and
> mapping B would be 'createGuardIface'. The problem is visible inside the
> 'getGuardIface' helper function, where I put two log messages, this is
> the output of the log :
>
> getGuardIface :: mapped targetIface to guardIface
> getGuardIface :: guardIface =
> 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1b3a7116 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@19d66951 (name: Invalid_Class)
> (instanceClassName: null) (abstract: false, interface: false))'
> getGuardIface :: mapped targetIface to guardIface
> getGuardIface :: guardIface =
> 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1b3a7116 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@19d66951 (name: Invalid_Class)
> (instanceClassName: null) (abstract: false, interface: false))'
>
>
> If necessary I am willing to make a simpler toy example for this issue,
> but unfortunately I don't have the time for that right now.
>
> Regards,
> Tony.
Previous Topic:[QVTo] How to specify source & target [meta]models?
Next Topic:[QVTO] Reflectively accessing a transformation
Goto Forum:
  


Current Time: Thu Apr 25 12:03:50 GMT 2024

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

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

Back to the top