1 package util;
2
3 import java.sql.SQLException;
4
5 import resource.ResourceLocator;
6 import chemaxon.jchem.db.StructureTableOptions;
7 import chemaxon.jchem.db.TableTypeConstants;
8 import chemaxon.jchem.db.UpdateHandler;
9 import chemaxon.util.ConnectionHandler;
10
11
19public final class TableOperations {
20
21 private static final int LARGE_TABLE_IMPORT_COUNT = 10;
22
23
31 public static void createMoleculeTable(ConnectionHandler connHandler, String tableName)
32 throws SQLException {
33 createStructureTable(connHandler, tableName, TableTypeConstants.TABLE_TYPE_MOLECULES);
34 }
35
36
45 public static void createStructureTable(ConnectionHandler connHandler, String tableName,
46 int tableType) throws SQLException {
47
48 if (UpdateHandler.isStructureTable(connHandler, tableName)) {
50 UpdateHandler.dropStructureTable(connHandler, tableName);
51 }
52
53 StructureTableOptions tableOptions = new StructureTableOptions(tableName, tableType);
55 UpdateHandler.createStructureTable(connHandler, tableOptions);
56 }
57
58
66 public static void setupMoleculeTable(ConnectionHandler connHandler, String tableName)
67 throws Exception {
68
69 System.out.print("Setting up default molecule table... ");
70
71 createMoleculeTable(connHandler, tableName);
72 MolImportUtil.databaseImport(ResourceLocator.getDefaultInputPath(), connHandler,
73 tableName);
74
75 System.out.println("Done.");
76 System.out.println();
77 }
78
79
87 public static void setupLargeMoleculeTable(ConnectionHandler connHandler, String tableName)
88 throws Exception {
89
90 System.out.print("Setting up large molecule table...");
91
92 createMoleculeTable(connHandler, tableName);
93 for (int i = 0; i < LARGE_TABLE_IMPORT_COUNT; i++) {
94 MolImportUtil.databaseImport(ResourceLocator.getDefaultInputPath(), connHandler,
95 tableName);
96 System.out.print(".");
97 System.out.flush();
98 }
99
00 System.out.println("Done.");
01 System.out.println();
02 }
03
04}
05