Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » acceleo 3 - passing collection type as a parameter to a Java service problem(acceleo 3 - passing collection type as a parameter to a Java service problem)
acceleo 3 - passing collection type as a parameter to a Java service problem [message #870717] Wed, 09 May 2012 12:36 Go to next message
ibrahim kara is currently offline ibrahim kara
Messages: 10
Registered: May 2012
Junior Member
Hi,

I am merging a plug-in written in Acceleo 2 to the new version Acceleo 3. In the old plug-in there are several calls to some java services with collection parameters. When I try to pass a collection to a Java service, I receive errors. I would like to know if it is possible to pass a collection from a template to a Java service as a parameter?

Thanks in advance.
Re: acceleo 3 - passing collection type as a parameter to a Java service problem [message #871487 is a reply to message #870717] Mon, 14 May 2012 07:55 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane Begaudeau
Messages: 406
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

It is indeed possible, which version of Acceleo are you using? You can grab the latest one on the Eclipse marketplace.


Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo



Re: acceleo 3 - passing collection type as a parameter to a Java service problem [message #871538 is a reply to message #871487] Mon, 14 May 2012 11:10 Go to previous messageGo to next message
ibrahim kara is currently offline ibrahim kara
Messages: 10
Registered: May 2012
Junior Member
Hi, I am using the version 3.0.3. I can give you a small example in order to explain my problem better.

java code: public LinkedList<Transition> sortTransitions(ENodeList list) {
...
}
acceleo 2:
this is directly called from acceleo templates by different lists such as:

* incoming.sortTransitions()...

* outgoing[anotherTemplate(args(1).filter("State").getQualifiedDotName(args(0))).trim() != "else"].sortTransitions().nGet(0)...

* outgoing[target.filter("State")].sortTransitions()...

I am rewriting this templates in acceleo 3. What can I use as a collection type in Java in order for this to work as in the same structure ?
Re: acceleo 3 - passing collection type as a parameter to a Java service problem [message #872073 is a reply to message #871538] Tue, 15 May 2012 12:13 Go to previous message
Stephane Begaudeau is currently offline Stephane Begaudeau
Messages: 406
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

You should use in your Java service something like "sortTransitions(List<Transition> list)" and call it from a query with a Sequence(Transition). If I recall correctly the ability to use collections as a parameter of Java services was not included in Acceleo 3.0.x, I think we have introduced it in Acceleo 3.1.0 (we've just released 3.2.1). By the way, an operation named "sortedBy" is also available so you may not need the Java service at all.

Expression: [Sequence{'aaaa', 'bb', 'ccc'}->sortedBy(s: String | s.size())/]
Result: Sequence{'bb', 'ccc', 'aaaa'}


Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo



Previous Topic:What to do with build.acceleo?
Next Topic:XPand non containment references
Goto Forum:
  


Current Time: Tue Sep 23 08:17:43 GMT 2014

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

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