Search in sources :

Example 1 with Model2XML

use of org.qi4j.library.rdf.model.Model2XML in project qi4j-sdk by Qi4j.

the class Model2XMLTest method testModel2XML.

@Test
public void testModel2XML() throws AssemblyException, TransformerException {
    Energy4Java is = new Energy4Java();
    ApplicationDescriptor model = is.newApplicationModel(new ApplicationAssembler() {

        @Override
        public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
            ApplicationAssembly assembly = applicationFactory.newApplicationAssembly();
            assembly.setName("Test application");
            LayerAssembly webLayer = assembly.layer("Web");
            LayerAssembly domainLayer = assembly.layer("Domain");
            LayerAssembly infrastructureLayer = assembly.layer("Infrastructure");
            webLayer.uses(domainLayer, infrastructureLayer);
            domainLayer.uses(infrastructureLayer);
            ModuleAssembly rest = webLayer.module("REST");
            rest.transients(TestTransient.class).visibleIn(Visibility.layer);
            domainLayer.module("Domain");
            infrastructureLayer.module("Database");
            return assembly;
        }
    });
    Document document = new Model2XML().map(model);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.setOutputProperty("indent", "yes");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    transformer.transform(new DOMSource(document), new StreamResult(System.out));
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) Model2XML(org.qi4j.library.rdf.model.Model2XML) StreamResult(javax.xml.transform.stream.StreamResult) Document(org.w3c.dom.Document) ApplicationDescriptor(org.qi4j.api.structure.ApplicationDescriptor) Test(org.junit.Test)

Aggregations

Transformer (javax.xml.transform.Transformer)1 TransformerFactory (javax.xml.transform.TransformerFactory)1 DOMSource (javax.xml.transform.dom.DOMSource)1 StreamResult (javax.xml.transform.stream.StreamResult)1 Test (org.junit.Test)1 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)1 Model2XML (org.qi4j.library.rdf.model.Model2XML)1 Document (org.w3c.dom.Document)1