use of org.jboss.tools.hibernate.runtime.spi.IForeignKey in project jbosstools-hibernate by jbosstools.
the class ElementsFactory method createForeingKeyConnections.
@SuppressWarnings("unchecked")
public void createForeingKeyConnections() {
// do clone cause elements could be changed during iteration!
HashMap<String, OrmShape> elementsTmp = (HashMap<String, OrmShape>) elements.clone();
Iterator<OrmShape> it = elementsTmp.values().iterator();
while (it.hasNext()) {
final OrmShape shape = it.next();
Object ormElement = shape.getOrmElement();
if (ormElement instanceof ITable) {
ITable databaseTable = (ITable) ormElement;
Iterator<IForeignKey> itFK = databaseTable.getForeignKeyIterator();
while (itFK.hasNext()) {
final IForeignKey fk = itFK.next();
ITable referencedTable = fk.getReferencedTable();
final OrmShape referencedShape = getOrCreateDatabaseTable(referencedTable);
//
Iterator<IColumn> itColumns = fk.columnIterator();
while (itColumns.hasNext()) {
IColumn col = itColumns.next();
Shape shapeColumn = shape.getChild(col);
Iterator<IColumn> itReferencedColumns = null;
if (fk.isReferenceToPrimaryKey()) {
itReferencedColumns = (Iterator<IColumn>) referencedTable.getPrimaryKey().columnIterator();
} else {
itReferencedColumns = (Iterator<IColumn>) fk.getReferencedColumns().iterator();
}
while (itReferencedColumns != null && itReferencedColumns.hasNext()) {
IColumn colReferenced = itReferencedColumns.next();
Shape shapeReferencedColumn = referencedShape.getChild(colReferenced);
if (shouldCreateConnection(shapeColumn, shapeReferencedColumn)) {
connections.add(new Connection(shapeColumn, shapeReferencedColumn));
}
}
}
}
}
}
}
use of org.jboss.tools.hibernate.runtime.spi.IForeignKey in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateForeignKey.
@Test
public void testCreateForeignKey() {
ForeignKey foreignKey = new ForeignKey();
IForeignKey facade = facadeFactory.createForeignKey(foreignKey);
Assert.assertSame(foreignKey, ((IFacade) facade).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.IForeignKey in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateForeignKey.
@Test
public void testCreateForeignKey() {
ForeignKey foreignKey = new ForeignKey();
IForeignKey facade = facadeFactory.createForeignKey(foreignKey);
Assert.assertSame(foreignKey, ((IFacade) facade).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.IForeignKey in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateForeignKey.
@Test
public void testCreateForeignKey() {
ForeignKey foreignKey = new ForeignKey();
IForeignKey facade = facadeFactory.createForeignKey(foreignKey);
Assert.assertSame(foreignKey, ((IFacade) facade).getTarget());
}
Aggregations