Revision 43114 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/SQLBuilderBase.java

View differences:

SQLBuilderBase.java
10 10
import org.apache.commons.lang3.StringUtils;
11 11
import org.apache.commons.lang3.tuple.ImmutablePair;
12 12
import org.apache.commons.lang3.tuple.Pair;
13
import org.cresques.cts.IProjection;
13 14
import org.gvsig.fmap.dal.DataTypes;
14 15
import org.gvsig.fmap.dal.ExpressionBuilder;
15 16
import org.gvsig.fmap.dal.SQLBuilder;
......
30 31
import org.gvsig.fmap.dal.SQLBuilder.UpdateBuilder;
31 32
import org.gvsig.fmap.dal.SQLBuilder.UpdateColumnBuilder;
32 33
import org.gvsig.fmap.dal.SQLBuilder.UpdateTableStatisticsBuilder;
34
import org.gvsig.fmap.geom.Geometry;
35
import org.gvsig.fmap.geom.GeometryLocator;
36
import org.gvsig.fmap.geom.GeometryManager;
37
import org.gvsig.fmap.geom.type.GeometryType;
33 38
import org.slf4j.Logger;
34 39
import org.slf4j.LoggerFactory;
35 40

  
......
48 53
    protected UpdateTableStatisticsBuilder update_table_statistics;
49 54
    protected List<Parameter> parameters;
50 55

  
51
    protected class ColumnInfo {
56
    protected class ColumnDescriptorBuilderBase implements ColumnDescriptorBuilder {
52 57

  
53
        public String name;
54
        public int type;
55
        public int type_p;
56
        public int type_s;
57
        public boolean isPk;
58
        public boolean allowNulls;
59
        public boolean isAutomatic;
60
        public Object defaultValue;
58
        private String name;
59
        private int type;
60
        private int type_p;
61
        private int type_s;
62
        private boolean isPk;
63
        private boolean _allowNulls;
64
        private boolean _isAutomatic;
65
        private Object defaultValue;
66
        private int geom_type;
67
        private int geom_subtype;
68
        private int geom_srsid;
61 69

  
62
        public ColumnInfo(String name, int type, Object defaultValue) {
70
        public ColumnDescriptorBuilderBase(String name, int type, Object defaultValue) {
63 71
            this.name = name;
64 72
            this.type = type;
65 73
            this.type_p = -1;
66 74
            this.type_s = -1;
67 75
            this.isPk = false;
68
            this.allowNulls = true;
69
            this.isAutomatic = false;
76
            this._allowNulls = true;
77
            this._isAutomatic = false;
70 78
            this.defaultValue = defaultValue;
79
            this.geom_type = Geometry.TYPES.GEOMETRY;
80
            this.geom_subtype = Geometry.SUBTYPES.GEOM2D;
81
            this.geom_srsid = -1;
71 82
        }
72 83

  
73
        public ColumnInfo(String name, int type, int type_p, int type_s, boolean isPk, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
84
        public ColumnDescriptorBuilderBase(String name, int type, int type_p, int type_s, boolean isPk, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
74 85
            this.name = name;
75 86
            this.type = type;
76 87
            this.type_p = type_p;
77 88
            this.type_s = type_s;
78 89
            this.isPk = isPk;
79
            this.allowNulls = allowNulls;
80
            this.isAutomatic = isAutomatic;
90
            this._allowNulls = allowNulls;
91
            this._isAutomatic = isAutomatic;
81 92
            this.defaultValue = defaultValue;
93
            this.geom_type = Geometry.TYPES.GEOMETRY;
94
            this.geom_subtype = Geometry.SUBTYPES.GEOM2D;
95
            this.geom_srsid = -1;
82 96
        }
97
        
98
        public ColumnDescriptorBuilderBase(String name, int geom_type, int geom_subtype, IProjection proj, boolean allowNulls) {
99
            this.name = name;
100
            this.type_p = 0;
101
            this.type_s = 0;
102
            this.isPk = false;
103
            this._allowNulls = allowNulls;
104
            this._isAutomatic = false;
105
            this.defaultValue = null;
106
            this.geom_type = geom_type;
107
            this.geom_subtype = geom_subtype;
108
            this.geom_srsid = getSRSId(proj);
109
        }
110
        
111
        @Override
112
        public String getName() {
113
            return this.name;
114
        }
115
        
116
        @Override
117
        public void setName(String name) {
118
            this.name = name;
119
        }
120

  
121
        @Override
122
        public int getType() {
123
            return this.type;
124
        }
125

  
126
        @Override
127
        public void setType(int type) {
128
            this.type = type;
129
        }
130

  
131
        @Override
132
        public int getPrecision() {
133
            return type_p;
134
        }
135

  
136
        @Override
137
        public void setPrecision(int precision) {
138
            this.type_p = precision;
139
        }
140

  
141
        @Override
142
        public int getSize() {
143
            return type_s;
144
        }
145

  
146
        @Override
147
        public void setSize(int size) {
148
            this.type_s = size;
149
        }
150

  
151
        @Override
152
        public boolean isPrimaryKey() {
153
            return isPk;
154
        }
155

  
156
        @Override
157
        public void setIsPrimaryKey(boolean isPk) {
158
            this.isPk = isPk;
159
        }
160

  
161
        @Override
162
        public boolean allowNulls() {
163
            return _allowNulls;
164
        }
165

  
166
        @Override
167
        public void setAllowNulls(boolean allowNulls) {
168
            this._allowNulls = allowNulls;
169
        }
170

  
171
        @Override
172
        public boolean isAutomatic() {
173
            return _isAutomatic;
174
        }
175

  
176
        @Override
177
        public void setIsAutomatic(boolean isAutomatic) {
178
            this._isAutomatic = isAutomatic;
179
        }
180

  
181
        @Override
182
        public Object getDefaultValue() {
183
            return defaultValue;
184
        }
185

  
186
        @Override
187
        public void setDefaultValue(Object defaultValue) {
188
            this.defaultValue = defaultValue;
189
        }
190

  
191
        @Override
192
        public int getGeometryType() {
193
            return geom_type;
194
        }
195

  
196
        @Override
197
        public void setGeometryType(int geom_type) {
198
            this.geom_type = geom_type;
199
        }
200

  
201
        @Override
202
        public int getGeometrySubtype() {
203
            return geom_subtype;
204
        }
205

  
206
        @Override
207
        public void setGeometrySubtype(int geom_subtype) {
208
            this.geom_subtype = geom_subtype;
209
        }
210

  
211
        @Override
212
        public int getGeometrySRSId() {
213
            return geom_srsid;
214
        }
215

  
216
        @Override
217
        public void setGeometrySRSId(int geom_srsid) {
218
            this.geom_srsid = geom_srsid;
219
        }        
220

  
221
        @Override
222
        public boolean isGeometry() {
223
            return this.type == DataTypes.GEOMETRY;
224
        }
225
                
83 226
    }
227
    
84 228

  
85 229
    public class TableNameBuilderBase implements TableNameBuilder {
86 230

  
......
222 366
        @Override
223 367
        public TableNameBuilder table() {
224 368
            if( tableName == null ) {
225
                this.tableName = new TableNameBuilderBase();
369
                this.tableName = createTableNameBuilder();
226 370
            }
227 371
            return this.tableName;
228 372
        }
......
363 507
        protected boolean ascending;
364 508
        
365 509
        public OrderByBuilderBase() {
366
            
510
            this.ascending = true;
367 511
        }
368 512

  
369 513
        @Override
......
620 764
        @Override
621 765
        public TableNameBuilder table() {
622 766
            if( table == null ) {
623
                table = new TableNameBuilderBase();
767
                table = createTableNameBuilder();
624 768
            }
625 769
            return table;
626 770
        }
......
804 948
        @Override
805 949
        public TableNameBuilder table() {
806 950
            if( table == null ) {
807
                table = new TableNameBuilderBase();
951
                table = createTableNameBuilder();
808 952
            }
809 953
            return table;
810 954
        }
......
912 1056
        @Override
913 1057
        public TableNameBuilder table() {
914 1058
            if( table == null ) {
915
                table = new TableNameBuilderBase();
1059
                table = createTableNameBuilder();
916 1060
            }
917 1061
            return table;
918 1062
        }
......
1002 1146
        @Override
1003 1147
        public TableNameBuilder table() {
1004 1148
            if( table == null ) {
1005
                table = new TableNameBuilderBase();
1149
                table = createTableNameBuilder();
1006 1150
            }
1007 1151
            return table;
1008 1152
        }
......
1039 1183

  
1040 1184
        protected TableNameBuilder table;
1041 1185
        protected List<String> drops;
1042
        protected List<ColumnInfo> adds;
1043
        protected List<ColumnInfo> alters;
1186
        protected List<ColumnDescriptorBuilderBase> adds;
1187
        protected List<ColumnDescriptorBuilderBase> alters;
1044 1188
        protected List<Pair> renames;
1045 1189

  
1046 1190
        public AlterTableBuilderBase() {
......
1063 1207
        @Override
1064 1208
        public TableNameBuilder table() {
1065 1209
            if( table == null ) {
1066
                table = new TableNameBuilderBase();
1210
                table = createTableNameBuilder();
1067 1211
            }
1068 1212
            return table;
1069 1213
        }
......
1079 1223
            if (isPk || isAutomatic) {
1080 1224
                allowNulls = false;
1081 1225
            }
1082
            this.adds.add(new ColumnInfo(columnName, type, type_p, type_s, isPk, allowNulls, isAutomatic, defaultValue));
1226
            this.adds.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, allowNulls, isAutomatic, defaultValue));
1083 1227
            return this;
1084 1228
        }
1085 1229

  
......
1088 1232
            if (isPk || isAutomatic) {
1089 1233
                allowNulls = false;
1090 1234
            }
1091
            this.alters.add(new ColumnInfo(columnName, type, type_p, type_s, isPk, allowNulls, isAutomatic, defaultValue));
1235
            this.alters.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, allowNulls, isAutomatic, defaultValue));
1092 1236
            return this;
1093 1237
        }
1094 1238

  
......
1189 1333
                builder.append(column);
1190 1334
            }
1191 1335
            first = drops.isEmpty();
1192
            for (ColumnInfo column : adds) {
1336
            for (ColumnDescriptorBuilderBase column : adds) {
1193 1337
                if (first) {
1194 1338
                    first = false;
1195 1339
                } else {
1196 1340
                    builder.append(", ");
1197 1341
                }
1198 1342
                builder.append("ADD COLUMN ");
1199
                builder.append(column.name);
1343
                builder.append(column.getName());
1200 1344
                builder.append(" ");
1201
                if( column.type == DataTypes.INT && column.isAutomatic ) {
1345
                if( column.getType() == DataTypes.INT && column.isAutomatic() ) {
1202 1346
                    builder.append(" SERIAL");
1203 1347
                } else {
1204
                    builder.append(sqltype(column.type, column.type_p, column.type_s));
1348
                    builder.append(sqltype(column.getType(), column.getPrecision(), column.getSize()));
1205 1349
                }
1206
                if (column.defaultValue == null) {
1207
                    if (column.allowNulls) {
1350
                if (column.getDefaultValue() == null) {
1351
                    if (column.allowNulls()) {
1208 1352
                        builder.append(" DEFAULT NULL");
1209 1353
                    }
1210 1354
                } else {
1211 1355
                    builder.append(" DEFAULT '");
1212
                    builder.append(column.defaultValue.toString());
1356
                    builder.append(column.getDefaultValue().toString());
1213 1357
                    builder.append("'");
1214 1358
                }
1215
                if (column.allowNulls) {
1359
                if (column.allowNulls()) {
1216 1360
                    builder.append(" NULL");
1217 1361
                } else {
1218 1362
                    builder.append(" NOT NULL");
1219 1363
                }
1220
                if (column.isPk) {
1364
                if (column.isPrimaryKey()) {
1221 1365
                    builder.append(" PRIMARY KEY");
1222 1366
                }
1223 1367
            }
1224 1368
            first = drops.isEmpty() && adds.isEmpty();
1225
            for (ColumnInfo column : alters) {
1369
            for (ColumnDescriptorBuilderBase column : alters) {
1226 1370
                if (first) {
1227 1371
                    first = false;
1228 1372
                } else {
1229 1373
                    builder.append(", ");
1230 1374
                }
1231 1375
                builder.append("ALTER COLUMN ");
1232
                builder.append(column.name);
1376
                builder.append(column.getName());
1233 1377
                builder.append("SET DATA TYPE ");
1234
                if( column.type == DataTypes.INT && column.isAutomatic ) {
1378
                if( column.getType() == DataTypes.INT && column.isAutomatic() ) {
1235 1379
                    builder.append(" SERIAL");
1236 1380
                } else {
1237
                    builder.append(sqltype(column.type, column.type_p, column.type_s));
1381
                    builder.append(sqltype(column.getType(), column.getPrecision(), column.getSize()));
1238 1382
                }
1239 1383
                builder.append(", ");
1240
                if (column.defaultValue == null) {
1241
                    if (column.allowNulls) {
1384
                if (column.getDefaultValue() == null) {
1385
                    if (column.allowNulls()) {
1242 1386
                        builder.append("ALTER COLUMN ");
1243
                        builder.append(column.name);
1387
                        builder.append(column.getName());
1244 1388
                        builder.append(" SET DEFAULT NULL");
1245 1389
                    } else {
1246 1390
                        builder.append("ALTER COLUMN ");
1247
                        builder.append(column.name);
1391
                        builder.append(column.getName());
1248 1392
                        builder.append(" DROP DEFAULT");
1249 1393
                    }
1250 1394
                } else {
1251 1395
                    builder.append("ALTER COLUMN ");
1252
                    builder.append(column.name);
1396
                    builder.append(column.getName());
1253 1397
                    builder.append(" SET DEFAULT '");
1254
                    builder.append(column.defaultValue.toString());
1398
                    builder.append(column.getDefaultValue().toString());
1255 1399
                    builder.append("'");
1256 1400
                }
1257 1401
            }
......
1277 1421
    public class CreateTableBuilderBase implements CreateTableBuilder {
1278 1422

  
1279 1423
        protected TableNameBuilder table;
1280
        protected List<ColumnInfo> columns;
1424
        protected List<ColumnDescriptorBuilderBase> columns;
1281 1425

  
1282 1426
        public CreateTableBuilderBase() {
1283 1427
            this.columns = new ArrayList<>();
......
1296 1440
        @Override
1297 1441
        public TableNameBuilder table() {
1298 1442
            if( table == null ) {
1299
                table = new TableNameBuilderBase();
1443
                table = createTableNameBuilder();
1300 1444
            }
1301 1445
            return table;
1302 1446
        }
1303 1447

  
1304 1448
        @Override
1305 1449
        public CreateTableBuilderBase add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
1450
            if( StringUtils.isEmpty(columnName) ) {
1451
                throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
1452
            }
1306 1453
            if (isPk || isAutomatic) {
1307 1454
                allowNulls = false;
1308 1455
            }
1309
            this.columns.add(new ColumnInfo(columnName, type, type_p, type_s, isPk, allowNulls, isAutomatic, defaultValue));
1456
            this.columns.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, allowNulls, isAutomatic, defaultValue));
1310 1457
            return this;
1311 1458
        }
1312 1459

  
1313 1460
        @Override
1461
        public CreateTableBuilder add_geometry_column(String columnName, int type, int subtype, IProjection proj, boolean allowNulls) {
1462
            if( StringUtils.isEmpty(columnName) ) {
1463
                throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
1464
            }
1465
            this.columns.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, proj, allowNulls));
1466
            return this;
1467
        }
1468

  
1469
        @Override
1470
        public ColumnDescriptorBuilder getColumnDescriptor(String columnName) {
1471
            if( StringUtils.isEmpty(columnName) ) {
1472
                return null;
1473
            }
1474
            for (ColumnDescriptorBuilderBase column : columns) {
1475
                if( columnName.equals(column.getName()) ) {
1476
                    return column;
1477
                }
1478
            }
1479
            return null;
1480
        }
1481
                
1482
        @Override
1314 1483
        public String toString() {
1315 1484
            StringBuilder builder = new StringBuilder();
1316 1485
            boolean first = true;
......
1362 1531
            builder.append(this.table.toString());
1363 1532
            builder.append(" (");
1364 1533
            boolean first = true;
1365
            for (ColumnInfo column : columns) {
1534
            for (ColumnDescriptorBuilderBase column : columns) {
1366 1535
                if (first) {
1367 1536
                    first = false;
1368 1537
                } else {
1369 1538
                    builder.append(", ");
1370 1539
                }
1371
                builder.append(identifier(column.name));
1540
                builder.append(identifier(column.getName()));
1372 1541
                builder.append(" ");
1373
                if( column.isAutomatic && column.type == DataTypes.INT ) {
1542
                if( column.isAutomatic() && column.getType() == DataTypes.INT ) {
1374 1543
                    builder.append("SERIAL");
1375
                } else if( column.isAutomatic && column.type == DataTypes.LONG ) {
1544
                } else if( column.isAutomatic() && column.getType() == DataTypes.LONG ) {
1376 1545
                    builder.append("BIGSERIAL");
1377 1546
                } else {
1378
                    builder.append(sqltype(column.type, column.type_p, column.type_s));
1547
                    builder.append(sqltype(column.getType(), column.getPrecision(), column.getSize()));
1379 1548
                }
1380
                if (column.defaultValue == null) {
1381
                    if (column.allowNulls) {
1549
                if (column.getDefaultValue() == null) {
1550
                    if (column.allowNulls()) {
1382 1551
                        builder.append(" DEFAULT NULL");
1383 1552
                    }
1384 1553
                } else {
1385 1554
                    builder.append(" DEFAULT '");
1386
                    builder.append(column.defaultValue.toString());
1555
                    builder.append(column.getDefaultValue().toString());
1387 1556
                    builder.append("'");
1388 1557
                }
1389
                if (column.allowNulls) {
1558
                if (column.allowNulls()) {
1390 1559
                    builder.append(" NULL");
1391 1560
                } else {
1392 1561
                    builder.append(" NOT NULL");
1393 1562
                }
1394
                if (column.isPk) {
1563
                if (column.isPrimaryKey()) {
1395 1564
                    builder.append(" PRIMARY KEY");
1396 1565
                }
1397 1566
            }
......
1475 1644
        @Override
1476 1645
        public TableNameBuilder table() {
1477 1646
            if( table == null ) {
1478
                table = new TableNameBuilderBase();
1647
                table = createTableNameBuilder();
1479 1648
            }
1480 1649
            return table;
1481 1650
        }
......
1544 1713
        @Override
1545 1714
        public TableNameBuilder table() {
1546 1715
            if( table == null ) {
1547
                table = new TableNameBuilderBase();
1716
                table = createTableNameBuilder();
1548 1717
            }
1549 1718
            return table;
1550 1719
        }
......
1704 1873
        }
1705 1874
    }
1706 1875

  
1876
    private static Map<Pair<Integer,Integer>,String> sqlgeometrytypes = null;
1877
    
1878
    @Override
1879
    public Object sqlgeometrytype(int type, int subtype) {
1880
        // Devuelve un Object por que algunos gestores de BBDD utilizan
1881
        // identificadores numericos para el tipo y otros strings.
1882
        // Por defecto vamos a devolver strings.
1883
        if( sqlgeometrytypes==null ) {
1884
            sqlgeometrytypes = new HashMap<>();
1885
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM2D), "POINT");
1886
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM3D), "POINTZ");
1887
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM2DM), "POINTM");
1888
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM3DM), "POINTZM");
1889

  
1890
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM2D), "LINESTRING");
1891
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM3D), "LINESTRINGZ");
1892
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM2DM), "LINESTRINGM");
1893
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM3DM), "LINESTRINGZM");
1894

  
1895
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM2D), "POLYGON");
1896
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM3D), "POLYGONZ");
1897
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM2DM), "POLYGONM");
1898
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM3DM), "POLYGONZM");
1899

  
1900
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM2D), "MULTIPOINT");
1901
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM3D), "MULTIPOINTZ");
1902
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM2DM), "MULTIPOINTM");
1903
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM3DM), "MULTIPOINTZM");
1904

  
1905
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM2D), "MULTILINESTRING");
1906
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM3D), "MULTILINESTRINGZ");
1907
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM2DM), "MULTILINESTRINGM");
1908
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM3DM), "MULTILINESTRINGZM");
1909

  
1910
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM2D), "MULTIPOLYGON");
1911
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM3D), "MULTIPOLYGONZ");
1912
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM2DM), "MULTIPOLYGONM");
1913
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM3DM), "MULTIPOLYGONZM");
1914

  
1915
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM2D), "GEOMETRY");
1916
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM3D), "GEOMETRYZ");
1917
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM2DM), "GEOMETRYM");
1918
            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM3DM), "GEOMETRYZM");
1919
        }
1920
        return sqlgeometrytypes.get(new ImmutablePair<>(type,subtype));
1921
    }
1922

  
1923
    @Override
1924
    public Object sqlgeometrydimension(int type, int subtype) {
1925
        // Devuelve un Object por que algunos gestortes de BBDD utilizan
1926
        // identificadores numericos para las dimensiones y otros strings.
1927
        // Por defecto vamos a devolver enteros.
1928
        switch(subtype) {
1929
            case Geometry.SUBTYPES.GEOM3D:
1930
                return 3;
1931
            case Geometry.SUBTYPES.GEOM2DM:
1932
                return 3;
1933
            case Geometry.SUBTYPES.GEOM3DM:
1934
                return 4;
1935
            case Geometry.SUBTYPES.GEOM2D:
1936
            default:
1937
                return 2;
1938
        }
1939
    }
1940
    
1941
    protected TableNameBuilder createTableNameBuilder() {
1942
        return new TableNameBuilderBase();
1943
    }
1944
    
1707 1945
    protected SelectColumnBuilder createSelectColumnBuilder() {
1708 1946
        return new SelectColumnBuilderBase();
1709 1947
    }

Also available in: Unified diff