@Test( expected = IllegalArgumentException.class ) public void shouldFailAddingNullReferencesColumn() throws Exception { this.foreignKey.addReferencesColumn( getTransaction(), null ); }
@Override public void addReferencesColumn( final UnitOfWork transaction, final Column newReferencesColumn ) throws KException { ArgCheck.isNotNull( transaction, "transaction" ); ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); ArgCheck.isNotNull( newReferencesColumn, "newReferencesColumn" ); String[] newValue = null; final Property property = getProperty( transaction, Constraint.TABLE_REFERENCE_REFERENCES ); final String columnId = newReferencesColumn.getRawProperty( transaction, JcrLexicon.UUID.getString() ).getStringValue( transaction ); if ( property == null ) { newValue = new String[ 1 ]; newValue[0] = columnId; } else { final String[] columnRefs = property.getStringValues( transaction ); newValue = new String[ columnRefs.length + 1 ]; System.arraycopy( columnRefs, 0, newValue, 0, columnRefs.length ); newValue[columnRefs.length] = columnId; } setProperty( transaction, Constraint.TABLE_REFERENCE_REFERENCES, ( Object[] )newValue ); }
ForeignKeyImpl extends TableConstraintImpl implements ForeignKey { @Override public void addReferencesColumn( final UnitOfWork transaction, final Column newReferencesColumn ) throws KException { ArgCheck.isNotNull( transaction, "transaction" ); ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); ArgCheck.isNotNull( newReferencesColumn, "newReferencesColumn" ); String[] newValue = null; final Property property = getProperty( transaction, Constraint.TABLE_REFERENCE_REFERENCES ); final String columnId = newReferencesColumn.getRawProperty( transaction, JcrLexicon.UUID.getString() ).getStringValue( transaction ); if ( property == null ) { newValue = new String[ 1 ]; newValue[0] = columnId; } else { final String[] columnRefs = property.getStringValues( transaction ); newValue = new String[ columnRefs.length + 1 ]; System.arraycopy( columnRefs, 0, newValue, 0, columnRefs.length ); newValue[columnRefs.length] = columnId; } setProperty( transaction, Constraint.TABLE_REFERENCE_REFERENCES, ( Object[] )newValue ); } }
ForeignKeyImpl extends TableConstraintImpl implements ForeignKey { @Override public void addReferencesColumn( final UnitOfWork transaction, final Column newReferencesColumn ) throws KException { ArgCheck.isNotNull( transaction, "transaction" ); ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); ArgCheck.isNotNull( newReferencesColumn, "newReferencesColumn" ); String[] newValue = null; final Property property = getProperty( transaction, Constraint.TABLE_REFERENCE_REFERENCES ); final String columnId = newReferencesColumn.getRawProperty( transaction, JcrLexicon.UUID.getString() ).getStringValue( transaction ); if ( property == null ) { newValue = new String[ 1 ]; newValue[0] = columnId; } else { final String[] columnRefs = property.getStringValues( transaction ); newValue = new String[ columnRefs.length + 1 ]; System.arraycopy( columnRefs, 0, newValue, 0, columnRefs.length ); newValue[columnRefs.length] = columnId; } setProperty( transaction, Constraint.TABLE_REFERENCE_REFERENCES, ( Object[] )newValue ); } ForeignKeyImpl( final UnitOfWork uow,
                           final Repository repository,
                           final String workspacePath ); }
ForeignKeyImpl extends TableConstraintImpl implements ForeignKey { @Override public void addReferencesColumn( final UnitOfWork transaction, final Column newReferencesColumn ) throws KException { ArgCheck.isNotNull( transaction, "transaction" ); ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); ArgCheck.isNotNull( newReferencesColumn, "newReferencesColumn" ); String[] newValue = null; final Property property = getProperty( transaction, Constraint.TABLE_REFERENCE_REFERENCES ); final String columnId = newReferencesColumn.getRawProperty( transaction, JcrLexicon.UUID.getString() ).getStringValue( transaction ); if ( property == null ) { newValue = new String[ 1 ]; newValue[0] = columnId; } else { final String[] columnRefs = property.getStringValues( transaction ); newValue = new String[ columnRefs.length + 1 ]; System.arraycopy( columnRefs, 0, newValue, 0, columnRefs.length ); newValue[columnRefs.length] = columnId; } setProperty( transaction, Constraint.TABLE_REFERENCE_REFERENCES, ( Object[] )newValue ); } ForeignKeyImpl( final UnitOfWork uow,
                           final Repository repository,
                           final String workspacePath ); @Override KomodoType getTypeIdentifier(UnitOfWork uow); @Override void addReferencesColumn( final UnitOfWork transaction,
                                     final Column newReferencesColumn ); @Override ConstraintType getConstraintType(); @Override Column[] getReferencesColumns( final UnitOfWork transaction ); @Override Table getReferencesTable( final UnitOfWork transaction ); @Override int getTypeId(); @Override Table getParent( final UnitOfWork transaction ); @Override void removeReferencesColumn( final UnitOfWork transaction,
                                        final Column removeReferencesColumn ); @Override void setReferencesTable( final UnitOfWork transaction,
                                    final Table newReferencesTable ); }
ForeignKeyImpl extends TableConstraintImpl implements ForeignKey { @Override public void addReferencesColumn( final UnitOfWork transaction, final Column newReferencesColumn ) throws KException { ArgCheck.isNotNull( transaction, "transaction" ); ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); ArgCheck.isNotNull( newReferencesColumn, "newReferencesColumn" ); String[] newValue = null; final Property property = getProperty( transaction, Constraint.TABLE_REFERENCE_REFERENCES ); final String columnId = newReferencesColumn.getRawProperty( transaction, JcrLexicon.UUID.getString() ).getStringValue( transaction ); if ( property == null ) { newValue = new String[ 1 ]; newValue[0] = columnId; } else { final String[] columnRefs = property.getStringValues( transaction ); newValue = new String[ columnRefs.length + 1 ]; System.arraycopy( columnRefs, 0, newValue, 0, columnRefs.length ); newValue[columnRefs.length] = columnId; } setProperty( transaction, Constraint.TABLE_REFERENCE_REFERENCES, ( Object[] )newValue ); } ForeignKeyImpl( final UnitOfWork uow,
                           final Repository repository,
                           final String workspacePath ); @Override KomodoType getTypeIdentifier(UnitOfWork uow); @Override void addReferencesColumn( final UnitOfWork transaction,
                                     final Column newReferencesColumn ); @Override ConstraintType getConstraintType(); @Override Column[] getReferencesColumns( final UnitOfWork transaction ); @Override Table getReferencesTable( final UnitOfWork transaction ); @Override int getTypeId(); @Override Table getParent( final UnitOfWork transaction ); @Override void removeReferencesColumn( final UnitOfWork transaction,
                                        final Column removeReferencesColumn ); @Override void setReferencesTable( final UnitOfWork transaction,
                                    final Table newReferencesTable );  }