Package org.appng.api.support
Class XmlGenerator
- java.lang.Object
-
- org.appng.api.support.XmlGenerator
-
public class XmlGenerator extends Object
Utility class for generating source XML (forAction
s andDatasource
) from a given list ofXmlGenerator.Entity
s. The generated XML will contain a basic master-detail navigation which can be used as a starting point to implement CRUD functionality. Anyhow, no Java-sourcecode (ActionProvider
s orDataProvider
s ) will be generated. This can be done for example by using custom freemarker templating.Example usage:
XmlGenerator generator = new XmlGenerator(); generator.setDatePattern("yyyy-MM-dd"); Entity entity = new Entity(Person.class, new String[] { "name", "firstName", "street", "birthDate" }); generator.generate("target/generated", "My generated person app", "messages-persons", entity);
See alsogenerate(String, String, String, Entity...)
- Author:
- Matthias Müller
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
XmlGenerator.Entity
Represents a domain object of a certain type with a number of properties
-
Constructor Summary
Constructors Constructor Description XmlGenerator()
XmlGenerator(boolean addPermissions)
Creates a new XmlGenerator
-
Method Summary
-
-
-
Constructor Detail
-
XmlGenerator
public XmlGenerator(boolean addPermissions) throws JAXBException, TransformerConfigurationException
Creates a new XmlGenerator- Parameters:
addPermissions
- ifPermissions
should be generated and used when referencingAction
s- Throws:
JAXBException
- if creating aMarshallService
failsTransformerConfigurationException
- if an error occurs while configuring theTransformerFactory
-
XmlGenerator
public XmlGenerator() throws JAXBException, TransformerConfigurationException
-
-
Method Detail
-
generate
public void generate(String outPath, String name, String dictionaryName, XmlGenerator.Entity... entities) throws Exception
Generates the source XML for the givenXmlGenerator.Entity
s. The following files will be created for eachXmlGenerator.Entity
, assuming thePerson.class
as the entities type:- conf/datasource/ds-persons.xml
- conf/action/ev-persons.xml
- conf/page/pg-persons.xml
- conf/config.xml - contains the
ApplicationRootConfig
- dictionary/<dictionaryName>.properties
- application.xml
- Parameters:
outPath
- the target folder for the files to be generatedname
- the name for theApplicationRootConfig
-file to be createddictionaryName
- the name for the dictionary file to be created (<dictionaryName>.properties)entities
- the list ofXmlGenerator.Entity
s to generate the source XML for- Throws:
Exception
- if something goes really wrong ;-)
-
generatePages
public Pages generatePages(XmlGenerator.Entity entity, Linkpanel navigation, OutputStream out) throws Exception
- Throws:
Exception
-
generateActions
public Event generateActions(Permissions permissions, XmlGenerator.Entity entity, OutputStream out) throws Exception
- Throws:
Exception
-
generateActions
public Event generateActions(Permissions permissions, XmlGenerator.Entity entity) throws Exception
- Throws:
Exception
-
generateDatasources
public Datasources generateDatasources(XmlGenerator.Entity entity, OutputStream out) throws Exception
- Throws:
Exception
-
generateDatasources
public Datasources generateDatasources(XmlGenerator.Entity entity, OutputStream out, String... properties) throws Exception
- Throws:
Exception
-
writeToOutputStream
public void writeToOutputStream(Object object, OutputStream out) throws ParserConfigurationException, JAXBException, TransformerException
-
getSingleItemDatasource
public Datasource getSingleItemDatasource(XmlGenerator.Entity entity, OutputStream out, String... properties) throws Exception
- Throws:
Exception
-
writeDictionary
public void writeDictionary(OutputStream out) throws IOException
- Throws:
IOException
-
generateRootConfig
public ApplicationRootConfig generateRootConfig(String name)
-
getDatePattern
public String getDatePattern()
-
setDatePattern
public void setDatePattern(String datePattern)
-
-