[Gvsig_english] Error in table creation (fieldType ignored)

Flavio Pompermaier fla83tn at gmail.com
Thu Apr 21 15:57:16 CEST 2011


Hi to all,
I don't know if I'm doing something wrong but I have a very strange problem
in table creation.
I want to create an alphanumeric table (DBF) from the scratch, and the code
I use for doing this is:

            Driver driver = LayerFactory.getDM().getDriver("gdbms dbf
driver");
            dsf.createFileDataSource(driver.getName(), tableName,
tableFile.getAbsolutePath(), campos, fieldTypes);

            DataSource dataSource = dsf.createRandomDataSource(tableName,
DataSourceFactory.AUTOMATIC_OPENING);
            dataSource.setDataSourceFactory(dsf);
            SelectableDataSource sds = new SelectableDataSource(dataSource);
            EditableAdapter auxea = new EditableAdapter();
            auxea.setOriginalDataSource(sds);
            ProjectTable projectTables =
ProjectFactory.createTable(tableName, auxea);
            ProjectExtension ext = (ProjectExtension)
PluginServices.getExtension(ProjectExtension.class);
            ext.getProject().addDocument(projectTables);

The problem is that in this way, suppose that I have a fieldType = 4
(Integer), then in the created table I found a Double (fieldType=8)!!
To build correctly my table I have to:

1 - create an empty table:
              dsf.createFileDataSource(driver.getName(), tableName,
tableFile.getAbsolutePath(), new String[0], new int[0]);
2 - add a FieldDescription one at a time:
               .......
               auxea.setOriginalDataSource(sds);
               auxea.startComplexRow();
                for (int j = 0; j < fields.length; j++) {
                    FieldDescription field = fields[j];
                    auxea.addField(field);
                }
                auxea.endComplexRow("Fix table creation");
                ProjectTable projectTables =
ProjectFactory.createTable(tableName, auxea);
               .......

Is this a bug??

Best regards,
Flavio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserv.gva.es/pipermail/gvsig_internacional/attachments/20110421/14c82c43/attachment.htm 


More information about the Gvsig_internacional mailing list