View Javadoc

1   package net.sourceforge.blogentis.om.map;
2   
3   import java.util.Date;
4   
5   import org.apache.torque.Torque;
6   import org.apache.torque.TorqueException;
7   import org.apache.torque.map.DatabaseMap;
8   import org.apache.torque.map.MapBuilder;
9   import org.apache.torque.map.TableMap;
10  
11  /***
12    */
13  public class PostMapBuilder implements MapBuilder
14  {
15      /***
16       * The name of this class
17       */
18      public static final String CLASS_NAME =
19          "net.sourceforge.blogentis.om.map.PostMapBuilder";
20  
21  
22      /***
23       * The database map.
24       */
25      private DatabaseMap dbMap = null;
26  
27      /***
28       * Tells us if this DatabaseMapBuilder is built so that we
29       * don't have to re-build it every time.
30       *
31       * @return true if this DatabaseMapBuilder is built
32       */
33      public boolean isBuilt()
34      {
35          return (dbMap != null);
36      }
37  
38      /***
39       * Gets the databasemap this map builder built.
40       *
41       * @return the databasemap
42       */
43      public DatabaseMap getDatabaseMap()
44      {
45          return this.dbMap;
46      }
47  
48      /***
49       * The doBuild() method builds the DatabaseMap
50       *
51       * @throws TorqueException
52       */
53      public void doBuild() throws TorqueException
54      {
55          dbMap = Torque.getDatabaseMap("blogentis");
56  
57          dbMap.addTable("Post");
58          TableMap tMap = dbMap.getTable("Post");
59  
60          tMap.setPrimaryKeyMethod(TableMap.NATIVE);
61  
62          tMap.setPrimaryKeyMethodInfo("Post_SEQ");
63  
64                tMap.addPrimaryKey("Post.POST_ID", new Integer(0));
65                      tMap.addForeignKey(
66                  "Post.BLOG_ID", new Integer(0) , "Blog" ,
67                  "Blog_Id");
68                      tMap.addColumn("Post.POST_TYPE", new Integer(0));
69                      tMap.addColumn("Post.TITLE", new String());
70                      tMap.addColumn("Post.URI_FRAGMENT", new String());
71                      tMap.addColumn("Post.SHORT_DESCRIPTION", new String());
72                      tMap.addColumn("Post.FULL_TEXT", new String());
73                      tMap.addColumn("Post.POSTED_TIME", new Date());
74                      tMap.addColumn("Post.AUTHOR_ID", new String());
75                      tMap.addColumn("Post.OBJECT_DATA", new Object());
76            }
77  }