Book a Demo

Author Topic: Setting NotNull or Unique flags in transformations  (Read 3184 times)

Soundwave

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Setting NotNull or Unique flags in transformations
« on: September 01, 2009, 04:42:48 pm »
Trying to enhance the built-in DDL transformation to set the NotNull field on an attribute based on some custom rules, but found that the documentation is vague on how to use the NotNull and Unique flags (which seem to only exist on column-stereotype attributes) in a transformation.

Is it actually possible to set these fields? I've tried NotNull="true", ="1", and many other variants and the syntax is always rejected.

I do notice that the other column specific field - PrimaryKey - is handled differently (you define it against the Table object apparently), so maybe I'm missing the point with these other two...

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Setting NotNull or Unique flags in transformat
« Reply #1 on: September 02, 2009, 09:03:25 am »
There is a Note just underneath the Columns description, that says:

In the column definition, you cannot assign a value to the NotNull, PrimaryKey or Unique properties.

See

http://www.sparxsystems.com/uml_tool_guide/mda_transformations/transformingobjects.html

right at the very end.
Best Regards, Roy

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Setting NotNull or Unique flags in transformat
« Reply #2 on: September 02, 2009, 09:54:28 am »
The quote that Roy points out simply means that you only write the keyword itself.  You do not have to assign a value to it...  To set these flags in transformation, you simply need to put the word Unique or NotNull on the line.  You do not need ="true" or =1 after the keyword.  Example:

Code: [Select]
Column
{
  ...
  Unique
  NotNull
}

Note that for the Unique constraint, you may also need to generate the required operation for the table.  EA does not appear to do this automatically.  Example:

Code: [Select]
Operation
{
  name=%qt%UQ_%className%_%attName%%qt%
  stereotype=%qt%unique%qt%
  
  Parameter
  {
    name=%qt%%attName%%qt%
    type=%qt%%CONVERT_TYPE(genOptDefaultDatabase,attType)%%qt%
  }
}
« Last Edit: September 02, 2009, 11:50:56 am by AaronB »