Search in sources :

Example 1 with SurveyIdmlBinder

use of org.openforis.idm.metamodel.xml.SurveyIdmlBinder in project collect by openforis.

the class SurveyUnmarshaller method initSurvey.

protected void initSurvey() {
    SurveyIdmlBinder surveyBinder = getSurveyBinder();
    SurveyContext surveyContext = surveyBinder.getSurveyContext();
    this.survey = surveyContext.createSurvey();
}
Also used : SurveyIdmlBinder(org.openforis.idm.metamodel.xml.SurveyIdmlBinder) SurveyContext(org.openforis.idm.metamodel.SurveyContext)

Example 2 with SurveyIdmlBinder

use of org.openforis.idm.metamodel.xml.SurveyIdmlBinder in project collect by openforis.

the class UIOptionsMigratorTest method setUp.

@Before
public void setUp() throws IdmlParseException {
    SurveyIdmlBinder binder = new SurveyIdmlBinder(surveyContext);
    binder.addApplicationOptionsBinder(new UIOptionsBinder());
    InputStream is = ClassLoader.getSystemResourceAsStream("test.idm.xml");
    survey = (CollectSurvey) binder.unmarshal(is);
    uiOptions = survey.getUIOptions();
}
Also used : UIOptionsBinder(org.openforis.collect.persistence.xml.UIOptionsBinder) InputStream(java.io.InputStream) SurveyIdmlBinder(org.openforis.idm.metamodel.xml.SurveyIdmlBinder) Before(org.junit.Before)

Example 3 with SurveyIdmlBinder

use of org.openforis.idm.metamodel.xml.SurveyIdmlBinder in project collect by openforis.

the class AbstractTest method setUp.

@BeforeClass
public static void setUp() throws IOException, XmlParseException, IdmlParseException {
    URL idm = AbstractTest.class.getResource("/test.idm.xml");
    InputStream is = idm.openStream();
    SurveyIdmlBinder binder = new SurveyIdmlBinder(new CollectTestSurveyContext());
    survey = (CollectSurvey) binder.unmarshal(is);
}
Also used : CollectTestSurveyContext(org.openforis.collect.model.CollectTestSurveyContext) InputStream(java.io.InputStream) SurveyIdmlBinder(org.openforis.idm.metamodel.xml.SurveyIdmlBinder) URL(java.net.URL) BeforeClass(org.junit.BeforeClass)

Example 4 with SurveyIdmlBinder

use of org.openforis.idm.metamodel.xml.SurveyIdmlBinder in project collect by openforis.

the class XmlBindingIntegrationTest method roundTripMarshallingTest.

// private Log log = LogFactory.getLog(XmlBindingIntegrationTest.class);
@Test
public void roundTripMarshallingTest() throws IdmlParseException, IOException {
    URL idm = ClassLoader.getSystemResource("test.idm.xml");
    InputStream is = idm.openStream();
    SurveyContext ctx = new DefaultSurveyContext();
    SurveyIdmlBinder binder = new SurveyIdmlBinder(ctx);
    Survey survey = binder.unmarshal(is);
    StringWriter sw = new StringWriter();
    binder.marshal(survey, sw);
    String idml2 = sw.toString();
    StringReader sr = new StringReader(idml2);
    Survey survey2 = binder.unmarshal(sr);
    Assert.assertTrue(survey.deepEquals(survey2));
    // TODO
    new File("target/test/output").mkdirs();
    FileOutputStream fos = new FileOutputStream("target/test/output/marshalled.idm.xml");
    SurveyMarshaller sm = new SurveyMarshaller(binder);
    // sm.setIndent(true);
    sm.marshal(survey, fos, "UTF-8");
    fos.flush();
    fos.close();
}
Also used : StringWriter(java.io.StringWriter) InputStream(java.io.InputStream) SurveyMarshaller(org.openforis.idm.metamodel.xml.internal.marshal.SurveyMarshaller) FileOutputStream(java.io.FileOutputStream) StringReader(java.io.StringReader) SurveyIdmlBinder(org.openforis.idm.metamodel.xml.SurveyIdmlBinder) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 5 with SurveyIdmlBinder

use of org.openforis.idm.metamodel.xml.SurveyIdmlBinder in project collect by openforis.

the class AbstractTest method createTestSurvey.

protected static Survey createTestSurvey() throws IdmlParseException {
    InputStream is = AbstractTest.class.getClassLoader().getResourceAsStream("test.idm.xml");
    SurveyContext surveyContext = new TestSurveyContext();
    SurveyIdmlBinder parser = new SurveyIdmlBinder(surveyContext);
    Survey survey = parser.unmarshal(is);
    return survey;
}
Also used : Survey(org.openforis.idm.metamodel.Survey) InputStream(java.io.InputStream) TestSurveyContext(org.openforis.idm.model.TestSurveyContext) SurveyIdmlBinder(org.openforis.idm.metamodel.xml.SurveyIdmlBinder) SurveyContext(org.openforis.idm.metamodel.SurveyContext) TestSurveyContext(org.openforis.idm.model.TestSurveyContext)

Aggregations

SurveyIdmlBinder (org.openforis.idm.metamodel.xml.SurveyIdmlBinder)6 InputStream (java.io.InputStream)5 URL (java.net.URL)3 SurveyContext (org.openforis.idm.metamodel.SurveyContext)3 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1 CollectTestSurveyContext (org.openforis.collect.model.CollectTestSurveyContext)1 UIOptionsBinder (org.openforis.collect.persistence.xml.UIOptionsBinder)1 DefaultSurveyContext (org.openforis.idm.metamodel.DefaultSurveyContext)1 Survey (org.openforis.idm.metamodel.Survey)1 SurveyMarshaller (org.openforis.idm.metamodel.xml.internal.marshal.SurveyMarshaller)1 TestSurveyContext (org.openforis.idm.model.TestSurveyContext)1