use of org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult in project collect by openforis.
the class XMLDataImportProcess method parseRecord.
private ParseRecordResult parseRecord(Reader reader, boolean validateAndLoadReferences) throws IOException {
dataUnmarshaller.setRecordValidationEnabled(validateAndLoadReferences);
ParseRecordResult result = dataUnmarshaller.parse(reader);
if (result.isSuccess()) {
CollectRecord record = result.getRecord();
if (validateAndLoadReferences) {
recordUserLoader.adjustUserReferences(record);
}
}
return result;
}
use of org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult in project collect by openforis.
the class XMLParsingRecordProvider method provideRecordParsingResult.
@Override
public ParseRecordResult provideRecordParsingResult(int entryId, Step step) throws IOException {
String entryName = getEntryName(entryId, step);
InputStream entryIS = backupFileExtractor.findEntryInputStream(entryName);
if (entryIS == null) {
return null;
}
InputStreamReader reader = OpenForisIOUtils.toReader(entryIS);
ParseRecordResult parseRecordResult = parseRecord(reader, step);
if (parseRecordResult.isSuccess()) {
CollectRecord record = parseRecordResult.getRecord();
recordUserLoader.adjustUserReferences(record);
recordUpdater.initializeRecord(record);
}
return parseRecordResult;
}
use of org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult in project collect by openforis.
the class XMLParsingRecordProvider method parseRecord.
private ParseRecordResult parseRecord(Reader reader, Step step) throws IOException {
ParseRecordResult result = dataUnmarshaller.parse(reader);
if (result.isSuccess()) {
CollectRecord record = result.getRecord();
record.setStep(step);
record.setDataStep(step);
// ignore rejected information
record.setState(null);
}
return result;
}
use of org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult in project collect by openforis.
the class DataRestoreSummaryTask method createSummaryForEntry.
private void createSummaryForEntry(int entryId, Step step) throws IOException, DataParsingExeption {
ParseRecordResult recordParsingResult = recordProvider.provideRecordParsingResult(entryId, step);
if (recordParsingResult == null) {
return;
}
CollectRecord parsedRecord = recordParsingResult.getRecord();
if (!recordParsingResult.isSuccess()) {
createParsingErrorSummary(entryId, step, recordParsingResult);
} else if (isToBeIncluded(parsedRecord)) {
createRecordParsedCorrectlySummary(entryId, step, recordParsingResult);
}
}
use of org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult 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));
}
}
Aggregations