Search in sources :

Example 1 with XmlStoreConsumerVisitor

use of org.whole.lang.xml.util.XmlStoreConsumerVisitor in project whole by wholeplatform.

the class PersistenceTest method testXmlModel2Builder.

@Test
public void testXmlModel2Builder() throws ParserConfigurationException, SAXException, IOException {
    IEntity xmlModel = SaxConsumerHandler.parse(this.getClass().getResourceAsStream("persistenceTest.xwl"), "UTF-8", true);
    ModelBuilderOperation op = new ModelBuilderOperation();
    new XmlStoreConsumerVisitor(op).visit(xmlModel);
    PrettyPrinterOperation.prettyPrint(op.wGetResult());
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IEntity(org.whole.lang.model.IEntity) XmlStoreConsumerVisitor(org.whole.lang.xml.util.XmlStoreConsumerVisitor) Test(org.junit.Test)

Example 2 with XmlStoreConsumerVisitor

use of org.whole.lang.xml.util.XmlStoreConsumerVisitor in project whole by wholeplatform.

the class PersistenceTest method xmlRoundtrip.

private IEntity xmlRoundtrip(IEntity model1) {
    ModelBuilderOperation op = new ModelBuilderOperation();
    XmlStoreProducerBuilderOperation xmlOp = new XmlStoreProducerBuilderOperation(op);
    ((XmlStoreProducerBuilder) xmlOp.wGetBuilder()).buildStartDocument();
    new ModelTemplate(model1).apply(xmlOp);
    ((XmlStoreProducerBuilder) xmlOp.wGetBuilder()).buildEndDocument();
    IEntity xmlModel = op.wGetResult();
    op = new ModelBuilderOperation();
    new XmlStoreConsumerVisitor(op).visit(xmlModel);
    IEntity model2 = op.wGetResult();
    return model2;
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) ModelTemplate(org.whole.lang.templates.ModelTemplate) XmlStoreProducerBuilder(org.whole.lang.xml.util.XmlStoreProducerBuilder) IEntity(org.whole.lang.model.IEntity) XmlStoreProducerBuilderOperation(org.whole.lang.xml.util.XmlStoreProducerBuilderOperation) XmlStoreConsumerVisitor(org.whole.lang.xml.util.XmlStoreConsumerVisitor)

Example 3 with XmlStoreConsumerVisitor

use of org.whole.lang.xml.util.XmlStoreConsumerVisitor in project whole by wholeplatform.

the class XmlBuilderPersistenceKit method doReadModel.

protected IEntity doReadModel(IPersistenceProvider pp) throws Exception {
    IEntity xmlModel = SaxConsumerHandler.parse(pp.getInputStream(), pp.getEncoding());
    ModelBuilderOperation op = new ModelBuilderOperation().withBindings(pp.getBindings());
    new XmlStoreConsumerVisitor(op).visit(xmlModel);
    return ReflectionFactory.makeRootEntity(op.wGetResult());
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IEntity(org.whole.lang.model.IEntity) XmlStoreConsumerVisitor(org.whole.lang.xml.util.XmlStoreConsumerVisitor)

Aggregations

ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)3 IEntity (org.whole.lang.model.IEntity)3 XmlStoreConsumerVisitor (org.whole.lang.xml.util.XmlStoreConsumerVisitor)3 Test (org.junit.Test)1 ModelTemplate (org.whole.lang.templates.ModelTemplate)1 XmlStoreProducerBuilder (org.whole.lang.xml.util.XmlStoreProducerBuilder)1 XmlStoreProducerBuilderOperation (org.whole.lang.xml.util.XmlStoreProducerBuilderOperation)1