Search in sources :

Example 6 with NodeUnmarshallingError

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();
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) InputStreamReader(java.io.InputStreamReader) HashMap(java.util.HashMap) InputStream(java.io.InputStream) NodeUnmarshallingError(org.openforis.collect.persistence.xml.NodeUnmarshallingError) ArrayList(java.util.ArrayList) MainStep(org.openforis.collect.io.data.DataImportState.MainStep) SubStep(org.openforis.collect.io.data.DataImportState.SubStep) Step(org.openforis.collect.model.CollectRecord.Step) CollectRecordSummary(org.openforis.collect.model.CollectRecordSummary) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) ParseRecordResult(org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult)

Example 7 with NodeUnmarshallingError

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;
}
Also used : NodeUnmarshallingError(org.openforis.collect.persistence.xml.NodeUnmarshallingError) ArrayList(java.util.ArrayList)

Aggregations

NodeUnmarshallingError (org.openforis.collect.persistence.xml.NodeUnmarshallingError)7 ArrayList (java.util.ArrayList)6 Step (org.openforis.collect.model.CollectRecord.Step)5 List (java.util.List)3 MainStep (org.openforis.collect.io.data.DataImportState.MainStep)3 SubStep (org.openforis.collect.io.data.DataImportState.SubStep)3 CollectRecord (org.openforis.collect.model.CollectRecord)3 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 FileErrorItem (org.openforis.collect.io.data.DataImportSummary.FileErrorItem)2 ParseRecordResult (org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ZipException (java.util.zip.ZipException)1 ExternalizedProperty (org.granite.messaging.amf.io.util.externalizer.annotation.ExternalizedProperty)1 RecordStep (org.openforis.collect.event.RecordStep)1 SurveyValidationException (org.openforis.collect.manager.exception.SurveyValidationException)1 RecordPersistenceException (org.openforis.collect.persistence.RecordPersistenceException)1