Revision 44058 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/TableIsEmptyOperation.java
TableIsEmptyOperation.java | ||
---|---|---|
10 | 10 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
11 | 11 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException; |
12 | 12 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
13 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
13 | 14 |
|
14 | 15 |
public class TableIsEmptyOperation extends AbstractConnectionOperation { |
15 | 16 |
|
16 |
private final String schemaName; |
|
17 |
private final String tableName; |
|
18 |
private final String subquery; |
|
17 |
private final TableReference table; |
|
19 | 18 |
private final String baseFilter; |
20 | 19 |
private final String filter; |
21 |
private final String dbName; |
|
22 | 20 |
|
23 | 21 |
public TableIsEmptyOperation( |
24 | 22 |
JDBCHelper helper |
25 | 23 |
) { |
26 |
this(helper, null, null, null, null, null, null);
|
|
24 |
this(helper, null, null, null); |
|
27 | 25 |
} |
28 | 26 |
|
29 | 27 |
public TableIsEmptyOperation( |
30 | 28 |
JDBCHelper helper, |
31 |
String dbName, |
|
32 |
String schemaName, |
|
33 |
String tableName, |
|
34 |
String subquery, |
|
29 |
TableReference table, |
|
35 | 30 |
String baseFilter, |
36 | 31 |
String filter |
37 | 32 |
) { |
38 | 33 |
super(helper); |
39 |
this.dbName = dbName; |
|
40 |
this.schemaName = schemaName; |
|
41 |
this.tableName = tableName; |
|
42 |
this.subquery = subquery; |
|
34 |
this.table = table; |
|
43 | 35 |
this.baseFilter = baseFilter; |
44 | 36 |
this.filter = filter; |
45 | 37 |
} |
46 | 38 |
|
47 | 39 |
@Override |
48 | 40 |
public final Object perform(Connection conn) throws DataException { |
49 |
return this.tableIsEmpty(conn, |
|
50 |
dbName, schemaName, tableName, subquery, baseFilter, filter); |
|
41 |
return this.tableIsEmpty(conn, table, baseFilter, filter); |
|
51 | 42 |
} |
52 | 43 |
|
53 | 44 |
public boolean tableIsEmpty(Connection conn, |
54 |
String database, |
|
55 |
String schema, |
|
56 |
String table, |
|
57 |
String subquery, |
|
45 |
TableReference table, |
|
58 | 46 |
String baseFilter, |
59 |
String filter) throws DataException { |
|
47 |
String filter |
|
48 |
) throws DataException { |
|
60 | 49 |
|
61 | 50 |
JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder(); |
62 | 51 |
|
63 | 52 |
sqlbuilder.select().column().all(); |
64 |
sqlbuilder.select().from().table().database(database).schema(schema).name(table); |
|
65 |
sqlbuilder.select().from().subquery(subquery); |
|
53 |
sqlbuilder.select().from().table() |
|
54 |
.database(this.table.getDatabase()) |
|
55 |
.schema(this.table.getSchema()) |
|
56 |
.name(this.table.getTable()); |
|
57 |
sqlbuilder.select().from().subquery(this.table.getSubquery()); |
|
66 | 58 |
if (!StringUtils.isEmpty(baseFilter)) { |
67 | 59 |
sqlbuilder.select().where().set( sqlbuilder.custom(baseFilter) ); |
68 | 60 |
} |
Also available in: Unified diff