KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > tigris > scarab > om > map > QueryMapBuilder


1 package org.tigris.scarab.om.map;
2
3 import java.util.Date JavaDoc;
4 import java.math.BigDecimal JavaDoc;
5
6 import org.apache.torque.Torque;
7 import org.apache.torque.TorqueException;
8 import org.apache.torque.map.MapBuilder;
9 import org.apache.torque.map.DatabaseMap;
10 import org.apache.torque.map.TableMap;
11
12 /**
13   */

14 public class QueryMapBuilder implements MapBuilder
15 {
16     /**
17      * The name of this class
18      */

19     public static final String JavaDoc CLASS_NAME =
20         "org.tigris.scarab.om.map.QueryMapBuilder";
21
22
23     /**
24      * The database map.
25      */

26     private DatabaseMap dbMap = null;
27
28     /**
29      * Tells us if this DatabaseMapBuilder is built so that we
30      * don't have to re-build it every time.
31      *
32      * @return true if this DatabaseMapBuilder is built
33      */

34     public boolean isBuilt()
35     {
36         return (dbMap != null);
37     }
38
39     /**
40      * Gets the databasemap this map builder built.
41      *
42      * @return the databasemap
43      */

44     public DatabaseMap getDatabaseMap()
45     {
46         return this.dbMap;
47     }
48
49     /**
50      * The doBuild() method builds the DatabaseMap
51      *
52      * @throws TorqueException
53      */

54     public void doBuild() throws TorqueException
55     {
56         dbMap = Torque.getDatabaseMap("scarab");
57
58         dbMap.addTable("SCARAB_QUERY");
59         TableMap tMap = dbMap.getTable("SCARAB_QUERY");
60
61         tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
62
63         tMap.setPrimaryKeyMethodInfo(tMap.getName());
64
65               tMap.addPrimaryKey("SCARAB_QUERY.QUERY_ID", new Long JavaDoc(0));
66                     tMap.addForeignKey(
67                 "SCARAB_QUERY.USER_ID", new Integer JavaDoc(0) , "TURBINE_USER" ,
68                 "USER_ID");
69                     tMap.addColumn("SCARAB_QUERY.NAME", "");
70                     tMap.addColumn("SCARAB_QUERY.DESCRIPTION", "");
71                     tMap.addColumn("SCARAB_QUERY.VALUE", "");
72                     tMap.addForeignKey(
73                 "SCARAB_QUERY.SCOPE_ID", new Integer JavaDoc(0) , "SCARAB_SCOPE" ,
74                 "SCOPE_ID");
75                     tMap.addForeignKey(
76                 "SCARAB_QUERY.ISSUE_TYPE_ID", new Integer JavaDoc(0) , "SCARAB_ISSUE_TYPE" ,
77                 "ISSUE_TYPE_ID");
78                     tMap.addForeignKey(
79                 "SCARAB_QUERY.MODULE_ID", new Integer JavaDoc(0) , "SCARAB_MODULE" ,
80                 "MODULE_ID");
81                     tMap.addForeignKey(
82                 "SCARAB_QUERY.LIST_ID", new Long JavaDoc(0) , "SCARAB_MIT_LIST" ,
83                 "LIST_ID");
84                     tMap.addColumn("SCARAB_QUERY.DELETED", new Integer JavaDoc(0));
85                     tMap.addColumn("SCARAB_QUERY.APPROVED", new Integer JavaDoc(0));
86                     tMap.addColumn("SCARAB_QUERY.CREATED_DATE", new Date JavaDoc());
87                     tMap.addForeignKey(
88                 "SCARAB_QUERY.SUBSCRIPTION_FREQUENCY_ID", new Integer JavaDoc(0) , "SCARAB_FREQUENCY" ,
89                 "FREQUENCY_ID");
90                     tMap.addColumn("SCARAB_QUERY.HOME_PAGE", new Integer JavaDoc(0));
91                     tMap.addColumn("SCARAB_QUERY.PREFERRED_ORDER", new Integer JavaDoc(0));
92           }
93 }
94
Popular Tags