Revision 47580 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.sqlite/org.gvsig.sqlite.provider/src/main/java/org/gvsig/sqlite/dal/SQLiteSQLBuilder.java
SQLiteSQLBuilder.java | ||
---|---|---|
12 | 12 |
import java.util.Date; |
13 | 13 |
import java.util.List; |
14 | 14 |
import org.apache.commons.lang3.StringUtils; |
15 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
|
15 | 16 |
import org.gvsig.expressionevaluator.ExpressionBuilder.Parameter; |
16 | 17 |
import org.gvsig.expressionevaluator.Formatter; |
17 | 18 |
import org.gvsig.fmap.dal.DataTypes; |
... | ... | |
55 | 56 |
this.STMT_DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table = null; //"DELETE FROM gpkg_geometry_columns WHERE table_name = {1}"; |
56 | 57 |
this.STMT_DELETE_GEOMETRY_COLUMN_FROM_TABLE_table = "DELETE FROM gpkg_geometry_columns WHERE table_name = {0}"; |
57 | 58 |
|
58 |
this.STMT_UPDATE_TABLE_STATISTICS_table = "SELECT UpdateLayerStatistics({0})";
|
|
59 |
this.STMT_UPDATE_TABLE_STATISTICS_table = "ANALYZE {0}";
|
|
59 | 60 |
|
60 | 61 |
this.type_boolean = "BOOLEAN"; |
61 | 62 |
this.type_byte = "TINYINT"; |
... | ... | |
136 | 137 |
sqls.add(TemplateUtils.getSqlTemplate(GeopackageIndexRTree.GROUP_NAME, "create_table_gpkg_extensions")); |
137 | 138 |
sqls.add(GeopackageGeometryColumns.buildCreateTableSQLIfNotExists()); |
138 | 139 |
sqls.add(String.format( |
139 |
"INSERT INTO \"main\".\"gpkg_contents\" (\"table_name\", \"data_type\", \"identifier\", \"description\", \"last_change\", \"min_x\", \"min_y\", \"max_x\", \"max_y\", \"srs_id\") VALUES ('%s', '%s', '%s', '', '%s', NULL, NULL, NULL, NULL, NULL)",
|
|
140 |
"INSERT INTO \"gpkg_contents\" (\"table_name\", \"data_type\", \"identifier\", \"description\", \"last_change\", \"min_x\", \"min_y\", \"max_x\", \"max_y\", \"srs_id\") VALUES ('%s', '%s', '%s', '', '%s', NULL, NULL, NULL, NULL, NULL)", |
|
140 | 141 |
this.table.getName(), |
141 | 142 |
"features", |
142 | 143 |
this.table.getName(), |
... | ... | |
144 | 145 |
)); |
145 | 146 |
} else { |
146 | 147 |
sqls.add(String.format( |
147 |
"INSERT INTO \"main\".\"gpkg_contents\" (\"table_name\", \"data_type\", \"identifier\", \"description\", \"last_change\", \"min_x\", \"min_y\", \"max_x\", \"max_y\", \"srs_id\") VALUES ('%s', '%s', '%s', '', '%s', NULL, NULL, NULL, NULL, NULL)",
|
|
148 |
"INSERT INTO \"gpkg_contents\" (\"table_name\", \"data_type\", \"identifier\", \"description\", \"last_change\", \"min_x\", \"min_y\", \"max_x\", \"max_y\", \"srs_id\") VALUES ('%s', '%s', '%s', '', '%s', NULL, NULL, NULL, NULL, NULL)", |
|
148 | 149 |
this.table.getName(), |
149 | 150 |
"attributes", |
150 | 151 |
this.table.getName(), |
... | ... | |
217 | 218 |
column.getGeometrySRSId() |
218 | 219 |
)); |
219 | 220 |
|
220 |
//TODO: A?adir el insert a gpkg_extensions |
|
221 | 221 |
GeopackageIndexRTree index = new GeopackageIndexRTree(); |
222 | 222 |
sqls.addAll(index.getCreateIndexSQL(this.table.getName(), column.getName(), pkName)); |
223 | 223 |
|
... | ... | |
245 | 245 |
@Override |
246 | 246 |
public List<String> toStrings(Formatter formatter) { |
247 | 247 |
List<String> sqls = new ArrayList<>(); |
248 |
|
|
249 |
String sql; |
|
250 |
sql = MessageFormat.format( |
|
251 |
STMT_DELETE_GEOMETRY_COLUMN_FROM_TABLE_table, |
|
252 |
as_identifier(this.table.getName()) |
|
253 |
); |
|
254 |
if (!StringUtils.isEmpty(sql)) { |
|
255 |
sqls.add(sql); |
|
256 |
} |
|
257 | 248 |
|
249 |
//No se pueden borrar aqui los indices espaciales, se hace en el explorer.remove |
|
250 |
// GeopackageIndexRTree index = new GeopackageIndexRTree(); |
|
251 |
// sqls.addAll(index.getRemoveIndexSQL(this.table.getName(), column.getName(), pkName)); |
|
252 |
|
|
253 |
sqls.add(GeopackageGeometryColumns.buildDeleteSQL(this.table.getName())); |
|
254 |
|
|
258 | 255 |
sqls.add(String.format( |
259 |
"DELETE FROM \"main\".\"gpkg_contents\" WHERE \"identifier\" = '%s'",
|
|
256 |
"DELETE FROM \"gpkg_contents\" WHERE \"identifier\" = '%s'", |
|
260 | 257 |
this.table.getName() |
261 | 258 |
)); |
262 | 259 |
|
263 | 260 |
sqls.add(String.format( |
264 |
"DELETE FROM \"main\".\"gpkg_extensions\" WHERE \"table_name\" = '%s'",
|
|
261 |
"DELETE FROM \"gpkg_extensions\" WHERE \"table_name\" = '%s'", |
|
265 | 262 |
this.table.getName() |
266 | 263 |
)); |
267 |
|
|
264 |
|
|
268 | 265 |
sqls.add( |
269 | 266 |
MessageFormat.format( |
270 | 267 |
STMT_DROP_TABLE_table, |
... | ... | |
481 | 478 |
} |
482 | 479 |
|
483 | 480 |
|
484 |
|
|
485 | 481 |
@Override |
486 | 482 |
public TableNameBuilder createTableNameBuilder() { |
487 | 483 |
return new SQLiteTableNameBuilderBase(); |
... | ... | |
508 | 504 |
this.formatter = new SQLiteFormatter(this); |
509 | 505 |
} |
510 | 506 |
return this.formatter; |
511 |
} |
|
507 |
}
|
|
512 | 508 |
} |
Also available in: Unified diff