if ( table instanceof TableDef ) {
if ( TRUE.equals( getPersistenceAttribute( mf, IS_VIEWONLY ))) continue;
}
// Create the column definition
ColumnDef colDef = new ColumnDef( col, getSQLType( mf ));
// Set the length of the varchar field
colDef.setLength( mf.getLength() );
// Is it a primary key?
String key = getPersistenceAttribute( mf , ObjectManager.IS_KEY );
if ( key != null && key.equalsIgnoreCase( TRUE )) {
colDef.setPrimaryKey( true );
}
// Load extra values if this is a Table Definition
if ( table instanceof TableDef ) {
// Is it an auto column?
String auto = getAutoGenerated( mf );
if ( auto != null ) {
if ( AUTO_ID.equals( auto )) {
colDef.setAutoType( ColumnDef.AUTO_ID );
}
else if ( ObjectManager.AUTO_CREATE.equals( auto )) {
colDef.setAutoType( ColumnDef.AUTO_DATE_CREATE );
}
else if ( ObjectManager.AUTO_UPDATE.equals( auto )) {
colDef.setAutoType( ColumnDef.AUTO_DATE_UPDATE );
}
}
// Get the sequence if it is defined
String seq = getSequenceRef( mf );
if ( seq != null ) {
int start = getSequenceStart( mf );
SequenceDef seqDef = new SequenceDef( NameDef.parseName( seq ), start, 1 );
colDef.setSequence( seqDef );
}
// Set if it is unique
colDef.setUnique( isUnique( mf ));
// Check if the column is an index
if ( isIndex( mf )) {
String name = table.getNameDef().getName() + "_" + col + "_index";