Hi all,
Modifying the query.
I am trying to generate DDL scripts from the underlying UML model.
In the UML model I have an enumeration ‘UNIT’ (which has a set of predefined values 'cm²', 'm²' and 'km²' ), Validity, SeverityKind, AlarmKind and a class (Rectangle) whose attribute 'area'
is of the type UNIT.
The DDL script generated is:
Create table Rectangle
{
area UNIT,
rectangleID Integer
}
I want to change the datatype of the column 'unit' to nvarchar and also add a check constraint on the column.
I have added the following code in Transformation Templates (attribute template):
%if attType=="UNIT"%
type = "nvarchar(max) check(%attName% in ('cm²','m²','km²'))"
%endIf%
%if attType == "Validity"%
type="nvarchar (max) check (%attName% in ('GOOD','QUESTIONABLE','INVALID'))"
%endIf%
%if attType == "Severitykind"%
type="nvarchar (max) check (%attName% in ('none','U4','U3','U2','U1'))"
%endIf%
%if attType == "AlarmKind"%
type="nvarchar (max) check (%attName% in ('process','system','sensor'))"
%endIf%
This above code helps me get the result.
But we want to optimize the above code in such a way that we do not have to repeat the rule for each enumeration type and need not have to hardcode the attType value and the
enumeration values (like 'GOOD','QUESTIONABLE','INVALID' Validity type and similarly for other types)
Query 1. Is there a way I can create one generic rule similar to the above for all enumeration types so that I do not have to repeat the rule for each enumeration type and do not have
to hardcode the values of enumeration type (like say using %list% etc).
Query 2. When the set of values defined for the enumeration is large, EA throws an error while generating the check constraint in the PSM and does not generate the desired scripts. Is
there a way to handle such cases?