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 (for `Action`s and `Datasource`) from a given list of `XmlGenerator.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 or `DataProvider`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 also `generate(String, String, String, Entity...)`
  Author:
    Matthias Müller

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `XmlGenerator.Entity` Represents a domain object of a certain type with a number of properties

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XmlGenerator()`
    `XmlGenerator(boolean addPermissions)` Creates a new XmlGenerator

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `generate(String outPath, String name, String dictionaryName, XmlGenerator.Entity... entities)` Generates the source XML for the given `XmlGenerator.Entity`s.
    `Event` | `generateActions(Permissions permissions, XmlGenerator.Entity entity)`
    `Event` | `generateActions(Permissions permissions, XmlGenerator.Entity entity, OutputStream out)`
    `Datasources` | `generateDatasources(XmlGenerator.Entity entity, OutputStream out)`
    `Datasources` | `generateDatasources(XmlGenerator.Entity entity, OutputStream out, String... properties)`
    `Pages` | `generatePages(XmlGenerator.Entity entity, Linkpanel navigation, OutputStream out)`
    `ApplicationRootConfig` | `generateRootConfig(String name)`
    `String` | `getDatePattern()`
    `Datasource` | `getSingleItemDatasource(XmlGenerator.Entity entity, OutputStream out, String... properties)`
    `void` | `setDatePattern(String datePattern)`
    `void` | `writeDictionary(OutputStream out)`
    `void` | `writeToOutputStream(Object object, OutputStream out)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### XmlGenerator

          public XmlGenerator(boolean addPermissions)
                       throws JAXBException,
                              TransformerConfigurationException

      Creates a new XmlGenerator
      Parameters:
        `addPermissions` - if `Permissions` should be generated and used when referencing `Action`s
      Throws:
        `JAXBException` - if creating a `MarshallService` fails
        `TransformerConfigurationException` - if an error occurs while configuring the `TransformerFactory`

    - #### XmlGenerator

          public XmlGenerator()
                       throws JAXBException,
                              TransformerConfigurationException

      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 given `XmlGenerator.Entity`s. The following files will be created for each `XmlGenerator.Entity`, assuming the `Person.class` as the entities type:
      - conf/datasource/ds-persons.xml
      - conf/action/ev-persons.xml
      - conf/page/pg-persons.xml
      The following files are created once:
      - conf/config.xml - contains the `ApplicationRootConfig`
      - dictionary/<dictionaryName>.properties
      - application.xml
      Parameters:
        `outPath` - the target folder for the files to be generated
        `name` - the name for the `ApplicationRootConfig`-file to be created
        `dictionaryName` - the name for the dictionary file to be created (<dictionaryName>.properties)
        `entities` - the list of `XmlGenerator.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

      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)

Copyright © 2011–2023 aiticon GmbH. All rights reserved.