Search in sources :

Example 6 with Table

use of liquibase.database.structure.Table in project collect by openforis.

the class IdmDatabaseSnapshotBuilder method createCodeListTables.

// private void createDataTable(EntityDefinition defn)  throws DatabaseException {
// Set<Table> tables = snapshot.getTables();
// 
// // Tail recursion so that leaf tables are created first; required for relations
// List<NodeDefinition> childDefns = ((EntityDefinition) defn).getChildDefinitions();
// for (NodeDefinition child : childDefns) {
// if ( child instanceof EntityDefinition ) {
// createDataTable((EntityDefinition) child);
// }
// }
// 
// IdmDataTableBuilder dtb = new IdmDataTableBuilder(defn);
// dtb.setTablePrefix(tablePrefix);
// dtb.setTableSuffix(dataTableSuffix);
// Table table = dtb.toTable();
// 
// if ( tables.contains(table) ) {
// throw new DatabaseException("Duplicate table name '"+table.getName()+"' for "+defn.getPath());
// }
// 
// tables.add(table);
// }
// TODO hierarchical code lists as multiple tables
private void createCodeListTables() throws DatabaseException {
    List<CodeList> lists = survey.getCodeLists();
    for (CodeList list : lists) {
        IdmCodeListTableBuilder tb = new IdmCodeListTableBuilder();
        tb.setList(list);
        tb.setTablePrefix(tablePrefix);
        tb.setTableSuffix(codeTableSuffix);
        Table table = tb.toTable();
        if (tables.contains(table)) {
            throw new DatabaseException("Duplicate table name '" + table.getName() + "' for list " + list.getName());
        }
        tables.add(table);
    }
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) Table(liquibase.database.structure.Table) DatabaseException(liquibase.exception.DatabaseException)

Aggregations

Table (liquibase.database.structure.Table)6 Column (liquibase.database.structure.Column)2 DatabaseException (liquibase.exception.DatabaseException)2 PrimaryKeyColumn (org.openforis.collect.relational.model.PrimaryKeyColumn)2 Database (liquibase.database.Database)1 UnsupportedDatabase (liquibase.database.core.UnsupportedDatabase)1 ForeignKey (liquibase.database.structure.ForeignKey)1 Index (liquibase.database.structure.Index)1 PrimaryKey (liquibase.database.structure.PrimaryKey)1 PrimaryKeyConstraint (org.openforis.collect.relational.model.PrimaryKeyConstraint)1 ReferentialConstraint (org.openforis.collect.relational.model.ReferentialConstraint)1 UniquenessConstraint (org.openforis.collect.relational.model.UniquenessConstraint)1 CodeList (org.openforis.idm.metamodel.CodeList)1