ch.dieseite.colladaloader.coreproc

## Class DataAssembler

- java.lang.Object
- - ch.dieseite.colladaloader.coreproc.DataAssembler

-     public class DataAssembler
      extends java.lang.Object

  DataAssembler combines the data from ObjectLinker's database into final wrapper objects they can be used by Processing. To do that it iterates through the database tables and invokes functions. The <assembling> section from linking schema defines iterations and function calls.

  The DataAssembler works recursively in natural order. Functions can be placed into iterations and iterations can be nested. However, nested functions is not allowed.

  The functions themselves are located in package "asmbeans" and beeing invoked via system class loader. They should do tiny helper jobs and DataAssembler should manage the whole procedure. Each function must have must have a method header like "public static [Object|void] functionName(ArrayList<Param> paramlist)"

  A next important part is the IO stub. The end results from the whole procedure must be returned to user on the other hand there may be some options coming from user what some functions need.

  The input is realized via user options. (java.util.Properties). The output results goes via LoadingListener as callback. On startup ColladaLoader creates an empty listener and commit it here.

  Such Class what handles this I/O relations is located in "asmbeans" package, is defined in <interface> section of linking schema, and must have a constructor like "MyName(Properties colladaMetaData, DataAssembler.LoadingListener ltnr)"

  The class has a main test method and depends on ObjectLinker SaxParser SimpleDomParser Log and in linking schema defined assembler classes

  This source is free; you can redistribute it and/or modify it under the terms of the GNU General Public License and by nameing of the originally author

  Version:
    3.1
  Author:
    Markus Zimmermann http://www.die-seite.ch

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DataAssembler.Job` contain all infos to do assembling job at runtime A Job may be an iteration or a function
    `static interface` | `DataAssembler.LoadingListener` Is invoked by assembling classes if any processing objects is parsed /ready to draw
    `private static class` | `DataAssembler.MyIterable` wrapps children array from a Record into a Iterable object
    `static class` | `DataAssembler.Param` A wrapper for the inparams to static methods from in package "asmbeans"
    `static class` | `DataAssembler.Variable` a Descriptor to establish fixed links from Job to Job

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataAssembler()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private void` | `addDescriptorsFromDB(java.util.HashMap<java.lang.String,DataAssembler.Variable> outputs, java.util.HashMap<java.lang.String,java.util.TreeMap<java.lang.String,SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>>> db)` adds into named descriptors the database from ObjectLinker.
    `private void` | `addFunctionDescriptors(DataAssembler.Job root)` goes through the Job tree recursively.
    `private void` | `createJobTreeSkel(SimpleDomParser.Element assembling, DataAssembler.Job parent)` scans the xml element <assembling> recursively and writes/maps its structure into Job "parent".It sets for each subjob a flag (for function or iteration) and String attributes defined in xml.
    `private void` | `getOutDescriptorsFromJobSkel(DataAssembler.Job root, java.util.HashMap<java.lang.String,DataAssembler.Variable> outputs)` Searches Job tree for "tuple" and "result" definitions recursively and gives them an output descriptor.
    `private void` | `hardLinkIoDescriptors(DataAssembler.Job root, java.util.HashMap<java.lang.String,DataAssembler.Variable> outputs)` establish recursively hard links to all I/O descriptors so each job has now a IN / OUT to the correct neighbours
    `DataAssembler.Job` | `init(java.lang.String linkerSchema, java.util.HashMap<java.lang.String,java.util.TreeMap<java.lang.String,SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>>> linkerDatabase, java.util.Properties colladaMetaData, DataAssembler.LoadingListener assembingCallback)` Main initial: parses LinkingSchema for jobs and gives back a valid tree of listed/nested jobs (function calls or iterations) with valid and linked descriptors for env vars, database interface or functions
    `private SimpleDomParser.Element` | `parseSchema(java.lang.String filename)` parses the xml linking schema as DOM Model should be placed into jar://ch/dieseite/colladaloader/coreproc
    `void` | `recursiveJobIteration(DataAssembler.Job js)` Starts recursively all defined iterations and Functions defined inside <assembling> in natural order.
    `private void` | `setInterfaceDescriptor(java.util.HashMap<java.lang.String,DataAssembler.Variable> outputs, SimpleDomParser.Element descr, java.util.Properties colladaMetaData, DataAssembler.LoadingListener callback)` put a named descriptor whose handle main I/O relations between assembler classes and upper layer main class.

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

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

- - ### Constructor Detail

    - #### DataAssembler

          public DataAssembler()

  - ### Method Detail

    - #### init

          public DataAssembler.Job init(java.lang.String linkerSchema,
                                        java.util.HashMap<java.lang.String,java.util.TreeMap<java.lang.String,SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>>> linkerDatabase,
                                        java.util.Properties colladaMetaData,
                                        DataAssembler.LoadingListener assembingCallback)
                                 throws javax.xml.parsers.ParserConfigurationException,
                                        org.xml.sax.SAXException,
                                        java.io.IOException,
                                        java.lang.NoSuchMethodException,
                                        java.lang.SecurityException,
                                        java.lang.ClassNotFoundException,
                                        java.lang.InstantiationException,
                                        java.lang.IllegalAccessException,
                                        java.lang.IllegalArgumentException,
                                        java.lang.reflect.InvocationTargetException

      Main initial: parses LinkingSchema for jobs and gives back a valid tree of listed/nested jobs (function calls or iterations) with valid and linked descriptors for env vars, database interface or functions
      Parameters:
        `linkerSchema` -
        `linkerDatabase` - (created by ObjectLinker)
        `colladaMetaData` - startparams, the class defined in <interface> uses it
        `assembingCallback,` - the class defined in <interface> gives a callback if any processing Objects is ready to draw
      Returns:
        a valid Job tree
      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `java.lang.NoSuchMethodException`
        `java.lang.SecurityException`
        `java.lang.ClassNotFoundException`
        `java.lang.reflect.InvocationTargetException`
        `java.lang.IllegalArgumentException`
        `java.lang.IllegalAccessException`
        `java.lang.InstantiationException`

    - #### recursiveJobIteration

          public void recursiveJobIteration(DataAssembler.Job js)
                                     throws java.lang.IllegalAccessException,
                                            java.lang.IllegalArgumentException,
                                            java.lang.reflect.InvocationTargetException

      Starts recursively all defined iterations and Functions defined inside <assembling> in natural order. Nested <iteration> tags is allowed but no nested <function> tags. However they can be placed into nested <iteration> tags
      Parameters:
        `js` - root tree defined by linker xml file
      Throws:
        `java.lang.IllegalAccessException`
        `java.lang.IllegalArgumentException`
        `java.lang.reflect.InvocationTargetException`

    - #### parseSchema

          private SimpleDomParser.Element parseSchema(java.lang.String filename)
                                               throws javax.xml.parsers.ParserConfigurationException,
                                                      org.xml.sax.SAXException,
                                                      java.io.IOException

      parses the xml linking schema as DOM Model should be placed into jar://ch/dieseite/colladaloader/coreproc
      Parameters:
        `filename` -
      Returns:
        the <root> root element
      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `org.xml.sax.SAXException`
        `java.io.IOException`

    - #### createJobTreeSkel

          private void createJobTreeSkel(SimpleDomParser.Element assembling,
                                         DataAssembler.Job parent)

      scans the xml element <assembling> recursively and writes/maps its structure into Job "parent".It sets for each subjob a flag (for function or iteration) and String attributes defined in xml.
      Parameters:
        `assembling` -
        `parent` - root

    - #### addDescriptorsFromDB

          private void addDescriptorsFromDB(java.util.HashMap<java.lang.String,DataAssembler.Variable> outputs,
                                            java.util.HashMap<java.lang.String,java.util.TreeMap<java.lang.String,SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>>> db)

      adds into named descriptors the database from ObjectLinker. Each table gets a new descriptor that contains the table. The naming is the same as tablename
      Parameters:
        `outputs` - named descriptors
        `db` -

    - #### getOutDescriptorsFromJobSkel

          private void getOutDescriptorsFromJobSkel(DataAssembler.Job root,
                                                    java.util.HashMap<java.lang.String,DataAssembler.Variable> outputs)

      Searches Job tree for "tuple" and "result" definitions recursively and gives them an output descriptor. Tuple and result is the first defined env vars in LinkingSchema
      Parameters:
        `root` -
        `outputs` - an empty Map, after method call it contains named descriptors

    - #### hardLinkIoDescriptors

          private void hardLinkIoDescriptors(DataAssembler.Job root,
                                             java.util.HashMap<java.lang.String,DataAssembler.Variable> outputs)

      establish recursively hard links to all I/O descriptors so each job has now a IN / OUT to the correct neighbours
      Parameters:
        `root` - tree
        `outputs` - all (particularly empty) IO descriptors
        `db` - from ObjectLinker

    - #### addFunctionDescriptors

          private void addFunctionDescriptors(DataAssembler.Job root)
                                       throws java.lang.NoSuchMethodException,
                                              java.lang.SecurityException,
                                              java.lang.ClassNotFoundException

      goes through the Job tree recursively. If a 'f' flag is found then a Method descriptor is set (see java reflection)
      Parameters:
        `root` -
      Throws:
        `java.lang.NoSuchMethodException`
        `java.lang.SecurityException`
        `java.lang.ClassNotFoundException`

    - #### setInterfaceDescriptor

          private void setInterfaceDescriptor(java.util.HashMap<java.lang.String,DataAssembler.Variable> outputs,
                                              SimpleDomParser.Element descr,
                                              java.util.Properties colladaMetaData,
                                              DataAssembler.LoadingListener callback)
                                       throws java.lang.InstantiationException,
                                              java.lang.IllegalAccessException,
                                              java.lang.IllegalArgumentException,
                                              java.lang.reflect.InvocationTargetException,
                                              java.lang.NoSuchMethodException,
                                              java.lang.SecurityException,
                                              java.lang.ClassNotFoundException

      put a named descriptor whose handle main I/O relations between assembler classes and upper layer main class. Purpose is to get startparams (i.e. file paths) and set end results back (i.e Triangles and Lines)
      Parameters:
        `outputs` - named descriptors
        `<interface>` - tag from LinkingSchema
        `colladaMetaData` - startparams
      Throws:
        `java.lang.ClassNotFoundException`
        `java.lang.SecurityException`
        `java.lang.NoSuchMethodException`
        `java.lang.reflect.InvocationTargetException`
        `java.lang.IllegalArgumentException`
        `java.lang.IllegalAccessException`
        `java.lang.InstantiationException`