Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319827 - comparator = fails between getAssociation.getMemberEnd.end and name.toLowerFirst()+nametoLowerFirst()
Summary: comparator = fails between getAssociation.getMemberEnd.end and name.toLowerFi...
Status: CLOSED INVALID
Alias: None
Product: Acceleo
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-14 06:38 EDT by Charlie Mordant CLA
Modified: 2010-07-29 16:06 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Charlie Mordant CLA 2010-07-14 06:38:54 EDT
Build Identifier: 3.0

I tried to detect reflexive relations in my uml diagram, but I'm facing a bug.

As I an Acceleo newBie, I tried this operation: c.getAssociation.getMemberEnd.name = c.name.toLowerFirst()+c.nametoLowerFirst(), but acceleo said it's not equal.
(I did this because I don't know how to catch the opposite class in a relation ).

Can you resolve this bug, and give me the solution for this:
for one to one relationships, I used to do:
[code]
<%if (getAssociations().memberEnd().name == peek().toL1Case()+peek().toL1Case()) {%>
<%if (getAssociations().memberEnd().upper.minimize() == 1) {%>
[/code]
How can I detect reflexive one to one relationships without minimize and this bug? Or only catch the opposite class of a relation

Reproducible: Always
Comment 1 Laurent Goubet CLA 2010-07-26 05:18:05 EDT
Hi Charlie,

With Acceleo 3, you need to pay extra attention to the type of the objects you compare. Specifically, you are here comparing a list and a String, thus Acceleo (in fact, OCL) tells you that the two objects are different.

c.getAssociations.getMemberEnd.name <= "getAssociation()" returns a list, thus this is equivalent to :

c.getAssociation()->collect(getMemberEnd()->collect(name)) and the whole expression itself returns a list. On the other end, c.name.toLowerFirst()+c.nametoLowerFirst() returns a String.

You have to either use "contains" instead of "=" or only take into account the first association returned through "first()" (if you have a Sequence) or "any(true)" (if you have a Set).

Please use the newsgroup to ask questions before entering bugzilla entries.
Comment 2 Charlie Mordant CLA 2010-07-27 14:03:47 EDT
So, can you add brackets for sequences and sets toString functions?
Comment 3 Laurent Goubet CLA 2010-07-28 04:01:21 EDT
Hi Charlie,

The brackets have been removed deliberately. We often (and you probably do it to) use a collection to generate text. An example would be :

package [ancestors()->reverse()->sep('.')/];

which generates 

package my.package;

and would be horrible if it didn't :

package [my,.,package];

The current behavior would be hard to attain with plain OCL. To generate the same text with collections having a "standard" toString would take things like this :

package [ancestors()->reverse()->sep('.')->iterate(e ; result : String = '' | result.append(e))/];

each and every time we need to have the toString of a Collection.
Comment 4 Charlie Mordant CLA 2010-07-29 15:40:54 EDT
Hi Laurent,
You're absolutly right, Acceleo syntax is damn good as it is, very easy to understand. I made many good things with it and with pleasure.
I'll avoid posting invalid bug in the near future, prefering brainstorm and at least forum.

One last question. Can I contribute to the community giving some templates?
My mail is cmordant1@gmail.com
Comment 5 Laurent Goubet CLA 2010-07-29 16:06:53 EDT
Hi Charlie,

Raising invalid bugs isn't a problem in itself, it's just that you'd have had a faster answer on the newsgroup :).

As for contributions, we always welcome them with pleasure, be it bug raising, documentations, example modules, patches... You can either discuss them on newsgroup, through bugs (with "importance" = "enhancement", mainly so that you can attach the patch/new modules to the bug), mails on the m2t-dev mailing list or direct mails.

We're somewhat lacking on the side of example modules, so feel free to contribute anything you feel is ready for the community :).