Class Association
java.lang.Object
net.sf.jailer.datamodel.ModelElement
net.sf.jailer.datamodel.Association
An association between database-tables.
- Author:
- Ralf Wisser
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAssociation(Table source, Table destination, boolean insertSourceBeforeDestination, boolean insertDestinationBeforeSource, String joinCondition, DataModel dataModel, boolean reversed, Cardinality cardinality) Constructor.Association(Table source, Table destination, boolean insertSourceBeforeDestination, boolean insertDestinationBeforeSource, String joinCondition, DataModel dataModel, boolean reversed, Cardinality cardinality, String author) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendCondition(String condition) Appends condition to join-condition.Maps source-columns to destination-columns, if this represents an equi-join.createSourceToDestinationKeyMapping(Set<Pair<Column, Column>> assignments) Maps source-columns to destination-columns, if this represents an equi-join.booleanChecks whether all foreign key columns on the source side have an exclude filter.booleanChecks whether all foreign key columns on the source side have a null filter.Gets the XML aggregation schema.Gets name of XML-tag used for aggregation.Gets the cardinality.Gets data-model to which this association belongs to.intgetId()Gets unique ID.Gets the restricted join-condition for joining source with destination table.getName()Gets the name of the association.Gets restriction-condition.Gets join-condition without any restrictions.booleanChecks whether this association has a nullable foreign key (i.e.booleanIs this association ignored?booleanWhether or not to insert destination-rows before source-rows in order to prevent foreign-key-constraint violation.booleanWhether or not to insert source-rows before destination rows in order to prevent foreign-key-constraint violation.booleanWhether there is any restriction of this association.booleanChecks whether this is a restricted dependency whose FK columns are set to null.renderJoinCondition(String restrictionSeparator) Stringifies the join condition.voidsetAggregationSchema(AggregationSchema aggregationSchema) Sets the XML aggregation schema.voidsetAggregationTagName(String aggregationTagName) Sets name of XML-tag used for aggregation.voidSets the name of the association.booleansetOrResetFKNullFilter(boolean set) Sets or resets null filters on the foreign key columns of the source side.toString()Stringifies the association.toString(int maxGab, boolean useDisplayName) Stringifies the association.Methods inherited from class net.sf.jailer.datamodel.ModelElement
getAuthor, setAuthor
-
Field Details
-
source
The source table. -
destination
The destination table. -
reversed
public final boolean reversedtruefor reversed association. -
reversalAssociation
The counterpart of the association for the reversal direction. -
NULL_FILTER_COMMENT_PREFIX
- See Also:
-
-
Constructor Details
-
Association
public Association(Table source, Table destination, boolean insertSourceBeforeDestination, boolean insertDestinationBeforeSource, String joinCondition, DataModel dataModel, boolean reversed, Cardinality cardinality) Constructor.- Parameters:
source- the source tabledestination- the destination tableinsertSourceBeforeDestination- whether or not to insert source-rows before destination rows in order to prevent foreign-key-constraint violationinsertDestinationBeforeSource- whether or not to insert destination-rows before source-rows in order to prevent foreign-key-constraint violationjoinCondition- the join-condition for join with destination tabledataModel- data-model containing this associationreversed-truefor reversed associationcardinality- the cardinality (optional)
-
Association
public Association(Table source, Table destination, boolean insertSourceBeforeDestination, boolean insertDestinationBeforeSource, String joinCondition, DataModel dataModel, boolean reversed, Cardinality cardinality, String author) Constructor.- Parameters:
source- the source tabledestination- the destination tableinsertSourceBeforeDestination- whether or not to insert source-rows before destination rows in order to prevent foreign-key-constraint violationinsertDestinationBeforeSource- whether or not to insert destination-rows before source-rows in order to prevent foreign-key-constraint violationjoinCondition- the join-condition for join with destination tabledataModel- data-model containing this associationreversed-truefor reversed associationcardinality- the cardinality (optional)author- the author
-
-
Method Details
-
getJoinCondition
Gets the restricted join-condition for joining source with destination table.- Returns:
- the restricted join-condition for joining source with destination
table,
nullif association must be ignored
-
isIgnored
public boolean isIgnored()Is this association ignored?- Returns:
trueiff this association is ignored
-
getCardinality
Gets the cardinality.- Returns:
- the cardinality.
nullif cardinality is not known.
-
toString
-
toString
Stringifies the association.- Parameters:
maxGab- minimum width of the destination table name columnuseDisplayName-trueto use display names for tables- Returns:
- string representation of the association
-
renderJoinCondition
-
getUnrestrictedJoinCondition
Gets join-condition without any restrictions.- Returns:
- join-condition as defined in data model
-
getRestrictionCondition
Gets restriction-condition.- Returns:
- restriction-condition,
nullif association is not restricted
-
setName
Sets the name of the association.- Parameters:
name- the name of the association
-
getName
-
isInsertSourceBeforeDestination
public boolean isInsertSourceBeforeDestination()Whether or not to insert source-rows before destination rows in order to prevent foreign-key-constraint violation.- Returns:
- the insertSourceBeforeDestination
-
isInsertDestinationBeforeSource
public boolean isInsertDestinationBeforeSource()Whether or not to insert destination-rows before source-rows in order to prevent foreign-key-constraint violation.- Returns:
- the insertDestinationBeforeSource
-
isRestricted
public boolean isRestricted()Whether there is any restriction of this association.- Returns:
trueif there is a restriction on this association
-
appendCondition
Appends condition to join-condition.- Parameters:
condition- the condition
-
getAggregationSchema
Gets the XML aggregation schema.- Returns:
- the XML aggregation schema
-
getAggregationTagName
Gets name of XML-tag used for aggregation.- Returns:
- name of XML-tag used for aggregation
-
setAggregationSchema
Sets the XML aggregation schema.- Parameters:
aggregationSchema- the XML aggregation schema
-
setAggregationTagName
Sets name of XML-tag used for aggregation.- Parameters:
aggregationTagName- name of XML-tag used for aggregation
-
getId
public int getId()Gets unique ID.- Returns:
- unique ID
-
getDataModel
Gets data-model to which this association belongs to.- Returns:
- the data model containing this association
-
createSourceToDestinationKeyMapping
-
createSourceToDestinationKeyMapping
Maps source-columns to destination-columns, if this represents an equi-join. Otherwise it returns an empty map.- Parameters:
assignments- if notnull, put column assignments into it- Returns:
- map from source-columns to destination-columns, if this represents an equi-join
-
hasNullableFK
public boolean hasNullableFK()Checks whether this association has a nullable foreign key (i.e. all FK columns on the source side are nullable and have no non-null filter).- Returns:
trueif the foreign key columns are all nullable
-
fkHasNullFilter
public boolean fkHasNullFilter()Checks whether all foreign key columns on the source side have a null filter.- Returns:
trueif all FK source columns have a null filter
-
fkHasExcludeFilter
public boolean fkHasExcludeFilter()Checks whether all foreign key columns on the source side have an exclude filter.- Returns:
trueif all FK source columns have an exclude filter
-
setOrResetFKNullFilter
public boolean setOrResetFKNullFilter(boolean set) Sets or resets null filters on the foreign key columns of the source side.- Parameters:
set-trueto set null filters,falseto remove them- Returns:
trueif any filter was changed
-
isRestrictedDependencyWithNulledFK
public boolean isRestrictedDependencyWithNulledFK()Checks whether this is a restricted dependency whose FK columns are set to null.- Returns:
trueif this is a restricted dependency with nulled FK columns
-