use of org.openforis.collect.relational.model.RelationalSchema in project collect by openforis.
the class RDBReportingRepositories method process.
@Override
public void process(final RecordTransaction recordTransaction) {
final RelationalSchema rdbSchema = getRelatedRelationalSchema(recordTransaction);
final CollectSurvey survey = (CollectSurvey) rdbSchema.getSurvey();
RecordStep step = recordTransaction.getRecordStep();
withConnection(survey.getName(), step, new Callback() {
public void execute(Connection connection) {
RDBUpdater rdbUpdater = createRDBUpdater(rdbSchema, connection);
for (RecordEvent recordEvent : recordTransaction.getEvents()) {
EventHandler handler = new EventHandler(recordEvent, rdbSchema, survey, rdbUpdater);
handler.handle();
}
}
});
}
use of org.openforis.collect.relational.model.RelationalSchema in project collect by openforis.
the class RDBReportingRepositories method createRepository.
@Override
public void createRepository(final String surveyName, final RecordStep recordStep, final String preferredLanguage, final ProgressListener progressListener) {
localRDBStorageManager.deleteRDBFile(surveyName, recordStep);
updateMondrianSchemaFile(surveyName, preferredLanguage);
if (saikuDatasourceStorageManager.isSaikuAvailable()) {
writeSaikuDatasource(surveyName, recordStep);
}
final RelationalSchema relationalSchema = getOrInitializeRelationalSchemaDefinition(surveyName);
withConnection(surveyName, recordStep, new Callback() {
public void execute(Connection connection) {
RelationalSchemaCreator relationalSchemaCreator = new JooqRelationalSchemaCreator();
relationalSchemaCreator.createRelationalSchema(relationalSchema, connection);
insertRecords(surveyName, recordStep, relationalSchema, connection, progressListener);
relationalSchemaCreator.addConstraints(relationalSchema, connection);
relationalSchemaCreator.addIndexes(relationalSchema, connection);
}
});
}
use of org.openforis.collect.relational.model.RelationalSchema 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
}
use of org.openforis.collect.relational.model.RelationalSchema 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
}
use of org.openforis.collect.relational.model.RelationalSchema 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);
}
}
Aggregations