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.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialFetchFeatureTypeOperation.java
H2SpatialFetchFeatureTypeOperation.java | ||
---|---|---|
9 | 9 |
import java.util.HashMap; |
10 | 10 |
import java.util.List; |
11 | 11 |
import java.util.Map; |
12 |
import org.apache.commons.lang3.StringUtils; |
|
13 | 12 |
import org.cresques.cts.IProjection; |
14 | 13 |
import org.gvsig.fmap.dal.DataTypes; |
15 | 14 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
17 | 16 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
18 | 17 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
19 | 18 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
19 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
20 | 20 |
import org.gvsig.fmap.dal.store.jdbc2.spi.SRSSolver; |
21 | 21 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation; |
22 | 22 |
import org.gvsig.fmap.geom.Geometry; |
... | ... | |
24 | 24 |
import org.gvsig.fmap.geom.GeometryManager; |
25 | 25 |
import org.gvsig.fmap.geom.type.GeometryType; |
26 | 26 |
|
27 |
@SuppressWarnings("UseSpecificCatch") |
|
27 | 28 |
public class H2SpatialFetchFeatureTypeOperation extends FetchFeatureTypeOperation { |
28 | 29 |
|
29 | 30 |
private static Map<String,GeometryType>h2spatialGeometryTypes = null; |
... | ... | |
68 | 69 |
public H2SpatialFetchFeatureTypeOperation( |
69 | 70 |
JDBCHelper helper, |
70 | 71 |
EditableFeatureType featureType, |
71 |
String dbname, |
|
72 |
String schema, |
|
73 |
String table, |
|
72 |
TableReference table, |
|
74 | 73 |
List<String> primaryKeys, |
75 | 74 |
String defaultGeometryColumn, |
76 | 75 |
IProjection crs |
77 | 76 |
) { |
78 |
super(helper, featureType, dbname, schema, table, primaryKeys, defaultGeometryColumn, crs);
|
|
77 |
super(helper, featureType, table, primaryKeys, defaultGeometryColumn, crs); |
|
79 | 78 |
} |
80 | 79 |
|
81 | 80 |
@Override |
82 |
public void fetch(EditableFeatureType featureType, Connection conn, String dbname, String schema, String table, List<String> pks, String defaultGeometryColumn, IProjection crs) throws DataException {
|
|
81 |
public void fetch(EditableFeatureType featureType, Connection conn, TableReference table, List<String> pks, String defaultGeometryColumn, IProjection crs) throws DataException {
|
|
83 | 82 |
geometry_column = new HashMap<>(); |
84 | 83 |
try { |
85 | 84 |
// |
86 | 85 |
// https://github.com/orbisgis/h2gis/wiki/1.-Spatial-data#geometry-columns-view |
87 | 86 |
// |
88 | 87 |
StringBuilder where = null; |
89 |
if( !StringUtils.isEmpty(dbname) ) {
|
|
88 |
if( table.hasDatabase() ) {
|
|
90 | 89 |
if( where == null ) { |
91 | 90 |
where = new StringBuilder(); |
92 | 91 |
} else { |
93 | 92 |
where.append(" AND "); |
94 | 93 |
} |
95 | 94 |
where.append("UPPER(F_TABLE_CATALOG) = '"); |
96 |
where.append(dbname.toUpperCase());
|
|
95 |
where.append(table.getDatabase().toUpperCase());
|
|
97 | 96 |
where.append("'"); |
98 | 97 |
} |
99 |
if( !StringUtils.isEmpty(schema) ) {
|
|
98 |
if( table.hasSchema()) {
|
|
100 | 99 |
if( where == null ) { |
101 | 100 |
where = new StringBuilder(); |
102 | 101 |
} else { |
103 | 102 |
where.append(" AND "); |
104 | 103 |
} |
105 | 104 |
where.append("UPPER(F_TABLE_SCHEMA) = '"); |
106 |
where.append(schema.toUpperCase());
|
|
105 |
where.append(table.getSchema().toUpperCase());
|
|
107 | 106 |
where.append("'"); |
108 | 107 |
} |
109 |
if( !StringUtils.isEmpty(table) ) {
|
|
108 |
if( table.hasTable()) {
|
|
110 | 109 |
if( where == null ) { |
111 | 110 |
where = new StringBuilder(); |
112 | 111 |
} else { |
113 | 112 |
where.append(" AND "); |
114 | 113 |
} |
115 | 114 |
where.append("UPPER(F_TABLE_NAME) = '"); |
116 |
where.append(table.toUpperCase()); |
|
115 |
where.append(table.getTable().toUpperCase());
|
|
117 | 116 |
where.append("'"); |
118 | 117 |
} |
119 | 118 |
String sql = "SELECT F_GEOMETRY_COLUMN, GEOMETRY_TYPE, COORD_DIMENSION, SRID, TYPE FROM GEOMETRY_COLUMNS WHERE " + where; |
... | ... | |
132 | 131 |
); |
133 | 132 |
} |
134 | 133 |
} catch (SQLException ex) { |
135 |
logger.warn("Can't read metadata from table '"+table+"'.",ex);
|
|
134 |
LOGGER.warn("Can't read metadata from table '"+table+"'.",ex);
|
|
136 | 135 |
} |
137 |
super.fetch(featureType, conn, dbname, schema, table, pks, defaultGeometryColumn, crs);
|
|
136 |
super.fetch(featureType, conn, table, pks, defaultGeometryColumn, crs); |
|
138 | 137 |
} |
139 | 138 |
|
140 | 139 |
@Override |
Also available in: Unified diff