| 1 | 0 | |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
package net.sourceforge.addam.ddlgen.oracle; |
| 6 | |
|
| 7 | |
|
| 8 | |
import java.io.BufferedWriter; |
| 9 | |
import java.sql.*; |
| 10 | |
import java.util.List; |
| 11 | |
|
| 12 | |
import net.sourceforge.addam.ddlgen.Filter; |
| 13 | |
|
| 14 | 0 | public class IndexGenerator extends DBMSMetadataGenerator { |
| 15 | |
|
| 16 | |
private static final String TABLE_SQL = "select distinct table_name from all_indexes ao where owner=? " + |
| 17 | |
"and index_name not in (select constraint_name from all_constraints where owner=ao.owner)"; |
| 18 | |
|
| 19 | |
private static final String INDEX_SQL = "select index_name from all_indexes ao where owner=? and table_name=?" + |
| 20 | |
"and index_name not in (select constraint_name from all_constraints where owner=ao.owner)"; |
| 21 | |
|
| 22 | |
public String objectType() { |
| 23 | 0 | return "TABLE"; |
| 24 | |
} |
| 25 | |
|
| 26 | |
public List<String> getObjects(String catalog, String schema, Filter filter, |
| 27 | |
Connection connection, DatabaseMetaData metadata) throws Exception { |
| 28 | 0 | return getObjects(catalog, schema, objectType(), filter, connection, metadata, TABLE_SQL, schema); |
| 29 | |
} |
| 30 | |
|
| 31 | |
public void generate(String catalog, String schema, String object, |
| 32 | |
String vendor, Connection connection, DatabaseMetaData metadata, BufferedWriter writer) |
| 33 | |
throws Exception { |
| 34 | 0 | Filter allIndexes = new Filter() { |
| 35 | 0 | public boolean includes(String objectName) { |
| 36 | 0 | return true; |
| 37 | |
} |
| 38 | |
}; |
| 39 | |
|
| 40 | 0 | List<String> indexes = getObjects(catalog, schema, "INDEX", allIndexes, connection, metadata, INDEX_SQL, schema, object); |
| 41 | 0 | for (String index : indexes) { |
| 42 | 0 | super.generate(catalog,schema,"INDEX",index,vendor,connection,metadata,writer); |
| 43 | 0 | } |
| 44 | 0 | } |
| 45 | |
} |