This is a translation of the post that was published by Joaquín del Cerro some days ago, made by Daniel Vicente Batista.
Hello everyone again.
Some days ago I had to correct an error in the exportation assistant to Database and I realized more than I expected, so I am telling you how it is now.
So I had some request…
- Add data in an existing table.
- gvSIG warning about if the table exists before trying to load it.
- Ability to validate geometries before loading them in Database and verify if any of them is corrupted.
- Ability to show to user about the errors produced so that user may be able to take correcting measures.
- Not inserting in Database if an error that aborts the operation is produced.
- The name of the table is proposed, and it’s based on the name of the table that user wants to export.
- It was not clear what the primary key was. It has to be clarified and it will allow to choose a field of those that already exists as primary key.
- Usability can be improved when introducing connection data.
- Blank spaces and uppercase letter in identifiers.
- Once connection data are introduced, just clicking in Next button to export data if there’s no setback.
With all these stuff in mind I remade almost all the assistant. Now it is divided in six steps or pages.
Options about identifiers to use.
It allows us to select two checks:
- One of them to indicate that we want just lowercase in fields identifiers and table.
- Another one to indicate that we don’t want blank spaces in identifiers, and if they are shown they have to be replaced by underline.
It doesn’t mean that gvSIG doesn’t work good with uppercase and blank spaces. It’s because other apps that interact with tables with blanks or uppercase fields they don’t do it well or they need user to avoid these characters, that could be more tricky.
These two checks are shown by default.
It asks us about connection parameters:
- Connection type (generic JDBC, PostgreSQL,…)
- Host name where the service is.
- Port where the service is.
- Database name we want to use
Here we can name this connection configuration to reuse it later.
Table to create
Here we need to choose to create a new table or add data to an existing one.
If connection parameters indicated in previous step are correct, the tables list is shown in the database and allows us to choose one where it can be added.
If we select the option to create a new one, that is the default value, we need to indicate the scheme and the name of the table. It will propose by default values as “public” to the scheme and as name equal to the one we want to export.
If clicking Next this table already exists, the assistant doesn’t let us proceed, informing us this table already exists, and if we introduce spaces or uppercases it would ask us if we want to fix it automatically or not, following to next if we choose fix it alone.
It will allow us to choose among creating a new primary key based in an automatic value or choosing an existing one. Creating a new one option is checked by default and it will propose a “pk” name.
If we indicate we want to use an existing field, we need to choose the field that we want from a list.
When loading data in a Database it is recommended that the geometries that we load are “correct”. This page will allow us to select among the option to lead with this:
Do nothing special, the geometries are inserted and the error aborts the process.
Verify that there’s no geometry corrupted, normally due to loading a format that is permissive to store geometries, for example lines with just one point or polygons with less than two.
If we select this option, we need to choose among three actions to do when this happens:
- Insert the entire feature with geometry set as null.
- Don’t insert the feature and go to the next.
- Fail, and abort the process.
Verify that the geometries are “valid” (ST_isValid). And if don’t, check to try to correct automatically the problem, and in case of don’t choosing among three actions, same as previous case.
By default first option is checked, nothing special has to be done with the geometries.
Last we’ll need to indicate what features have to be loaded. We can:
- Insert all features of the table, that is the default option.
- Insert just selected features, what will insert just features that are selected ones in original table or layer.
- Apply a filter, where we can apply a filter using syntax of a “where” of SQL that we can record, assigning a name.
After passed for these pages of the assistant the process of exportation to Database will begin, and in case of an error a dialogue box will be shown trying to describe what the problem is, and if it happened processing a feature, it will show us the values of the feature that occasioned it.
Well, it’s all.