Search in sources :

Example 11 with ParseRecordResult

use of org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult in project collect by openforis.

the class BackupDataExtractor method nextRecord.

public ParseRecordResult nextRecord() throws Exception {
    checkInitialized();
    ParseRecordResult result = null;
    ZipEntry zipEntry = nextDataEntry();
    while (zipEntry != null) {
        String entryName = zipEntry.getName();
        if (BackupRecordEntry.isValidRecordEntry(zipEntry, oldFormat)) {
            BackupRecordEntry recordEntry = BackupRecordEntry.parse(entryName, oldFormat);
            if (isToBeExported(recordEntry)) {
                InputStream is = zipFile.getInputStream(zipEntry);
                return parse(is);
            } else {
                zipEntry = nextDataEntry();
            }
        }
    }
    return result;
}
Also used : InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) ParseRecordResult(org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult)

Example 12 with ParseRecordResult

use of org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult in project collect by openforis.

the class DataMarshallerIntegrationTest method testMarshal.

@Test
public void testMarshal() throws Exception {
    // LOAD MODEL
    CollectSurvey survey = loadSurvey();
    CollectRecord record = createTestRecord(survey);
    StringWriter out = new StringWriter();
    dataMarshaller.write(record, out);
    String xml = out.toString();
    assertNotNull(xml);
    ParseRecordResult parseRecordResult = parseRecord(survey, xml);
    assertNotNull(parseRecordResult);
    CollectRecord record2 = parseRecordResult.getRecord();
    assertNotNull(record2);
    assertEquals(record, record2);
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) StringWriter(java.io.StringWriter) CollectSurvey(org.openforis.collect.model.CollectSurvey) ParseRecordResult(org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Aggregations

ParseRecordResult (org.openforis.collect.persistence.xml.DataUnmarshaller.ParseRecordResult)12 CollectRecord (org.openforis.collect.model.CollectRecord)7 InputStream (java.io.InputStream)5 InputStreamReader (java.io.InputStreamReader)4 Step (org.openforis.collect.model.CollectRecord.Step)3 MainStep (org.openforis.collect.io.data.DataImportState.MainStep)2 SubStep (org.openforis.collect.io.data.DataImportState.SubStep)2 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)2 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 NodeUnmarshallingError (org.openforis.collect.persistence.xml.NodeUnmarshallingError)2 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ZipEntry (java.util.zip.ZipEntry)1 Test (org.junit.Test)1 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)1 RecordStep (org.openforis.collect.event.RecordStep)1