1 54 55 package org.apache.jetspeed.portal.portlets.util.poll; 56 57 import java.util.*; 58 59 import org.apache.turbine.util.db.pool.*; 60 import org.apache.turbine.util.db.map.*; 61 62 64 public class PollMapBuilder implements MapBuilder { 65 66 69 private DatabaseMap dbMap = null; 70 71 72 public String getTablePolls() { 73 return "Polls"; 74 } 75 76 public String getTableAnswers() { 77 return "Answers"; 78 } 79 80 82 public void doBuild() throws Exception { 83 84 String string = new String (""); 86 Integer integer = new Integer (0); 87 88 dbMap = new DatabaseMap(DBBroker.DEFAULT); 90 91 dbMap.addTable( getTablePolls() ); 93 dbMap.addTable( getTableAnswers() ); 94 95 TableMap tMap = dbMap.getTable( getTablePolls() ); 97 tMap.addPrimaryKey( "POLLID", integer ); 98 tMap.addColumn( "TITLE", string ); 99 100 tMap = dbMap.getTable( getTableAnswers() ); 102 tMap.addPrimaryKey( "ANSWERID", integer ); 103 tMap.addForeignPrimaryKey( "POLLID", integer, this.getTablePolls(), "POLLID" ); 104 tMap.addColumn( "TITLE", string ); 105 tMap.addColumn( "COUNT", integer ); 106 107 } 108 109 public boolean isBuilt() { 110 if ( dbMap != null ) 111 return true; 112 return false; 113 } 114 115 public DatabaseMap getDatabaseMap() { 116 return this.dbMap; 117 } 118 } 119 120 121 | Popular Tags |