Book a Demo

Author Topic: accessing the attribute's class stereotype  (Read 3371 times)

mvackel

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
accessing the attribute's class stereotype
« on: November 11, 2009, 07:24:38 am »
Hello,

Using the code template language, how do I access the stereotype (and other fields) of the attribute's class?

Class AttClass -> has stereotype "MyAttStereotype"

Class MainClass -> has attribute  myAtt of type AttClass

How can I access the stereotype "MyAttStereotype" when generating code for class MainClass? I think this should be possible in the "Attribute Declaration" template, but couldn't find out how.

Note that MyAttStereotype is stereotype of the Class AttClass, NOT of the attribute myAtt.

Thanks in advance,

Marcos Ackel

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

mvackel

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: accessing the attribute's class stereotype
« Reply #2 on: November 13, 2009, 04:11:36 am »
Hello Günter,

thank you for your answer.

The Field Substitution Macros does not address the problem. For instance, the "attStereotype" returns the stereotype of the attribute (as all other similar macros) and not the stereotype of the class that the attribute is referring to. Please see the example in the first message.

If you have any other idea, it's really welcome.

Marcos Ackel

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: accessing the attribute's class stereotype
« Reply #3 on: November 13, 2009, 04:46:31 am »
Hi Marcos,

You can get the attributes' class (type) using the attType or attQualType field substitution macros. But I'm afraid, it won't at least be easy to get the stereotypes of these types, using just code generation template syntax (not to say it's not possible). I didn't find any appropriate function or macro for such yet.
One idea could be, to use the EXEC_ADDIN and provide an AddIn and appropriate function to do this for you.
What exactly do you want to achieve? May be there's a simpler way, than referring to your attribute types' stereotypes.

WBR
Günther

mvackel

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: accessing the attribute's class stereotype
« Reply #4 on: November 14, 2009, 02:01:47 am »
Hello Günter,

thanks again for your support.

I'm using a third party model that is very big (EPRI's CIM model) and it's not advisable to change it, as there will be following versions.
There are some classes with stereotype <<enumeration>> and in Java we must use enums like this:

enum Symbol { V, A, kVA };  // the Symbol "class" has <<enumeration>> stereotype

class Test {
    public Symbol testSymbol = Symbol.kVA;
    public int testVar = 3;
    ....
}   // in the class  Test  the  testSymbol  attribute does not have any stereotype (has initial value  kVA)

So, when generating the Java code I would need to access the Symbol class stereotype and if it has the stereotype <<enumeration>> I can generate the initialization ("Symbol.kVA). This is not the case with   testVar   that is a normal class and must not have the "<class>." decoration in front of it.
There are many other interesting uses for this functionality.

I'll check your suggestion of using the EXEC_ADDIN function. Thank you for the idea. If you have any other suggestions, they'll be very welcome.

Marcos Ackel