Search in sources :

Example 1 with CollectSurveyIdmlBinder

use of org.openforis.collect.persistence.xml.CollectSurveyIdmlBinder in project collect by openforis.

the class CollectRelationalTest method loadSurvey.

@BeforeClass
public static void loadSurvey() throws IdmlParseException, FileNotFoundException {
    InputStream is = ClassLoader.getSystemResourceAsStream("test.idm.xml");
    // InputStream is = new FileInputStream("/home/gino/workspace/of/idm/idm-test/src/main/resources/test.idm.xml");
    // InputStream is = new FileInputStream("D:/data/workspace/idm/idm-test/src/main/resources/test.idm.xml");
    // InputStream is = new FileInputStream("/home/gino/workspace/faofin/tz/naforma-idm/tanzania-naforma.idm.xml");
    CollectSurveyContext ctx = new CollectSurveyContext(new ExpressionFactory(), null);
    // DefaultSurveyContext ctx = new DefaultSurveyContext();
    CollectSurveyIdmlBinder binder = new CollectSurveyIdmlBinder(ctx);
    survey = (CollectSurvey) binder.unmarshal(is);
}
Also used : ExpressionFactory(org.openforis.idm.model.expression.ExpressionFactory) InputStream(java.io.InputStream) CollectSurveyContext(org.openforis.collect.model.CollectSurveyContext) CollectSurveyIdmlBinder(org.openforis.collect.persistence.xml.CollectSurveyIdmlBinder) BeforeClass(org.junit.BeforeClass)

Example 2 with CollectSurveyIdmlBinder

use of org.openforis.collect.persistence.xml.CollectSurveyIdmlBinder in project collect by openforis.

the class CollectEarthProjectFileCreatorImpl method createPlacemark.

private File createPlacemark(CollectSurvey survey) throws IOException {
    File file = File.createTempFile("collect-earth-placemark.idm", ".xml");
    FileOutputStream os = new FileOutputStream(file);
    CollectSurveyIdmlBinder binder = new CollectSurveyIdmlBinder(survey.getContext());
    try {
        binder.marshal(survey, os, true, true, false);
    } finally {
        IOUtils.closeQuietly(os);
    }
    return file;
}
Also used : FileOutputStream(java.io.FileOutputStream) CollectSurveyIdmlBinder(org.openforis.collect.persistence.xml.CollectSurveyIdmlBinder) SurveyFile(org.openforis.collect.model.SurveyFile) ZipFile(net.lingala.zip4j.core.ZipFile) File(java.io.File)

Aggregations

CollectSurveyIdmlBinder (org.openforis.collect.persistence.xml.CollectSurveyIdmlBinder)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 ZipFile (net.lingala.zip4j.core.ZipFile)1 BeforeClass (org.junit.BeforeClass)1 CollectSurveyContext (org.openforis.collect.model.CollectSurveyContext)1 SurveyFile (org.openforis.collect.model.SurveyFile)1 ExpressionFactory (org.openforis.idm.model.expression.ExpressionFactory)1