Search in sources :

Example 1 with FileErrorItem

use of org.openforis.collect.io.data.DataImportSummary.FileErrorItem in project collect by openforis.

the class XMLDataImportProcess method createSummary.

private DataImportSummary createSummary(Map<String, List<NodeUnmarshallingError>> packagedSkippedFileErrors, String surveyName, Map<Step, Integer> totalPerStep, Map<Integer, CollectRecord> packagedRecords, Map<Integer, List<Step>> packagedStepsPerRecord, Map<Integer, CollectRecordSummary> conflictingPackagedRecords, Map<Integer, Map<Step, List<NodeUnmarshallingError>>> warnings) {
    DataImportSummary summary = new DataImportSummary();
    summary.setSurveyName(surveyName);
    List<DataImportSummaryItem> recordsToImport = new ArrayList<DataImportSummaryItem>();
    Set<Integer> entryIds = packagedRecords.keySet();
    for (Integer entryId : entryIds) {
        CollectRecord record = packagedRecords.get(entryId);
        if (!conflictingPackagedRecords.containsKey(entryId)) {
            List<Step> steps = packagedStepsPerRecord.get(entryId);
            DataImportSummaryItem item = new DataImportSummaryItem(entryId, CollectRecordSummary.fromRecord(record), steps);
            item.setWarnings(warnings.get(entryId));
            recordsToImport.add(item);
        }
    }
    List<DataImportSummaryItem> conflictingRecordItems = new ArrayList<DataImportSummaryItem>();
    Set<Integer> conflictingEntryIds = conflictingPackagedRecords.keySet();
    for (Integer entryId : conflictingEntryIds) {
        CollectRecord record = packagedRecords.get(entryId);
        CollectRecordSummary conflictingRecord = conflictingPackagedRecords.get(entryId);
        List<Step> steps = packagedStepsPerRecord.get(entryId);
        DataImportSummaryItem item = new DataImportSummaryItem(entryId, CollectRecordSummary.fromRecord(record), steps, conflictingRecord);
        item.setWarnings(warnings.get(entryId));
        conflictingRecordItems.add(item);
    }
    summary.setRecordsToImport(recordsToImport);
    summary.setConflictingRecords(conflictingRecordItems);
    List<FileErrorItem> packagedSkippedFileErrorsList = new ArrayList<DataImportSummary.FileErrorItem>();
    Set<String> skippedFileNames = packagedSkippedFileErrors.keySet();
    for (String fileName : skippedFileNames) {
        List<NodeUnmarshallingError> nodeErrors = packagedSkippedFileErrors.get(fileName);
        FileErrorItem fileErrorItem = new FileErrorItem(fileName, nodeErrors);
        packagedSkippedFileErrorsList.add(fileErrorItem);
    }
    summary.setSkippedFileErrors(packagedSkippedFileErrorsList);
    summary.setTotalPerStep(totalPerStep);
    return summary;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) NodeUnmarshallingError(org.openforis.collect.persistence.xml.NodeUnmarshallingError) ArrayList(java.util.ArrayList) FileErrorItem(org.openforis.collect.io.data.DataImportSummary.FileErrorItem) 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)

Example 2 with FileErrorItem

use of org.openforis.collect.io.data.DataImportSummary.FileErrorItem in project collect by openforis.

the class DataRestoreSummaryTask method createSkippedFileErrorItems.

private List<FileErrorItem> createSkippedFileErrorItems() {
    List<FileErrorItem> errorItems = new ArrayList<FileErrorItem>();
    Set<String> skippedFileNames = errorsByEntryName.keySet();
    for (String fileName : skippedFileNames) {
        List<NodeUnmarshallingError> nodeErrors = errorsByEntryName.get(fileName);
        FileErrorItem fileErrorItem = new FileErrorItem(fileName, nodeErrors);
        errorItems.add(fileErrorItem);
    }
    return errorItems;
}
Also used : NodeUnmarshallingError(org.openforis.collect.persistence.xml.NodeUnmarshallingError) FileErrorItem(org.openforis.collect.io.data.DataImportSummary.FileErrorItem) ArrayList(java.util.ArrayList)

Example 3 with FileErrorItem

use of org.openforis.collect.io.data.DataImportSummary.FileErrorItem in project collect by openforis.

the class FileUnmarshallingErrorProxy method fromList.

public static List<FileUnmarshallingErrorProxy> fromList(List<FileErrorItem> list) {
    List<FileUnmarshallingErrorProxy> result = new ArrayList<FileUnmarshallingErrorProxy>();
    if (list != null) {
        for (FileErrorItem item : list) {
            FileUnmarshallingErrorProxy proxy = new FileUnmarshallingErrorProxy(item);
            result.add(proxy);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) FileErrorItem(org.openforis.collect.io.data.DataImportSummary.FileErrorItem)

Aggregations

ArrayList (java.util.ArrayList)3 FileErrorItem (org.openforis.collect.io.data.DataImportSummary.FileErrorItem)3 NodeUnmarshallingError (org.openforis.collect.persistence.xml.NodeUnmarshallingError)2 MainStep (org.openforis.collect.io.data.DataImportState.MainStep)1 SubStep (org.openforis.collect.io.data.DataImportState.SubStep)1 CollectRecord (org.openforis.collect.model.CollectRecord)1 Step (org.openforis.collect.model.CollectRecord.Step)1 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)1