use of org.openforis.collect.persistence.xml.DataUnmarshaller in project collect by openforis.
the class XMLDataImportProcess method createDataImportSummary.
private void createDataImportSummary() throws DataImportExeption {
try {
state.setSubStep(SubStep.RUNNING);
summary = null;
packagedSurvey = extractPackagedSurvey();
existingSurvey = loadExistingSurvey();
validatePackagedSurvey();
if (existingSurvey == null) {
dataUnmarshaller = new DataUnmarshaller(packagedSurvey);
} else {
dataUnmarshaller = new DataUnmarshaller(existingSurvey, packagedSurvey);
}
Map<Step, Integer> totalPerStep = new HashMap<CollectRecord.Step, Integer>();
for (Step step : Step.values()) {
totalPerStep.put(step, 0);
}
Map<Integer, CollectRecord> packagedRecords = new HashMap<Integer, CollectRecord>();
Map<Integer, List<Step>> packagedStepsPerRecord = new HashMap<Integer, List<Step>>();
Map<String, List<NodeUnmarshallingError>> packagedSkippedFileErrors = new HashMap<String, List<NodeUnmarshallingError>>();
Map<Integer, CollectRecordSummary> conflictingPackagedRecords = new HashMap<Integer, CollectRecordSummary>();
Map<Integer, Map<Step, List<NodeUnmarshallingError>>> warnings = new HashMap<Integer, Map<Step, List<NodeUnmarshallingError>>>();
state.setTotal(backupFileExtractor.size());
state.resetCount();
List<String> entryNames = backupFileExtractor.getEntryNames();
for (String entryName : entryNames) {
if (state.getSubStep() != DataImportState.SubStep.RUNNING) {
break;
}
if (!RecordEntry.isValidRecordEntry(entryName)) {
continue;
}
createSummaryForEntry(entryName, packagedSkippedFileErrors, packagedRecords, packagedStepsPerRecord, totalPerStep, conflictingPackagedRecords, warnings);
}
if (state.getSubStep() == SubStep.RUNNING) {
String oldSurveyName = existingSurvey == null ? null : existingSurvey.getName();
summary = createSummary(packagedSkippedFileErrors, oldSurveyName, totalPerStep, packagedRecords, packagedStepsPerRecord, conflictingPackagedRecords, warnings);
state.setSubStep(DataImportState.SubStep.COMPLETE);
}
includesRecordFiles = backupFileExtractor.isIncludingRecordFiles();
} catch (Exception e) {
state.setSubStep(SubStep.ERROR);
state.setErrorMessage(e.getMessage());
LOG.error(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(backupFileExtractor);
}
}
use of org.openforis.collect.persistence.xml.DataUnmarshaller in project collect by openforis.
the class DataMarshallerIntegrationTest method parseRecord.
private ParseRecordResult parseRecord(CollectSurvey survey, String xml) throws IOException, DataUnmarshallerException {
DataUnmarshaller dataUnmarshaller = new DataUnmarshaller(survey);
StringReader reader = new StringReader(xml);
ParseRecordResult result = dataUnmarshaller.parse(reader);
return result;
}
use of org.openforis.collect.persistence.xml.DataUnmarshaller in project collect by openforis.
the class XMLParsingRecordProvider method init.
@Override
public void init(ProgressListener progressListener) throws Exception {
this.backupFileExtractor = new NewBackupFileExtractor(file);
this.backupFileExtractor.init(progressListener);
this.dataUnmarshaller = new DataUnmarshaller(existingSurvey == null ? packagedSurvey : existingSurvey, packagedSurvey);
this.dataUnmarshaller.setRecordValidationEnabled(validateRecords);
this.dataUnmarshaller.setIgnoreDuplicateRecordKeyValidationErrors(ignoreDuplicateRecordKeyValidationErrors);
this.dataUnmarshaller.setRecordApplicationVersion(backupFileExtractor.getInfo().getCollectVersion());
this.recordUpdater = new RecordUpdater();
this.recordUpdater.setValidateAfterUpdate(validateRecords);
initializeRecordUserLoader();
}
use of org.openforis.collect.persistence.xml.DataUnmarshaller in project collect by openforis.
the class BackupDataExtractor method init.
public void init() throws ZipException, IOException {
this.fileExtractor = new BackupFileExtractor(zipFile);
this.oldFormat = this.fileExtractor.isOldFormat();
this.dataUnmarshaller = new DataUnmarshaller(survey);
this.zipEntries = zipFile.entries();
this.initialized = true;
}
Aggregations