db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1470239 - in /db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/codegen-reference: concepts.xml index.xml
Date Sat, 20 Apr 2013 21:50:45 GMT
Author: tfischer
Date: Sat Apr 20 21:50:45 2013
New Revision: 1470239

URL: http://svn.apache.org/r1470239
Log:
TORQUE-272 Support groovy templates out of the box
TORQUE-273 Support typed models in the generator 

Modified:
    db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/codegen-reference/concepts.xml
    db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/codegen-reference/index.xml

Modified: db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/codegen-reference/concepts.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/codegen-reference/concepts.xml?rev=1470239&r1=1470238&r2=1470239&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/codegen-reference/concepts.xml
(original)
+++ db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/codegen-reference/concepts.xml
Sat Apr 20 21:50:45 2013
@@ -91,8 +91,8 @@
       to produce its output.
     </p>
     <p>
-      The graph is represented similarly to the structure which is normally 
-      used to represent XML files: 
+      Initially (when loaded), the graph is represented similarly 
+      to the structure which is normally used to represent XML files: 
       The nodes are called "elements", and each element has a list of children
       and a list of parents (i.e. parents and children are ordered).
       Elements without parents
@@ -110,8 +110,11 @@
       In the simplest generation projects, it suffices to pass the sources
       directly to the outlets. But in more complex projects, it makes sense
       to transform the source before generating output from it.
-      A transformer performs the transformation from an input graph to an
-      output graph. The output graph is then used for generation.
+      A transformer performs the transformation from an input model to an
+      output model. The output model is then used for generation.
+      In general, the input model and the output model do not need to have the
+      same structure. For example, it is common to transform the element graph
+      from reading the sources to a typed model. An example is shown below.
     </p>
      
     <p>  
@@ -164,6 +167,73 @@
       ]]>
       </source>      
     </p>
+    <p>
+      A third typical example is to transform the graph model to a typed model.
+      Consider again the example source
+      <source><![CDATA[
+      <database>
+        <table name="FIRST_TABLE" />
+      </database>
+      ]]>
+      </source>
+      Now, in generation, we want to use not the graph model, but a java model
+      representing the XML structure, for example
+      <source><![CDATA[
+      // Database.java
+      public class Database {
+        public List<Table> tableList;
+      }
+      
+      // Table.java
+      public class Table {
+        public String name;
+      }
+      ]]>
+      </source>
+      Torque brings a transformer which can do the above transformation 
+      out of the box: the SourceElementToModelTransformer.
+      This transformer needs the root class of the typed model as argument,
+      e.g. in the above case (assuming the class Database is in the package
+      "model")
+      <source><![CDATA[
+      ...
+      <transformer class="org.apache.torque.generator.source.transform.SourceElementToModelTransformer">
+         <modelRootClass>model.Database</modelRootClass>
+      </transformer>
+      ...
+      ]]>
+      </source>
+      This transformer brings a few restrictions:
+      <ul>
+        <li>
+          The attribute types must be concrete classes with a default
+          constructor.
+        </li>
+        <li>
+          Each attribute in the source graph must have an associated property
+          in the target model.
+        </li>
+        <li>
+          Each child element in the source graph must have an associated 
+          property in the target model.
+        </li>
+        <li>
+          The name of the associated property must be either the name of the 
+          attribute/child element, 
+          or the the name of the attribute/child element with suffix "s",
+          or the the name of the attribute/child element with suffix "List".
+          Should the name of the attribute/child element be a reserved
+          java word, the java property name must be prefixed by an 
+          underscore (_). (e.g. attribute "default" -> java field "_default")  
+        </li>
+        <li>
+          The java property can either consist of a public field or a public 
+          setter using the JavaBeans conventions. If using setters for arrays
+          or collections, a public getter must also be available in the case
+          more than one element needs to be filled into the array or collection.
+        </li>
+      </ul>
+    </p>
   </section>
   
   <section name="SkipDeciders">

Modified: db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/codegen-reference/index.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/codegen-reference/index.xml?rev=1470239&r1=1470238&r2=1470239&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/codegen-reference/index.xml
(original)
+++ db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/codegen-reference/index.xml
Sat Apr 20 21:50:45 2013
@@ -39,6 +39,13 @@
       <li>Output from existing templates should be easily modifiable</li>
       <li>Not bound to a single template language</li>
     </ul>
+    <p>
+      Currently, the following template languages are provided out of the box:
+    </p>
+    <ul>
+      <li>Velocity</li>
+      <li>Groovy</li>
+    </ul>
   </section>
 
  </body>



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message