Java Reference
In-Depth Information
The
primitiveAttributes2columns()
query simply invokes the
primitiveAttribute2column
query for each attribute, returning the results
as an ordered set.
query
UML::DataType::primitiveAttributes2columns(
in
targetType:
UML::DataType) :
OrderedSet
(RDB::TableColumn) {
self
.attributes->
collect
(a |
a.primitiveAttribute2column(targetType))->asOrderedSet()
}
Primitive types are filtered using the
isPrimitive()
query in the
when
clause, which checks to see that the
targetType
parameter is of type
UML::PrimitiveType
. The column's
isPrimaryKey
property is set using the
isPrimaryKey()
query, which checks to see that a stereotype is present equal
to the String
"primaryKey"
. The name of the primitive type passed in is used
as the column name, and the type is set to a
PrimitiveDataType
object whose
name is initialized by the
umlPrimitive2rdbPrimitive()
query. This query
uses a simple String comparison of basic types.
mapping
UML::Property::primitiveAttribute2column(
in
targetType:
UML::DataType) : RDB::TableColumn
when
{
self
.isPrimitive() }
{
isPrimaryKey :=
self
.isPrimaryKey();
name :=
self
.name;
type :=
object
RDB::datatypes::PrimitiveDataType { name :=
umlPrimitive2rdbPrimitive(
self
.type.name); };
}
query
UML::Property::isPrimitive() :
Boolean
{
type.
oclIsKindOf
(UML::PrimitiveType)
}
query
UML::Property::isPrimaryKey() :
Boolean
{
stereotype->includes('primaryKey')
}
query
umlPrimitive2rdbPrimitive(
in
name :
String
) :
String
{
if
name = 'String'
then
'varchar'
else
if
name = 'Boolean'
then
'int'
else
if
name = 'Integer'
then
'int'
else
name
endif
endif
endif
}
Search WWH ::
Custom Search