Revision 20621

View differences:

trunk/libraries/libFMap_dataFile/.settings/org.eclipse.jdt.core.prefs
1
#Mon Feb 25 13:53:40 CET 2008
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6
org.eclipse.jdt.core.compiler.compliance=1.4
7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8
org.eclipse.jdt.core.compiler.debug.localVariable=generate
9
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
11
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
12
org.eclipse.jdt.core.compiler.source=1.3
trunk/libraries/libFMap_dataFile/.settings/org.eclipse.jdt.ui.prefs
1
#Mon Feb 25 13:53:40 CET 2008
2
eclipse.preferences.version=1
3
internal.default.compliance=default
trunk/libraries/libFMap_dataFile/build.xml
1
<project name="extCAD" default="dist" basedir=".">
2
    <description>
3
        Instala el plugin de CAD
4
    </description>
5
  <!-- set global properties for this build -->
6
  <property name="src" location="src"/>
7
  <property name="build" location="bin"/>
8
  <property name="src-test" location="src-test"/>
9
  <property name="build-test" location="bin-test"/>
10
  <property name="dist"  location="dist"/>
11
  <property name="plugin" value="com.iver.cit.gvsig.cad"/>
12
  <property name="mainplugin" value="com.iver.cit.gvsig"/>
13

  
14
	<property name="lib" value="lib"/>
15
	<property name="andami" value="../_fwAndami"/>
16
	<property name="jarName" value="${plugin}.jar"/>
17
	<property name="extensionsDir" location="${andami}/gvSIG/extensiones"/>
18
	<property name="andamiJar" location="${andami}/andami.jar"/>
19
	<property name="gvsigJar" location="${extensionsDir}/com.iver.cit.gvsig/lib/com.iver.cit.gvsig.jar"/>
20
	<property name="andamiLibs" location="${andami}/lib"/>
21
	<property name="fmapLibs" location="../libFMap/lib" />
22
	<import file="../binaries/ant/utilities.xml"/>
23

  
24

  
25
  <target name="init">
26
    <!-- Create the time stamp -->
27
    <tstamp/>
28
	<echo>
29
		Compiling ${ant.project.name}...</echo>
30

  
31
  </target>
32

  
33

  
34
  <target name="dist"
35
        description="generate the distribution" >
36
    <!-- Create the distribution directory -->
37
    <mkdir dir="${dist}"/>
38
    <copy todir="${extensionsDir}/${mainplugin}/lib">
39
    	<fileset dir="./lib" includes="*.jar,*.zip"/>
40
    </copy>
41
  	<jar jarfile="${dist}/${jarName}" basedir="${build}"/>
42
    <copy file="config/config.xml" todir="${dist}"/>
43
  	<copy file="build.number" todir="${dist}"/>
44
    <copy todir="${dist}">
45
    	<fileset dir="config" includes="text*.properties"/>
46
    </copy>
47
    <copy todir="${dist}/images">
48
    	<fileset dir="images/" includes="*"/>
49
    </copy>
50

  
51
    <move todir="${extensionsDir}/${plugin}/">
52
    	<fileset dir="${dist}" includes="**/**"/>
53
    </move>
54
  </target>
55

  
56
		<target name="batch-build"
57
				description="compile the sources, create the jar file"
58
				depends="init,compile,create-jar,copy-data-files,move-to-andami">
59
		</target>
60

  
61
		<target name="compile" description="compile the source" >
62
			<!-- Compile the Java code from ${src} to ${build} -->
63
			<antcall target="gvSIG-import-build-number"/>
64
			<mkdir dir="${build}" />
65
			<loadEclipseClasspath project="${basedir}"/>
66
			<gvSIG-javac
67
				classpath="${eclipseClasspath}"/>
68
		</target>
69

  
70
		<target name="create-jar"
71
				description="Creates the plugin jar">
72
			<mkdir dir="${dist}"/>
73
		    <jar jarfile="${dist}/${jarName}" basedir="${build}"/>
74
		</target>
75

  
76
		<target name="copy-data-files">
77
		    <copy file="config/config.xml" todir="${dist}"/>
78
			<copy file="build.number" todir="${dist}"/>
79
			<copy todir="${dist}">
80
				<fileset dir="config" includes="text*.properties"/>
81
			</copy>
82
			<copy todir="${dist}/images">
83
				<fileset dir="images/" includes="*"/>
84
			</copy>
85
		</target>
86

  
87
		<target name="move-to-andami">
88
		    <move todir="${extensionsDir}/${plugin}/">
89
		    	<fileset dir="${dist}" includes="**/**"/>
90
	    	</move>
91
		    <copy todir="${extensionsDir}/${mainplugin}/lib">
92
		    	<fileset dir="./lib" includes="*.jar,*.zip"/>
93
		    </copy>
94
		</target>
95

  
96
  <target name="clean"
97
        description="clean up" >
98
    <!-- Delete the ${build} and ${dist} directory trees -->
99
    <delete dir="${build}"/>
100
    <delete dir="${dist}"/>
101
  </target>
102

  
103

  
104
	<target name="run-tests" depends="batch-build,compile-tests">
105
			<antcall target="generic-run-tests">
106
				<param name="TestSuite.Name" value="org.gvsig.data.datastores.vectorial.driver.AllTests"/>
107
			</antcall>
108
		</target>
109
</project>
110

  
trunk/libraries/libFMap_dataFile/.classpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="src" path="/libFMap_data"/>
6
	<classpathentry sourcepath="/libIverUtiles" kind="lib" path="/_fwAndami/lib/iver-utiles.jar"/>
7
	<classpathentry output="bin-test" kind="src" path="src-test"/>
8
	<classpathentry kind="lib" path="/libFMap/lib/org.cresques.dxf.jar"/>
9
	<classpathentry sourcepath="ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.1.1/src/org.junit_3.8.1/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/>
10
	<classpathentry combineaccessrules="false" kind="src" path="/libMetadata"/>
11
	<classpathentry sourcepath="/libProjection" kind="lib" path="/libFMap/lib/org.cresques.cts.jar"/>
12
	<classpathentry combineaccessrules="false" kind="src" path="/libFMap"/>
13
	<classpathentry sourcepath="/libExceptions" kind="lib" path="/libFMap_data/lib/org.gvsig.exceptions.jar"/>
14
	<classpathentry sourcepath="/SQLJEP" kind="lib" path="/libFMap_data/lib/sqljep-0.2.jar"/>
15
	<classpathentry kind="output" path="bin"/>
16
</classpath>
trunk/libraries/libFMap_dataFile/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>libFMap_dataFile</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>de.loskutov.FileSync.FSBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
	</buildSpec>
19
	<natures>
20
		<nature>org.eclipse.jdt.core.javanature</nature>
21
	</natures>
22
</projectDescription>
trunk/libraries/libFMap_dataFile/src-test/org/gvsig/data/datastores/vectorial/file/dxf/DXFTest.java
1
package org.gvsig.data.datastores.vectorial.file.dxf;
2

  
3
import java.io.File;
4
import java.util.Iterator;
5

  
6
import junit.framework.TestCase;
7

  
8
import org.cresques.cts.IProjection;
9
import org.gvsig.data.DataManager;
10
import org.gvsig.data.datastores.vectorial.file.DataStoreTest;
11
import org.gvsig.data.datastores.vectorial.file.dxf.DXFStore;
12
import org.gvsig.data.datastores.vectorial.file.dxf.DXFStoreParameters;
13
import org.gvsig.data.datastores.vectorial.file.dxf.Register;
14
import org.gvsig.data.exception.CloseException;
15
import org.gvsig.data.exception.InitializeException;
16
import org.gvsig.data.exception.OpenException;
17
import org.gvsig.data.exception.ReadException;
18
import org.gvsig.data.vectorial.FeatureManager;
19
import org.gvsig.data.vectorial.IFeature;
20
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor;
21
import org.gvsig.data.vectorial.IFeatureCollection;
22
import org.gvsig.data.vectorial.IFeatureType;
23
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
24
import org.gvsig.data.vectorial.expansionadapter.MemoryExpansionAdapter;
25

  
26
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
27

  
28
public class DXFTest extends TestCase {
29
	private File file = new File(DataStoreTest.class.getResource("data/prueba.dxf").getFile());
30

  
31

  
32
	public static void main(String[] args) {
33
	}
34

  
35
	protected void setUp() throws Exception {
36
		super.setUp();
37
	}
38

  
39
	public void testInitialize() {
40
		Register.selfRegister();
41
		DataManager manager = DataManager.getManager();
42
		DXFStore store =null;
43

  
44
		DXFStoreParameters dxfParameters=null;
45
		dxfParameters=(DXFStoreParameters)manager.createDataStoreParameters(DXFStore.DATASTORE_NAME);
46
		dxfParameters.setFile(file);
47
		IProjection proj = CRSFactory.getCRS("EPSG:23030");
48
		dxfParameters.setProjection(proj);
49
		try {
50
			store=(DXFStore)manager.createDataStore(dxfParameters);
51
		} catch (InitializeException e) {
52
			// TODO Auto-generated catch block
53
			e.printStackTrace();
54
		}
55
		try {
56
			store.open();
57
		} catch (OpenException e1) {
58
			// TODO Auto-generated catch block
59
			e1.printStackTrace();
60
		}
61

  
62
		IFeatureType ft=store.getDefaultFeatureType();
63
		IFeatureCollection featureCollection=null;
64
		try {
65
			featureCollection = (IFeatureCollection)store.getDataCollection(ft,null,null);
66

  
67
		} catch (ReadException e) {
68
			// TODO Auto-generated catch block
69
			e.printStackTrace();
70
		}
71
		Iterator iter = featureCollection.iterator();
72
		while (iter.hasNext()) {
73
			IFeature feature = (IFeature)iter.next();
74
			System.out.println("DXF Feature ------------------- ");
75
			Iterator iterator=ft.iterator();
76
			while (iterator.hasNext()) {
77
				IFeatureAttributeDescriptor descriptor = (IFeatureAttributeDescriptor) iterator.next();
78
				int i=descriptor.ordinal();
79
				String type=descriptor.getDataType();
80
				if (type.equals(IFeatureAttributeDescriptor.TYPE_BOOLEAN)){
81
					System.out.println("Boolean ----- "+ feature.getBoolean(i));
82
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_BYTE)){
83
					System.out.println("Byte ----- "+ feature.getByte(i));
84
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_DATE)){
85
					System.out.println("Date ----- "+ feature.getDate(i));
86
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_DOUBLE)){
87
					System.out.println("Double ----- "+ feature.getDouble(i));
88
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_FLOAT)){
89
					System.out.println("Float ----- "+ feature.getFloat(i));
90
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_INT)){
91
					System.out.println("Integer ----- "+ feature.getInt(i));
92
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_LONG)){
93
					System.out.println("Long ----- "+ feature.getLong(i));
94
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_STRING)){
95
					System.out.println("String ----- "+ feature.getString(i));
96
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_GEOMETRY)){
97

  
98
					System.out.println("Geometry ----- "+ feature.getGeometry(i));
99
				}
100
			}
101
		}
102
		iter = null;
103
		featureCollection.dispose();
104

  
105
		try {
106
			store.close();
107

  
108
			store.dispose();
109
		} catch (CloseException e) {
110
			// TODO Auto-generated catch block
111
			e.printStackTrace();
112
		}
113
	}
114
}
trunk/libraries/libFMap_dataFile/src-test/org/gvsig/data/datastores/vectorial/file/DataStoreTest.java
1
package org.gvsig.data.datastores.vectorial.file;
2

  
3
import java.io.File;
4
import java.util.Iterator;
5

  
6
import junit.framework.TestCase;
7

  
8
import org.cresques.cts.IProjection;
9
import org.gvsig.data.DataManager;
10
import org.gvsig.data.IDataStoreParameters;
11
import org.gvsig.data.commands.ICommandsRecord;
12
import org.gvsig.data.datastores.vectorial.file.dbf.DBFStore;
13
import org.gvsig.data.datastores.vectorial.file.dbf.DBFStoreParameters;
14
import org.gvsig.data.datastores.vectorial.file.dgn.DGNStore;
15
import org.gvsig.data.datastores.vectorial.file.dgn.DGNStoreParameters;
16
import org.gvsig.data.datastores.vectorial.file.dxf.DXFStore;
17
import org.gvsig.data.datastores.vectorial.file.dxf.DXFStoreParameters;
18
import org.gvsig.data.datastores.vectorial.file.shp.SHPStore;
19
import org.gvsig.data.datastores.vectorial.file.shp.SHPStoreParameters;
20
import org.gvsig.data.datastores.vectorial.file.shp.utils.SHP;
21
import org.gvsig.data.exception.CloseException;
22
import org.gvsig.data.exception.DataException;
23
import org.gvsig.data.exception.InitializeException;
24
import org.gvsig.data.exception.OpenException;
25
import org.gvsig.data.exception.ReadException;
26
import org.gvsig.data.exception.WriteException;
27
import org.gvsig.data.vectorial.AttributeDescriptor;
28
import org.gvsig.data.vectorial.FeatureType;
29
import org.gvsig.data.vectorial.IFeature;
30
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor;
31
import org.gvsig.data.vectorial.IFeatureCollection;
32
import org.gvsig.data.vectorial.IFeatureStore;
33
import org.gvsig.data.vectorial.IFeatureType;
34
import org.gvsig.data.vectorial.IsNotAttributeSettingException;
35
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
36
import org.gvsig.data.vectorial.visitor.PrintlnFeaturesVisitor;
37
import org.gvsig.exceptions.BaseException;
38

  
39
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
40

  
41
public class DataStoreTest extends TestCase {
42

  
43
	private File dbffile = new File(DataStoreTest.class.getResource("data/prueba.dbf").getFile());
44
	private File shpfile = new File(DataStoreTest.class.getResource("data/prueba.shp").getFile());
45
	private File dxffile = new File(DataStoreTest.class.getResource("data/prueba.dxf").getFile());
46
	private File dgnfile = new File(DataStoreTest.class.getResource("data/cv_300_todo.dgn").getFile());
47

  
48
	public static void main(String[] args) {
49
		junit.textui.TestRunner.run(DataStoreTest.class);
50
	}
51

  
52
	protected void setUp() throws Exception {
53
		super.setUp();
54

  
55
	}
56

  
57
	public void testDBF() {
58
		try {
59
			System.out.println("======= DBF ==============");
60
			org.gvsig.data.datastores.vectorial.file.dbf.Register.selfRegister();
61

  
62
			DataManager dsm=DataManager.getManager();
63

  
64

  
65
			IDataStoreParameters dp=dsm.createDataStoreParameters(DBFStore.DATASTORE_NAME);
66
			((DBFStoreParameters)dp).setFile(dbffile);
67

  
68
			driverTest(dp,null,null,true);
69
			IFeatureStore fs=null;
70
			try {
71
				fs = (IFeatureStore)dsm.createDataStore(dp);
72
			} catch (InitializeException e) {
73
				e.printStackTrace();
74
				fail("Exception:" + e);
75
			}
76
			assertNotNull("Can't create Feature Store", fs);
77

  
78

  
79
			fs.open();
80

  
81

  
82
			Iterator it;
83
			IFeatureCollection fc;
84
			Comparable v1,v2;
85
			IFeature feature,pfeature;
86
			long count;
87

  
88

  
89
			fc = (IFeatureCollection)fs.getDataCollection();
90

  
91
			assertEquals(9, fc.size());
92

  
93
			fc = (IFeatureCollection)fs.getDataCollection(null,"lower(NOMBRE) like 'b%'",null);
94

  
95
			assertEquals(2, fc.size());
96

  
97
			it = fc.iterator();
98
			count=0;
99
			while (it.hasNext()){
100
				feature = (IFeature)it.next();
101
				assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
102
				count++;
103
			}
104
			assertEquals("Iteration error",2,count);
105

  
106

  
107
			fc = (IFeatureCollection)fs.getDataCollection(null,null,"NOMBRE ASC");
108
			assertEquals(9, fc.size());
109
			it = fc.iterator();
110
			count=0;
111
			pfeature = (IFeature)it.next();
112
			count++;
113
			while (it.hasNext()){
114
				feature = (IFeature)it.next();
115
				v1 = (Comparable)pfeature.get("NOMBRE");
116
				v2 = (Comparable)feature.get("NOMBRE");
117
				pfeature=feature;
118
				assertTrue("Short error", (v1.compareTo(v1) <= 0));
119
				count++;
120
			}
121
			assertEquals("Iteration error",9,count);
122

  
123

  
124
			fc = (IFeatureCollection)fs.getDataCollection(null,null,"NOMBRE DESC");
125
			assertEquals(9, fc.size());
126
			it = fc.iterator();
127

  
128
			count=0;
129
			pfeature = (IFeature)it.next();
130
			count++;
131
			while (it.hasNext()){
132
				feature = (IFeature)it.next();
133
				v1 = (Comparable)pfeature.get("NOMBRE");
134
				v2 = (Comparable)feature.get("NOMBRE");
135
				pfeature=feature;
136
				assertTrue("Short error", (v1.compareTo(v1) >= 0));
137
				count++;
138
			}
139
			assertEquals("Iteration error",9,count);
140

  
141

  
142
			fc = (IFeatureCollection)fs.getDataCollection(null,"lower(NOMBRE) like 'b%'","NOMBRE");
143

  
144
			assertEquals(2, fc.size());
145

  
146
			it = fc.iterator();
147

  
148
			count=0;
149
			pfeature = (IFeature)it.next();
150
			assertTrue(pfeature.getString("NOMBRE").toLowerCase().startsWith("b"));
151
			count++;
152
			while (it.hasNext()){
153
				feature = (IFeature)it.next();
154
				assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
155
				v1 = (Comparable)pfeature.get("NOMBRE");
156
				v2 = (Comparable)feature.get("NOMBRE");
157
				pfeature=feature;
158
				assertTrue("Short error", (v1.compareTo(v1) <= 0));
159
				count++;
160
			}
161
			assertEquals("Iteration error",2,count);
162

  
163

  
164

  
165
			fc = (IFeatureCollection)fs.getDataCollection(null,null,"Tipo,lower(NOMBRE) Desc");
166
			assertEquals(9, fc.size());
167
			it = fc.iterator();
168
			count=0;
169
			pfeature = (IFeature)it.next();
170
			System.out.println(pfeature.getString("NOMBRE"));
171
			count++;
172
			while (it.hasNext()){
173
				feature = (IFeature)it.next();
174
				v1 = (Comparable)((String)pfeature.get("NOMBRE")).toLowerCase();
175
				v2 = (Comparable)((String)feature.get("NOMBRE")).toLowerCase();
176
				pfeature=feature;
177
				assertTrue("Short error", (v1.compareTo(v2) >= 0));
178
				System.out.println(pfeature.getString("NOMBRE"));
179
				count++;
180
			}
181
			assertEquals("Iteration error",9,count);
182

  
183

  
184
			/// CON  EDICION
185

  
186
			fs.startEditing();
187

  
188
			IFeature newFeature = fs.createFeature(fs.getDefaultFeatureType());
189
			newFeature.editing();
190
			newFeature.set("NOMBRE","BuRjaSOT");
191
			newFeature.set("TIPO","MUNICIPIO");
192
			fs.insert(newFeature);
193

  
194
			try {
195
				fc = (IFeatureCollection)fs.getDataCollection();
196
			} catch (ReadException e1) {
197
				e1.printStackTrace();
198
				fail();
199
			}
200

  
201
			assertEquals(10, fc.size());
202

  
203
			try {
204
				fc = (IFeatureCollection)fs.getDataCollection(null,"lower(NOMBRE) like 'b%'",null);
205
			} catch (ReadException e1) {
206
				e1.printStackTrace();
207
				fail();
208
			}
209

  
210
			assertEquals(3, fc.size());
211

  
212
			it = fc.iterator();
213
			count=0;
214
			while (it.hasNext()){
215
				feature = (IFeature)it.next();
216
				assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
217
				count++;
218
			}
219
			assertEquals("Iteration error",3,count);
220

  
221

  
222
			try {
223
				fc = (IFeatureCollection)fs.getDataCollection(null,null,"NOMBRE ASC");
224
			} catch (ReadException e1) {
225
				e1.printStackTrace();
226
				fail();
227
			}
228
			assertEquals(10, fc.size());
229
			it = fc.iterator();
230
			count=0;
231
			pfeature = (IFeature)it.next();
232
			count++;
233
			while (it.hasNext()){
234
				feature = (IFeature)it.next();
235
				v1 = (Comparable)pfeature.get("NOMBRE");
236
				v2 = (Comparable)feature.get("NOMBRE");
237
				pfeature=feature;
238
				assertTrue("Short error", (v1.compareTo(v1) <= 0));
239
				count++;
240
			}
241
			assertEquals("Iteration error",10,count);
242

  
243

  
244
			try {
245
				fc = (IFeatureCollection)fs.getDataCollection(null,null,"NOMBRE DESC");
246
			} catch (ReadException e1) {
247
				e1.printStackTrace();
248
				fail();
249
			}
250
			assertEquals(10, fc.size());
251
			it = fc.iterator();
252

  
253
			count=0;
254
			pfeature = (IFeature)it.next();
255
			count++;
256
			while (it.hasNext()){
257
				feature = (IFeature)it.next();
258
				v1 = (Comparable)pfeature.get("NOMBRE");
259
				v2 = (Comparable)feature.get("NOMBRE");
260
				pfeature=feature;
261
				if (v1!=null && v2!=null)
262
					assertTrue("Short error", (v1.compareTo(v1) >= 0));
263
				count++;
264
			}
265
			assertEquals("Iteration error",10,count);
266

  
267

  
268
			try {
269
				fc = (IFeatureCollection)fs.getDataCollection(null,"lower(NOMBRE) like 'b%'","NOMBRE");
270
			} catch (ReadException e1) {
271
				e1.printStackTrace();
272
				fail();
273
			}
274

  
275
			assertEquals(3, fc.size());
276

  
277
			it = fc.iterator();
278

  
279
			count=0;
280
			pfeature = (IFeature)it.next();
281
			assertTrue(pfeature.getString("NOMBRE").toLowerCase().startsWith("b"));
282
			count++;
283
			while (it.hasNext()){
284
				feature = (IFeature)it.next();
285
				assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
286
				v1 = (Comparable)pfeature.get("NOMBRE");
287
				v2 = (Comparable)feature.get("NOMBRE");
288
				pfeature=feature;
289
				assertTrue("Short error", (v1.compareTo(v1) <= 0));
290
				count++;
291
			}
292
			assertEquals("Iteration error",3,count);
293

  
294

  
295

  
296
			try {
297
				fc = (IFeatureCollection)fs.getDataCollection(null,null,"Tipo,lower(NOMBRE) Desc");
298
			} catch (ReadException e1) {
299
				e1.printStackTrace();
300
				fail();
301
			}
302
			assertEquals(10, fc.size());
303
			it = fc.iterator();
304
			count=0;
305
			pfeature = (IFeature)it.next();
306
			System.out.println(pfeature.getString("TIPO")+","+pfeature.getString("NOMBRE"));
307
			count++;
308
			while (it.hasNext()){
309
				feature = (IFeature)it.next();
310
				System.out.println(feature.getString("TIPO")+","+feature.getString("NOMBRE"));
311
				v1 = (Comparable)((String)pfeature.get("TIPO")).toLowerCase();
312
				v2 = (Comparable)((String)feature.get("TIPO")).toLowerCase();
313
				assertTrue("Short error", (v2.compareTo(v1) >= 0));
314
				if (v1.compareTo(v2) == 0){
315
					v1 = (Comparable)((String)pfeature.get("NOMBRE")).toLowerCase();
316
					v2 = (Comparable)((String)feature.get("NOMBRE")).toLowerCase();
317
					assertTrue("Short error", (v1.compareTo(v2) >= 0));
318
				}
319
				pfeature=feature;
320

  
321
//				System.out.println(pfeature.getString("TIPO")+","+pfeature.getString("NOMBRE"));
322
				count++;
323
			}
324
			assertEquals("Iteration error",10,count);
325

  
326
			fs.cancelEditing();
327

  
328
			try {
329
				fs.close();
330
			} catch (CloseException e) {
331
				e.printStackTrace();
332
				fail("Exception:" + e);
333
			}
334

  
335

  
336
			System.out.println("======= /DBF ==============");
337

  
338
		} catch (DataException e) {
339
			// TODO Auto-generated catch block
340
			e.printStackTrace();
341
		}
342
	}
343

  
344
	public void testSHP() {
345
		try {
346
			System.out.println("======= SHP ==============");
347
			org.gvsig.data.datastores.vectorial.file.shp.Register.selfRegister();
348
			org.gvsig.data.datastores.vectorial.file.dbf.Register.selfRegister();
349

  
350
			DataManager dsm=DataManager.getManager();
351

  
352

  
353
			IDataStoreParameters dp=dsm.createDataStoreParameters(SHPStore.DATASTORE_NAME);
354
			((SHPStoreParameters)dp).setFile(shpfile);
355
//			((SHPStoreParameters)dp).setSHXFile(SHP.getShxFile(shpfile));
356
//			((SHPStoreParameters)dp).setDBFFile(SHP.getDbfFile(shpfile));
357

  
358

  
359
			driverTest(dp,null,null,true);
360

  
361
			IFeatureStore fs=null;
362
			try {
363
				fs = (IFeatureStore)dsm.createDataStore(dp);
364
			} catch (InitializeException e) {
365
				e.printStackTrace();
366
				fail("Exception:" + e);
367
			}
368

  
369
			assertNotNull("Can't create Feature Store", fs);
370

  
371

  
372
			fs.open();
373

  
374

  
375
			Iterator it;
376
			IFeatureCollection fc;
377
			Comparable v1,v2;
378
			IFeature feature,pfeature;
379
			long count;
380

  
381

  
382
			fc = (IFeatureCollection)fs.getDataCollection();
383

  
384
			assertEquals(9, fc.size());
385

  
386
			fc = (IFeatureCollection)fs.getDataCollection(null,"lower(NOMBRE) like 'b%'",null);
387

  
388
			assertEquals(2, fc.size());
389

  
390
			it = fc.iterator();
391
			count=0;
392
			while (it.hasNext()){
393
				feature = (IFeature)it.next();
394
				assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
395
				count++;
396
			}
397
			assertEquals("Iteration error",2,count);
398

  
399

  
400
			fc = (IFeatureCollection)fs.getDataCollection(null,null,"NOMBRE");
401
			assertEquals(9, fc.size());
402
			it = fc.iterator();
403
			count=0;
404
			pfeature = (IFeature)it.next();
405
			count++;
406
			while (it.hasNext()){
407
				feature = (IFeature)it.next();
408
				v1 = (Comparable)pfeature.get("NOMBRE");
409
				v2 = (Comparable)feature.get("NOMBRE");
410
				pfeature=feature;
411
				assertTrue("Short error", (v1.compareTo(v2) <= 0));
412
				count++;
413
			}
414
			assertEquals("Iteration error",9,count);
415

  
416

  
417
			fc = (IFeatureCollection)fs.getDataCollection(null,null,"NOMBRE DESC");
418
			assertEquals(9, fc.size());
419
			it = fc.iterator();
420
			count=0;
421
			pfeature = (IFeature)it.next();
422
			System.out.println(pfeature.getString("NOMBRE"));
423
			count++;
424
			while (it.hasNext()){
425
				feature = (IFeature)it.next();
426
				v1 = (Comparable)pfeature.get("NOMBRE");
427
				v2 = (Comparable)feature.get("NOMBRE");
428
				pfeature=feature;
429
				assertTrue("Short error", (v1.compareTo(v2) >= 0));
430
				System.out.println(pfeature.getString("NOMBRE"));
431
				count++;
432
			}
433
			assertEquals("Iteration error",9,count);
434

  
435

  
436
			fc = (IFeatureCollection)fs.getDataCollection(null,"lower(NOMBRE) like 'b%'","NOMBRE ASC");
437

  
438
			assertEquals(2, fc.size());
439

  
440
			it = fc.iterator();
441

  
442
			count=0;
443
			pfeature = (IFeature)it.next();
444
			assertTrue(pfeature.getString("NOMBRE").toLowerCase().startsWith("b"));
445
			count++;
446
			while (it.hasNext()){
447
				feature = (IFeature)it.next();
448
				assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
449
				v1 = (Comparable)pfeature.get("NOMBRE");
450
				v2 = (Comparable)feature.get("NOMBRE");
451
				pfeature=feature;
452
				assertTrue("Short error", (v1.compareTo(v2) <= 0));
453
				count++;
454
			}
455
			assertEquals("Iteration error",2,count);
456

  
457

  
458
			fc = (IFeatureCollection)fs.getDataCollection(null,null,"lower(NOMBRE) ASC");
459
			assertEquals(9, fc.size());
460
			it = fc.iterator();
461
			count=0;
462
			pfeature = (IFeature)it.next();
463
			count++;
464
			while (it.hasNext()){
465
				feature = (IFeature)it.next();
466
				v1 = (Comparable)((String)pfeature.get("NOMBRE")).toLowerCase();
467
				v2 = (Comparable)((String)feature.get("NOMBRE")).toLowerCase();
468
				pfeature=feature;
469
				assertTrue("Short error", (v1.compareTo(v2) <= 0));
470
				count++;
471
			}
472
			assertEquals("Iteration error",9,count);
473

  
474

  
475

  
476
			fc = (IFeatureCollection)fs.getDataCollection(null,null,"Tipo,lower(NOMBRE) Desc");
477
			assertEquals(9, fc.size());
478
			it = fc.iterator();
479
			count=0;
480
			pfeature = (IFeature)it.next();
481
			System.out.println(pfeature.getString("NOMBRE"));
482
			count++;
483
			while (it.hasNext()){
484
				feature = (IFeature)it.next();
485
				v1 = (Comparable)((String)pfeature.get("NOMBRE")).toLowerCase();
486
				v2 = (Comparable)((String)feature.get("NOMBRE")).toLowerCase();
487
				pfeature=feature;
488
				assertTrue("Short error", (v1.compareTo(v2) >= 0));
489
				System.out.println(pfeature.getString("NOMBRE"));
490
				count++;
491
			}
492
			assertEquals("Iteration error",9,count);
493

  
494

  
495

  
496
			/// CON  EDICION
497

  
498
			fs.startEditing();
499

  
500
			IFeature newFeature = fs.createFeature(fs.getDefaultFeatureType());
501
			newFeature.editing();
502
			newFeature.set("NOMBRE","BuRjaSOT");
503
			newFeature.set("TIPO","MUNICIPIO");
504
			fs.insert(newFeature);
505

  
506

  
507

  
508
			try {
509
				fc = (IFeatureCollection)fs.getDataCollection();
510
			} catch (ReadException e1) {
511
				e1.printStackTrace();
512
				fail();
513
			}
514

  
515
			assertEquals(10, fc.size());
516

  
517
			try {
518
				fc = (IFeatureCollection)fs.getDataCollection(null,"lower(NOMBRE) like 'b%'",null);
519
			} catch (ReadException e1) {
520
				e1.printStackTrace();
521
				fail();
522
			}
523

  
524
			assertEquals(3, fc.size());
525

  
526
			it = fc.iterator();
527
			count=0;
528
			while (it.hasNext()){
529
				feature = (IFeature)it.next();
530
				assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
531
				count++;
532
			}
533
			assertEquals("Iteration error",3,count);
534

  
535

  
536
			try {
537
				fc = (IFeatureCollection)fs.getDataCollection(null,null,"NOMBRE ASC");
538
			} catch (ReadException e1) {
539
				e1.printStackTrace();
540
				fail();
541
			}
542
			assertEquals(10, fc.size());
543
			it = fc.iterator();
544
			count=0;
545
			pfeature = (IFeature)it.next();
546
			count++;
547
			while (it.hasNext()){
548
				feature = (IFeature)it.next();
549
				v1 = (Comparable)pfeature.get("NOMBRE");
550
				v2 = (Comparable)feature.get("NOMBRE");
551
				pfeature=feature;
552
				assertTrue("Short error", (v1.compareTo(v1) <= 0));
553
				count++;
554
			}
555
			assertEquals("Iteration error",10,count);
556

  
557

  
558
			try {
559
				fc = (IFeatureCollection)fs.getDataCollection(null,null,"NOMBRE DESC");
560
			} catch (ReadException e1) {
561
				e1.printStackTrace();
562
				fail();
563
			}
564
			assertEquals(10, fc.size());
565
			it = fc.iterator();
566

  
567
			count=0;
568
			pfeature = (IFeature)it.next();
569
			count++;
570
			while (it.hasNext()){
571
				feature = (IFeature)it.next();
572
				v1 = (Comparable)pfeature.get("NOMBRE");
573
				v2 = (Comparable)feature.get("NOMBRE");
574
				pfeature=feature;
575
				assertTrue("Short error", (v1.compareTo(v1) >= 0));
576
				count++;
577
			}
578
			assertEquals("Iteration error",10,count);
579

  
580

  
581
			try {
582
				fc = (IFeatureCollection)fs.getDataCollection(null,"lower(NOMBRE) like 'b%'","NOMBRE");
583
			} catch (ReadException e1) {
584
				e1.printStackTrace();
585
				fail();
586
			}
587

  
588
			assertEquals(3, fc.size());
589

  
590
			it = fc.iterator();
591

  
592
			count=0;
593
			pfeature = (IFeature)it.next();
594
			assertTrue(pfeature.getString("NOMBRE").toLowerCase().startsWith("b"));
595
			count++;
596
			while (it.hasNext()){
597
				feature = (IFeature)it.next();
598
				assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
599
				v1 = (Comparable)pfeature.get("NOMBRE");
600
				v2 = (Comparable)feature.get("NOMBRE");
601
				pfeature=feature;
602
				assertTrue("Short error", (v1.compareTo(v1) <= 0));
603
				count++;
604
			}
605
			assertEquals("Iteration error",3,count);
606

  
607

  
608

  
609
			try {
610
				fc = (IFeatureCollection)fs.getDataCollection(null,null,"Tipo,lower(NOMBRE) Desc");
611
			} catch (ReadException e1) {
612
				e1.printStackTrace();
613
				fail();
614
			}
615
			assertEquals(10, fc.size());
616
			it = fc.iterator();
617
			count=0;
618
			pfeature = (IFeature)it.next();
619
			System.out.println(pfeature.getString("NOMBRE"));
620
			count++;
621
			while (it.hasNext()){
622
				feature = (IFeature)it.next();
623
				v1 = (Comparable)((String)pfeature.get("NOMBRE")).toLowerCase();
624
				v2 = (Comparable)((String)feature.get("NOMBRE")).toLowerCase();
625
				pfeature=feature;
626
				assertTrue("Short error", (v1.compareTo(v2) >= 0));
627
				System.out.println(pfeature.getString("NOMBRE"));
628
				count++;
629
			}
630
			assertEquals("Iteration error",10,count);
631

  
632

  
633

  
634

  
635
			fs.cancelEditing();
636

  
637

  
638

  
639
			try {
640
				fs.close();
641
			} catch (CloseException e) {
642
				e.printStackTrace();
643
				fail("Exception:" + e);
644
			}
645

  
646

  
647

  
648
			System.out.println("======= /SHP ==============");
649
		} catch (DataException e) {
650
			// TODO Auto-generated catch block
651
			e.printStackTrace();
652
		}
653
	}
654

  
655
	public void testDXF() {
656
		try {
657
			System.out.println("======= DXF ==============");
658
			org.gvsig.data.datastores.vectorial.file.dxf.Register.selfRegister();
659

  
660
			DataManager dsm=DataManager.getManager();
661

  
662

  
663
			IDataStoreParameters dp=dsm.createDataStoreParameters(DXFStore.DATASTORE_NAME);
664
			((DXFStoreParameters)dp).setFile(dxffile);
665
			IProjection proj = CRSFactory.getCRS("EPSG:23030");
666
			((DXFStoreParameters)dp).setProjection(proj);
667
			driverTest(dp,null,null,true);
668

  
669
			IFeatureStore fs=null;
670
			try {
671
				fs = (IFeatureStore)dsm.createDataStore(dp);
672
			} catch (InitializeException e) {
673
				e.printStackTrace();
674
				fail("Exception:" + e);
675
			}
676
			assertNotNull("Can't create Feature Store", fs);
677

  
678

  
679
			fs.open();
680

  
681

  
682
			Iterator it;
683
			IFeatureCollection fc;
684
			Comparable v1,v2;
685
			IFeature feature,pfeature;
686
			long count;
687

  
688

  
689
			fc = (IFeatureCollection)fs.getDataCollection();
690

  
691
			assertEquals(10, fc.size());
692

  
693
			fc = (IFeatureCollection)fs.getDataCollection(null,"Color > '7'",null);
694

  
695
			assertEquals(2, fc.size());
696

  
697
			it = fc.iterator();
698
			count=0;
699
			while (it.hasNext()){
700
				feature = (IFeature)it.next();
701
				assertTrue("Filter error",feature.getInt("Color")>7);
702
				count++;
703
			}
704
			assertEquals("Iteration error",2,count);
705

  
706

  
707
			fc = (IFeatureCollection)fs.getDataCollection(null,null,"Layer ASC");
708
			assertEquals(10, fc.size());
709
			it = fc.iterator();
710
			count=0;
711
			pfeature = (IFeature)it.next();
712
			count++;
713
			while (it.hasNext()){
714
				feature = (IFeature)it.next();
715
				v1 = (Comparable)pfeature.get("Layer");
716
				v2 = (Comparable)feature.get("Layer");
717
				pfeature=feature;
718
				assertTrue("Short error", (v1.compareTo(v1) <= 0));
719
				count++;
720
			}
721
			assertEquals("Iteration error",10,count);
722

  
723

  
724
			fc = (IFeatureCollection)fs.getDataCollection(null,null,"Layer DESC");
725
			assertEquals(10, fc.size());
726
			it = fc.iterator();
727

  
728
			count=0;
729
			pfeature = (IFeature)it.next();
730
			count++;
731
			while (it.hasNext()){
732
				feature = (IFeature)it.next();
733
				v1 = (Comparable)pfeature.get("Layer");
734
				v2 = (Comparable)feature.get("Layer");
735
				pfeature=feature;
736
				assertTrue("Short error", (v1.compareTo(v1) >= 0));
737
				count++;
738
			}
739
			assertEquals("Iteration error",10,count);
740

  
741

  
742
			fc = (IFeatureCollection)fs.getDataCollection(null,"Color > '7'","Layer ASC");
743

  
744
			assertEquals(2, fc.size());
745

  
746
			it = fc.iterator();
747

  
748
			count=0;
749
			pfeature = (IFeature)it.next();
750
			assertTrue(pfeature.getInt("Color")>7);
751
			count++;
752
			while (it.hasNext()){
753
				feature = (IFeature)it.next();
754
				assertTrue("Filter error",feature.getInt("Color")>7);
755
				v1 = (Comparable)pfeature.get("Color");
756
				v2 = (Comparable)feature.get("Color");
757
				pfeature=feature;
758
				Integer i1=(Integer)v1;
759
				Integer i2=(Integer)v2;
760
				assertTrue("Short error", (i1.intValue()>i2.intValue()));
761
				count++;
762
			}
763
			assertEquals("Iteration error",2,count);
764

  
765

  
766

  
767
//			fc = (IFeatureCollection)fs.getDataCollection(null,null,"Color,Layer Desc");
768
//			assertEquals(10, fc.size());
769
//			it = fc.iterator();
770
//			count=0;
771
//			pfeature = (IFeature)it.next();
772
//			System.out.println(pfeature.getString("Layer"));
773
//			count++;
774
//			while (it.hasNext()){
775
//			feature = (IFeature)it.next();
776
//			v1 = (Comparable)((String)pfeature.get("Layer")).toLowerCase();
777
//			v2 = (Comparable)((String)feature.get("Layer")).toLowerCase();
778
//			pfeature=feature;
779
//			assertTrue("Short error", (v1.compareTo(v2) >= 0));
780
//			System.out.println(pfeature.getString("Layer"));
781
//			count++;
782
//			}
783
//			assertEquals("Iteration error",10,count);
784

  
785

  
786
			try {
787
				fs.close();
788
			} catch (CloseException e) {
789
				e.printStackTrace();
790
				fail("Exception:" + e);
791
			}
792

  
793

  
794
			System.out.println("======= /DXF ==============");
795
		} catch (OpenException e1) {
796
			e1.printStackTrace();
797
			fail();
798
		} catch (ReadException e) {
799
			// TODO Auto-generated catch block
800
			e.printStackTrace();
801
		}
802
	}
803

  
804
	public void testDGN() {
805
		try {
806
			System.out.println("======= DGN ==============");
807
			org.gvsig.data.datastores.vectorial.file.dgn.Register.selfRegister();
808

  
809
			DataManager dsm=DataManager.getManager();
810

  
811

  
812
			IDataStoreParameters dp=dsm.createDataStoreParameters(DGNStore.DATASTORE_NAME);
813
			((DGNStoreParameters)dp).setFile(dgnfile);
814
			driverTest(dp,null,null,true);
815
			IFeatureStore fs=null;
816
			try {
817
				fs = (IFeatureStore)dsm.createDataStore(dp);
818
			} catch (InitializeException e) {
819
				e.printStackTrace();
820
				fail("Exception:" + e);
821
			}
822
			assertNotNull("Can't create Feature Store", fs);
823

  
824

  
825
			fs.open();
826

  
827

  
828
			Iterator it;
829
			IFeatureCollection fc;
830
			Comparable v1,v2;
831
			IFeature feature,pfeature;
832
			long count;
833

  
834

  
835
			fc = (IFeatureCollection)fs.getDataCollection();
836

  
837
			assertEquals(14646, fc.size());
838

  
839
			fc = (IFeatureCollection)fs.getDataCollection(null,"Color > '7'",null);
840

  
841
			assertEquals(7352, fc.size());
842

  
843
			it = fc.iterator();
844
			count=0;
845
			while (it.hasNext()){
846
				feature = (IFeature)it.next();
847
				assertTrue("Filter error",feature.getInt("Color")>=7);
848
				count++;
849
			}
850
			assertEquals("Iteration error",7352,count);
851

  
852

  
853
			fc = (IFeatureCollection)fs.getDataCollection(null,null,"Layer ASC");
854
			assertEquals(14646, fc.size());
855
			it = fc.iterator();
856
			count=0;
857
			pfeature = (IFeature)it.next();
858
			count++;
859
			while (it.hasNext()){
860
				feature = (IFeature)it.next();
861
				v1 = (Comparable)pfeature.get("Layer");
862
				v2 = (Comparable)feature.get("Layer");
863
				if (v2==null)
864
					System.out.println("null");
865
				assertTrue("Short error", (v1.compareTo(v2) <= 0));
866
				pfeature=feature;
867
				count++;
868
			}
869
			assertEquals("Iteration error",14646,count);
870

  
871

  
872
			fc = (IFeatureCollection)fs.getDataCollection(null,null,"Layer DESC");
873
			assertEquals(14646, fc.size());
874
			it = fc.iterator();
875

  
876
			count=0;
877
			pfeature = (IFeature)it.next();
878
			count++;
879
			while (it.hasNext()){
880
				feature = (IFeature)it.next();
881
				v1 = (Comparable)pfeature.get("Layer");
882
				v2 = (Comparable)feature.get("Layer");
883
				assertTrue("Short error", (v1.compareTo(v2) >= 0));
884
				pfeature=feature;
885
				count++;
886
			}
887
			assertEquals("Iteration error",14646,count);
888

  
889

  
890
			fc = (IFeatureCollection)fs.getDataCollection(null,"Color > '7'","Layer ASC");
891

  
892
			assertEquals(7352, fc.size());
893

  
894
			it = fc.iterator();
895

  
896
			count=0;
897
			pfeature = (IFeature)it.next();
898
			assertTrue(pfeature.getInt("Color")>7);
899
			count++;
900
			while (it.hasNext()){
901
				feature = (IFeature)it.next();
902
				assertTrue("Filter error",feature.getInt("Color")>7);
903
				v1 = (Comparable)pfeature.get("Layer");
904
				v2 = (Comparable)feature.get("Layer");
905
				pfeature=feature;
906
				Integer i1=(Integer)v1;
907
				Integer i2=(Integer)v2;
908
				assertTrue("Short error", (i1.intValue()<=i2.intValue()));
909
				count++;
910
			}
911
			assertEquals("Iteration error",7352,count);
912

  
913

  
914

  
915
//			fc = (IFeatureCollection)fs.getDataCollection(null,null,"Color,Layer Desc");
916
//			assertEquals(10, fc.size());
917
//			it = fc.iterator();
918
//			count=0;
919
//			pfeature = (IFeature)it.next();
920
//			System.out.println(pfeature.getString("Layer"));
921
//			count++;
922
//			while (it.hasNext()){
923
//			feature = (IFeature)it.next();
924
//			v1 = (Comparable)((String)pfeature.get("Layer")).toLowerCase();
925
//			v2 = (Comparable)((String)feature.get("Layer")).toLowerCase();
926
//			pfeature=feature;
927
//			assertTrue("Short error", (v1.compareTo(v2) >= 0));
928
//			System.out.println(pfeature.getString("Layer"));
929
//			count++;
930
//			}
931
//			assertEquals("Iteration error",10,count);
932

  
933

  
934
			try {
935
				fs.close();
936
			} catch (CloseException e) {
937
				e.printStackTrace();
938
				fail("Exception:" + e);
939
			}
940

  
941

  
942
			System.out.println("======= /DGN ==============");
943
		} catch (OpenException e1) {
944
			e1.printStackTrace();
945
			fail();
946
		} catch (ReadException e) {
947
			// TODO Auto-generated catch block
948
			e.printStackTrace();
949
		}
950
	}
951

  
952

  
953

  
954

  
955

  
956

  
957
//	private IFeatureStore createFeatureStore(IDriverParameters dp){
958
//	DataSourceManager dsm=DataSourceManager.getManager();
959

  
960
//	IDataStoreParameters dsp=dsm.createDataStoreParameters(DriverStore.DATASTORE_NAME);
961

  
962
//	((IDriverStoreParameters)dsp).setDriverParameters(dp);
963
//	IFeatureStore fs=null;
964
//	try {
965
//	fs = (IFeatureStore)dsm.createDataStore(dsp);
966
//	} catch (InitializeException e) {
967
//	e.printStackTrace();
968
//	fail("Exception:" + e);
969
//	}
970
//	return fs;
971

  
972
//	}
973

  
974

  
975
	private void driverTest(IDataStoreParameters dp,String filter, String order,boolean testEdit){
976
		DataManager dsm=DataManager.getManager();
977

  
978
//		IDataStoreParameters dsp=dsm.createDataStoreParameters(DriverStore.DATASTORE_NAME);
979

  
980
//		((IDriverStoreParameters)dsp).setDriverParameters(dp);
981
//		IFeatureStore fs=createFeatureStore(dp);
982
		IFeatureStore fs=null;
983
		try {
984
			fs = (IFeatureStore)dsm.createDataStore(dp);
985
		} catch (InitializeException e) {
986
			e.printStackTrace();
987
			fail("Exception:" + e);
988
		}
989
		try {
990
			fs.open();
991
		} catch (OpenException e2) {
992
			e2.printStackTrace();
993
			fail();
994
		}
995

  
996
		if (fs.isEditable() && testEdit) {
997
			try {
998
				fs.startEditing();
999
				if (fs.canAlterFeatureType()){
1000
					IFeatureType featureType=fs.getDefaultFeatureType();
1001
//					DefaultAttributeDescriptor dad=new DefaultAttributeDescriptor();
1002
//					dad.loading();
1003
//					dad.setName("Prueba1");
1004
//					dad.setDefaultValue("11p");
1005
//					dad.setSize(10);
1006
//					dad.setType(IFeatureAttributeDescriptor.TYPE_STRING);
1007
//					dad.stopLoading();
1008
//					fs.insert(dad);
1009
//					fs.delete((IFeatureAttributeDescriptor)featureType.get(featureType.getFieldIndex("Prueba1")));
1010
					AttributeDescriptor dad2=(AttributeDescriptor)featureType.get(featureType.getFieldIndex("TIPO"));
1011
					dad2.editing();
1012
//					dad2.setName("TIPO");
1013
					dad2.setDefaultValue("Tipop");
1014
//					dad2.setSize(10);
1015
					dad2.setType(IFeatureAttributeDescriptor.TYPE_STRING);
1016
					fs.update(dad2);
1017
				}
1018
			} catch (ReadException e) {
1019
				e.printStackTrace();
1020
				fail();
1021
			}
1022
			catch (IsNotAttributeSettingException e) {
1023
				// TODO Auto-generated catch block
1024
				e.printStackTrace();
1025
			}
1026
			try {
1027
				IFeature feature1 = fs.createDefaultFeature(false);
1028

  
1029
				IFeature feature2 = fs.createDefaultFeature(false);
1030
				IFeature feature3 = fs.createDefaultFeature(false);
1031

  
1032
				fs.insert(feature1);
1033
				fs.insert(feature2);
1034

  
1035
				feature1.editing();
1036
				feature1.set(1,"hola");
1037

  
1038
				fs.update(feature1);
1039
				fs.delete(feature3);
1040
				fs.delete(feature2);
1041
			} catch (DataException e) {
1042
				// TODO Auto-generated catch block
1043
				e.printStackTrace();
1044
			}
1045
		}
1046

  
1047
		//Mostrar por consola todos los registros.
1048
		IFeatureType ft= fs.getDefaultFeatureType();
1049
		IFeatureCollection featureCollection=null;
1050
//		featureCollection = (IFeatureCollection)fs.getDataCollection();
1051
//		featureCollection = (IFeatureCollection)fs.getDataCollection(ft,"NOMBRE = 'CALPE'",null);
1052
//		featureCollection = (IFeatureCollection)fs.getDataCollection(ft,"AREA > 3.2213163729E7 and AREA < 3.2213163749E7",null);
1053
		try {
1054
			featureCollection = (IFeatureCollection)fs.getDataCollection(ft,filter,order);
1055
		} catch (ReadException e2) {
1056
			// TODO Auto-generated catch block
1057
			e2.printStackTrace();
1058
		}
1059

  
1060
		PrintlnFeaturesVisitor visitor=new PrintlnFeaturesVisitor(ft);
1061
		try {
1062
			featureCollection.accept(visitor);
1063
		} catch (BaseException e1) {
1064
			e1.printStackTrace();
1065
			fail("Exception: "+e1);
1066
		}
1067

  
1068
		featureCollection.dispose();
1069

  
1070
		if (fs.isEditable() && testEdit){
1071
			try {
1072
				fs.finishEditing();
1073
			} catch (WriteException e) {
1074
				e.printStackTrace();
1075
				fail("Exception: "+e);
1076
			} catch (ReadException e) {
1077
				e.printStackTrace();
1078
				fail("Exception: "+e);
1079
			}
1080
		}
1081
		try {
1082
			fs.close();
1083
		} catch (CloseException e) {
1084
			e.printStackTrace();
1085
			fail("Exception: "+e);
1086
		}
1087
		try {
1088
			fs.dispose();
1089
		} catch (CloseException e) {
1090
			// TODO Auto-generated catch block
1091
			e.printStackTrace();
1092
		}
1093
	}
1094
}
trunk/libraries/libFMap_dataFile/src-test/org/gvsig/data/datastores/vectorial/file/dgn/DGNTest.java
1
package org.gvsig.data.datastores.vectorial.file.dgn;
2

  
3
import java.io.File;
4
import java.util.Iterator;
5

  
6
import junit.framework.TestCase;
7

  
8
import org.gvsig.data.DataManager;
9
import org.gvsig.data.datastores.vectorial.file.DataStoreTest;
10
import org.gvsig.data.datastores.vectorial.file.dgn.DGNStore;
11
import org.gvsig.data.datastores.vectorial.file.dgn.DGNStoreParameters;
12
import org.gvsig.data.datastores.vectorial.file.dgn.Register;
13
import org.gvsig.data.exception.CloseException;
14
import org.gvsig.data.exception.InitializeException;
15
import org.gvsig.data.exception.OpenException;
16
import org.gvsig.data.exception.ReadException;
17
import org.gvsig.data.vectorial.FeatureManager;
18
import org.gvsig.data.vectorial.IFeature;
19
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor;
20
import org.gvsig.data.vectorial.IFeatureCollection;
21
import org.gvsig.data.vectorial.IFeatureType;
22
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
23
import org.gvsig.data.vectorial.expansionadapter.MemoryExpansionAdapter;
24

  
25
public class DGNTest extends TestCase {
26

  
27
	private File file = new File(DataStoreTest.class.getResource("data/cv_300_todo.dgn").getFile());
28

  
29

  
30
	public static void main(String[] args) {
31
	}
32

  
33
	protected void setUp() throws Exception {
34
		super.setUp();
35
	}
36

  
37
	public void testInitialize() {
38
		Register.selfRegister();
39
		DataManager manager = DataManager.getManager();
40
		DGNStore store = null;
41

  
42
		DGNStoreParameters dgnParameters;
43
		dgnParameters=(DGNStoreParameters)manager.createDataStoreParameters(DGNStore.DATASTORE_NAME);
44
		dgnParameters.setFile(file);
45
		try {
46
			store = (DGNStore)manager.createDataStore(dgnParameters);
47
		} catch (InitializeException e) {
48
			// TODO Auto-generated catch block
49
			e.printStackTrace();
50
		}
51
		try {
52
			store.open();
53
		} catch (OpenException e) {
54
			// TODO Auto-generated catch block
55
			e.printStackTrace();
56
		}
57

  
58
		IFeatureType ft=store.getDefaultFeatureType();
59
		IFeatureCollection featureCollection=null;
60
		try {
61
			featureCollection = (IFeatureCollection)store.getDataCollection(ft,null,null);
62
		} catch (ReadException e) {
63
			// TODO Auto-generated catch block
64
			e.printStackTrace();
65
		}
66
		Iterator iter = featureCollection.iterator();
67
		while (iter.hasNext()) {
68
			IFeature feature = (IFeature)iter.next();
69
			System.out.println("DGN Feature ------------------- ");
70
			Iterator iterator=ft.iterator();
71
			while (iterator.hasNext()) {
72
				IFeatureAttributeDescriptor descriptor = (IFeatureAttributeDescriptor) iterator.next();
73
				int i=descriptor.ordinal();
74
				String type=descriptor.getDataType();
75
				if (type.equals(IFeatureAttributeDescriptor.TYPE_BOOLEAN)){
76
					System.out.println("Boolean ----- "+ feature.getBoolean(i));
77
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_BYTE)){
78
					System.out.println("Byte ----- "+ feature.getByte(i));
79
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_DATE)){
80
					System.out.println("Date ----- "+ feature.getDate(i));
81
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_DOUBLE)){
82
					System.out.println("Double ----- "+ feature.getDouble(i));
83
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_FLOAT)){
84
					System.out.println("Float ----- "+ feature.getFloat(i));
85
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_INT)){
86
					System.out.println("Integer ----- "+ feature.getInt(i));
87
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_LONG)){
88
					System.out.println("Long ----- "+ feature.getLong(i));
89
				}else if (type.equals(IFeatureAttributeDescriptor.TYPE_STRING)){
90
					System.out.println("String ----- "+ feature.getString(i));
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff