Author Topic: Enum Class as Table Column?  (Read 4660 times)

m2i7c9k

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Enum Class as Table Column?
« on: April 22, 2021, 08:26:14 pm »
Hi guys,

I can't figure out how can I add ENUM class associated (aggregation) to another Class?
I'd like to add the ENUM class name as Tabel Columnt name?

Thanks

MIck

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Enum Class as Table Column?
« Reply #1 on: April 22, 2021, 08:56:54 pm »
Hi Mick,

From your explanation I have no clue what you mean, sorry.

In terms of UML you normally create an enumeration, and then use that enumeration as the type of an attribute.
Generally we don't use associations or aggregations between classes and enumerations.

Geert

m2i7c9k

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: Enum Class as Table Column?
« Reply #2 on: April 22, 2021, 09:12:11 pm »
Hi Geert,

well, you're right :) So here are more details.
1. I have a PIM model that has enum associated to the class as (composite)
2. when I run transformation PIM to Table for MS SQL DB, the code does noting with enum?

so I thought that I can somehow add the enum class name as a Table column?


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Enum Class as Table Column?
« Reply #3 on: April 22, 2021, 09:17:54 pm »
I see, that's why you better use attributes and set the type, instead of an association to the enumeration.

It's not wrong per sé, but simply unusual, and therefore probably not supported by the transformation logic.

Geert

m2i7c9k

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: Enum Class as Table Column?
« Reply #4 on: April 22, 2021, 09:53:00 pm »
Well, here is the way :)

1.
In Transformation Table
%if classStereotype=="enumeration"%
%endTemplate%

Table
{
   %TRANSFORM_REFERENCE("Table")%
   %TRANSFORM_CURRENT("language", "stereotype")%
 
   name=%qt%%CONVERT_NAME(className, "Camel Case", "ab(_)ab")%%qt%
   language=%qt%%genOptDefaultDatabase%%qt%
   
   %list="Attribute" @separator="\n" @indent="  "%
   
   $COMMENT="Enum class ako attribĂșt v Tabuľke."
   %list="Connector__Enum" @separator="\n" @indent="  "%
...

2 adding a new Connector__Enum Template
%if connectorType == "Association" or connectorType=="Aggregation"%

   %if connectorSourceElemStereotype == "enumeration" %
      Column
      {
         %if connectorSourceRole != ""%
            name=%qt%%CONVERT_NAME(connectorSourceRole, "cascal Case", "ab(_)ab")%%qt%
         %else%
            name=%qt%%CONVERT_NAME(connectorSourceElemName, "cascal Case", "ab(_)ab")%%qt%
         %endIf%
         
         type=%qt%%CONVERT_TYPE(genOptDefaultDatabase,"varchar(10)")%%qt%
         
         %if connectorNotes != ""%
            notes=%qt%%connectorNotes% %connectorSourceElemNotes%%qt%
         %else%
            notes=%qt%%connectorSourceElemNotes%%qt%
         %endIf%
          
         Tag
         {
            name="LengthType"
            value="CHAR"
         }
      }
   %endIf%
%endIf%

.... in the end, it worked :)