Book a Demo

Author Topic: Setter params  (Read 5550 times)

du-it

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Setter params
« on: October 26, 2005, 08:39:26 am »
I wonder how I can change the name of a setter method for an attribute without having conflicts during code generation?

After defining an attribute I checked the Property checkbox whereafter the appropriate get and set methods are generated automatically. When I, however, want to change the setter method's parameter name the code generated during forward engineering leads to compiler errors because the parameter's name in the method's signature was changed but the code in the method's code block still works with the parameter's old name 'newVal'.

How can I change the name without running into troubles with the Java compiler?

Thank you,

Dirk

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Setter params
« Reply #1 on: October 26, 2005, 01:49:10 pm »
Quote
I wonder how I can change the name of a setter method for an attribute without having conflicts during code generation?

After defining an attribute I checked the Property checkbox whereafter the appropriate get and set methods are generated automatically. When I, however, want to change the setter method's parameter name the code generated during forward engineering leads to compiler errors because the parameter's name in the method's signature was changed but the code in the method's code block still works with the parameter's old name 'newVal'.

How can I change the name without running into troubles with the Java compiler?

Thank you,

Dirk
By hand in your source code...

As you're discovering, there's more to EA code generation than you thought...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Setter params
« Reply #2 on: October 26, 2005, 03:22:37 pm »
You can modify the code generation templates to use your changed parameter name.

What you can do is create a custom template for parameter that just gives the name.  From your operation body template you would have to list over all parameters for the name, and possibly check to make sure that there is only one parameter.

du-it

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Setter params
« Reply #3 on: October 27, 2005, 12:37:48 am »
Oh, Jesus!

A good idea to override the template but how can I do this (since I'm a newbie to EA)?
Where can I get information about the script language?

Dirk

thomaskilian

  • Guest
Re: Setter params
« Reply #4 on: October 27, 2005, 01:14:51 am »
It's not too difficult. Take your sandbox model and make changes to the template (also read the help -> index "Code"...). Watch the results. Be warned that syntax errors just result in wrong results - no warnings :( Start debugging the code gen - and call it a day.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Setter params
« Reply #5 on: October 27, 2005, 03:48:35 pm »
I'd specifically recommend looking at List macros and Custom Templates.

thomaskilian

  • Guest
Re: Setter params
« Reply #6 on: October 27, 2005, 11:21:45 pm »
Simon,
just yesterday I specifically looked for the description of %if and was not able to find it :( Maybe I overlooked it and more or less it's obvious, but it isn't. E.g. %if <cond> <statement>% seems to work, but only one of the %-attributes (e.g. className) is involved.  Can you pls. also give the link to the complete syntax?
Thanks in advance.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Setter params
« Reply #7 on: October 30, 2005, 01:18:30 pm »
Hi Thomas,

Did you look at http://www.sparxsystems.com.au/EAUserGuide/index.html?controlmacros.htm?

The only thing really missing from that would be an explicit grammar.  That would look something like this.

ifCond:
    %if conditions %
conditions:
    test conditionsExtopt
test:
    ifTerm operator ifTerm
conditionsExt:
    testJoin test conditionsExtopt
testJoin:
    and
    or
operator:
    ==
    !=

ElseIf would then be the same.  Both open a block which is then closed with one of an else, elseIf, endIf or endTemplate.

thomaskilian

  • Guest
Re: Setter params
« Reply #8 on: October 31, 2005, 02:00:59 am »
Simon,
thanks for the pointer. I probably overlooked that.  The syntax for <cond> ? <then> : <else> is also not given explicitely (only as example below). I was quite sure that I found a %if <cond> <assignment>% somewhere in the macros. But that may have been due to the late hour.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Setter params
« Reply #9 on: October 31, 2005, 01:05:17 pm »
The conditional substitution macro is documented right at the end of both http://sparxsystems.com.au/EAUserGuide/index.html?fieldsubstitutionmacros.htm and http://sparxsystems.com.au/EAUserGuide/index.html?taggedvaluemacros.htm.

The only part of it that doesn't appear to be thoroughly documented is what form the substitution values are.  That is one or more strings and the keyword value, which copies the value of the macro.  No '+' or any other delimiter is expected between terms.
« Last Edit: October 31, 2005, 01:06:00 pm by simonm »

thomaskilian

  • Guest
Re: Setter params
« Reply #10 on: November 01, 2005, 03:59:39 am »
Thanks again, Simon. I probably expect some kind of syntax definition for any kind of language at a dedicated place and not at mixed locations in the documentation. I guess it shouldn't be too hard to place a (E)BNF grammar somewhere. At least for me, that makes learning a language much easier :)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Setter params
« Reply #11 on: November 01, 2005, 04:21:37 am »
Quote
Thanks again, Simon. I probably expect some kind of syntax definition for any kind of language at a dedicated place and not at mixed locations in the documentation. I guess it shouldn't be too hard to place a (E)BNF grammar somewhere. At least for me, that makes learning a language much easier :)
Seconded!

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

mikewhit

  • EA User
  • **
  • Posts: 608
  • Karma: +0/-0
  • Accessing ....
    • View Profile
Re: Setter params
« Reply #12 on: November 01, 2005, 04:52:27 am »
Yep - grammar should be all together in one place, with local copies under the doc page of each construct.

Please.