Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Syntax problems
[Acceleo] Syntax problems [message #538201] Sun, 06 June 2010 07:00 Go to next message
Daniel  is currently offline Daniel
Messages: 44
Registered: June 2010
Member
Hi again, I am having some trouble debugging some problems which araised when doing an automatic mt2mtl conversion:

1- There are some functions like filter which existed in .mt for ENode and I cant find how can I map to mtl ones, for example:

[if (self->select(not (filter(Behavior))) <> null and not (owner.eClass().name.toLower() = 'Class'.toLower()))]

Which comes from

<%if (current[!filter("Behavior")] != null && !owner.eClass.name.equalsIgnoreCase("Class")){%>

I tried:

[if (self->filter(Behavior) <> null and not (owner.eClass().name.toLower() = 'Class'.toLower()))]

Am I doing the conversion right?


2- Other case:

<%if (general != null){%>extends <%general.nFirst().genName%> <%}%>

Migrated to:

[if (general <> null)]extends [general->first().genName()/] [/if]

I couldnt find the first() operation for general so I did:

[if (general <> null)]extends [general.genName()/] [/if]

Is it right?

3- In .mt I had:

<%script type="Element" name="isArray" post="trim"%>
<%(getProperty("tuple.genArrays") == true)%>

Migrated to:

[query public isArray(element : Element) post(trim()) : Boolean = (getProperty('tuple.genArrays') = true)/]

To correct it I eliminated the post(trim()) and changed the true to 'true':

[query public isArray(element : Element) : Boolean = (getProperty('tuple.genArrays') = 'true')/]

Is that right?

4- I was unable to fix some problems, in .mt I had:

<%script type="Classifier" name="genImport" post="trim()" %>
<%if (!isArray){%>
<%if ((ownedMember.filter("Operation").ownedParameter + ownedMember.filter("Property")+ getAssociations().navigableOwnedEnd)[(upper == -1 || upper > 1) && isOrdered] != null){%>

import <%getOrderedCollectionClassPath%>;
<%}%>
<%if ((ownedMember.filter("Operation").ownedParameter + ownedMember.filter("Property") + getAssociations().navigableOwnedEnd)[(upper == -1 || upper > 1) && !isOrdered] != null){%>
import <%getNotOrderedCollectionClassPath%>;
<%}%>
<%}%>

The automatic migration was:

[if ((ownedMember->filter(Operation).ownedParameter + ownedMember->filter(Property) + getAssociations.navigableOwnedEnd)->select((upper = -1 or upper > 1) and isOrdered) <> null)]

From:

<%if ((ownedMember.filter("Operation").ownedParameter + ownedMember.filter("Property")+ getAssociations().navigableOwnedEnd)[(upper == -1 || upper > 1) && isOrdered] != null){%>

The problem it gaves me is:

"Cannont find operation (+(Collection(Property))) for the type Bag(Parameter))

I tried to solve it with the union operation like I did befor but I couldnt.

5- Also:

[template public getTypeList(interface : Interface)]
[ownedAttribute.type + getAssociations.navigableOwnedEnd->select(type<>current(1)).type + ownedOperation.ownedParameter.type + general->first() + nestedClassifier->filter(Class).getTypeList()/]

From:

<%script type="Interface" name="getTypeList" post="nMinimize()" %>
<%ownedAttribute.type
+ getAssociations().navigableOwnedEnd.select("type!=current(1) ").type
+ ownedOperation.ownedParameter.type
+ general.nFirst()
+ nestedClassifier.filter("Class").getTypeList%>

Fails, and the problem is "Unrecognized variable: (getAssociations)"

Why is it treating it as a variable? How can I fix it?

Thank you very much again.

Re: [Acceleo] Syntax problems [message #538273 is a reply to message #538201] Mon, 07 June 2010 04:04 Go to previous messageGo to next message
Sebastien Roy is currently offline Sebastien Roy
Messages: 51
Registered: November 2009
Member
I think you should replace

self->select(...) <> null

with

not(self->select(...))->isEmpty())


Regards

Sebastien
Re: [Acceleo] Syntax problems [message #538298 is a reply to message #538273] Mon, 07 June 2010 04:31 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1621
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080006060802090708070001
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Daniel,

<%if (current[!filter("Behavior")] != null &&
!owner.eClass.name.equalsIgnoreCase("Class")){%>

seems really convoluted to me ... I don't really even know how
"[!filter(...)]" would behave. Anyway, "equalsIgnoreCase" and "filter"
have been ported in Acceleo 3 but we didn't make it soon enough to
change the automatic migration. If I understand correctly the meaning of
"current[!filter("Behavior")]", you should be able to use :

[if (not (self.oclIsKindOf(Behavior)) and not
(owner.eClass.name.equalsIgnoreCase("Class"))]

for the same result.

Laurent Goubet
Obeo

Sebastien Roy wrote:
> I think you should replace
>
> self->select(...) <> null
>
> with
>
> not(self->select(...))->isEmpty())
>
> Regards
>
> Sebastien


--------------080006060802090708070001
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=
--------------080006060802090708070001--
Re: [Acceleo] Syntax problems [message #538752 is a reply to message #538298] Tue, 08 June 2010 10:48 Go to previous messageGo to next message
Daniel  is currently offline Daniel
Messages: 44
Registered: June 2010
Member
Hi again and thank you both for your answers.

For the filter problem I tried what you said:

[if (not (self.oclIsKindOf(Behavior)) and not(owner.eClass().name.equalsIgnoreCase('Class')))]

And it seems it works Smile

I have been working in the other problems, now I know that to solve:

"Unrecognized variable: (getAssociations)"

I only had to add the (), getAssociations().

But I still dont know how to migrate some code:

1-

[if ((ownedMember->filter(Operation).ownedParameter + ownedMember->filter(Property) + getAssociations.navigableOwnedEnd)->select((upper = -1 or upper > 1) and isOrdered) <> null)]

From:

<%if ((ownedMember.filter("Operation").ownedParameter + ownedMember.filter("Property")+ getAssociations().navigableOwnedEnd)[(upper == -1 || upper > 1) && isOrdered] != null){%>

The problem it gaves me is:

"Cannont find operation (+(Collection(Property))) for the type Bag(Parameter))

What equivalent to the "+" could I use?

2-

In an Acceleo 2 script I had:

<%script type="Classifier" name="getTypeList"%>

Which is empty and then:

<%script type="Class" name="getTypeList" post="nMinimize()" %>
code........

and

<%script type="Interface" name="getTypeList" post="nMinimize()" %>
code........

In the same template I found:

<%for (getTypeList.nMinimize){%>
<%-- If import path contains only one segment (no '.' character), we don't need to import this element --%>
<%if (genImportPath.indexOf(".") != -1){%>
import <%genImportPath%>;


I dont know if I am right but I think the empty getTypeList for classifier isnt used, instead the getTypeList for classes and the other getTypeList for interfaces are used on classifieres which are classes and classifiers which are interfaces.

I think this is done automatically, I mean, when it reachs the point:

<%for (getTypeList.nMinimize){%>

If the Classifier is a Class it uses the class one and if it is an inteface it uses the interface one.

I dont know if this is right and I would also like to know if Acceleo 3 works in the same way because I think it is giving me some trouble.

Thank you very much again for all the help!!!!







Re: [Acceleo] Syntax problems [message #538783 is a reply to message #538752] Tue, 08 June 2010 11:42 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1621
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080200060806020605020708
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Daniel,

See comments inlined below.

Laurent Goubet
Obeo

Daniel wrote:
> Hi again and thank you both for your answers.
>
> For the filter problem I tried what you said:
>
> [if (not (self.oclIsKindOf(Behavior)) and
> not(owner.eClass().name.equalsIgnoreCase('Class')))]
>
> And it seems it works :)

Nice to hear.

>
> I have been working in the other problems, now I know that to solve:
>
> "Unrecognized variable: (getAssociations)"
>
> I only had to add the (), getAssociations().
>
> But I still dont know how to migrate some code:
>
> 1-
> [if ((ownedMember->filter(Operation).ownedParameter +
> ownedMember->filter(Property) +
> getAssociations.navigableOwnedEnd)->select((upper = -1 or upper > 1) and
> isOrdered) <> null)]
>
> From:
>
> <%if ((ownedMember.filter("Operation").ownedParameter +
> ownedMember.filter("Property")+
> getAssociations().navigableOwnedEnd)[(upper == -1 || upper > 1) &&
> isOrdered] != null){%>
>
> The problem it gaves me is:
>
> "Cannont find operation (+(Collection(Property))) for the type
> Bag(Parameter))
>
> What equivalent to the "+" could I use?

Once again, this is some convoluted code :/. Anyway, the "+" used here
is the "+" between collections. You can use OCL's "union" instead. that
would give something like :

[if
((ownedMember->filter(Operation).ownedParameter.union(ownedMember- > filter(Property)).union(getAssociations.navigableOwnedEnd))- >select((upper
= -1 or upper > 1) and isOrdered)->size() > 0)]

>
> 2-
>
> In an Acceleo 2 script I had:
>
> <%script type="Classifier" name="getTypeList"%>
>
> Which is empty and then:
>
> <%script type="Class" name="getTypeList" post="nMinimize()" %>
> code........
>
> and
>
> <%script type="Interface" name="getTypeList" post="nMinimize()" %>
> code........
>
> In the same template I found:
>
> <%for (getTypeList.nMinimize){%>
> <%-- If import path contains only one segment (no '.' character), we
> don't need to import this element --%>
> <%if (genImportPath.indexOf(".") != -1){%>
> import <%genImportPath%>;
>
>
> I dont know if I am right but I think the empty getTypeList for
> classifier isnt used, instead the getTypeList for classes and the other
> getTypeList for interfaces are used on classifieres which are classes
> and classifiers which are interfaces.
>
> I think this is done automatically, I mean, when it reachs the point:
>
> <%for (getTypeList.nMinimize){%>
>
> If the Classifier is a Class it uses the class one and if it is an
> inteface it uses the interface one.
>
> I dont know if this is right and I would also like to know if Acceleo 3
> works in the same way because I think it is giving me some trouble.

Acceleo 3 checks at runtime the actual type of the arguments before
calling a template; it will then act as did Acceleo 2 and call the good
template if you have the two defined (one on Class and one on Interface).

I believe the empty one (on Classifier) is there to allow the compilation.

>
> Thank you very much again for all the help!!!!

--------------080200060806020605020708
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=
--------------080200060806020605020708--
Re: [Acceleo] Syntax problems [message #538859 is a reply to message #538783] Tue, 08 June 2010 15:48 Go to previous messageGo to next message
Daniel  is currently offline Daniel
Messages: 44
Registered: June 2010
Member
Hi again!

I have been trying the union operator but it doesnt work, if I use:

[if
((ownedMember->filter(Operation).ownedParameter.union(ownedMember- > filter(Property)).union(getAssociations.navigableOwnedEnd))- >select((upper
= -1 or upper > 1) and isOrdered)->size() > 0)]

It gives me an error:

"Cannot find the operation union(Collection(Property)) for the type Parameter"

I also tried with ->union() and it didnt work

How can I fix it? Should I do some kind of upcasting?

Thanks
Re: [Acceleo] Syntax problems [message #538963 is a reply to message #538859] Wed, 09 June 2010 03:48 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1621
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060600090309090602070304
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Daniel,

Sorry my bad, it is indeed "->union()" and not ".union()"... yet your
comment reminds me that OCL is far from good when manipulating collections.

the "union" operator is only defined as such :
Bag::union(Bag)
Bag::union(Set)
Set::union(Bag)
Set::union(Set)

OrderedSet::union(Bag)
OrderedSet::union(Set)

Don't ask me why these last two ...

You'll have to cast your collections to either Bag (non unique, non
ordered) or Set (unique, non ordered) before being able to concatenate
two of them. There is no way of adding to a Sequence another Sequence.

You can cast collections with "->asSet()", "->asBag()", "->asOrderedSet"
and "->asSequence()". Take note that if you cast a Sequence as a Set,
all duplicates will be removed.

Laurent Goubet
Obeo

Daniel wrote:
> Hi again!
>
> I have been trying the union operator but it doesnt work, if I use:
>
> [if
> ((ownedMember->filter(Operation).ownedParameter.union(ownedMember- >
> filter(Property)).union(getAssociations.navigableOwnedEnd))- >select((upper
> = -1 or upper > 1) and isOrdered)->size() > 0)]
>
> It gives me an error:
>
> "Cannot find the operation union(Collection(Property)) for the type
> Parameter"
>
> I also tried with ->union() and it didnt work
>
> How can I fix it? Should I do some kind of upcasting?
>
> Thanks
>


--------------060600090309090602070304
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=
--------------060600090309090602070304--
Re: [Acceleo] Syntax problems [message #539193 is a reply to message #538963] Wed, 09 June 2010 17:51 Go to previous messageGo to next message
Daniel  is currently offline Daniel
Messages: 44
Registered: June 2010
Member
Hi and thanks for your help!

I'm still having some trouble:

I did:



Which works fine, except for the last part
union((nestedClassifier->filter(Class).getTypeList())->asBag())/]

It gives this error:

"Cannont find operation union(Bag(String)) for the type Bag(Type)"

The .getTypeList() is a recursive call to the same template, I mean, I have:



[/template]

So this template calls itself on nestedClassifier.
And I think that when executing the getTypeList() template it is returning a String, and so the union() operator cannont be used to concat Types and Strings.

Am I right?

I tried to solve it using: union((ownedOperation.ownedParameter.type)->asBag())->union(general)- >asBag()->union((nestedClassifier->filter(Class).getTypeList().oclAsType(Type))- >asBag())

I mean using oclAsType, but I dont know it that might be correct.

What do you think?

2-

Also I use the getTypeList() on a for loop:



But when I am calling methods which need a "Type" parameter, such as when I do:



It says it is not a valid signature, because it doesnt identify the parameters of the sequence generated by the for loop as types, I tried to solve it also with oclAsType like this:

[if (self.oclAsType(Type).genImportPath().index('.') <> -1)]

Might that be right?




3-


I am trying to use asBag() here:

[if ((ownedMember->filter(Operation).ownedParameter->union((ownedMember- >filter(Property))->asBag())

But it says it cant find the asBag() operation for Collection(Property), so I cant use the union operator again.

How can I solve this too?

Thank you very much and sorry because I know I am bothering you too much, but I am really stuck with this Sad.

Thank you again!





Re: [Acceleo] Syntax problems [message #539257 is a reply to message #539193] Thu, 10 June 2010 03:41 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1621
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050004060704010401040907
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Daniel,

Sorry, but you forgot parts of this message and I cannot understand most
of it without these parts. Please find my comments inline for what I
could make out.

Laurent Goubet
Obeo

Daniel wrote:
> Hi and thanks for your help!
>
> I'm still having some trouble:
>
> I did:
>
>
>
> Which works fine, except for the last part
> union((nestedClassifier->filter(Class).getTypeList())->asBag())/]
>
> It gives this error:
>
> "Cannont find operation union(Bag(String)) for the type Bag(Type)"

This can be solved in most cases through
".oclAsType(String)->union". (If you are sure you've got
Strings in the source collection.)

>
> The .getTypeList() is a recursive call to the same template, I mean, I
> have:
>
>
>
> [/template]
>
> So this template calls itself on nestedClassifier.
> And I think that when executing the getTypeList() template it is
> returning a String, and so the union() operator cannont be used to
> concat Types and Strings.
>
> Am I right?

Yup, 'union' needs the two operands to have the same type (or a common
supertype).

>
> I tried to solve it using:
> union((ownedOperation.ownedParameter.type)->asBag())->union(general)-
> >asBag()->union((nestedClassifier->filter(Class).getTypeList().oclAsType(Type))-
> >asBag())
>
> I mean using oclAsType, but I dont know it that might be correct.
>
> What do you think?

It is the way to go if you are sure about the contents of your
collections (lest you get ClassCastExceptions).

>
> 2-
>
> Also I use the getTypeList() on a for loop:
>
>
>
> But when I am calling methods which need a "Type" parameter, such as
> when I do:
>
>
>
> It says it is not a valid signature, because it doesnt identify the
> parameters of the sequence generated by the for loop as types, I tried
> to solve it also with oclAsType like this:
>
> [if (self.oclAsType(Type).genImportPath().index('.') <> -1)]
>
> Might that be right?

I am missing both of your exemples ... but yes, oclAsType is the way to
tell OCL that your objects are of another type. This works the same as
Java casts, and can throw the same exceptions (ClassCastException) if
the cast isn't possible.

>
>
>
>
> 3-
>
>
> I am trying to use asBag() here:
>
> [if ((ownedMember->filter(Operation).ownedParameter->union((ownedMember-
> >filter(Property))->asBag())
> But it says it cant find the asBag() operation for Collection(Property),
> so I cant use the union operator again.
>
> How can I solve this too?

Are you sure you even need the cast to bag here? I'd think your two
collections are of the same type from the start. Otherwise I must admit
I don't understand why you get this error here. Try removing the extra
parenthesis maybe?
>
> Thank you very much and sorry because I know I am bothering you too
> much, but I am really stuck with this :(.
>
> Thank you again!
>
>
>
>
>
>


--------------050004060704010401040907
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=
--------------050004060704010401040907--
Re: [Acceleo] Syntax problems [message #539475 is a reply to message #539257] Thu, 10 June 2010 17:44 Go to previous messageGo to next message
Daniel  is currently offline Daniel
Messages: 44
Registered: June 2010
Member
Hi and thanks again for your help.

I will try the use the oclAsType for the castings, later I will see if I get or I dont get exceptions.

The only thing left to try to execute my module is the point 3 of the other post. I am going to try to explain the problem and what I have tried:

This is from Acceleo 2:

<%if ((ownedMember.filter("Operation").ownedParameter + ownedMember.filter("Property")+ getAssociations().navigableOwnedEnd)[(upper == -1 || upper > 1) && isOrdered] != null){%>

This is from mt2mtl:

[if ((ownedMember->filter(Operation).ownedParameter + ownedMember->filter(Property) + getAssociations.navigableOwnedEnd)->select((upper = -1 or upper > 1) and isOrdered) <> null)]

In the first 'x' it says:

"Cannot find the operation +Collection(Property) for the type Bag(Parameter)"

I understand that ownedMember->filter(Operation).ownedParameter is being taken as a Bag(Parameter) and ownedMember.filter("Property") as a Collection(Property)

So I tried with union (and without the double () )

[if ((ownedMember->filter(Operation).ownedParameter->union(ownedMember- >filter(Property)) .......

It says:

"Cannont find the operation union(Collection(Property)) for the type BagParameter()"

So i tried to convert the last part to a bag parameter with:

...->union(ownedMember->filter(Property)->asBag())....

but then it says:

"Cannot find operation asBag() for the type Collection(Property)"

I dont know, it seems like it is taking one part of the union as a thing and the other as another that cant cast to a bagParameter

So in the end I used again a casting:

[if ((ownedMember->filter(Operation).ownedParameter->union(ownedMember- >filter(Property).oclAsType(Parameter))

And it gaves no error but I dont know what am I really doing.

The final result is:

[if ((ownedMember->filter(Operation).ownedParameter->union((getAssociations().navigableOwnedEnd)- >select((upper = -1 or upper > 1) and isOrdered).oclAsType(Parameter))->union(ownedMember->filter(Property).oclAsType(Parameter))) <> null)]

Does it have any sense?

Thank you.

Re: [Acceleo] Syntax problems [message #539535 is a reply to message #539475] Fri, 11 June 2010 04:25 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1621
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050809080802010103010101
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Daniel,

Casting Property to Parameter seems like it will fail in
ClassCastException. I would have done something like :

ownedMember->filter(Operation).ownedParameter.oclAsType(TypedElement)- >union(ownedMember-
>filter(Property))

and add the cast from Property to TypedElement if OCL still failed
compiling. Otherwise, what you have seems good to me.

Laurent Goubet
Obeo

Daniel wrote:
> Hi and thanks again for your help.
>
> I will try the use the oclAsType for the castings, later I will see if I
> get or I dont get exceptions.
>
> The only thing left to try to execute my module is the point 3 of the
> other post. I am going to try to explain the problem and what I have tried:
>
> This is from Acceleo 2:
>
> <%if ((ownedMember.filter("Operation").ownedParameter +
> ownedMember.filter("Property")+
> getAssociations().navigableOwnedEnd)[(upper == -1 || upper > 1) &&
> isOrdered] != null){%>
>
> This is from mt2mtl:
>
> [if ((ownedMember->filter(Operation).ownedParameter +
> ownedMember->filter(Property) +
> getAssociations.navigableOwnedEnd)->select((upper = -1 or upper > 1) and
> isOrdered) <> null)]
>
> In the first 'x' it says:
>
> "Cannot find the operation +Collection(Property) for the type
> Bag(Parameter)"
>
> I understand that ownedMember->filter(Operation).ownedParameter is
> being taken as a Bag(Parameter) and ownedMember.filter("Property") as a
> Collection(Property)
>
> So I tried with union (and without the double () )
>
> [if ((ownedMember->filter(Operation).ownedParameter->union(ownedMember-
> >filter(Property)) .......
>
> It says:
>
> "Cannont find the operation union(Collection(Property)) for the type
> BagParameter()"
>
> So i tried to convert the last part to a bag parameter with:
>
> ..->union(ownedMember->filter(Property)->asBag())....
> but then it says:
>
> "Cannot find operation asBag() for the type Collection(Property)"
>
> I dont know, it seems like it is taking one part of the union as a thing
> and the other as another that cant cast to a bagParameter
>
> So in the end I used again a casting:
>
> [if ((ownedMember->filter(Operation).ownedParameter->union(ownedMember-
> >filter(Property).oclAsType(Parameter))
>
> And it gaves no error but I dont know what am I really doing.
>
> The final result is:
>
> [if
> ((ownedMember->filter(Operation).ownedParameter->union((getAssociations().navigableOwnedEnd)-
> >select((upper = -1 or upper > 1) and
> isOrdered).oclAsType(Parameter))->union(ownedMember->filter(Property).oclAsType(Parameter)))
> <> null)]
>
> Does it have any sense?
> Thank you.
>
>


--------------050809080802010103010101
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=
--------------050809080802010103010101--
Re: [Acceleo] Syntax problems [message #539614 is a reply to message #539535] Fri, 11 June 2010 09:58 Go to previous messageGo to next message
Daniel  is currently offline Daniel
Messages: 44
Registered: June 2010
Member
Hi again and thanks for your advice.

I have tried what you said:

[if ((ownedMember->filter(Operation).ownedParameter.oclAsType(TypedElement)- >union(ownedMember->filter(Property))

But it still doesnt compile:

"Cannont find operation union(Collection(Property)) for the type Bag(TypedElement"

You also said:

"and add the cast from Property to TypedElement if OCL still failed
compiling. Otherwise, what you have seems good to me."

How do i add the cast?

Thank you!

Re: [Acceleo] Syntax problems [message #539730 is a reply to message #539614] Sat, 12 June 2010 05:30 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1621
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090806070605010903080209
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Daniel,

My comment was for the second cast :

[if
((ownedMember->filter(Operation).ownedParameter.oclAsType(TypedElement)-
>union(ownedMember->filter(Property).oclAsType(TypedElement))

Regards,

Laurent Goubet
Obeo

Daniel wrote:
> Hi again and thanks for your advice.
>
> I have tried what you said:
>
> [if
> ((ownedMember->filter(Operation).ownedParameter.oclAsType(TypedElement)-
> >union(ownedMember->filter(Property))
>
> But it still doesnt compile:
>
> "Cannont find operation union(Collection(Property)) for the type
> Bag(TypedElement"
>
> You also said:
>
> "and add the cast from Property to TypedElement if OCL still failed
> compiling. Otherwise, what you have seems good to me."
>
> How do i add the cast?
>
> Thank you!
>
>


--------------090806070605010903080209
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=
--------------090806070605010903080209--
Re: [Acceleo] Syntax problems [message #539812 is a reply to message #539730] Sun, 13 June 2010 12:05 Go to previous messageGo to next message
Daniel  is currently offline Daniel
Messages: 44
Registered: June 2010
Member
Hi again! And thank you very much, because it worked Smile

But now I have a problem I didnt have before. After performing the union of all the elements I do a ->select(upper....

Like this:

[if((ownedMember->filter(Operation).ownedParameter.oclAsType(TypedElement)- >union(ownedMember->filter(Property).oclAsType(TypedElement))- >union(getAssociations().navigableOwnedEnd))->select((upper = -1 or upper > 1) and isOrdered) <> null)]

Well, before it didnt say anything but now it says:

"Unrecognized variable upper"

Why could it be?

Thanks!
Re: [Acceleo] Syntax problems [message #539813 is a reply to message #539812] Sun, 13 June 2010 12:07 Go to previous messageGo to next message
Daniel  is currently offline Daniel
Messages: 44
Registered: June 2010
Member
I solved it like this:

[if((ownedMember->filter(Operation).ownedParameter.oclAsType(TypedElement)- >union(ownedMember->filter(Property).oclAsType(TypedElement))- > union(getAssociations().navigableOwnedEnd)).oclAsType(Parame ter)- >select((upper = -1 or upper > 1) and isOrdered) <> null)]

Casting to Parameter, is it all right?
Re: [Acceleo] Syntax problems [message #540328 is a reply to message #539813] Tue, 15 June 2010 11:47 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1621
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040805050205090703030201
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Daniel,

As far as I know, UML Properties are not Parameters, thus you risk a
ClassCast exception when throwing the result of your unions to Parameter.

IIUC, what you seek to do on the elements of the resulting collection is
only to access "upper", "lower" and "isOrdered" ... which are all
defined on "MultiplicityElement". The easiest way to solve these
compilation issues is then to directly cast to this type :

[if((ownedMember-> filter(Operation).ownedParameter.oclAsType(MultiplicityEleme nt)- >union(ownedMember->filter(Property).oclAsType(MultiplicityElement))- >
union(getAssociations().navigableOwnedEnd))->select((upper = -1 or upper
> 1) and isOrdered) <> null)]

Laurent Goubet
Obeo

Daniel wrote:
> I solved it like this:
>
> [if((ownedMember->filter(Operation).ownedParameter.oclAsType(TypedElement)-
> >union(ownedMember->filter(Property).oclAsType(TypedElement))- >
> union(getAssociations().navigableOwnedEnd)).oclAsType(Parame ter)-
> >select((upper = -1 or upper > 1) and isOrdered) <> null)]
>
> Casting to Parameter, is it all right?


--------------040805050205090703030201
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=
--------------040805050205090703030201--
Re: [Acceleo] Syntax problems [message #540618 is a reply to message #540328] Wed, 16 June 2010 13:44 Go to previous message
Daniel  is currently offline Daniel
Messages: 44
Registered: June 2010
Member
Thank you! You were right, that worked!

Now I will focus on how to get it running because I dont know why it just terminates.

Thank you!
Previous Topic:[xtend] RSM/RSA Adapter replacement
Next Topic:XtendParser
Goto Forum:
  


Current Time: Thu Jul 24 11:32:05 EDT 2014

Powered by FUDForum. Page generated in 0.02256 seconds