Search in sources :

Example 1 with SurveyMarshaller

use of org.openforis.idm.metamodel.xml.internal.marshal.SurveyMarshaller in project collect by openforis.

the class SurveyIdmlBinder method marshal.

public void marshal(Survey survey, Writer wr, boolean marshalCodeLists, boolean marshalExternalCodeLists, boolean marshalPersistedCodeLists) throws IOException {
    SurveyMarshaller ser = new SurveyMarshaller(this, new SurveyMarshalParameters(marshalCodeLists, marshalPersistedCodeLists, marshalExternalCodeLists, survey.getDefaultLanguage()));
    ser.marshal(survey, wr, UTF_8);
}
Also used : SurveyMarshaller(org.openforis.idm.metamodel.xml.internal.marshal.SurveyMarshaller) SurveyMarshalParameters(org.openforis.idm.metamodel.xml.internal.marshal.SurveyMarshaller.SurveyMarshalParameters)

Example 2 with SurveyMarshaller

use of org.openforis.idm.metamodel.xml.internal.marshal.SurveyMarshaller in project collect by openforis.

the class SurveyIdmlBinder method marshal.

public void marshal(Survey survey, OutputStream os, SurveyMarshalParameters parameters) throws IOException {
    SurveyMarshaller ser = new SurveyMarshaller(this, parameters);
    ser.marshal(survey, os, UTF_8);
}
Also used : SurveyMarshaller(org.openforis.idm.metamodel.xml.internal.marshal.SurveyMarshaller)

Example 3 with SurveyMarshaller

use of org.openforis.idm.metamodel.xml.internal.marshal.SurveyMarshaller 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)

Aggregations

SurveyMarshaller (org.openforis.idm.metamodel.xml.internal.marshal.SurveyMarshaller)3 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 URL (java.net.URL)1 Test (org.junit.Test)1 SurveyIdmlBinder (org.openforis.idm.metamodel.xml.SurveyIdmlBinder)1 SurveyMarshalParameters (org.openforis.idm.metamodel.xml.internal.marshal.SurveyMarshaller.SurveyMarshalParameters)1