blob: c34be770b4926cb818942d4a7cd558a06bfd077c [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007,2008 Tata Consultancy Services and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* TCS - initial implementation for ModelMorf
* E.D.Willink - alignment with evolved specification
*******************************************************************************/
import umlmm : 'UmlMM.emof'::umlMM2;
import relmm : 'RelMM.emof'::relMM2;
transformation UmlToRel(uml:umlmm, rdbms:relmm)
{
key umlmm::Class {name};
key umlmm::Attribute {name, _'class'};
key relmm::Table {name};
key relmm::Column {name, table};
query UmlToSqlDataType(utyp:String):String
{
if
(utyp = 'Int')
then
'Number'
else
if
(utyp = 'Binary')
then
'Raw'
else
'Varchar'
endif
endif
}
query SqlToUmlDataType(styp:String):String
{
if
(styp = 'Number')
then
'Int'
else
if
(styp = 'Raw')
then
'Binary'
else
'String'
endif
endif
}
top relation ClassToTable
{
n : String;
enforce domain uml
c:Class
{
name = n
};
enforce domain rdbms
t:Table
{
name = n
};
}
top relation AttributeToColumn
{
n:String;
utyp:String;
rtyp:String;
enforce domain uml
a:Attribute
{
name = n,
type = utyp,
_'class' = c:Class{}
}
default_values
{
utyp = SqlToUmlDataType(rtyp);
};
enforce domain rdbms
cl:Column
{
name = n,
dataType = rtyp,
table = t:Table{}
};
when
{
ClassToTable(c, t);
}
where
{
rtyp = UmlToSqlDataType(utyp);
}
}
}