File: torque.xml

package info (click to toggle)
turbine 20010419-1
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 17,460 kB
  • ctags: 7,501
  • sloc: java: 41,929; xml: 12,430; sql: 637; sh: 90; makefile: 50
file content (365 lines) | stat: -rw-r--r-- 10,129 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
<?xml version="1.0"?>

<document>
<properties>
    <title>Turbine Torque</title>
    <author email="jvanzyl@periapt.com">Turbine Documentation Team</author>
</properties>

<body>

<section name="What is Torque?">
<p>
Torque is a utility packaged with <a href="http://jakarta.apache.org/turbine/">
Turbine</a> that generates all the database resources required by your web
application. Torque uses a single XML database schema to generate the SQL for
your target database, Turbine's Peer-based object relation model representing 
your XML database schema, and a HTML document describing the database. The 
HTML document is obviously not required by Turbine, but helps in describing 
your web app to other developers.
</p>

<p>
Torque is currently deployed in two forms: a stand-alone version and a version
that is bundled with the Turbine Developer's Kit. Both versions are identical 
in function, they just have slightly different configurations. The TDK version
outputs the sources in a location where the project build system can find them,
and the stand-alone version simply places the generated sources in an "output"
directory in the Torque directory structure.
</p>
</section>

<section name="Torque Directory Structure">
<p>
Here is what the Torque directory structure looks like. There are slight
differences between the stand-alone and TDK versions but nothing significant:
</p>

<source><![CDATA[

torque/
    config/      <--- Torque configuration properties.
    lib/         <--  Jar files required by Torque (stand-alone version)
    dtd/         <--- DTD for Torque XML database descriptors.
    schema/      <--- Project specific XML database descriptor.
    templates/   <--- Velocity templates used for source generation.
    xsl/         <--- XSLT stylesheets use for HTML generation.
    output/      <--- Target location for output (stand-alone version).

    torque.xml   <--- Ant build file that controls Torque.
    torque.sh    <--- Unix script to start up Ant.
    torque.bat   <--- DOS bat file to start up Ant.

]]></source>

<p>
A typical user of Torque would really only ever need to edit the
<em>torque.props</em> file in the <strong>config</strong> directory, and the
<em>project-schema.xml</em> in the <strong>schema</strong> directory. We'll
quickly go over each of these files and some of options you have using Torque.
</p>
</section>

<section name="Quick Start Guide">
<p>
For those who just want to see Torque go all you have to do is select your
target database and target package in <em>torque.props</em>, edit the
<em>project-schema.xml</em> to suit your needs, then run torque.sh or
torque.bat. That's it!
</p>

<p>
You will probably want to set the <em>project</em> property in the
<em>torque.props</em> file eventually so that your generated sources have names
that reflect your project name, but you can do that later :-). You also have to
remember that if you change the <em>project</em> property that you have to
change the name of your project XML database schema to match! For example if you
change the <em>project</em> property from the default value of "project" to
"killerapp" then you must change the name of the default schema in the
<strong>schema</strong> directory from <em>project-schema.xml</em> to
<em>killerapp-schema.xml</em>.
</p>
</section>

<section name="Configuring Torque">
<strong>torque.props</strong>

<p>
Here is a list of all the properties currently supported by Torque:
</p>

<table>
<tr>
    <td>project</td>
    <td>The name of your Turbine project. The project name is reflected in the
    names used for the generated output. If your project is set to "killerapp"
    then you will get the following files:<br/>
    killerapp-schema.sql<br/>
    killerapp.generation.report<br/>
    Remember when changing this property to change the name
    of your XML database schema to match!
    </td>
</tr>
<tr>
    <td>database</td>
    <td>The target database for your Turbine project. This is used in conjuction
    with SQL generation.
    </td>
</tr>
<tr>
    <td>extend</td>
    <td>Used in conjuction with the OM generation.</td>
</tr>
<tr>
    <td>mapname</td>
    <td>Used in conjuction with the OM generation.</td>
</tr>
<tr>
    <td>suffix</td>
    <td>
        Used in conjuction with the OM generation.
    </td>
</tr>
<tr>
    <td>targetPackage</td>
    <td>
        Used in conjuction with the OM generation.
    </td>
</tr>
<tr>
    <td>databaseUrl</td>
    <td>
        Used by the JDBC -> XML process, and by the SQL Ant Task
        that will initialize your target database with the
        generated SQL.
    </td>
</tr>
<tr>
    <td>databaseDriver</td>
    <td>
        Used by the JDBC -> XML process, and by the SQL Ant Task
        that will initialize your target database with the
        generated SQL.
    </td>
</tr>
<tr>
    <td>databaseUser</td>
    <td>
        Used by the JDBC -> XML process, and by the SQL Ant Task
        that will initialize your target database with the
        generated SQL.
    </td>
</tr>
<tr>
    <td>databasePassword</td>
    <td>
        Used by the JDBC -> XML process, and by the SQL Ant Task
        that will initialize your target database with the
        generated SQL.
    </td>
</tr>
<tr>
    <td><strong>You should not have to edit any properties below here!</strong></td>
    <td></td>
</tr>
<tr>
    <td>configDir</td>
    <td>The directory Torque looks in for the <em>torque.props</em> file.</td>
</tr>
<tr>
    <td>templatePath</td>
    <td>The path to the Velocity templates used for source generation.</td>
</tr>
<tr>
    <td>SQLControlTemplate</td>
    <td>Control template used for SQL source generation.</td>
</tr>
<tr>
    <td>OMControlTemplate</td>
    <td>Control template used for object model source generation.</td>
</tr>
<tr>
    <td>idTableControlTemplate</td>
    <td>Control template used for Id Broker source generation.</td>
</tr>
<tr>
    <td>outputDirectory</td>
    <td>Directory where the generated sources are placed.</td>
</tr>
<tr>
    <td>schemaDirectory</td>
    <td>Directory where Torque looks for XML database schemas.</td>
</tr>
</table>

<strong>project-schema.xml</strong>
<p>
This is an example of what the XML database schema might look like. This
particular example is a snippet of the database used for Turbines role-based
user system:
</p>

<source><![CDATA[

<database>

  <table name="ID_TABLE">
    <column name="ID_TABLE_ID" required="true" primaryKey="true" type="INTEGER"/>
    <column name="TABLE_NAME" required="true" size="255" type="VARCHAR"/>
    <column name="NEXT_ID" type="INTEGER"/>
    <column name="QUANTITY" type="INTEGER"/>

    <unique>
      <unique-column name="TABLE_NAME"/>
    </unique>

  </table>

  <table name="Jobentry">
    <column name="JOBID" null="false" primaryKey="true" type="INTEGER"/>
    <column name="MINUTE" default="-1" null="false" type="INTEGER"/>
    <column name="HOUR" default="-1" null="false" type="INTEGER"/>
    <column name="WEEKDAY" default="-1" null="false" type="INTEGER"/>
    <column name="DAY_OF_MONTH" default="-1" null="false" type="INTEGER"/>
    <column name="TASK" null="false" size="99" type="VARCHAR"/>
    <column name="EMAIL" size="99" type="VARCHAR"/>
  </table>

</database>
]]></source>

<p>
This is what the resultant SQL looks like, in the case the target database is
<a href="http://www.mysql.com">MySQL</a>:
</p>

<source><![CDATA[

drop table if exists ID_TABLE;
CREATE TABLE ID_TABLE
(
    ID_TABLE_ID integer NOT NULL,
    TABLE_NAME varchar(255) NOT NULL,
    NEXT_ID integer,
    QUANTITY integer,
    PRIMARY KEY(ID_TABLE_ID),
    UNIQUE(TABLE_NAME)
);

drop table if exists Jobentry;
CREATE TABLE Jobentry
(
    OID integer NOT NULL,
    MINUTE integer default -1 NOT NULL,
    HOUR integer default -1 NOT NULL,
    WEEKDAY integer default -1 NOT NULL,
    DAY_OF_MONTH integer default -1 NOT NULL,
    TASK varchar(99) NOT NULL,
    EMAIL varchar(99),
    PRIMARY KEY(OID)
);

]]></source>

<p>
This is what the sources look like for the Peer based object model:
</p>

<p>
<ul>
    <li>BaseObjects
        <ul>
            <li><a href="resources/IdTable.java">IdTable.java</a></li>
            <li><a href="resources/Jobentry.java">Jobentry.java</a></li>
        </ul>
    </li>

    <li>Peers
        <ul>
            <li><a href="resources/IdTablePeer.java">IdTablePeer.java</a></li>
            <li><a href="resources/JobentryPeer.java">JobentryPeer.java</a></li>
        </ul>
    </li>

    <li>MapBuilders
        <ul>
            <li><a href="resources/IdTableMapBuilder.java">IdTableMapBuilder.java</a></li>
            <li><a href="resources/JobentryMapBuilder.java">JobentryMapBuilder.java</a></li>
        </ul>
    </li>
</ul>
</p>

<p>
Please refer to <a href="getting-started.html">Getting Started</a> to find out
more about the Peer based object model.
</p>

<p>
This is what the HTML description of the database looks like:
</p>

<table>
<tr>
    <td colspan="3">
        <strong>
        <font face="Lucida,Verdana,Helvetica,Arial" color="white">ID_TABLE</font>
        </strong>
    </td>
</tr>
<tr>
    <td>Column</td><td>Type</td><td>Size</td>
</tr>
<tr>
    <td>ID_TABLE_ID</td><td >INTEGER</td><td>&#160;</td>
</tr>
<tr>
    <td>TABLE_NAME</td><td >VARCHAR</td><td >255&#160;</td>
</tr>
<tr>
    <td>NEXT_ID</td><td >INTEGER</td><td >&#160;</td>
</tr>
<tr>
    <td>QUANTITY</td><td >INTEGER</td><td >&#160;</td>
</tr>

</table>

<table>
<tr>
    <td colspan="3">
        <strong>
        <font face="Lucida,Verdana,Helvetica,Arial" color="white">Jobentry</font>
        </strong>
    </td>
</tr>
<tr><td>Column</td><td>Type</td><td>Size</td>
</tr>
<tr>
    <td>JOBID</td><td >INTEGER</td><td>&#160;</td>
</tr>
<tr>
    <td>MINUTE</td><td >INTEGER</td><td>&#160;</td>
</tr>
<tr>
    <td>HOUR</td><td >INTEGER</td><td>&#160;</td>
</tr>
<tr>
    <td>WEEKDAY</td><td >INTEGER</td><td>&#160;</td>
</tr>
<tr>
    <td>DAY_OF_MONTH</td><td >INTEGER</td><td>&#160;</td
></tr>
<tr>
    <td>TASK</td><td >VARCHAR</td><td >99&#160;</td>
</tr>
<tr>
    <td>EMAIL</td><td >VARCHAR</td><td >99&#160;</td>
</tr>

</table>

</section>

</body>
</document>