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);
}
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);
}
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();
}
Aggregations