Search in sources :

Example 1 with BackupRecordEntry

use of org.openforis.collect.io.data.BackupDataExtractor.BackupRecordEntry in project collect by openforis.

the class DataBackupTask method backup.

private void backup(CollectRecordSummary summary, Step step) {
    Integer id = summary.getId();
    try {
        CollectRecord record = recordManager.load(survey, id, step, false);
        BackupRecordEntry recordEntry = new BackupRecordEntry(step, id);
        ZipEntry entry = new ZipEntry(recordEntry.getName());
        zipOutputStream.putNextEntry(entry);
        OutputStreamWriter writer = new OutputStreamWriter(zipOutputStream);
        dataMarshaller.write(record, writer);
        zipOutputStream.closeEntry();
    } catch (Exception e) {
        DataBackupError error = new DataBackupError(summary.getId(), summary.getRootEntityKeyValues(), summary.getStep(), e.getMessage());
        errors.add(error);
        log().error(error.toString(), e);
    }
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) ZipEntry(java.util.zip.ZipEntry) BackupRecordEntry(org.openforis.collect.io.data.BackupDataExtractor.BackupRecordEntry) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 2 with BackupRecordEntry

use of org.openforis.collect.io.data.BackupDataExtractor.BackupRecordEntry in project collect by openforis.

the class DataRestoreSummaryTask method getEntryName.

private String getEntryName(int entryId, Step step) {
    BackupRecordEntry recordEntry = new BackupRecordEntry(step, entryId, oldFormat);
    String entryName = recordEntry.getName();
    return entryName;
}
Also used : BackupRecordEntry(org.openforis.collect.io.data.BackupDataExtractor.BackupRecordEntry)

Example 3 with BackupRecordEntry

use of org.openforis.collect.io.data.BackupDataExtractor.BackupRecordEntry in project collect by openforis.

the class XMLParsingRecordProvider method getEntryName.

@Override
public String getEntryName(int entryId, Step step) {
    if (backupFileExtractor.isOldFormat()) {
        return step.getStepNumber() + "/" + entryId + ".xml";
    } else {
        BackupRecordEntry recordEntry = new BackupRecordEntry(step, entryId);
        String entryName = recordEntry.getName();
        return entryName;
    }
}
Also used : BackupRecordEntry(org.openforis.collect.io.data.BackupDataExtractor.BackupRecordEntry)

Aggregations

BackupRecordEntry (org.openforis.collect.io.data.BackupDataExtractor.BackupRecordEntry)3 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ZipEntry (java.util.zip.ZipEntry)1 CollectRecord (org.openforis.collect.model.CollectRecord)1