Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Parameters of one operation([Acceleo] PArameters of one operation)
[Acceleo] Parameters of one operation [message #663884] Wed, 06 April 2011 17:27 Go to next message
olafo987  is currently offline olafo987 Friend
Messages: 13
Registered: November 2010
Junior Member
Hello

I you can you please tell me how I can check if an operation has parameters?

I tried with

[query private hasNotParameterOperation(o : Operation) : Boolean = if o.ownedParameter -> isEmpty() then true else false endif/]

but, I failed. This will invoke from the other query to obtain all types of the parameters of all operations of the class

[query private getSetAllParamsTypeName(c : Class) : Set(String) = c.ownedOperation ->
select(o : Operation | not o.hasNotParameterOperation()) -> ownedParameter -> collect(type.name) -> asSet() /]

As you can see the final objective is to obtain all the parameters of a class, the middle Quiery put it because I saw that if he had an operation without parameters failed me.

In advance, thanks

Re: [Acceleo] Parameters of one operation [message #664074 is a reply to message #663884] Thu, 07 April 2011 12:26 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

If you want to find if an operation has any parameters:
[for (anOperation : Operation | class.ownedOperation)]
[anOperation.ownedParameter->isEmpty()/]
[/for]

If you want to find all the parameters from all the operations of a class:
[class.ownedOperation-> union(class.getImplementedInterfaces().ownedOperation).owned Parameter/]

You would also need to look for the parameters from abstract method coming from the superclasses etc.

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com
Re: [Acceleo] Parameters of one operation [message #664580 is a reply to message #664074] Mon, 11 April 2011 09:47 Go to previous messageGo to next message
olafo987  is currently offline olafo987 Friend
Messages: 13
Registered: November 2010
Junior Member
Thanks for your response.

My goal is to generate the "Imports " of class that I am modeling, regardless of its superclasses. I do the following:

[query private getSetAllParamsTypeNameSimples(c : Class) : Set(String) = getBagAllParams(c) -> collect(type.name) -> asSet() /]

[query private getBagAllParams(c : Class) : Bag(Parameter) = c.ownedOperation->ownedParameter -> asBag() /]

This works fine when all class operations with parameters in a class that has an operation without parameters neither input nor output gives me the following error:

Invalid result for expression getBagAllParams(c)->collect(temp5 : Parameter | temp5.type.name)->asSet() at line 219 in Module generateHelpers for query getSetAllParamsTypeNameSimples(Class). Last recorded value of self was org.eclipse.uml2.uml.internal.impl.ClassImpl@1fc89e9 (name: GccomMantUnidadesHelper, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false).
Re: [Acceleo] Parameters of one operation [message #664581 is a reply to message #664580] Mon, 11 April 2011 09:48 Go to previous messageGo to next message
olafo987  is currently offline olafo987 Friend
Messages: 13
Registered: November 2010
Junior Member
Sorry, in my previous post is missing farewell

Thanks for your help
Re: [Acceleo] Parameters of one operation [message #664714 is a reply to message #663884] Mon, 11 April 2011 16:48 Go to previous messageGo to next message
olafo987  is currently offline olafo987 Friend
Messages: 13
Registered: November 2010
Junior Member
Thanks for your response.

My goal is to generate the "Imports " of class that I am modeling, regardless of its superclasses. I do the following:

[query private getSetAllParamsTypeNameSimples(c : Class) : Set(String) = getBagAllParams(c) -> collect(type.name) -> asSet() /]

[query private getBagAllParams(c : Class) : Bag(Parameter) = c.ownedOperation->ownedParameter -> asBag() /]

This works fine when all class operations with parameters in a class that has an operation without parameters neither input nor output gives me the following error:

Invalid result for expression getBagAllParams(c)->collect(temp5 : Parameter | temp5.type.name)->asSet() at line 219 in Module generateHelpers for query getSetAllParamsTypeNameSimples(Class). Last recorded value of self was org.eclipse.uml2.uml.internal.impl.ClassImpl@1fc89e9 (name: GccomMantUnidadesHelper, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false).

Thanks

PD: I'm not user of eclipse forum and I can not see my first reply, forgive me if you see this message 2 times.
Re: [Acceleo] Parameters of one operation [message #664828 is a reply to message #663884] Tue, 12 April 2011 08:41 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

First of all, this query should not work:
[query private getBagAllParams(c : Class) : Bag(Parameter) = c.ownedOperation->ownedParameter -> asBag() /]

It may be a typo of your message in this newsgroup but it should be:
[query private getBagAllParams(c : Class) : Bag(Parameter) = c.ownedOperation.ownedParameter -> asBag() /]

The message invalid result is returned if your query return a "null". The class "GccomMantUnidadesHelper" may be a class with methods without parameters. To solve your problem, you could try something like this:

[query private getBagAllParams(c : Class) : Bag(Parameter) = c.ownedOperation->select(ownedParameter->size() > 0).ownedParameter->asBag() /]


Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com
Re: [Acceleo] Parameters of one operation [message #664839 is a reply to message #664828] Tue, 12 April 2011 09:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7677
Registered: July 2009
Senior Member
Hi Stephane
>
> First of all, this query should not work:
> [query private getBagAllParams(c : Class) : Bag(Parameter) =
> c.ownedOperation->ownedParameter -> asBag() /]
>
> It may be a typo of your message in this newsgroup but it should be:
> [query private getBagAllParams(c : Class) : Bag(Parameter) =
> c.ownedOperation.ownedParameter -> asBag() /]

No it's ok. There is an implicit toCollection operation that I'm
proposing to reify as an explicit OclAny::oclAsSet() operation.

The first example is therefore just inefficient:

c.ownedOperation.oclAsSet()->collect(ownedParameter)-> asBag()

Regards

Ed Willink
Re: [Acceleo] Parameters of one operation [message #665657 is a reply to message #663884] Fri, 15 April 2011 12:03 Go to previous messageGo to next message
olafo987  is currently offline olafo987 Friend
Messages: 13
Registered: November 2010
Junior Member
Thanks for your answers

Using the option that tells me Sthepane working fine. With the option of Edward It can't find the method "oclAsSet () ".

Again, thank you
Re: [Acceleo] Parameters of one operation [message #665666 is a reply to message #665657] Fri, 15 April 2011 12:30 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7677
Registered: July 2009
Senior Member
Hi

There is no oclAsSet() method. I used it to clarify the implicit conversion.

I wrote that I'm proposing to reify it so that it can be used and
overloaded.

Regards

Ed Willink


On 15/04/2011 13:03, olafo987 wrote:
> Thanks for your answers
>
> Using the option that tells me Sthepane working fine. With the option
> of Edward It can't find the method "oclAsSet () ".
>
> Again, thank you
Previous Topic:[Acceleo] eContainer returns invalid class
Next Topic:[Acceleo] Problems with UI launcher project
Goto Forum:
  


Current Time: Tue Oct 15 01:22:27 GMT 2024

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

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

Back to the top