Java Reference
In-Depth Information
When mapping enumeration attributes to columns, the enumeration
Attributes2columns() query invokes the enumerationAttribute2col-
umn() mapping for each attribute. A when clause checks that the passed prop-
erty is an enumeration using the isEnumeration() query, which checks that its
type attribute is of type UML::Enumeration .
Again, the isPrimaryKey property is set using the isPrimaryKey() query,
and the name attributes are directly mapped. The column's type is set to a new
PrimitiveDataType object initialized with a name of 'int' .
query UML::DataType::enumerationAttributes2columns( in targetType:
UML::DataType) : OrderedSet (RDB::TableColumn) {
self .attributes-> collect ( map
enumerationAttribute2column(targetType))->asOrderedSet()
}
mapping UML::Property::enumerationAttribute2column( in targetType:
UML::DataType) : RDB::TableColumn
when { self .isEnumeration() }
{
isPrimaryKey := self .isPrimaryKey();
name := self .name;
type := object RDB::datatypes::PrimitiveDataType { name := 'int'; };
}
query UML::Property::isEnumeration() : Boolean {
type. oclIsKindOf (UML::Enumeration)
}
Relationships are mapped to columns using the relationshipAttributes
2columns() query. Unlike the primitive and enumeration types, which map to
simple columns, relationships involve the creation of foreign keys. The input
targetType parameter is passed to the relationshipAttribute
2foreignKey() mapping, where a when clause checks that it is a relationship
type using the isRelationship() query. In this case, valid relationships are
data types that are persistent.
Looking closer at our relationshipAttributes2columns() query, after
the collection of ForeignKey elements, those that are undefined are rejected.
From this collection, the TableColumn objects from each includedColumns
attribute of the foreign keys are collected and returned in an ordered set.
query UML::DataType::relationshipAttributes2columns( in targetType:
UML::DataType) : OrderedSet (RDB::TableColumn) {
self .attributes-> collect ( map
relationshipAttribute2foreignKey(targetType))-> reject (a |
Search WWH ::




Custom Search