private void createTables ( Catalog catalog , Schema schema , SchemaDescriptor schemaDescriptor , Map < String , ColumnTypeDescriptor > columnTypes , Map < Column , ColumnDescriptor > allColumns , Set < ForeignKey > allForeignKeys , Store store ) { for ( Table table : catalog . getTables ( schema ) ) { TableDescriptor tableDescriptor = getTableDescriptor ( table , schemaDescriptor , store ) ; Map < String , ColumnDescriptor > localColumns = new HashMap <> ( ) ; for ( Column column : table . getColumns ( ) ) { ColumnDescriptor columnDescriptor = createColumnDescriptor ( column , ColumnDescriptor . class , columnTypes , store ) ; columnDescriptor . setDefaultValue ( column . getDefaultValue ( ) ) ; columnDescriptor . setGenerated ( column . isGenerated ( ) ) ; columnDescriptor . setPartOfIndex ( column . isPartOfIndex ( ) ) ; columnDescriptor . setPartOfPrimaryKey ( column . isPartOfPrimaryKey ( ) ) ; columnDescriptor . setPartOfForeignKey ( column . isPartOfForeignKey ( ) ) ; columnDescriptor . setAutoIncremented ( column . isAutoIncremented ( ) ) ; tableDescriptor . getColumns ( ) . add ( columnDescriptor ) ; localColumns . put ( column . getName ( ) , columnDescriptor ) ; allColumns . put ( column , columnDescriptor ) ; } // Primary key PrimaryKey primaryKey = table . getPrimaryKey ( ) ; if ( primaryKey != null ) { PrimaryKeyDescriptor primaryKeyDescriptor = storeIndex ( primaryKey , tableDescriptor , localColumns , PrimaryKeyDescriptor . class , PrimaryKeyOnColumnDescriptor . class , store ) ; tableDescriptor . setPrimaryKey ( primaryKeyDescriptor ) ; } // Indices for ( Index index : table . getIndices ( ) ) { IndexDescriptor indexDescriptor = storeIndex ( index , tableDescriptor , localColumns , IndexDescriptor . class , IndexOnColumnDescriptor . class , store ) ; tableDescriptor . getIndices ( ) . add ( indexDescriptor ) ; } // Trigger for ( Trigger trigger : table . getTriggers ( ) ) { TriggerDescriptor triggerDescriptor = store . create ( TriggerDescriptor . class ) ; triggerDescriptor . setName ( trigger . getName ( ) ) ; triggerDescriptor . setActionCondition ( trigger . getActionCondition ( ) ) ; triggerDescriptor . setActionOrder ( trigger . getActionOrder ( ) ) ; triggerDescriptor . setActionOrientation ( trigger . getActionOrientation ( ) . name ( ) ) ; triggerDescriptor . setActionStatement ( trigger . getActionStatement ( ) ) ; triggerDescriptor . setConditionTiming ( trigger . getConditionTiming ( ) . name ( ) ) ; triggerDescriptor . setEventManipulationTime ( trigger . getEventManipulationType ( ) . name ( ) ) ; tableDescriptor . getTriggers ( ) . add ( triggerDescriptor ) ; } allForeignKeys . addAll ( table . getForeignKeys ( ) ) ; } }
Create the table descriptors .