Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/openscience/nmrshiftdb/om/map/DBChemicalNameMapBuilder.java


1   package org.openscience.nmrshiftdb.om.map;
2   
3   import java.util.*;
4   import java.math.*;
5   import org.apache.turbine.services.db.PoolBrokerService;
6   import org.apache.turbine.services.db.TurbineDB;
7   import org.apache.turbine.util.db.map.MapBuilder;
8   import org.apache.turbine.util.db.map.DatabaseMap;
9   import org.apache.turbine.util.db.map.TableMap;
10  
11  /**
12   */
13  public class DBChemicalNameMapBuilder implements MapBuilder
14  {
15      /** the name of this class */
16      public static final String CLASS_NAME = "org.openscience.nmrshiftdb.om.map.DBChemicalNameMapBuilder";
17  
18      /** item */
19      public static String getTable( )
20      {
21          return "CHEMICAL_NAME";
22      }
23  
24  
25      /** CHEMICAL_NAME.MOLECULE_ID */
26      public static String getDBChemicalName_MoleculeId()
27      {
28          return getTable() + ".MOLECULE_ID";
29      }
30  
31      /** CHEMICAL_NAME.NAME */
32      public static String getDBChemicalName_Name()
33      {
34          return getTable() + ".NAME";
35      }
36  
37      /** CHEMICAL_NAME.NAME_SOUNDEX */
38      public static String getDBChemicalName_NameSoundex()
39      {
40          return getTable() + ".NAME_SOUNDEX";
41      }
42  
43      /**  the database map  */
44      private DatabaseMap dbMap = null;
45  
46      /**
47          tells us if this DatabaseMapBuilder is built so that we don't have
48          to re-build it every time
49      */
50      public boolean isBuilt()
51      {
52          if ( dbMap != null )
53              return true;
54          return false;
55      }
56  
57      /**  gets the databasemap this map builder built.  */
58      public DatabaseMap getDatabaseMap()
59      {
60          return this.dbMap;
61      }
62      /** the doBuild() method builds the DatabaseMap */
63      public void doBuild() throws Exception
64      {
65          dbMap = TurbineDB.getDatabaseMap("default");
66  
67          dbMap.addTable(getTable());
68          TableMap tMap = dbMap.getTable(getTable());
69  
70                  tMap.setPrimaryKeyMethod("none");
71          
72  
73  
74                    tMap.addForeignPrimaryKey ( getDBChemicalName_MoleculeId(), new Integer(0) , "MOLECULE" , "MOLECULE_ID" );
75            
76                    tMap.addPrimaryKey ( getDBChemicalName_Name(), new String() );
77            
78                    tMap.addColumn ( getDBChemicalName_NameSoundex(), new String() );
79            
80      }
81  
82  }