Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Acceleo: Cannot make c.id() works.
Acceleo: Cannot make c.id() works. [message #857527] Thu, 26 April 2012 12:11 Go to next message
Alain Lavoie is currently offline Alain Lavoie
Messages: 82
Registered: April 2012
Member
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4027
Registered: July 2009
Senior Member
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 #857588 is a reply to message #857541] Thu, 26 April 2012 13:26 Go to previous messageGo to next message
Alain Lavoie is currently offline Alain Lavoie
Messages: 82
Registered: April 2012
Member
@Willink

Thanks for your original post and for this answer.
I am completely new to this type of addin procedure.
Can you redirect me to a tutorial or provide me with
some keywords to get me started in this direction ?

Regards.

[Updated on: Thu, 26 April 2012 13:26]

Report message to a moderator

Re: Acceleo: Cannot make c.id() works. [message #857601 is a reply to message #857588] Thu, 26 April 2012 13:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4027
Registered: July 2009
Senior Member
Hi

[query public javaString(aComment : Comment) : String =
invoke('org.eclipse.xtext.util.Strings',
'convertToJavaString(java.lang.String)', Sequence{aComment._body}) /]

Regards

Ed Willink


On 26/04/2012 18:26, Alain Lavoie wrote:
> @Willink
>
> Thanks for your original post and for this answer.
> I am completely new to this type of addin procedure.
> Can you redirect me to a tutorial or provide me with
> some keywords to get me started in this direction.
>
> Regards.
Re: Acceleo: Cannot make c.id() works. [message #857606 is a reply to message #857601] Thu, 26 April 2012 13:45 Go to previous messageGo to next message
Alain Lavoie is currently offline Alain Lavoie
Messages: 82
Registered: April 2012
Member
I will look into it, great, Thanks.
Re: Acceleo: Cannot make c.id() works. [message #857693 is a reply to message #857606] Thu, 26 April 2012 15:31 Go to previous messageGo to next message
Alain Lavoie is currently offline Alain Lavoie
Messages: 82
Registered: April 2012
Member
Hello again,

In order to implement a java service, I followed the
tutorial Java services wrappers (Acceleo/Getting started].
I end up with the following problem:

The Java service class 'org.eclipse.acceleo.module.sample.services.myservice'
does not seem to have been exported.


This error seems to have been reported in a bug previously.
I found some advises on the web, on getting the plugin.xml and to add
my package in the runtime tab of a window I cannot find.

Anybody, any hint on how to fix this ?
Re: Acceleo: Cannot make c.id() works. [message #857949 is a reply to message #857693] Thu, 26 April 2012 20:10 Go to previous messageGo to next message
Alain Lavoie is currently offline Alain Lavoie
Messages: 82
Registered: April 2012
Member
Ok, I was to quick on my previous reply, the tutorial described above shows where to continue on this invoke() setup.
Re: Acceleo: Cannot make c.id() works. [message #859297 is a reply to message #857541] Fri, 27 April 2012 11:05 Go to previous messageGo to next message
Alain Lavoie is currently offline Alain Lavoie
Messages: 82
Registered: April 2012
Member
@Willink

Since you propose the getXMIID() implementation in a
precedent post, did you follow that solution to
reach uniqueness of your uml elements accross:

+ Time,
+ Sessions,
+ Packages,
+ ...


?

From your experience, what was finally your solution to this ?

Regards

[Updated on: Fri, 27 April 2012 11:06]

Report message to a moderator

Re: Acceleo: Cannot make c.id() works. [message #859462 is a reply to message #859297] Fri, 27 April 2012 12:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4027
Registered: July 2009
Senior Member
Hi

I think I was only offering advice. For my own purposes I only need
uniquess for the duration of a transformation so a static counter works
well.

Regards

Ed Willink


On 27/04/2012 16:05, Alain Lavoie wrote:
> @Willink
>
> Since you propose the getXMIID() implementation in a
> precedent post, did you follow that solution to
> reach uniqueness of your uml elements accross:
> Time,
> Sessions,
> Packages, ...
>
> ?
>
> From your experience, what was finally your solution to this ?
>
> Regards
Re: Acceleo: Cannot make c.id() works. [message #859519 is a reply to message #859462] Fri, 27 April 2012 13:23 Go to previous message
Alain Lavoie is currently offline Alain Lavoie
Messages: 82
Registered: April 2012
Member
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.
Previous Topic:In M2T, How to order logically my activity nodes, actions, ...
Next Topic:[Acceleo] Protect entire java file?
Goto Forum:
  


Current Time: Fri Aug 22 15:38:58 EDT 2014

Powered by FUDForum. Page generated in 0.02077 seconds