Search in sources :

Example 1 with RdbDialect

use of org.openforis.collect.relational.print.RDBPrintJob.RdbDialect in project collect by openforis.

the class SQLRelationalSchemaCreator method getRdbDialect.

private RdbDialect getRdbDialect(CollectDSLContext dsl) {
    SQLDialect dialect = dsl.getDialect();
    RdbDialect rdbDialect;
    switch(dialect) {
        case SQLITE:
            rdbDialect = RdbDialect.SQLITE;
            break;
        default:
            rdbDialect = RdbDialect.STANDARD;
    }
    return rdbDialect;
}
Also used : RdbDialect(org.openforis.collect.relational.print.RDBPrintJob.RdbDialect) SQLDialect(org.jooq.SQLDialect)

Example 2 with RdbDialect

use of org.openforis.collect.relational.print.RDBPrintJob.RdbDialect in project collect by openforis.

the class SQLRelationalSchemaCreator method createRelationalSchema.

@Override
public void createRelationalSchema(RelationalSchema schema, Connection conn) {
    CollectDSLContext dsl = new CollectDSLContext(conn);
    RdbDialect rdbDialect = getRdbDialect(dsl);
    Writer writer = new StringWriter();
    SqlSchemaWriter schemaWriter = new SqlSchemaWriter(writer, schema, rdbDialect);
    try {
        schemaWriter.write();
        String sql = writer.toString();
        Statement stmt = conn.createStatement();
        stmt.executeUpdate(sql);
    } catch (Throwable e) {
        throw new RuntimeException(String.format("Error generating schema on db for rdb schema %s", schema.getName()), e);
    }
}
Also used : RdbDialect(org.openforis.collect.relational.print.RDBPrintJob.RdbDialect) StringWriter(java.io.StringWriter) Statement(java.sql.Statement) CollectDSLContext(org.openforis.collect.persistence.jooq.CollectDSLContext) StringWriter(java.io.StringWriter) Writer(java.io.Writer)

Aggregations

RdbDialect (org.openforis.collect.relational.print.RDBPrintJob.RdbDialect)2 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 Statement (java.sql.Statement)1 SQLDialect (org.jooq.SQLDialect)1 CollectDSLContext (org.openforis.collect.persistence.jooq.CollectDSLContext)1