Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Multi meta models and i don't know them
[Acceleo] Multi meta models and i don't know them [message #527855] Fri, 16 April 2010 16:37 Go to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Hi i'm coding a software generating Acceleo templates (meta generation ?
:) )
and i don't know in advance which metamodel will be used. I know the
meta model of the selection (context) for example an UML element. But
the user of my software can access to elements of another meta model.
For example 'CustomMetaModel'. I don't want to force my users to fill
the uri of the metamodel. But they can write a code like this :

-- this is a uml call
[self.name /]
[for self.packagedElement /]
-- this is a call to my custom meta model
property : [self.myCustomProperty/]
[/for]

Is it possible to write this template without declaring the
CustomMetaModel ? is it plan ? do i have to force my users :( ?

Regards

Tristan FAURE




Re: [Acceleo] Multi meta models and i don't know them [message #528137 is a reply to message #527855] Mon, 19 April 2010 13:55 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000607040007010204060401
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Tristan,

I must admit I am quite puzzled as to what you're trying to achieve.
I'll use my usual scattershot to answer :p.

Acceleo doesn't force you to write the URI of the metamodel you're
defining a module for ... if the types can be inferred from the "main"
metamodel. For example if you define a module on Genmodel (the
metamodel), and you have a variable of type "GenPackage", you can use
the following : [genPack.ecorePackage.nsURI/] without declaring the
Ecore metamodel for your module (even though "ecorePackage" is of type
"EPackage" and "nsURI" a property defined on EPackage in the ecore
metamodel, not in the genmodel metamodel).

However if your "custom meta model" cannot be inferred from anything
else, for example if [self.myCustomProperty/] needs "self" to be cast to
the accurate type beforehand, then you cannot do this with Acceleo... In
fact I wouldn't know how this would be possible at all since we can't
understand what the type of "self" is ... and thus can't determine which
structural features it proposes.

On the other hand, you can use EMF reflection to achieve this with
[self.eGet(self.eClass().getEStructuralFeature('myCustomProp erty'))/] or
Acceleo's shorthand : [self.eGet('myCustomProperty')/].

Laurent Goubet
Obeo

Tristan FAURE wrote:
> Hi i'm coding a software generating Acceleo templates (meta generation ?
> :) )
> and i don't know in advance which metamodel will be used. I know the
> meta model of the selection (context) for example an UML element. But
> the user of my software can access to elements of another meta model.
> For example 'CustomMetaModel'. I don't want to force my users to fill
> the uri of the metamodel. But they can write a code like this :
>
> -- this is a uml call
> [self.name /]
> [for self.packagedElement /]
> -- this is a call to my custom meta model
> property : [self.myCustomProperty/]
> [/for]
>
> Is it possible to write this template without declaring the
> CustomMetaModel ? is it plan ? do i have to force my users :( ?
>
> Regards
>
> Tristan FAURE


--------------000607040007010204060401
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------000607040007010204060401--
Re: [Acceleo] Multi meta models and i don't know them [message #528318 is a reply to message #528137] Tue, 20 April 2010 07:23 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Hi Laurent,
thank you to take a look on my problem.

Actually in my case. I have a module referencing UML metamodel and the
model browsed is an instance of Sysml metamodel.
The generator recognizes UML metamodel because it takes the metamodel of
the selected object (a Package for example).
But when i browse the child of my packages i need to cast to a Block or
anything else from Sysml metamodel. And as i write this I recognize it's
not quite evident ^^

I think i will try other solutions to insert my metamodels :p

Regards

Tristan FAURE


Le 19/04/2010 15:55, Laurent Goubet a écrit :
> Hi Tristan,
>
> I must admit I am quite puzzled as to what you're trying to achieve.
> I'll use my usual scattershot to answer :p.
>
> Acceleo doesn't force you to write the URI of the metamodel you're
> defining a module for ... if the types can be inferred from the "main"
> metamodel. For example if you define a module on Genmodel (the
> metamodel), and you have a variable of type "GenPackage", you can use
> the following : [genPack.ecorePackage.nsURI/] without declaring the
> Ecore metamodel for your module (even though "ecorePackage" is of type
> "EPackage" and "nsURI" a property defined on EPackage in the ecore
> metamodel, not in the genmodel metamodel).
>
> However if your "custom meta model" cannot be inferred from anything
> else, for example if [self.myCustomProperty/] needs "self" to be cast
> to the accurate type beforehand, then you cannot do this with
> Acceleo... In fact I wouldn't know how this would be possible at all
> since we can't understand what the type of "self" is ... and thus
> can't determine which structural features it proposes.
>
> On the other hand, you can use EMF reflection to achieve this with
> [self.eGet(self.eClass().getEStructuralFeature('myCustomProp erty'))/]
> or Acceleo's shorthand : [self.eGet('myCustomProperty')/].
>
> Laurent Goubet
> Obeo
>
> Tristan FAURE wrote:
>> Hi i'm coding a software generating Acceleo templates (meta
>> generation ? :) )
>> and i don't know in advance which metamodel will be used. I know the
>> meta model of the selection (context) for example an UML element. But
>> the user of my software can access to elements of another meta model.
>> For example 'CustomMetaModel'. I don't want to force my users to fill
>> the uri of the metamodel. But they can write a code like this :
>>
>> -- this is a uml call
>> [self.name /]
>> [for self.packagedElement /]
>> -- this is a call to my custom meta model
>> property : [self.myCustomProperty/]
>> [/for]
>>
>> Is it possible to write this template without declaring the
>> CustomMetaModel ? is it plan ? do i have to force my users :( ?
>>
>> Regards
>>
>> Tristan FAURE
>




Re: [Acceleo] Multi meta models and i don't know them [message #528351 is a reply to message #528318] Tue, 20 April 2010 08:33 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030608000603090504090401
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Tristan,

As what you're doing is navigating a reference, and this is what causes
the switch from one metamodel to the next, I believe that should be
understood by Acceleo (that is, if "the child of my packages" is an
accurately typed reference in your metamodel and not a genericaly typed
reference to "EJavaObject" or the sort).

I have some fixes pending to have Acceleo be a little more permissive
than OCL in terms of context (inferring OCL context from other
elements). Maybe your use case could be allowed by tweaks from Acceleo too.

Do you have any way to provide us with a minimal example of your use
case (Acceleo module and an example model)? Preferably through an
enhancement request on the bugzilla :).

Laurent Goubet
Obeo

Tristan FAURE wrote:
> Hi Laurent,
> thank you to take a look on my problem.
>
> Actually in my case. I have a module referencing UML metamodel and the
> model browsed is an instance of Sysml metamodel.
> The generator recognizes UML metamodel because it takes the metamodel of
> the selected object (a Package for example).
> But when i browse the child of my packages i need to cast to a Block or
> anything else from Sysml metamodel. And as i write this I recognize it's
> not quite evident ^^
>
> I think i will try other solutions to insert my metamodels :p
>
> Regards
>
> Tristan FAURE
>
>
> Le 19/04/2010 15:55, Laurent Goubet a écrit :
>> Hi Tristan,
>>
>> I must admit I am quite puzzled as to what you're trying to achieve.
>> I'll use my usual scattershot to answer :p.
>>
>> Acceleo doesn't force you to write the URI of the metamodel you're
>> defining a module for ... if the types can be inferred from the "main"
>> metamodel. For example if you define a module on Genmodel (the
>> metamodel), and you have a variable of type "GenPackage", you can use
>> the following : [genPack.ecorePackage.nsURI/] without declaring the
>> Ecore metamodel for your module (even though "ecorePackage" is of type
>> "EPackage" and "nsURI" a property defined on EPackage in the ecore
>> metamodel, not in the genmodel metamodel).
>>
>> However if your "custom meta model" cannot be inferred from anything
>> else, for example if [self.myCustomProperty/] needs "self" to be cast
>> to the accurate type beforehand, then you cannot do this with
>> Acceleo... In fact I wouldn't know how this would be possible at all
>> since we can't understand what the type of "self" is ... and thus
>> can't determine which structural features it proposes.
>>
>> On the other hand, you can use EMF reflection to achieve this with
>> [self.eGet(self.eClass().getEStructuralFeature('myCustomProp erty'))/]
>> or Acceleo's shorthand : [self.eGet('myCustomProperty')/].
>>
>> Laurent Goubet
>> Obeo
>>
>> Tristan FAURE wrote:
>>> Hi i'm coding a software generating Acceleo templates (meta
>>> generation ? :) )
>>> and i don't know in advance which metamodel will be used. I know the
>>> meta model of the selection (context) for example an UML element. But
>>> the user of my software can access to elements of another meta model.
>>> For example 'CustomMetaModel'. I don't want to force my users to fill
>>> the uri of the metamodel. But they can write a code like this :
>>>
>>> -- this is a uml call
>>> [self.name /]
>>> [for self.packagedElement /]
>>> -- this is a call to my custom meta model
>>> property : [self.myCustomProperty/]
>>> [/for]
>>>
>>> Is it possible to write this template without declaring the
>>> CustomMetaModel ? is it plan ? do i have to force my users :( ?
>>>
>>> Regards
>>>
>>> Tristan FAURE
>>


--------------030608000603090504090401
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------030608000603090504090401--
Re: [Acceleo] Multi meta models and i don't know them [message #528758 is a reply to message #528351] Wed, 21 April 2010 16:32 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060905040907020007050403
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi
these are my sample files. In my environment they don't compile :/

Regards
Tristan FAURE


Le 20/04/2010 10:33, Laurent Goubet a écrit :
> Tristan,
>
> As what you're doing is navigating a reference, and this is what
> causes the switch from one metamodel to the next, I believe that
> should be understood by Acceleo (that is, if "the child of my
> packages" is an accurately typed reference in your metamodel and not a
> genericaly typed reference to "EJavaObject" or the sort).
>
> I have some fixes pending to have Acceleo be a little more permissive
> than OCL in terms of context (inferring OCL context from other
> elements). Maybe your use case could be allowed by tweaks from Acceleo
> too.
>
> Do you have any way to provide us with a minimal example of your use
> case (Acceleo module and an example model)? Preferably through an
> enhancement request on the bugzilla :).
>
> Laurent Goubet
> Obeo
>
> Tristan FAURE wrote:
>> Hi Laurent,
>> thank you to take a look on my problem.
>>
>> Actually in my case. I have a module referencing UML metamodel and
>> the model browsed is an instance of Sysml metamodel.
>> The generator recognizes UML metamodel because it takes the metamodel
>> of the selected object (a Package for example).
>> But when i browse the child of my packages i need to cast to a Block
>> or anything else from Sysml metamodel. And as i write this I
>> recognize it's not quite evident ^^
>>
>> I think i will try other solutions to insert my metamodels :p
>>
>> Regards
>>
>> Tristan FAURE
>>
>>
>> Le 19/04/2010 15:55, Laurent Goubet a écrit :
>>> Hi Tristan,
>>>
>>> I must admit I am quite puzzled as to what you're trying to achieve.
>>> I'll use my usual scattershot to answer :p.
>>>
>>> Acceleo doesn't force you to write the URI of the metamodel you're
>>> defining a module for ... if the types can be inferred from the
>>> "main" metamodel. For example if you define a module on Genmodel
>>> (the metamodel), and you have a variable of type "GenPackage", you
>>> can use the following : [genPack.ecorePackage.nsURI/] without
>>> declaring the Ecore metamodel for your module (even though
>>> "ecorePackage" is of type "EPackage" and "nsURI" a property defined
>>> on EPackage in the ecore metamodel, not in the genmodel metamodel).
>>>
>>> However if your "custom meta model" cannot be inferred from anything
>>> else, for example if [self.myCustomProperty/] needs "self" to be
>>> cast to the accurate type beforehand, then you cannot do this with
>>> Acceleo... In fact I wouldn't know how this would be possible at all
>>> since we can't understand what the type of "self" is ... and thus
>>> can't determine which structural features it proposes.
>>>
>>> On the other hand, you can use EMF reflection to achieve this with
>>> [self.eGet(self.eClass().getEStructuralFeature('myCustomProp erty'))/] or
>>> Acceleo's shorthand : [self.eGet('myCustomProperty')/].
>>>
>>> Laurent Goubet
>>> Obeo
>>>
>>> Tristan FAURE wrote:
>>>> Hi i'm coding a software generating Acceleo templates (meta
>>>> generation ? :) )
>>>> and i don't know in advance which metamodel will be used. I know
>>>> the meta model of the selection (context) for example an UML
>>>> element. But the user of my software can access to elements of
>>>> another meta model.
>>>> For example 'CustomMetaModel'. I don't want to force my users to
>>>> fill the uri of the metamodel. But they can write a code like this :
>>>>
>>>> -- this is a uml call
>>>> [self.name /]
>>>> [for self.packagedElement /]
>>>> -- this is a call to my custom meta model
>>>> property : [self.myCustomProperty/]
>>>> [/for]
>>>>
>>>> Is it possible to write this template without declaring the
>>>> CustomMetaModel ? is it plan ? do i have to force my users :( ?
>>>>
>>>> Regards
>>>>
>>>> Tristan FAURE
>>>
>

--------------060905040907020007050403
Content-Type: text/plain;
name="generate.mtl"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="generate.mtl"

W2NvbW1lbnQgZW5jb2RpbmcgPSBDcDEyNTIgL10NClttb2R1bGUgZ2VuZXJh dGUoJ2h0dHA6
Ly93d3cuZWNsaXBzZS5vcmcvdW1sMi8zLjAuMC9VTUwnKS9dDQoNClt0ZW1w bGF0ZSBwdWJs
aWMgZ2VuZXJhdGUocCA6IFBhY2thZ2UpXQ0KCQ0KCVtjb21tZW50IEBtYWlu IC9dDQoJW2Zp
bGUgKHAubmFtZSwgZmFsc2UsICdDcDEyNTInKV0NCgkJW2ZvciAoYjpCbG9j a3xzZWxmLm93
bmVkRWxlbWVudCldDQoJCQlbZS5uYW1lL10NCgkJWy9mb3JdDQoJWy9maWxl XQ0KCQ0KWy90
ZW1wbGF0ZV0NCg==
--------------060905040907020007050403
Content-Type: text/xml;
name="test.sysml"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="test.sysml"

<?xml version="1.0" encoding="UTF-8"?>
<uml:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:sysML="http://www.topcased.org/2.0/sysML" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xmi:id="idModel" name="test">
<packagedElement xmi:type="uml:Package" xmi:id="idPackage" name="monPackage">
<packagedElement xmi:type="sysML:Block" xmi:id="_L_eKkE1iEd-rMMnUyELmzA" name="Block1"/>
<packagedElement xmi:type="sysML:Block" xmi:id="_MBQ6W01iEd-rMMnUyELmzA" name="Block2"/>
<packagedElement xmi:type="sysML:Block" xmi:id="_MFboq01iEd-rMMnUyELmzA" name="Block3"/>
<packagedElement xmi:type="sysML:Block" xmi:id="_MItmIE1iEd-rMMnUyELmzA" name="Block4"/>
<packagedElement xmi:type="sysML:Block" xmi:id="_MQBIC01iEd-rMMnUyELmzA" name="Block5"/>
<packagedElement xmi:type="sysML:Block" xmi:id="_MSZtoE1iEd-rMMnUyELmzA" name="Block6"/>
<packagedElement xmi:type="sysML:Block" xmi:id="_MVrrK01iEd-rMMnUyELmzA" name="Block7"/>
<packagedElement xmi:type="sysML:Block" xmi:id="_MYqGoE1iEd-rMMnUyELmzA" name="Block8"/>
</packagedElement>
<profileApplication xmi:type="uml:ProfileApplication" xmi:id="idProfileApplication">
<eAnnotations xmi:type="ecore:EAnnotation" xmi:id="idProfileAnnotation" source="http://www.eclipse.org/uml2/2.0.0/UML">
<references xmi:type="ecore:EPackage" href=" ../../../plugin/org.topcased.modeler.sysml/templates/activit ydiagram/profile/SysMLActivityExtensionsProfile.uml#ProfileC ontentId "/>
</eAnnotations>
<appliedProfile xmi:type="uml:Profile" href=" ../../../plugin/org.topcased.modeler.sysml/templates/activit ydiagram/profile/SysMLActivityExtensionsProfile.uml#Activity ProfileId "/>
</profileApplication>
</uml:Model>

--------------060905040907020007050403--




Re: [Acceleo] Multi meta models and i don't know them [message #528881 is a reply to message #528758] Thu, 22 April 2010 09:29 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070603050904040801080101
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Tristan,

In this particular case, the cast to Block isn't necessary ... but I
believe this isn't always true ^^.

Anyway ... I believe (at least it works with Acceleo 3.0M6 in Helios)
that you can use qualified names to work around your issue. For example
in this example :

[for (b : sysML::Block | self.ownedElement)]
[b.name/]
[/for]

Does that seem like an acceptable workaround?

Laurent Goubet
Obeo

Tristan FAURE wrote:
> Hi
> these are my sample files. In my environment they don't compile :/
>
> Regards
> Tristan FAURE
>
>
> Le 20/04/2010 10:33, Laurent Goubet a écrit :
>> Tristan,
>>
>> As what you're doing is navigating a reference, and this is what
>> causes the switch from one metamodel to the next, I believe that
>> should be understood by Acceleo (that is, if "the child of my
>> packages" is an accurately typed reference in your metamodel and not a
>> genericaly typed reference to "EJavaObject" or the sort).
>>
>> I have some fixes pending to have Acceleo be a little more permissive
>> than OCL in terms of context (inferring OCL context from other
>> elements). Maybe your use case could be allowed by tweaks from Acceleo
>> too.
>>
>> Do you have any way to provide us with a minimal example of your use
>> case (Acceleo module and an example model)? Preferably through an
>> enhancement request on the bugzilla :).
>>
>> Laurent Goubet
>> Obeo
>>
>> Tristan FAURE wrote:
>>> Hi Laurent,
>>> thank you to take a look on my problem.
>>>
>>> Actually in my case. I have a module referencing UML metamodel and
>>> the model browsed is an instance of Sysml metamodel.
>>> The generator recognizes UML metamodel because it takes the metamodel
>>> of the selected object (a Package for example).
>>> But when i browse the child of my packages i need to cast to a Block
>>> or anything else from Sysml metamodel. And as i write this I
>>> recognize it's not quite evident ^^
>>>
>>> I think i will try other solutions to insert my metamodels :p
>>>
>>> Regards
>>>
>>> Tristan FAURE
>>>
>>>
>>> Le 19/04/2010 15:55, Laurent Goubet a écrit :
>>>> Hi Tristan,
>>>>
>>>> I must admit I am quite puzzled as to what you're trying to achieve.
>>>> I'll use my usual scattershot to answer :p.
>>>>
>>>> Acceleo doesn't force you to write the URI of the metamodel you're
>>>> defining a module for ... if the types can be inferred from the
>>>> "main" metamodel. For example if you define a module on Genmodel
>>>> (the metamodel), and you have a variable of type "GenPackage", you
>>>> can use the following : [genPack.ecorePackage.nsURI/] without
>>>> declaring the Ecore metamodel for your module (even though
>>>> "ecorePackage" is of type "EPackage" and "nsURI" a property defined
>>>> on EPackage in the ecore metamodel, not in the genmodel metamodel).
>>>>
>>>> However if your "custom meta model" cannot be inferred from anything
>>>> else, for example if [self.myCustomProperty/] needs "self" to be
>>>> cast to the accurate type beforehand, then you cannot do this with
>>>> Acceleo... In fact I wouldn't know how this would be possible at all
>>>> since we can't understand what the type of "self" is ... and thus
>>>> can't determine which structural features it proposes.
>>>>
>>>> On the other hand, you can use EMF reflection to achieve this with
>>>> [self.eGet(self.eClass().getEStructuralFeature('myCustomProp erty'))/]
>>>> or Acceleo's shorthand : [self.eGet('myCustomProperty')/].
>>>>
>>>> Laurent Goubet
>>>> Obeo
>>>>
>>>> Tristan FAURE wrote:
>>>>> Hi i'm coding a software generating Acceleo templates (meta
>>>>> generation ? :) )
>>>>> and i don't know in advance which metamodel will be used. I know
>>>>> the meta model of the selection (context) for example an UML
>>>>> element. But the user of my software can access to elements of
>>>>> another meta model.
>>>>> For example 'CustomMetaModel'. I don't want to force my users to
>>>>> fill the uri of the metamodel. But they can write a code like this :
>>>>>
>>>>> -- this is a uml call
>>>>> [self.name /]
>>>>> [for self.packagedElement /]
>>>>> -- this is a call to my custom meta model
>>>>> property : [self.myCustomProperty/]
>>>>> [/for]
>>>>>
>>>>> Is it possible to write this template without declaring the
>>>>> CustomMetaModel ? is it plan ? do i have to force my users :( ?
>>>>>
>>>>> Regards
>>>>>
>>>>> Tristan FAURE
>>>>
>>


--------------070603050904040801080101
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------070603050904040801080101--
Re: [Acceleo] Multi meta models and i don't know them [message #528883 is a reply to message #528881] Thu, 22 April 2010 09:46 Go to previous message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
It works thank you very much !

Tristan

Le 22/04/2010 11:29, Laurent Goubet a écrit :
> Tristan,
>
> In this particular case, the cast to Block isn't necessary ... but I
> believe this isn't always true ^^.
>
> Anyway ... I believe (at least it works with Acceleo 3.0M6 in Helios)
> that you can use qualified names to work around your issue. For
> example in this example :
>
> [for (b : sysML::Block | self.ownedElement)]
> [b.name/]
> [/for]
>
> Does that seem like an acceptable workaround?
>
> Laurent Goubet
> Obeo
>
> Tristan FAURE wrote:
>> Hi
>> these are my sample files. In my environment they don't compile :/
>>
>> Regards
>> Tristan FAURE
>>
>>
>> Le 20/04/2010 10:33, Laurent Goubet a écrit :
>>> Tristan,
>>>
>>> As what you're doing is navigating a reference, and this is what
>>> causes the switch from one metamodel to the next, I believe that
>>> should be understood by Acceleo (that is, if "the child of my
>>> packages" is an accurately typed reference in your metamodel and not
>>> a genericaly typed reference to "EJavaObject" or the sort).
>>>
>>> I have some fixes pending to have Acceleo be a little more
>>> permissive than OCL in terms of context (inferring OCL context from
>>> other elements). Maybe your use case could be allowed by tweaks from
>>> Acceleo too.
>>>
>>> Do you have any way to provide us with a minimal example of your use
>>> case (Acceleo module and an example model)? Preferably through an
>>> enhancement request on the bugzilla :).
>>>
>>> Laurent Goubet
>>> Obeo
>>>
>>> Tristan FAURE wrote:
>>>> Hi Laurent,
>>>> thank you to take a look on my problem.
>>>>
>>>> Actually in my case. I have a module referencing UML metamodel and
>>>> the model browsed is an instance of Sysml metamodel.
>>>> The generator recognizes UML metamodel because it takes the
>>>> metamodel of the selected object (a Package for example).
>>>> But when i browse the child of my packages i need to cast to a
>>>> Block or anything else from Sysml metamodel. And as i write this I
>>>> recognize it's not quite evident ^^
>>>>
>>>> I think i will try other solutions to insert my metamodels :p
>>>>
>>>> Regards
>>>>
>>>> Tristan FAURE
>>>>
>>>>
>>>> Le 19/04/2010 15:55, Laurent Goubet a écrit :
>>>>> Hi Tristan,
>>>>>
>>>>> I must admit I am quite puzzled as to what you're trying to
>>>>> achieve. I'll use my usual scattershot to answer :p.
>>>>>
>>>>> Acceleo doesn't force you to write the URI of the metamodel you're
>>>>> defining a module for ... if the types can be inferred from the
>>>>> "main" metamodel. For example if you define a module on Genmodel
>>>>> (the metamodel), and you have a variable of type "GenPackage", you
>>>>> can use the following : [genPack.ecorePackage.nsURI/] without
>>>>> declaring the Ecore metamodel for your module (even though
>>>>> "ecorePackage" is of type "EPackage" and "nsURI" a property
>>>>> defined on EPackage in the ecore metamodel, not in the genmodel
>>>>> metamodel).
>>>>>
>>>>> However if your "custom meta model" cannot be inferred from
>>>>> anything else, for example if [self.myCustomProperty/] needs
>>>>> "self" to be cast to the accurate type beforehand, then you cannot
>>>>> do this with Acceleo... In fact I wouldn't know how this would be
>>>>> possible at all since we can't understand what the type of "self"
>>>>> is ... and thus can't determine which structural features it
>>>>> proposes.
>>>>>
>>>>> On the other hand, you can use EMF reflection to achieve this with
>>>>> [self.eGet(self.eClass().getEStructuralFeature('myCustomProp erty'))/]
>>>>> or Acceleo's shorthand : [self.eGet('myCustomProperty')/].
>>>>>
>>>>> Laurent Goubet
>>>>> Obeo
>>>>>
>>>>> Tristan FAURE wrote:
>>>>>> Hi i'm coding a software generating Acceleo templates (meta
>>>>>> generation ? :) )
>>>>>> and i don't know in advance which metamodel will be used. I know
>>>>>> the meta model of the selection (context) for example an UML
>>>>>> element. But the user of my software can access to elements of
>>>>>> another meta model.
>>>>>> For example 'CustomMetaModel'. I don't want to force my users to
>>>>>> fill the uri of the metamodel. But they can write a code like this :
>>>>>>
>>>>>> -- this is a uml call
>>>>>> [self.name /]
>>>>>> [for self.packagedElement /]
>>>>>> -- this is a call to my custom meta model
>>>>>> property : [self.myCustomProperty/]
>>>>>> [/for]
>>>>>>
>>>>>> Is it possible to write this template without declaring the
>>>>>> CustomMetaModel ? is it plan ? do i have to force my users :( ?
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>> Tristan FAURE
>>>>>
>>>
>




Previous Topic:how to get names from some metaclasses
Next Topic:[xpand] how to get input model from xmi
Goto Forum:
  


Current Time: Fri Mar 29 07:56:58 GMT 2024

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

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

Back to the top