Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: m2i7c9k 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
-
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
-
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?
(https://uloz.to/file/cOTtRxE4P9YQ/enum-class-to-table-as-column-png#!ZJSzAQR2AJL4MzRjAJDlBGpkAmD0AISMBIOVHHqUpRLjqQR2Mt==)
-
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
-
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 :)