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);
}
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);
}
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();
}
}
});
}
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));
}
}
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();
}
Aggregations