@Override public boolean equals(Object object) { return object instanceof Table && equals((Table) object); }
private boolean propertyIteratorContainsColumn(Iterator propertyIterator, Column column) { for ( Iterator it = propertyIterator; it.hasNext(); ) { final Property property = (Property) it.next(); for ( Iterator<Selectable> selectableIterator = property.getColumnIterator(); selectableIterator.hasNext(); ) { final Selectable selectable = selectableIterator.next(); if ( column.equals( selectable ) ) { final Column iteratedColumn = (Column) selectable; if ( column.getValue().getTable().equals( iteratedColumn.getValue().getTable() ) ) { return true; } } } } return false; }
public void addProperty(Property prop, Ejb3Column[] columns, XClass declaringClass) { //Ejb3Column.checkPropertyConsistency( ); //already called earlier /* * Check table matches between the component and the columns * if not, change the component table if no properties are set * if a property is set already the core cannot support that */ if (columns != null) { Table table = columns[0].getTable(); if ( !table.equals( component.getTable() ) ) { if ( component.getPropertySpan() == 0 ) { component.setTable( table ); } else { throw new AnnotationException( "A component cannot hold properties split into 2 different tables: " + this.getPath() ); } } } addProperty( prop, declaringClass ); }
public static void checkPropertyConsistency(Ejb3Column[] columns, String propertyName) { int nbrOfColumns = columns.length; if ( nbrOfColumns > 1 ) { for (int currentIndex = 1; currentIndex < nbrOfColumns; currentIndex++) { if (columns[currentIndex].isFormula() || columns[currentIndex - 1].isFormula()) { continue; } if ( columns[currentIndex].isInsertable() != columns[currentIndex - 1].isInsertable() ) { throw new AnnotationException( "Mixing insertable and non insertable columns in a property is not allowed: " + propertyName ); } if ( columns[currentIndex].isNullable() != columns[currentIndex - 1].isNullable() ) { throw new AnnotationException( "Mixing nullable and non nullable columns in a property is not allowed: " + propertyName ); } if ( columns[currentIndex].isUpdatable() != columns[currentIndex - 1].isUpdatable() ) { throw new AnnotationException( "Mixing updatable and non updatable columns in a property is not allowed: " + propertyName ); } if ( !columns[currentIndex].getTable().equals( columns[currentIndex - 1].getTable() ) ) { throw new AnnotationException( "Mixing different tables in a property is not allowed: " + propertyName ); } } } }
@Override public boolean equals(Object object) { return object instanceof Table && equals( (Table) object ); }
/** return true if this foreignkey is the only reference from this table to the same foreign table */ private boolean isUniqueReference(ForeignKey foreignKey) { Iterator<?> foreignKeyIterator = foreignKey.getTable().getForeignKeyIterator(); while ( foreignKeyIterator.hasNext() ) { ForeignKey element = (ForeignKey) foreignKeyIterator.next(); if(element!=foreignKey && element.getReferencedTable().equals(foreignKey.getReferencedTable())) { return false; } } return true; }
/** return true if this foreignkey is the only reference from this table to the same foreign table */ private boolean isUniqueReference(ForeignKey foreignKey) { Iterator<?> foreignKeyIterator = foreignKey.getTable().getForeignKeyIterator(); while ( foreignKeyIterator.hasNext() ) { ForeignKey element = (ForeignKey) foreignKeyIterator.next(); if(element!=foreignKey && element.getReferencedTable().equals(foreignKey.getReferencedTable())) { return false; } } return true; }