@Override public final Collection<Relationship> getRelationships(final Table otherTable) { Collection<Relationship> relationships = getRelationships(); return CollectionUtils.filter(relationships, relation -> { if (relation.getForeignTable() == otherTable && relation.getPrimaryTable() == AbstractTable.this) { return true; } else if (relation.getForeignTable() == AbstractTable.this && relation.getPrimaryTable() == otherTable) { return true; } return false; }); }
@Override public final Collection<Relationship> getRelationships(final Table otherTable) { Collection<Relationship> relationships = getRelationships(); return CollectionUtils.filter(relationships, relation -> { if (relation.getForeignTable() == otherTable && relation.getPrimaryTable() == AbstractTable.this) { return true; } else if (relation.getForeignTable() == AbstractTable.this && relation.getPrimaryTable() == otherTable) { return true; } return false; }); }
@Override public final Collection<Relationship> getForeignKeyRelationships() { return CollectionUtils.filter(getRelationships(), rel -> { return AbstractTable.this.equals(rel.getForeignTable()); }); }
@Override public final Collection<Relationship> getForeignKeyRelationships() { return CollectionUtils.filter(getRelationships(), rel -> { return AbstractTable.this.equals(rel.getForeignTable()); }); }
/** * Constructor for join FROM clauses that join two tables using their * relationship. The primary table of the relationship will be the left side * of the join and the foreign table of the relationship will be the right * side of the join. * * @param join * the join type to use * @param relationship * the relationship to use for joining the tables */ public FromItem(JoinType join, Relationship relationship) { _join = join; _leftSide = new FromItem(relationship.getPrimaryTable()); List<Column> columns = relationship.getPrimaryColumns(); _leftOn = new SelectItem[columns.size()]; for (int i = 0; i < columns.size(); i++) { _leftOn[i] = new SelectItem(columns.get(i)); } _rightSide = new FromItem(relationship.getForeignTable()); columns = relationship.getForeignColumns(); _rightOn = new SelectItem[columns.size()]; for (int i = 0; i < columns.size(); i++) { _rightOn[i] = new SelectItem(columns.get(i)); } }
/** * Constructor for join FROM clauses that join two tables using their * relationship. The primary table of the relationship will be the left side * of the join and the foreign table of the relationship will be the right * side of the join. * * @param join * the join type to use * @param relationship * the relationship to use for joining the tables */ public FromItem(JoinType join, Relationship relationship) { _join = join; _leftSide = new FromItem(relationship.getPrimaryTable()); List<Column> columns = relationship.getPrimaryColumns(); _leftOn = new SelectItem[columns.size()]; for (int i = 0; i < columns.size(); i++) { _leftOn[i] = new SelectItem(columns.get(i)); } _rightSide = new FromItem(relationship.getForeignTable()); columns = relationship.getForeignColumns(); _rightOn = new SelectItem[columns.size()]; for (int i = 0; i < columns.size(); i++) { _rightOn[i] = new SelectItem(columns.get(i)); } }
public XmlDomDataContext flattenTables(Relationship relationship) { MutableTable primaryTable = (MutableTable) relationship.getPrimaryTable(); MutableTable foreignTable = (MutableTable) relationship.getForeignTable(); String[] foreignPrimaryNames = new String[foreignPrimaryRelationships.length]; for (int i = 0; i < foreignPrimaryRelationships.length; i++) { foreignPrimaryNames[i] = foreignPrimaryRelationships[i].getForeignTable().getName();
List<Column> foreignColumns = r.getForeignColumns(); Table pTable = r.getPrimaryTable(); Table fTable = r.getForeignTable(); for (int i = 0; i < primaryColumns.size(); i++) { Column pColumn = primaryColumns.get(i);
List<Column> foreignColumns = r.getForeignColumns(); Table pTable = r.getPrimaryTable(); Table fTable = r.getForeignTable(); for (int i = 0; i < primaryColumns.size(); i++) { Column pColumn = primaryColumns.get(i);
public static void create(Relationship origRelationship, ImmutableSchema schema) { ImmutableTable primaryTable = getSimilarTable( origRelationship.getPrimaryTable(), schema); assert primaryTable != null; List<Column> primaryColumns = getSimilarColumns( origRelationship.getPrimaryColumns(), primaryTable); checkSameTable(primaryColumns); ImmutableTable foreignTable = getSimilarTable( origRelationship.getForeignTable(), schema); assert foreignTable != null; List<Column> foreignColumns = getSimilarColumns( origRelationship.getForeignColumns(), foreignTable); checkSameTable(foreignColumns); ImmutableRelationship relationship = new ImmutableRelationship( primaryColumns, foreignColumns); primaryTable.addRelationship(relationship); foreignTable.addRelationship(relationship); }
public static void create(Relationship origRelationship, ImmutableSchema schema) { ImmutableTable primaryTable = getSimilarTable( origRelationship.getPrimaryTable(), schema); assert primaryTable != null; List<Column> primaryColumns = getSimilarColumns( origRelationship.getPrimaryColumns(), primaryTable); checkSameTable(primaryColumns); ImmutableTable foreignTable = getSimilarTable( origRelationship.getForeignTable(), schema); assert foreignTable != null; List<Column> foreignColumns = getSimilarColumns( origRelationship.getForeignColumns(), foreignTable); checkSameTable(foreignColumns); ImmutableRelationship relationship = new ImmutableRelationship( primaryColumns, foreignColumns); primaryTable.addRelationship(relationship); foreignTable.addRelationship(relationship); }