Java Reference
In-Depth Information
a. oclIsUndefined ())->
collect (includedColumns)->asOrderedSet();
}
To create a ForeignKey object from a DataType that is a Relationship, first
the key's name is set to the relationship name prefixed with FK . The included
Columns attribute is set using the dataType2primaryKeyColumns query,
which passes a Boolean value equal to the result of the isIdentifying() query.
This query looks for a stereotype String equal to identifying .
Finally, the referredUC property is set using a late resolveoneIn
class2primaryKey() mapping. Using late means the mapping will be
invoked at the end of the transformation, which allows for the resolution of
objects that might not yet be created. Using resolveoneIn returns a primary
key object that has previously been created by the type attribute of the passed in
property. This is accomplished by examining the trace model that is created dur-
ing the transformation and avoids creating duplicate object instances.
mapping UML::Property::relationshipAttribute2foreignKey( in targetType:
UML::DataType) : RDB::constraints::ForeignKey
when { self .isRelationship() }
{
name := 'FK' + self .name;
includedColumns :=
self .type.asDataType().dataType2primaryKeyColumns( self .name,
self .isIdentifying());
referredUC := self .type. late
resolveoneIn (UML::Class::class2primaryKey,
RDB::constraints::PrimaryKey);
}
query UML::Property::isRelationship() : Boolean {
type. oclIsKindOf (UML::DataType) and type.isPersistent()
}
To create primary key columns from data types, two parameters are passed
in addition to the data type: a prefix String for the column name and a Boolean
to set the isPrimaryKey property. The body is a little complicated. First the
dataType2columns() query is called, and those that are primary keys are
selected. Then a collection based on TableColumn objects created using passed
parameters is returned as an ordered set.
query UML::DataType::dataType2primaryKeyColumns( in prefix : String ,
in leaveIsPrimaryKey : Boolean ) : OrderedSet (RDB::TableColumn) {
Search WWH ::




Custom Search