Hi to all,<br>I don't know if I'm doing something wrong but I have a very strange problem in table creation.<br>I want to create an alphanumeric table (DBF) from the scratch, and the code I use for doing this is:<br>
<br> Driver driver = LayerFactory.getDM().getDriver("gdbms dbf driver");<br> dsf.createFileDataSource(driver.getName(), tableName, tableFile.getAbsolutePath(), campos, fieldTypes);<br> <br>
DataSource dataSource = dsf.createRandomDataSource(tableName, DataSourceFactory.AUTOMATIC_OPENING);<br> dataSource.setDataSourceFactory(dsf);<br> SelectableDataSource sds = new SelectableDataSource(dataSource);<br>
EditableAdapter auxea = new EditableAdapter();<br> auxea.setOriginalDataSource(sds);<br> ProjectTable projectTables = ProjectFactory.createTable(tableName, auxea);<br> ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);<br>
ext.getProject().addDocument(projectTables);<br><br>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)!!<br>To build correctly my table I have to:<br>
<br>1 - create an empty table:<br> dsf.createFileDataSource(driver.getName(), tableName, tableFile.getAbsolutePath(), new String[0], new int[0]);<br>2 - add a FieldDescription one at a time:<br> ....... <br>
auxea.setOriginalDataSource(sds);<br> auxea.startComplexRow();<br> for (int j = 0; j < fields.length; j++) {<br> FieldDescription field = fields[j];<br> auxea.addField(field);<br>
}<br> auxea.endComplexRow("Fix table creation");<br> ProjectTable projectTables = ProjectFactory.createTable(tableName, auxea);<br> ....... <br><br>Is this a bug??<br>
<br>Best regards,<br>Flavio<br>