Acceleo: Cannot make c.id() works. [message #857527] |
Thu, 26 April 2012 12:11  |
Eclipse User |
|
|
|
Hi all,
In Acceleo, I am not able to used the id() related
to any XMI items I parse. In the MOFM2T, they present
the c.id() as returning the unique id of a UML!Class
(if c:Class).
From web searches, I found an old discussion on the access
of this id() via Acceleo services. Is this still the case in Acceleo ?
The 2009 discussion present this code snippet:
---
public String getXMIID(EObject element) {
if (element.eResource instanceof XMIResource)
return ((XMIResource)element.eResource()).getID();
return "";
}
---
If I have to follow that advise, can somebody redirect me on a tutorial
or give a brief overview of how to access this code from a template.mtl
file ?
Regards.
|
|
|
Re: Acceleo: Cannot make c.id() works. [message #857541 is a reply to message #857527] |
Thu, 26 April 2012 12:30   |
Eclipse User |
|
|
|
Hi
The MOFM2T specification seems to use c.id() without ever defining its
semantics, so there is no guarantee as to how 'unique' an id might be.
Unique with respect to parent, resource, resource set, multiple sessions
??? PLease raise an OMG issue.
The Acceleo capability to 'invoke' a Java function is a very useful
solution to this kind of problem. Just invoke a function that returns an
incrementing static count and the query cache will ensure that re-calls
get the same value.
Regards
Ed Willink
On 26/04/2012 17:11, Alain Lavoie wrote:
> Hi all,
>
> In Acceleo, I am not able to used the id() related to any XMI items I
> parse. In the MOFM2T, they present
> the c.id() as returning the unique id of a UML!Class (if c:Class).
>
> From web searches, I found an old discussion on the access
> of this id() via Acceleo services. Is this still the case in Acceleo ?
>
> The 2009 discussion present this code snippet:
> ---
> public String getXMIID(EObject element) { if (element.eResource
> instanceof XMIResource) return
> ((XMIResource)element.eResource()).getID(); return ""; }
> ---
>
> If I have to follow that advise, can somebody redirect me on a tutorial
> or give a brief overview of how to access this code from a template.mtl
> file ?
>
> Regards.
|
|
|
|
|
|
|
|
|
|
Re: Acceleo: Cannot make c.id() works. [message #859519 is a reply to message #859462] |
Fri, 27 April 2012 13:23  |
Eclipse User |
|
|
|
Thanks,
I will use what you first proposed getXMIid(), seems
to be perfect to me to guarantee uniqueness across all
line of abstraction (time, ...), although I do not
know on what base Papyrus creates these ids. I will
ask this on the correct Forum.
Regards.
Subject Closed.
|
|
|
Powered by
FUDForum. Page generated in 0.25609 seconds