Hello,
This is my first attempt at creating a custom MDA transformation. First, I am creating a DDL transformation which should be pretty simple, but things are not working out quite right. What I am trying to do is set the attribute type based on attribute name suffix. For example, if the name ends with _Id, then the type is guid, if Indicator, then Boolean, etc. You get the idea. The type is not set in the PIM it is determined during the transform.
Here is a sample of the Attribute template...it is raw...just trying to get it to work.
%if attName == "Id"%
PrimaryKey
{
Column
{
%TRANSFORM_CURRENT("type", "stereotype", "collection", "constant", "containment", "ordered", "static", "volatile")%
type=%qt%%CONVERT_TYPE(genOptDefaultDatabase,"guid")%%qt%
}
}
%else%
$genType="_"+%attName%
$genType=%qt%+%RIGHT($genType,2)%+%qt%
%If $genType == "id"%
Column
{
%TRANSFORM_CURRENT("type", "stereotype", "collection", "constant", "containment", "ordered", "static", "volatile")%
type=%qt%%CONVERT_TYPE(genOptDefaultDatabase,"guid")%%qt%
}
%endIf%
%if $genType == "or"%
Column
{
%TRANSFORM_CURRENT("type", "stereotype", "collection", "constant", "containment", "ordered", "static", "volatile")%
type=%qt%%CONVERT_TYPE(genOptDefaultDatabase,"Boolean")%%qt%
}
%endIf%
%endIf%
Here is what is produced in the intermediate file...
---------- DDL ----------
Package
{
name="DDL"
namespaceroot="true"
Table
{
XRef{namespace="DDL" name="Table" source="{F74B34AE-E63A-4d00-BAFF-6E7B7E6FEA3C}"}
notes=""
scope="Public"
multiplicity=""
version="1.0"
author="Bill"
alias=""
name="CodeList"
complexity="1"
concurrency=""
persistence=""
arguments=""
phase="1.0"
status="Proposed"
visibility=""
cardinality=""
language="SQL Server 2008"
PrimaryKey
{
Column
{
notes="Uniquely identifies a row in the table."
scope="Public"
container=""
alias=""
lowerbound="1"
name="Id"
default=""
upperbound="1"
type="uniqueidentifier"
}
}
%If "or" == "id"%
Column
{
notes=""
scope="Public"
container=""
alias=""
lowerbound="1"
name="IsActiveIndicator"
default=""
upperbound="1"
type="uniqueidentifier"
}
}
}
The if statement seems to be correct, but it is being written instead of being executed.
Any ideas?
:-/
Bill Stoddart