Revision 23383 branches/v2_0_0_prep/applications/appgvSIG/src-test/com/iver/cit/gvsig/project/TableTest.java
TableTest.java | ||
---|---|---|
61 | 61 |
|
62 | 62 |
import java.io.File; |
63 | 63 |
|
64 |
import org.gvsig.fmap.datasources.SelectableDataSource; |
|
65 |
import org.gvsig.fmap.drivers.formats.dbf.reading.DBFDriver; |
|
66 |
import org.gvsig.fmap.drivers.writing.adapters.EditableAdapter; |
|
64 |
//import org.gvsig.fmap.datasources.SelectableDataSource;
|
|
65 |
//import org.gvsig.fmap.drivers.formats.dbf.reading.DBFDriver;
|
|
66 |
//import org.gvsig.fmap.drivers.writing.adapters.EditableAdapter;
|
|
67 | 67 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
68 | 68 |
|
69 | 69 |
import junit.framework.TestCase; |
70 | 70 |
|
71 |
import com.hardcode.driverManager.Driver; |
|
72 |
import com.hardcode.driverManager.DriverLoadException; |
|
73 |
import com.hardcode.driverManager.DriverManager; |
|
74 |
import com.hardcode.driverManager.DriverValidation; |
|
75 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
76 |
import com.hardcode.gdbms.engine.data.DataSource; |
|
77 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
|
78 |
import com.hardcode.gdbms.engine.data.NoSuchTableException; |
|
79 |
import com.hardcode.gdbms.engine.data.driver.DBDriver; |
|
80 |
import com.hardcode.gdbms.engine.data.driver.FileDriver; |
|
81 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
|
71 |
//import com.hardcode.driverManager.Driver;
|
|
72 |
//import com.hardcode.driverManager.DriverLoadException;
|
|
73 |
//import com.hardcode.driverManager.DriverManager;
|
|
74 |
//import com.hardcode.driverManager.DriverValidation;
|
|
75 |
//import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
|
|
76 |
//import com.hardcode.gdbms.engine.data.DataSource;
|
|
77 |
//import com.hardcode.gdbms.engine.data.DataSourceFactory;
|
|
78 |
//import com.hardcode.gdbms.engine.data.NoSuchTableException;
|
|
79 |
//import com.hardcode.gdbms.engine.data.driver.DBDriver;
|
|
80 |
//import com.hardcode.gdbms.engine.data.driver.FileDriver;
|
|
81 |
//import com.hardcode.gdbms.engine.data.driver.ObjectDriver;
|
|
82 | 82 |
import com.iver.andami.PluginServices; |
83 | 83 |
import com.iver.cit.gvsig.ProjectExtension; |
84 | 84 |
import com.iver.cit.gvsig.project.documents.table.ProjectTable; |
85 |
|
|
85 |
//TODO comentado para que compile |
|
86 | 86 |
public class TableTest extends TestCase { |
87 | 87 |
public void testTable() { |
88 |
DriverManager dm = new DriverManager(); |
|
89 |
dm.setValidation(new DriverValidation() { |
|
90 |
public boolean validate(Driver d) { |
|
91 |
return ((d instanceof ObjectDriver) || |
|
92 |
(d instanceof FileDriver) || |
|
93 |
(d instanceof DBDriver)); |
|
94 |
} |
|
95 |
}); |
|
96 |
dm.loadDrivers(new File("../_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/drivers")); |
|
97 |
|
|
98 |
String[] Campos= {"Tipo_Via","Nombre","Numero","Sexo","CoorX","CoorY"}; |
|
99 |
int [] fieldTypes={12,12,12,12,12,12}; |
|
100 |
DBFDriver driver = new DBFDriver(); |
|
101 |
String name = "Tabla"; |
|
102 |
DataSourceFactory dsf =LayerFactory.getDataSourceFactory(); |
|
103 |
dsf.setDriverManager(dm); |
|
104 |
dsf.createFileDataSource(driver.getName(), name, "Archivo", Campos, fieldTypes); |
|
105 |
DataSource dataSource = null; |
|
106 |
dsf.createFileDataSource(driver.getName(), name, "MYTABLA.dbf", Campos, fieldTypes); |
|
107 |
|
|
108 |
try { |
|
109 |
dataSource = dsf.createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING); |
|
110 |
|
|
111 |
dataSource.setDataSourceFactory(dsf); |
|
112 |
SelectableDataSource sds = new SelectableDataSource(dataSource); |
|
113 |
EditableAdapter auxea = new EditableAdapter(); |
|
114 |
auxea.setOriginalDataSource(sds); |
|
115 |
|
|
116 |
|
|
117 |
ProjectTable projectTables = ProjectFactory.createTable(name, |
|
118 |
auxea); |
|
119 |
|
|
120 |
ProjectExtension ext = (ProjectExtension)PluginServices.getExtension(ProjectExtension.class); |
|
121 |
ext.getProject().addDocument(projectTables); |
|
122 |
} catch (DriverLoadException e) { |
|
123 |
// TODO Auto-generated catch block |
|
124 |
e.printStackTrace(); |
|
125 |
} catch (NoSuchTableException e) { |
|
126 |
// TODO Auto-generated catch block |
|
127 |
e.printStackTrace(); |
|
128 |
} catch (ReadDriverException e) { |
|
129 |
// TODO Auto-generated catch block |
|
130 |
e.printStackTrace(); |
|
131 |
} |
|
88 |
// DriverManager dm = new DriverManager();
|
|
89 |
// dm.setValidation(new DriverValidation() {
|
|
90 |
// public boolean validate(Driver d) {
|
|
91 |
// return ((d instanceof ObjectDriver) ||
|
|
92 |
// (d instanceof FileDriver) ||
|
|
93 |
// (d instanceof DBDriver));
|
|
94 |
// }
|
|
95 |
// });
|
|
96 |
// dm.loadDrivers(new File("../_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/drivers"));
|
|
97 |
// |
|
98 |
// String[] Campos= {"Tipo_Via","Nombre","Numero","Sexo","CoorX","CoorY"};
|
|
99 |
// int [] fieldTypes={12,12,12,12,12,12};
|
|
100 |
// DBFDriver driver = new DBFDriver();
|
|
101 |
// String name = "Tabla";
|
|
102 |
// DataSourceFactory dsf =LayerFactory.getDataSourceFactory();
|
|
103 |
// dsf.setDriverManager(dm);
|
|
104 |
// dsf.createFileDataSource(driver.getName(), name, "Archivo", Campos, fieldTypes);
|
|
105 |
// DataSource dataSource = null;
|
|
106 |
// dsf.createFileDataSource(driver.getName(), name, "MYTABLA.dbf", Campos, fieldTypes);
|
|
107 |
// |
|
108 |
// try {
|
|
109 |
// dataSource = dsf.createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING);
|
|
110 |
// |
|
111 |
// dataSource.setDataSourceFactory(dsf);
|
|
112 |
// SelectableDataSource sds = new SelectableDataSource(dataSource);
|
|
113 |
// EditableAdapter auxea = new EditableAdapter();
|
|
114 |
// auxea.setOriginalDataSource(sds);
|
|
115 |
// |
|
116 |
// |
|
117 |
// ProjectTable projectTables = ProjectFactory.createTable(name,
|
|
118 |
// auxea);
|
|
119 |
// |
|
120 |
// ProjectExtension ext = (ProjectExtension)PluginServices.getExtension(ProjectExtension.class);
|
|
121 |
// ext.getProject().addDocument(projectTables);
|
|
122 |
// } catch (DriverLoadException e) {
|
|
123 |
// // TODO Auto-generated catch block
|
|
124 |
// e.printStackTrace();
|
|
125 |
// } catch (NoSuchTableException e) {
|
|
126 |
// // TODO Auto-generated catch block
|
|
127 |
// e.printStackTrace();
|
|
128 |
// } catch (ReadDriverException e) {
|
|
129 |
// // TODO Auto-generated catch block
|
|
130 |
// e.printStackTrace();
|
|
131 |
// }
|
|
132 | 132 |
} |
133 | 133 |
|
134 | 134 |
// public void testSignature() { |
Also available in: Unified diff