Search in sources :

Example 1 with RecordStep

use of org.openforis.collect.event.RecordStep in project collect by openforis.

the class RDBReportingRepositories method createRepositories.

@Override
public void createRepositories(String surveyName, String preferredLanguage, ProgressListener progressListener) {
    initializeRelationalSchemaDefinition(surveyName);
    ProcessProgressListener processProgressListener = new ProcessProgressListener(RecordStep.values().length);
    for (RecordStep step : RecordStep.values()) {
        try {
            createRepository(surveyName, step, preferredLanguage, new ProcessStepProgressListener(processProgressListener, progressListener));
            processProgressListener.stepCompleted();
        } catch (CollectRdbException e) {
            LOG.error("Error generating RDB for survey " + surveyName, e);
        }
    }
    updateMondrianSchemaFile(surveyName, preferredLanguage);
    writeSaikuDatasources(surveyName);
}
Also used : RecordStep(org.openforis.collect.event.RecordStep) ProcessStepProgressListener(org.openforis.concurrency.ProcessStepProgressListener) ProcessProgressListener(org.openforis.concurrency.ProcessProgressListener)

Example 2 with RecordStep

use of org.openforis.collect.event.RecordStep in project collect by openforis.

the class RDBReportingRepositories method deleteRepositories.

@Override
public void deleteRepositories(String surveyName) {
    for (RecordStep step : RecordStep.values()) {
        localRDBStorageManager.deleteRDBFile(surveyName, step);
    }
    relationalSchemaDefinitionBySurvey.remove(surveyName);
    mondrianSchemaStorageManager.deleteSchemaFile(surveyName);
    deleteSaikuDatasources(surveyName);
}
Also used : RecordStep(org.openforis.collect.event.RecordStep)

Example 3 with RecordStep

use of org.openforis.collect.event.RecordStep 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();
            }
        }
    });
}
Also used : RecordStep(org.openforis.collect.event.RecordStep) Connection(java.sql.Connection) RecordEvent(org.openforis.collect.event.RecordEvent) CollectSurvey(org.openforis.collect.model.CollectSurvey) RelationalSchema(org.openforis.collect.relational.model.RelationalSchema)

Example 4 with RecordStep

use of org.openforis.collect.event.RecordStep in project collect by openforis.

the class DataRestoreTask method reportRecordParsingErrors.

private void reportRecordParsingErrors(int entryId, RecordParsingException e) {
    Step recordStep = e.getRecordStep();
    String entryName = recordProvider.getEntryName(entryId, recordStep);
    ParseRecordResult parseResult = e.getParseRecordResult();
    for (NodeUnmarshallingError failure : parseResult.getFailures()) {
        errors.add(new RecordImportError(entryId, entryName, recordStep, String.format("%s : %s", failure.getPath(), failure.getMessage()), Level.ERROR));
    }
    for (NodeUnmarshallingError warn : parseResult.getWarnings()) {
        errors.add(new RecordImportError(entryId, entryName, recordStep, String.format("%s : %s", warn.getPath(), warn.getMessage()), Level.WARNING));
    }
}
Also used : NodeUnmarshallingError(org.openforis.collect.persistence.xml.NodeUnmarshallingError) Step(org.openforis.collect.model.CollectRecord.Step) RecordStep(org.openforis.collect.event.RecordStep) ParseRecordResult(org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult)

Example 5 with RecordStep

use of org.openforis.collect.event.RecordStep in project collect by openforis.

the class RDBReportingRepositories method insertRecords.

private void insertRecords(String surveyName, RecordStep recordStep, RelationalSchema targetSchema, Connection targetConn, ProgressListener progressListener) throws CollectRdbException {
    ProcessProgressListener processProgressListener = new ProcessProgressListener(2);
    CollectSurvey survey = surveyManager.get(surveyName);
    DatabaseExporter databaseUpdater = createRDBUpdater(targetSchema, targetConn);
    databaseUpdater.insertReferenceData(new ProcessStepProgressListener(processProgressListener, progressListener));
    processProgressListener.stepCompleted();
    RecordFilter recordFilter = new RecordFilter(survey);
    Step step = Step.fromRecordStep(recordStep);
    recordFilter.setStepGreaterOrEqual(step);
    List<CollectRecordSummary> summaries = recordManager.loadSummaries(recordFilter);
    ProcessStepProgressListener recordInsertProcessListener = new ProcessStepProgressListener(processProgressListener, progressListener);
    recordInsertProcessListener.progressMade(new Progress(0, summaries.size()));
    long processedRecords = 0;
    for (CollectRecordSummary summary : summaries) {
        CollectRecord record = recordManager.load(survey, summary.getId(), step, false);
        databaseUpdater.insertRecordData(record, ProgressListener.NULL_PROGRESS_LISTENER);
        processedRecords++;
        recordInsertProcessListener.progressMade(new Progress(processedRecords, summaries.size()));
    }
    IOUtils.closeQuietly(databaseUpdater);
    processProgressListener.stepCompleted();
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) Progress(org.openforis.concurrency.Progress) JooqDatabaseExporter(org.openforis.collect.relational.jooq.JooqDatabaseExporter) CollectRecordSummary(org.openforis.collect.model.CollectRecordSummary) ProcessStepProgressListener(org.openforis.concurrency.ProcessStepProgressListener) ProcessProgressListener(org.openforis.concurrency.ProcessProgressListener) RecordStep(org.openforis.collect.event.RecordStep) Step(org.openforis.collect.model.CollectRecord.Step) CollectSurvey(org.openforis.collect.model.CollectSurvey) RecordFilter(org.openforis.collect.model.RecordFilter)

Aggregations

RecordStep (org.openforis.collect.event.RecordStep)5 Step (org.openforis.collect.model.CollectRecord.Step)2 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 ProcessProgressListener (org.openforis.concurrency.ProcessProgressListener)2 ProcessStepProgressListener (org.openforis.concurrency.ProcessStepProgressListener)2 Connection (java.sql.Connection)1 RecordEvent (org.openforis.collect.event.RecordEvent)1 CollectRecord (org.openforis.collect.model.CollectRecord)1 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)1 RecordFilter (org.openforis.collect.model.RecordFilter)1 ParseRecordResult (org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult)1 NodeUnmarshallingError (org.openforis.collect.persistence.xml.NodeUnmarshallingError)1 JooqDatabaseExporter (org.openforis.collect.relational.jooq.JooqDatabaseExporter)1 RelationalSchema (org.openforis.collect.relational.model.RelationalSchema)1 Progress (org.openforis.concurrency.Progress)1