Search in sources :

Example 1 with RelationalSchemaGenerator

use of org.openforis.collect.relational.model.RelationalSchemaGenerator in project collect by openforis.

the class Mondrian4SchemaGenerator method init.

private void init() {
    RelationalSchemaGenerator schemaGenerator = new RelationalSchemaGenerator(rdbConfig);
    rdbSchema = schemaGenerator.generateSchema(survey, survey.getName());
}
Also used : RelationalSchemaGenerator(org.openforis.collect.relational.model.RelationalSchemaGenerator)

Example 2 with RelationalSchemaGenerator

use of org.openforis.collect.relational.model.RelationalSchemaGenerator in project collect by openforis.

the class RelationalDataConverterTest method testGenerator.

@Test
public void testGenerator() throws Exception {
    RelationalSchemaGenerator rsg = new RelationalSchemaGenerator();
    RelationalSchema rs = rsg.generateSchema(survey, "archenland1");
    List<Table<?>> tables = rs.getTables();
    CollectRecord record = createTestRecord(survey, "123_456");
    Dataset data = rs.createDataset(record);
    data.print(System.out);
// TODO proper integration test
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) Table(org.openforis.collect.relational.model.Table) RelationalSchemaGenerator(org.openforis.collect.relational.model.RelationalSchemaGenerator) Dataset(org.openforis.collect.relational.model.Dataset) RelationalSchema(org.openforis.collect.relational.model.RelationalSchema) Test(org.junit.Test)

Example 3 with RelationalSchemaGenerator

use of org.openforis.collect.relational.model.RelationalSchemaGenerator in project collect by openforis.

the class RelationalSchemaGeneratorTest method testGenerator.

@Test
public void testGenerator() throws Exception {
    RelationalSchemaGenerator rsg = new RelationalSchemaGenerator();
    RelationalSchema rs = rsg.generateSchema(survey, "archenland1");
    List<Table<?>> tables = rs.getTables();
    // Debug
    for (Table<?> table : tables) {
        DataTable t = (DataTable) table;
        t.print(System.out);
    }
// TODO proper integration test
}
Also used : DataTable(org.openforis.collect.relational.model.DataTable) Table(org.openforis.collect.relational.model.Table) DataTable(org.openforis.collect.relational.model.DataTable) RelationalSchemaGenerator(org.openforis.collect.relational.model.RelationalSchemaGenerator) RelationalSchema(org.openforis.collect.relational.model.RelationalSchema) Test(org.junit.Test)

Example 4 with RelationalSchemaGenerator

use of org.openforis.collect.relational.model.RelationalSchemaGenerator in project collect by openforis.

the class CollectRDBPublisher method export.

public void export(String surveyName, String rootEntityName, Step step, String targetSchemaName, Connection targetConn, RelationalSchemaConfig config, ProgressListener progressListener) throws CollectRdbException {
    try {
        targetConn.setAutoCommit(false);
    } catch (SQLException e) {
    }
    try {
        CollectSurvey survey = surveyManager.get(surveyName);
        // Generate relational model
        RelationalSchemaGenerator schemaGenerator = new RelationalSchemaGenerator(config);
        RelationalSchema relationalSchema = schemaGenerator.generateSchema(survey, targetSchemaName);
        RelationalSchemaCreator relationalSchemaCreator = createRelationalSchemaCreator();
        relationalSchemaCreator.createRelationalSchema(relationalSchema, targetConn);
        relationalSchemaCreator.addConstraints(relationalSchema, targetConn);
        relationalSchemaCreator.addIndexes(relationalSchema, targetConn);
        insertData(survey, rootEntityName, step, targetConn, relationalSchema, progressListener);
        targetConn.commit();
        if (LOG.isInfoEnabled()) {
            LOG.info("RDB generation completed");
        }
    } catch (Exception e) {
        try {
            targetConn.rollback();
        } catch (SQLException e1) {
        }
        throw new RuntimeException(e);
    }
}
Also used : SQLException(java.sql.SQLException) RelationalSchemaGenerator(org.openforis.collect.relational.model.RelationalSchemaGenerator) JooqRelationalSchemaCreator(org.openforis.collect.relational.jooq.JooqRelationalSchemaCreator) CollectSurvey(org.openforis.collect.model.CollectSurvey) RelationalSchema(org.openforis.collect.relational.model.RelationalSchema) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Example 5 with RelationalSchemaGenerator

use of org.openforis.collect.relational.model.RelationalSchemaGenerator in project collect by openforis.

the class NewMondrianSchemaGenerator method generateRdbSchema.

private RelationalSchema generateRdbSchema() {
    RelationalSchemaGenerator generator = new RelationalSchemaGenerator(rdbConfig);
    RelationalSchema rdbSchema = generator.generateSchema(survey, dbSchemaName);
    return rdbSchema;
}
Also used : RelationalSchemaGenerator(org.openforis.collect.relational.model.RelationalSchemaGenerator) RelationalSchema(org.openforis.collect.relational.model.RelationalSchema)

Aggregations

RelationalSchemaGenerator (org.openforis.collect.relational.model.RelationalSchemaGenerator)7 RelationalSchema (org.openforis.collect.relational.model.RelationalSchema)6 Test (org.junit.Test)2 Table (org.openforis.collect.relational.model.Table)2 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 CollectRecord (org.openforis.collect.model.CollectRecord)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 JooqRelationalSchemaCreator (org.openforis.collect.relational.jooq.JooqRelationalSchemaCreator)1 DataTable (org.openforis.collect.relational.model.DataTable)1 Dataset (org.openforis.collect.relational.model.Dataset)1