Community
Participate
Working Groups
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
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.
So, can you add brackets for sequences and sets toString functions?
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.
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
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 :).