use of org.openforis.collect.persistence.xml.NodeUnmarshallingError in project collect by openforis.
the class XMLDataImportProcess method createSummaryForEntry.
private void createSummaryForEntry(String entryName, Map<String, List<NodeUnmarshallingError>> packagedSkippedFileErrors, Map<Integer, CollectRecord> packagedRecords, Map<Integer, List<Step>> packagedStepsPerRecord, Map<Step, Integer> totalPerStep, Map<Integer, CollectRecordSummary> conflictingPackagedRecords, Map<Integer, Map<Step, List<NodeUnmarshallingError>>> warnings) throws IOException, DataParsingExeption {
RecordEntry recordEntry = RecordEntry.parse(entryName);
Step step = recordEntry.getStep();
InputStream is = backupFileExtractor.findEntryInputStream(entryName);
InputStreamReader reader = OpenForisIOUtils.toReader(is);
ParseRecordResult parseRecordResult = parseRecord(reader, false);
CollectRecord parsedRecord = parseRecordResult.getRecord();
if (!parseRecordResult.isSuccess()) {
List<NodeUnmarshallingError> failures = parseRecordResult.getFailures();
packagedSkippedFileErrors.put(entryName, failures);
} else if (includeRecordPredicate == null || includeRecordPredicate.evaluate(parsedRecord)) {
int entryId = recordEntry.getRecordId();
CollectRecord recordSummary = createRecordSummary(parsedRecord);
packagedRecords.put(entryId, recordSummary);
List<Step> stepsPerRecord = packagedStepsPerRecord.get(entryId);
if (stepsPerRecord == null) {
stepsPerRecord = new ArrayList<CollectRecord.Step>();
packagedStepsPerRecord.put(entryId, stepsPerRecord);
}
stepsPerRecord.add(step);
Integer totalPerStep1 = totalPerStep.get(step);
totalPerStep.put(step, totalPerStep1 + 1);
CollectRecordSummary oldRecord = findAlreadyExistingRecordSummary(parsedRecord);
if (oldRecord != null) {
conflictingPackagedRecords.put(entryId, oldRecord);
}
if (parseRecordResult.hasWarnings()) {
Map<Step, List<NodeUnmarshallingError>> warningsPerEntry = warnings.get(entryId);
if (warningsPerEntry == null) {
warningsPerEntry = new HashMap<CollectRecord.Step, List<NodeUnmarshallingError>>();
warnings.put(entryId, warningsPerEntry);
}
warningsPerEntry.put(step, parseRecordResult.getWarnings());
}
}
state.incrementCount();
}
use of org.openforis.collect.persistence.xml.NodeUnmarshallingError in project collect by openforis.
the class NodeUnmarshallingErrorProxy method fromList.
public static List<NodeUnmarshallingErrorProxy> fromList(List<NodeUnmarshallingError> list) {
List<NodeUnmarshallingErrorProxy> result = new ArrayList<NodeUnmarshallingErrorProxy>();
if (list != null) {
for (NodeUnmarshallingError nodeErrorItem : list) {
NodeUnmarshallingErrorProxy proxy = new NodeUnmarshallingErrorProxy(nodeErrorItem);
result.add(proxy);
}
}
return result;
}
Aggregations