Revision 11193
trunk/extensions/extSDE/build.xml | ||
---|---|---|
11 | 11 |
<property name="gvsiglibjar" value="gvsig-sde"/> |
12 | 12 |
<property name="fmapjar" value="fmap-sde"/> |
13 | 13 |
<property name="driverjar" value="sde"/> |
14 |
<property name="extensionDir" location="../Andami/gvSIG/extensiones"/> |
|
14 |
<property name="extensionDir" location="../_fwAndami/gvSIG/extensiones"/>
|
|
15 | 15 |
<property name="drivers-dir" location="${extensionDir}/${mainplugin}/drivers" /> |
16 | 16 |
|
17 | 17 |
<target name="init"> |
... | ... | |
20 | 20 |
<!-- Create the build directory structure used by compile --> |
21 | 21 |
<mkdir dir="${build}"/> |
22 | 22 |
<mkdir dir="${dist}"/> |
23 |
|
|
23 |
|
|
24 | 24 |
</target> |
25 | 25 |
|
26 |
<target name="generate-without-source" |
|
26 |
<target name="generate-without-source" depends="init"
|
|
27 | 27 |
description="generate the distribution without the source file"> |
28 | 28 |
<!-- Create the distribution directory --> |
29 | 29 |
<mkdir dir="${dist}"/> |
30 |
<mkdir dir="${dist}/lib"/> |
|
30 |
<mkdir dir="${dist}/lib"/> |
|
31 |
<mkdir dir="${dist}/images"/> |
|
31 | 32 |
<mkdir dir="${drivers-dir}/sde" /> |
32 |
|
|
33 |
|
|
33 | 34 |
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --> |
34 |
<jar jarfile="${dist}/lib/${plugin}.jar" basedir="${build}" includes="com/iver/cit/gvsig/**"/> |
|
35 |
<jar jarfile="${dist}/lib/${plugin}.jar" basedir="${build}" excludes="**/*VectorialSDE*" includes="com/iver/cit/gvsig/**"/>
|
|
35 | 36 |
<!-- <jar jarfile="${drivers-dir}/sde/sde.jar" basedir="${build}" includes="com/iver/cit/gvsig/fmap/drivers/sde/**"/> --> |
36 | 37 |
<copy file="config/config.xml" todir="${dist}"/> |
37 | 38 |
<copy todir="${dist}"> |
... | ... | |
40 | 41 |
<copy todir="${dist}/lib"> |
41 | 42 |
<fileset dir="./lib" includes="*.jar,*.zip"/> |
42 | 43 |
<!-- <fileset dir="." includes=".keystore"/> --> |
43 |
</copy> |
|
44 |
<move todir="${extensionDir}/${mainplugin}/lib"> |
|
44 |
</copy> |
|
45 |
<copy todir="${dist}/images"> |
|
46 |
<fileset dir="images" includes="*"/> |
|
47 |
</copy> |
|
48 |
<move todir="${extensionDir}/${plugin}/images"> |
|
49 |
<fileset dir="${dist}/images" includes="*"/> |
|
50 |
</move> |
|
51 |
<move todir="${extensionDir}/${plugin}"> |
|
52 |
<fileset dir="${dist}" includes="*"/> |
|
53 |
</move> |
|
54 |
<copy todir="${drivers-dir}/sde"> |
|
55 |
<fileset dir="${dist}/lib" includes="j*sdk.jar"/> |
|
56 |
</copy> |
|
57 |
<move todir="${extensionDir}/${plugin}/lib"> |
|
58 |
<fileset dir="${dist}/lib" includes="**"/> |
|
59 |
</move> |
|
60 |
<!--move todir="${extensionDir}/${mainplugin}/lib"> |
|
45 | 61 |
<fileset dir="${dist}" includes="${gvsiglibjar}.jar"/> |
46 | 62 |
<fileset dir="${dist}" includes="${fmapjar}.jar"/> |
47 |
</move> |
|
48 |
<move todir="${extensionDir}/${plugin}/"> |
|
49 |
<fileset dir="${dist}" includes="**/**"/> |
|
50 |
</move> |
|
63 |
</move--> |
|
64 |
|
|
65 |
<jar jarfile="${drivers-dir}/sde/sde.jar" basedir="./bin" excludes="**/VectorialSDE*" |
|
66 |
includes="com/iver/cit/gvsig/fmap/drivers/sde/*.*" |
|
67 |
/> |
|
68 |
<jar jarfile="${extensionDir}/${mainplugin}/lib/gvsig-sde.jar" basedir="./bin" includes="**/VectorialSDE*.*"/> |
|
69 |
|
|
51 | 70 |
</target> |
52 | 71 |
|
53 | 72 |
|
54 |
<target name="generate-with-source" description="generate the distribution with the source file" > |
|
55 |
<!-- Create the distribution directory --> |
|
73 |
<!--target name="generate-with-source" description="generate the distribution with the source file" > |
|
56 | 74 |
<mkdir dir="${dist}"/> |
75 |
<mkdir dir="${dist}/images"/> |
|
57 | 76 |
|
58 |
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --> |
|
59 | 77 |
<jar jarfile="${dist}/${plugin}.jar" basedir="${build}"/> |
60 | 78 |
<copy file="config/config.xml" todir="${dist}"/> |
61 | 79 |
<copy todir="${dist}"> |
... | ... | |
63 | 81 |
</copy> |
64 | 82 |
<copy todir="${dist}"> |
65 | 83 |
<fileset dir="." includes="${src}"/> |
84 |
|
|
66 | 85 |
</copy> |
67 |
<copy todir="${dist}/images">
|
|
86 |
<copy todir="${dist}/images">
|
|
68 | 87 |
<fileset dir="images/" includes="*"/> |
69 | 88 |
</copy> |
70 |
<move todir="${extension-dir}/${plugin}/"> |
|
71 |
<fileset dir="${dist}" includes="**/**"/> |
|
89 |
<move todir="${extensionDir}/${plugin}/images"> |
|
90 |
<fileset dir="images/" includes="*"/> |
|
91 |
</move> |
|
92 |
<move todir="${extensionDir}/${plugin}/"> |
|
93 |
<fileset dir="${dist}" includes="**/**" excludes="com/iver/cit/gvsig/fmap/drivers/sde/**"/> |
|
72 | 94 |
</move> |
73 |
</target> |
|
95 |
<jar jarfile="${drivers-dir}/sde/sde.jar" basedir="./bin" excludes="**/*VectorialSDEDriver*" |
|
96 |
includes="com/iver/cit/gvsig/fmap/drivers/sde/*.*" |
|
97 |
/> |
|
98 |
<jar jarfile="${extensionDir}/${mainplugin}/lib/gvsig-sde.jar" basedir="./bin" includes="com/iver/cit/gvsig/fmap/drivers/sde/VectorialSDEDriver.*"/> |
|
99 |
</target--> |
|
74 | 100 |
|
75 | 101 |
<target name="clean" |
76 | 102 |
description="clean up" > |
77 |
<!-- Delete the ${build} and ${dist} directory trees --> |
|
78 | 103 |
<delete dir="${dist}"/> |
79 | 104 |
</target> |
80 | 105 |
</project> |
trunk/extensions/extSDE/.classpath | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
<classpath> |
3 |
<classpathentry kind="src" path="src"> |
|
4 |
<attributes> |
|
5 |
</attributes> |
|
6 |
</classpathentry> |
|
7 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> |
|
8 |
<attributes> |
|
9 |
</attributes> |
|
10 |
</classpathentry> |
|
11 |
<classpathentry combineaccessrules="false" kind="src" path="/Andami"> |
|
12 |
<attributes> |
|
13 |
</attributes> |
|
14 |
</classpathentry> |
|
15 |
<classpathentry sourcepath="/Utiles/src" kind="lib" path="/Andami/lib/iver-utiles.jar"> |
|
16 |
<attributes> |
|
17 |
</attributes> |
|
18 |
</classpathentry> |
|
19 |
<classpathentry sourcepath="/DriverManager/src" kind="lib" path="/FMap 03/lib/driver-manager-1.0.jar"> |
|
20 |
<attributes> |
|
21 |
</attributes> |
|
22 |
</classpathentry> |
|
23 |
<classpathentry sourcepath="/jCMS" kind="lib" path="/FMap 03/lib/cms.jar"> |
|
24 |
<attributes> |
|
25 |
</attributes> |
|
26 |
</classpathentry> |
|
27 |
<classpathentry kind="lib" path="/Andami/lib/log4j-1.2.8.jar"> |
|
28 |
<attributes> |
|
29 |
</attributes> |
|
30 |
</classpathentry> |
|
31 |
<classpathentry kind="lib" path="lib/jsde_sdk-8.3.jar"> |
|
32 |
<attributes> |
|
33 |
</attributes> |
|
34 |
</classpathentry> |
|
35 |
<classpathentry kind="lib" path="/FMap 03/lib/gdbms-0.8-SNAPSHOT.jar"> |
|
36 |
<attributes> |
|
37 |
</attributes> |
|
38 |
</classpathentry> |
|
39 |
<classpathentry combineaccessrules="false" kind="src" path="/FMap 03"> |
|
40 |
<attributes> |
|
41 |
</attributes> |
|
42 |
</classpathentry> |
|
43 |
<classpathentry combineaccessrules="false" kind="src" path="/gvSIG 03"> |
|
44 |
<attributes> |
|
45 |
</attributes> |
|
46 |
</classpathentry> |
|
3 |
<classpathentry kind="src" path="src"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
5 |
<classpathentry combineaccessrules="false" kind="src" path="/_fwAndami"/> |
|
6 |
<classpathentry combineaccessrules="false" kind="src" path="/appgvSIG"/> |
|
7 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap"/> |
|
8 |
<classpathentry sourcepath="/libCq CMS for java" kind="lib" path="/libFMap/lib/cms.jar"/> |
|
9 |
<classpathentry sourcepath="/libDriverManager" kind="lib" path="/libFMap/lib/driver-manager-1.1.jar"/> |
|
10 |
<classpathentry sourcepath="/libGDBMS" kind="lib" path="/libFMap/lib/gdbms-0.8-SNAPSHOT.jar"/> |
|
11 |
<classpathentry sourcepath="/Utiles/src" kind="lib" path="/_fwAndami/lib/iver-utiles.jar"/> |
|
12 |
<classpathentry kind="lib" path="/_fwAndami/lib/log4j-1.2.8.jar"/> |
|
13 |
<classpathentry kind="lib" path="lib/jpe91_sdk.jar"/> |
|
14 |
<classpathentry kind="lib" path="lib/jsde91_sdk.jar"/> |
|
15 |
<classpathentry sourcepath="/libUI" kind="lib" path="/_fwAndami/lib/beans.jar"/> |
|
16 |
<classpathentry kind="src" path="src-test"/> |
|
17 |
<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"/> |
|
47 | 18 |
<classpathentry kind="output" path="bin"/> |
48 | 19 |
</classpath> |
trunk/extensions/extSDE/.project | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
<projectDescription> |
3 |
<name>gvSIG_JDBC</name>
|
|
4 |
<comment></comment> |
|
3 |
<name>extSDE</name>
|
|
4 |
<comment>@key 32303037303132322D31303030206578745344452F76636E </comment>
|
|
5 | 5 |
<projects> |
6 | 6 |
</projects> |
7 | 7 |
<buildSpec> |
... | ... | |
10 | 10 |
<arguments> |
11 | 11 |
</arguments> |
12 | 12 |
</buildCommand> |
13 |
<buildCommand> |
|
14 |
<name>de.loskutov.FileSync.FSBuilder</name> |
|
15 |
<arguments> |
|
16 |
</arguments> |
|
17 |
</buildCommand> |
|
18 |
<buildCommand> |
|
19 |
<name>com.soyatec.uml.std.Builder</name> |
|
20 |
<arguments> |
|
21 |
</arguments> |
|
22 |
</buildCommand> |
|
13 | 23 |
</buildSpec> |
14 | 24 |
<natures> |
15 | 25 |
<nature>org.eclipse.jdt.core.javanature</nature> |
26 |
<nature>com.soyatec.uml.std.Nature</nature> |
|
16 | 27 |
</natures> |
17 | 28 |
</projectDescription> |
trunk/extensions/extSDE/src-test/com/iver/cit/gvsig/sde/SDETest.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.sde; |
|
2 |
|
|
3 |
import java.sql.ResultSet; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
|
|
7 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
|
8 |
import com.hardcode.gdbms.engine.values.NumericValue; |
|
9 |
import com.iver.cit.gvsig.fmap.drivers.sde.ArcSdeDriver; |
|
10 |
import com.iver.cit.gvsig.fmap.drivers.sde.ArcSDELayerDefinition; |
|
11 |
|
|
12 |
public class SDETest extends TestCase { |
|
13 |
ArcSdeDriver driver = new ArcSdeDriver(); |
|
14 |
ResultSet rsGood = null; |
|
15 |
|
|
16 |
protected void setUp() throws Exception { |
|
17 |
super.setUp(); |
|
18 |
try { |
|
19 |
ArcSDELayerDefinition lyrDef = new ArcSDELayerDefinition(); |
|
20 |
lyrDef.setUser("sde"); |
|
21 |
lyrDef.setPassword("iver"); |
|
22 |
lyrDef.setHost("192.168.0.114"); |
|
23 |
lyrDef.setPort("5151"); |
|
24 |
lyrDef.setName("EJES"); |
|
25 |
lyrDef.setTableName("EJES"); |
|
26 |
lyrDef.setSchema("ProvinciasPruebas"); |
|
27 |
lyrDef.setFieldGeometry("SHAPE"); |
|
28 |
lyrDef.setFieldID("OBJECTID"); |
|
29 |
lyrDef.setWhereClause(""); |
|
30 |
lyrDef.setFieldNames(new String[] {"OBJECTID","ID","REFERINE","CALLE_ID","DESDEPAR","HASTAPAR","DESDEIMPAR","HASTAIMPAR"}); |
|
31 |
lyrDef.setSRID_EPSG("23030"); |
|
32 |
lyrDef.setConnectionName("NOMBRE CONEXI?N"); |
|
33 |
driver.setData(null, lyrDef); |
|
34 |
|
|
35 |
} |
|
36 |
catch (Exception e){ |
|
37 |
e.printStackTrace(); |
|
38 |
} |
|
39 |
} |
|
40 |
|
|
41 |
protected void tearDown() throws Exception { |
|
42 |
super.tearDown(); |
|
43 |
driver.close(); |
|
44 |
} |
|
45 |
|
|
46 |
public void testGetFieldValue() { |
|
47 |
try { |
|
48 |
for (int i=0; i < 15; i++){ |
|
49 |
//String aux = driver.getFieldValue(i, 0).toString(); |
|
50 |
int id = ((NumericValue) driver.getFieldValue(i, 0)).intValue(); |
|
51 |
System.out.println(id); |
|
52 |
assertEquals(id,i+1); |
|
53 |
} |
|
54 |
} catch (DriverException e) { |
|
55 |
e.printStackTrace(); |
|
56 |
} |
|
57 |
|
|
58 |
} |
|
59 |
} |
|
0 | 60 |
trunk/extensions/extSDE/src-test/com/iver/cit/gvsig/sde/SDETestSuite.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 08-feb-2007 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
/* CVS MESSAGES: |
|
45 |
* |
|
46 |
* $Id$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.2 2007-04-13 12:05:32 caballero |
|
49 |
* funcionando |
|
50 |
* |
|
51 |
* Revision 1.1.2.1 2007/03/28 06:37:15 caballero |
|
52 |
* arcSDE |
|
53 |
* |
|
54 |
* Revision 1.1.2.1 2007/02/28 07:35:10 jmvivo |
|
55 |
* Actualizado desde el HEAD. |
|
56 |
* |
|
57 |
* Revision 1.1 2007/02/08 20:27:57 azabala |
|
58 |
* *** empty log message *** |
|
59 |
* |
|
60 |
* |
|
61 |
*/ |
|
62 |
package com.iver.cit.gvsig.sde; |
|
63 |
|
|
64 |
import junit.framework.Test; |
|
65 |
import junit.framework.TestSuite; |
|
66 |
|
|
67 |
public class SDETestSuite { |
|
68 |
|
|
69 |
public static Test suite() { |
|
70 |
TestSuite suite = new TestSuite("Test for com.iver.cit.gvsig.sde"); |
|
71 |
//$JUnit-BEGIN$ |
|
72 |
suite.addTestSuite(SDETest.class); |
|
73 |
//$JUnit-END$ |
|
74 |
return suite; |
|
75 |
} |
|
76 |
|
|
77 |
} |
|
78 |
|
|
0 | 79 |
trunk/extensions/extSDE/config/config.xml | ||
---|---|---|
7 | 7 |
description="Support to access SDE" |
8 | 8 |
active="true" |
9 | 9 |
priority="1"> |
10 |
</extension> |
|
10 |
</extension> |
|
11 |
<extension class-name="com.iver.cit.gvsig.sde.SingleSDEConnectionExtension" |
|
12 |
description="Opens SDE connections manager" |
|
13 |
active="true"> |
|
14 |
|
|
15 |
<menu text="Ver/gestor_sde" action-command="GESTOR_SDE" key="d" |
|
16 |
tooltip="abrir_gestor_de_orig_sde" |
|
17 |
position="4"/> |
|
18 |
</extension> |
|
11 | 19 |
</extensions> |
12 | 20 |
</plugin-config> |
trunk/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/VectorialSDELayerDefinition.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.fmap.drivers.sde; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
|
4 |
|
|
5 |
|
|
6 |
/** |
|
7 |
* SDE Layer definition. |
|
8 |
* @author Vicente Caballero Navarro |
|
9 |
*/ |
|
10 |
public abstract class VectorialSDELayerDefinition extends DBLayerDefinition { |
|
11 |
|
|
12 |
public abstract void setUser(String stringProperty); |
|
13 |
|
|
14 |
public abstract void setHost(String stringProperty); |
|
15 |
|
|
16 |
public abstract void setPort(String stringProperty); |
|
17 |
public abstract void setSchema(String stringProperty); |
|
18 |
public abstract void setConnectionName(String stringProperty); |
|
19 |
|
|
20 |
public abstract String getHost(); |
|
21 |
|
|
22 |
public abstract String getSchema(); |
|
23 |
|
|
24 |
public abstract String getUser(); |
|
25 |
|
|
26 |
public abstract String getPort(); |
|
27 |
|
|
28 |
public abstract void setPassword(String clave); |
|
29 |
|
|
30 |
public abstract String getPassword(); |
|
31 |
|
|
32 |
public abstract String getConnectionName(); |
|
33 |
} |
|
0 | 34 |
trunk/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/testSDE.java | ||
---|---|---|
2 | 2 |
* Created on 13-may-2005 |
3 | 3 |
* |
4 | 4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
7 |
*
|
|
7 |
* |
|
8 | 8 |
* This program is free software; you can redistribute it and/or |
9 | 9 |
* modify it under the terms of the GNU General Public License |
10 | 10 |
* as published by the Free Software Foundation; either version 2 |
11 | 11 |
* of the License, or (at your option) any later version. |
12 |
*
|
|
12 |
* |
|
13 | 13 |
* This program is distributed in the hope that it will be useful, |
14 | 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | 16 |
* GNU General Public License for more details. |
17 |
*
|
|
17 |
* |
|
18 | 18 |
* You should have received a copy of the GNU General Public License |
19 | 19 |
* along with this program; if not, write to the Free Software |
20 | 20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 |
*
|
|
21 |
* |
|
22 | 22 |
* For more information, contact: |
23 | 23 |
* |
24 | 24 |
* Generalitat Valenciana |
... | ... | |
30 | 30 |
* +34 963862235 |
31 | 31 |
* gvsig@gva.es |
32 | 32 |
* www.gvsig.gva.es |
33 |
*
|
|
33 |
* |
|
34 | 34 |
* or |
35 |
*
|
|
35 |
* |
|
36 | 36 |
* IVER T.I. S.A |
37 | 37 |
* Salamanca 50 |
38 | 38 |
* 46005 Valencia |
39 | 39 |
* Spain |
40 |
*
|
|
40 |
* |
|
41 | 41 |
* +34 963163400 |
42 | 42 |
* dac@iver.es |
43 | 43 |
*/ |
... | ... | |
56 | 56 |
import com.esri.sde.sdk.client.SeSqlConstruct; |
57 | 57 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
58 | 58 |
|
59 |
|
|
60 |
/** |
|
61 |
* DOCUMENT ME! |
|
62 |
* |
|
63 |
* @author Vicente Caballero Navarro |
|
64 |
*/ |
|
59 | 65 |
public class testSDE { |
60 |
public static void main(String[] args) |
|
61 |
{ |
|
66 |
/** |
|
67 |
* DOCUMENT ME! |
|
68 |
* |
|
69 |
* @param args DOCUMENT ME! |
|
70 |
*/ |
|
71 |
public static void main(String[] args) { |
|
62 | 72 |
// Conexi?n: |
63 | 73 |
SeConnection conn = null; |
64 |
String server = "alvaro"; |
|
65 |
int instance = 5151; |
|
66 |
String database = "sigespa"; |
|
67 |
String user = "sde"; |
|
68 |
String password = "sde"; |
|
74 |
String server = "192.168.0.114"; |
|
75 |
int instance = 5151; |
|
76 |
String database = "ProvinciasPruebas"; |
|
77 |
String user = "sde"; |
|
78 |
String password = "iver"; |
|
79 |
|
|
69 | 80 |
try { |
70 |
conn = new SeConnection(server, instance, database, user, password);
|
|
71 |
}catch (SeException e) { |
|
81 |
conn = new SeConnection(server, instance, database, user, password); |
|
82 |
} catch (SeException e) {
|
|
72 | 83 |
e.printStackTrace(); |
84 |
|
|
73 | 85 |
return; |
74 |
}
|
|
75 |
|
|
86 |
} |
|
87 |
|
|
76 | 88 |
// Fetching data |
77 |
|
|
78 |
String layerName = "vias"; |
|
89 |
String layerName = "EJES"; |
|
79 | 90 |
SeObjectId layerID = null; |
80 | 91 |
String strSpatialColumn = ""; |
92 |
|
|
81 | 93 |
try { |
82 | 94 |
Vector theLayers = conn.getLayers(); |
83 |
for (int i=0; i < theLayers.size(); i++) |
|
84 |
{ |
|
85 |
SeLayer layer = (SeLayer)theLayers.elementAt(i); |
|
86 |
if (layer.getName().compareToIgnoreCase(layerName) == 0 ); |
|
87 |
{ |
|
95 |
|
|
96 |
for (int i = 0; i < theLayers.size(); i++) {
|
|
97 |
SeLayer layer = (SeLayer) theLayers.elementAt(i);
|
|
98 |
|
|
99 |
if (layer.getName().equals(layerName)) {
|
|
88 | 100 |
layerID = layer.getID(); |
89 | 101 |
strSpatialColumn = layer.getSpatialColumn(); |
90 |
|
|
102 |
System.err.println("Nombre de la capa= " + layer.getName()); |
|
103 |
|
|
104 |
for (int k = 0; k < layerID.longValue(); k++) { |
|
105 |
layer.getAccess(); |
|
106 |
layer.getQualifiedName(); |
|
107 |
layer.getArraySize(); |
|
108 |
layer.getDescription(); |
|
109 |
layer.getInfo(); |
|
110 |
layer.getShapeTypes(); |
|
111 |
|
|
112 |
// try{ |
|
113 |
System.err.println("Nombre campo= " + |
|
114 |
layerID.longValue()); |
|
115 |
|
|
116 |
// } catch( SeException e ) { |
|
117 |
// //System.out.println(e.getSeError().getErrDesc()); |
|
118 |
// } |
|
119 |
} |
|
91 | 120 |
} |
92 | 121 |
} |
93 |
if (layerID == null) |
|
94 |
{ |
|
122 |
|
|
123 |
if (layerID == null) {
|
|
95 | 124 |
System.err.println("Capa no encontrada"); |
125 |
|
|
96 | 126 |
return; |
97 | 127 |
} |
98 |
|
|
99 |
SeLayer layer = new SeLayer( conn, layerName, strSpatialColumn );
|
|
100 |
SeSqlConstruct sqlConstruct = new SeSqlConstruct( layerName);
|
|
128 |
|
|
129 |
SeLayer layer = new SeLayer(conn, layerName, strSpatialColumn);
|
|
130 |
SeSqlConstruct sqlConstruct = new SeSqlConstruct(layerName); |
|
101 | 131 |
long t1 = System.currentTimeMillis(); |
102 |
// Create a query stream between the client and server |
|
132 |
|
|
133 |
// Create a query stream between the client and server |
|
103 | 134 |
String[] cols = new String[2]; |
104 |
cols[0] = new String("RD_5"); |
|
105 |
cols[1] = layer.getSpatialColumn(); |
|
106 |
SeQuery query = new SeQuery( conn, cols, sqlConstruct ); |
|
135 |
cols[0] = new String("FID"); |
|
136 |
cols[1] = layer.getSpatialColumn(); |
|
137 |
|
|
138 |
SeQuery query = new SeQuery(conn, cols, sqlConstruct); |
|
107 | 139 |
query.prepareQuery(); |
108 | 140 |
query.execute(); |
141 |
|
|
109 | 142 |
long t2 = System.currentTimeMillis(); |
110 |
|
|
111 |
System.out.println("Tiempo de consulta:" + (t2 - t1) + " milisegundos"); |
|
143 |
|
|
144 |
System.out.println("Tiempo de consulta:" + (t2 - t1) + |
|
145 |
" milisegundos"); |
|
112 | 146 |
t1 = System.currentTimeMillis(); |
147 |
|
|
113 | 148 |
int cont = 0; |
114 | 149 |
SeRow row = query.fetch(); |
115 |
if( row == null ) { |
|
116 |
|
|
150 |
|
|
151 |
if (row == null) { |
|
117 | 152 |
System.out.println(" No rows fetched"); |
153 |
|
|
118 | 154 |
return; |
119 | 155 |
} |
156 |
|
|
120 | 157 |
// String rowID = "2"; |
121 |
|
|
122 | 158 |
// Get the definitions of all the columns retrieved |
123 | 159 |
SeColumnDefinition[] colDefs = row.getColumns(); |
124 |
while (row != null) |
|
125 |
{ |
|
160 |
|
|
161 |
while (row != null) {
|
|
126 | 162 |
evaluateRow(row, colDefs); |
127 | 163 |
row = query.fetch(); |
128 | 164 |
cont++; |
129 | 165 |
} |
166 |
|
|
130 | 167 |
// Close the query. |
131 |
|
|
132 | 168 |
query.close(); |
133 | 169 |
t2 = System.currentTimeMillis(); |
134 | 170 |
|
135 |
System.out.println("Tiempo de recorrido:" + (t2 - t1) + " milisegundos. " + cont + " registros."); |
|
171 |
System.out.println("Tiempo de recorrido:" + (t2 - t1) + |
|
172 |
" milisegundos. " + cont + " registros."); |
|
136 | 173 |
|
137 |
/* SeQuery extentQuery = new SeQuery( conn, cols, sqlConstruct );
|
|
138 |
SeQueryInfo queryInfo = new SeQueryInfo();
|
|
174 |
/* SeQuery extentQuery = new SeQuery( conn, cols, sqlConstruct ); |
|
175 |
SeQueryInfo queryInfo = new SeQueryInfo(); |
|
139 | 176 |
queryInfo.setConstruct(sqlConstruct); |
140 | 177 |
// queryInfo.setQueryType(SeQueryInfo.SE_QUERYTYPE_JFA); |
141 | 178 |
// query.prepareQueryInfo(queryInfo); |
142 |
|
|
179 |
|
|
143 | 180 |
SeExtent seExtent = extentQuery.calculateLayerExtent(queryInfo); |
144 | 181 |
extentQuery.close(); |
145 | 182 |
System.out.println(seExtent.toString()); |
146 |
|
|
147 |
|
|
183 |
|
|
184 |
|
|
148 | 185 |
SeQuery queryAux; |
149 | 186 |
t1 = System.currentTimeMillis(); |
150 |
// queryAux = new SeQuery( conn, cols, sqlConstruct );
|
|
187 |
// queryAux = new SeQuery( conn, cols, sqlConstruct ); |
|
151 | 188 |
for (int i=0; i < 250; i++) |
152 | 189 |
{ |
153 | 190 |
queryAux = new SeQuery( conn, cols, sqlConstruct ); |
154 | 191 |
SeObjectId rowID = new SeObjectId(i+1); |
155 | 192 |
row = queryAux.fetchRow("provin", rowID, cols); |
156 |
|
|
193 |
|
|
157 | 194 |
evaluateRow(row, colDefs); |
158 | 195 |
queryAux.close(); |
159 | 196 |
} |
160 | 197 |
// queryAux.close(); |
161 | 198 |
t2 = System.currentTimeMillis(); |
162 | 199 |
System.out.println("Tiempo de recorrido:" + (t2 - t1) + " milisegundos. "); */ |
163 |
|
|
164 | 200 |
/* queryAux = new SeQuery( conn, cols, sqlConstruct ); |
165 | 201 |
SeObjectId rowID = new SeObjectId(1); |
166 |
row = queryAux.fetchRow("provin", rowID, cols);
|
|
202 |
row = queryAux.fetchRow("provin", rowID, cols); |
|
167 | 203 |
evaluateRow(row, colDefs); |
168 |
row = queryAux.fetch();
|
|
204 |
row = queryAux.fetch(); |
|
169 | 205 |
evaluateRow(row, colDefs); |
170 |
|
|
206 |
|
|
171 | 207 |
queryAux.close(); */ |
172 |
|
|
173 |
} catch( SeException e ) { |
|
208 |
} catch (SeException e) { |
|
174 | 209 |
System.out.println(e.getSeError().getErrDesc()); |
175 | 210 |
} |
176 |
|
|
177 |
|
|
178 | 211 |
} |
179 | 212 |
|
180 |
static GeneralPathX convertSeShapeToGeneralPathX(SeShape spVal) throws SeException
|
|
181 |
{ |
|
213 |
static GeneralPathX convertSeShapeToGeneralPathX(SeShape spVal) |
|
214 |
throws SeException {
|
|
182 | 215 |
double[][][] points = spVal.getAllCoords(); |
183 | 216 |
GeneralPathX gpx = new GeneralPathX(); |
217 |
|
|
184 | 218 |
// Display the X and Y values |
185 | 219 |
boolean bStartPart; |
186 |
for( int partNo = 0 ; partNo < points.length ; partNo++) |
|
187 |
{ |
|
220 |
|
|
221 |
for (int partNo = 0; partNo < points.length; partNo++) {
|
|
188 | 222 |
bStartPart = true; |
189 |
for( int subPartNo = 0 ; subPartNo < points[partNo].length ; subPartNo++) |
|
190 |
for( int pointNo = 0 ; pointNo < points[partNo][subPartNo].length ; pointNo+=2) |
|
191 |
{ |
|
192 |
if (bStartPart) |
|
193 |
{ |
|
223 |
|
|
224 |
for (int subPartNo = 0; subPartNo < points[partNo].length; |
|
225 |
subPartNo++) |
|
226 |
for (int pointNo = 0; |
|
227 |
pointNo < points[partNo][subPartNo].length; |
|
228 |
pointNo += 2) { |
|
229 |
if (bStartPart) { |
|
194 | 230 |
bStartPart = false; |
195 | 231 |
gpx.moveTo(points[partNo][subPartNo][pointNo], |
196 |
points[partNo][subPartNo][(pointNo+1)]); |
|
232 |
points[partNo][subPartNo][(pointNo + 1)]); |
|
233 |
} else { |
|
234 |
gpx.lineTo(points[partNo][subPartNo][pointNo], |
|
235 |
points[partNo][subPartNo][(pointNo + 1)]); |
|
197 | 236 |
} |
198 |
else |
|
199 |
gpx.lineTo(points[partNo][subPartNo][pointNo], |
|
200 |
points[partNo][subPartNo][(pointNo+1)]); |
|
237 |
} |
|
238 |
} |
|
201 | 239 |
|
202 |
} |
|
203 |
} |
|
204 | 240 |
return gpx; |
205 | 241 |
} |
206 |
static void evaluateRow(SeRow row, SeColumnDefinition[] colDefs) |
|
207 |
{ |
|
208 |
try |
|
209 |
{ |
|
210 |
for (int colNum = 0; colNum < colDefs.length; colNum++) |
|
211 |
{ |
|
242 |
|
|
243 |
static void evaluateRow(SeRow row, SeColumnDefinition[] colDefs) { |
|
244 |
try { |
|
245 |
for (int colNum = 0; colNum < colDefs.length; colNum++) { |
|
212 | 246 |
SeColumnDefinition colDef = colDefs[colNum]; |
213 | 247 |
int dataType = colDef.getType(); |
214 |
if ( row.getIndicator((short)colNum) != SeRow.SE_IS_NULL_VALUE) |
|
215 |
{ |
|
216 |
switch( dataType ) |
|
217 |
{ |
|
218 |
case SeColumnDefinition.TYPE_SMALLINT: |
|
219 |
break; |
|
220 |
|
|
221 |
case SeColumnDefinition.TYPE_DATE: |
|
222 |
break; |
|
223 |
|
|
224 |
case SeColumnDefinition.TYPE_INTEGER: |
|
225 |
break; |
|
226 |
|
|
227 |
case SeColumnDefinition.TYPE_FLOAT: |
|
228 |
break; |
|
229 |
|
|
230 |
case SeColumnDefinition.TYPE_DOUBLE: |
|
231 |
break; |
|
232 |
|
|
233 |
case SeColumnDefinition.TYPE_STRING: |
|
234 |
// System.out.println(row.getString(colNum)); |
|
235 |
break; |
|
236 |
|
|
237 |
case SeColumnDefinition.TYPE_SHAPE: |
|
238 |
SeShape spVal = row.getShape(colNum); |
|
239 |
convertSeShapeToGeneralPathX(spVal); |
|
240 | 248 |
|
241 |
// GeneralPath gp = spVal.toGeneralPath(); |
|
242 |
// GeneralPathX gpx = new GeneralPathX(gp); |
|
243 |
// System.out.println("spVal.FID = " + spVal.getFeatureId().longValue()); |
|
244 |
// getShapeDetails(spVal); |
|
245 |
break; |
|
249 |
if (row.getIndicator((short) colNum) != SeRow.SE_IS_NULL_VALUE) { |
|
250 |
switch (dataType) { |
|
251 |
case SeColumnDefinition.TYPE_SMALLINT: |
|
252 |
break; |
|
253 |
|
|
254 |
case SeColumnDefinition.TYPE_DATE: |
|
255 |
break; |
|
256 |
|
|
257 |
case SeColumnDefinition.TYPE_INTEGER: |
|
258 |
break; |
|
259 |
|
|
260 |
case SeColumnDefinition.TYPE_FLOAT: |
|
261 |
break; |
|
262 |
|
|
263 |
case SeColumnDefinition.TYPE_DOUBLE: |
|
264 |
break; |
|
265 |
|
|
266 |
case SeColumnDefinition.TYPE_STRING: |
|
267 |
|
|
268 |
// System.out.println(row.getString(colNum)); |
|
269 |
break; |
|
270 |
|
|
271 |
case SeColumnDefinition.TYPE_SHAPE: |
|
272 |
|
|
273 |
SeShape spVal = row.getShape(colNum); |
|
274 |
convertSeShapeToGeneralPathX(spVal); |
|
275 |
|
|
276 |
// GeneralPath gp = spVal.toGeneralPath(); |
|
277 |
// GeneralPathX gpx = new GeneralPathX(gp); |
|
278 |
// System.out.println("spVal.FID = " + spVal.getFeatureId().longValue()); |
|
279 |
// getShapeDetails(spVal); |
|
280 |
break; |
|
246 | 281 |
} // End switch |
247 | 282 |
} // End if |
248 | 283 |
} // for |
249 |
} catch (SeException e) |
|
250 |
{ |
|
284 |
} catch (SeException e) { |
|
251 | 285 |
e.printStackTrace(); |
252 | 286 |
} |
253 | 287 |
} |
trunk/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/ArcSdeDriver.java | ||
---|---|---|
2 | 2 |
* Created on 13-may-2005 |
3 | 3 |
* |
4 | 4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
7 |
*
|
|
7 |
* |
|
8 | 8 |
* This program is free software; you can redistribute it and/or |
9 | 9 |
* modify it under the terms of the GNU General Public License |
10 | 10 |
* as published by the Free Software Foundation; either version 2 |
11 | 11 |
* of the License, or (at your option) any later version. |
12 |
*
|
|
12 |
* |
|
13 | 13 |
* This program is distributed in the hope that it will be useful, |
14 | 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | 16 |
* GNU General Public License for more details. |
17 |
*
|
|
17 |
* |
|
18 | 18 |
* You should have received a copy of the GNU General Public License |
19 | 19 |
* along with this program; if not, write to the Free Software |
20 | 20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 |
*
|
|
21 |
* |
|
22 | 22 |
* For more information, contact: |
23 | 23 |
* |
24 | 24 |
* Generalitat Valenciana |
... | ... | |
30 | 30 |
* +34 963862235 |
31 | 31 |
* gvsig@gva.es |
32 | 32 |
* www.gvsig.gva.es |
33 |
*
|
|
33 |
* |
|
34 | 34 |
* or |
35 |
*
|
|
35 |
* |
|
36 | 36 |
* IVER T.I. S.A |
37 | 37 |
* Salamanca 50 |
38 | 38 |
* 46005 Valencia |
39 | 39 |
* Spain |
40 |
*
|
|
40 |
* |
|
41 | 41 |
* +34 963163400 |
42 | 42 |
* dac@iver.es |
43 | 43 |
*/ |
... | ... | |
45 | 45 |
|
46 | 46 |
import java.awt.geom.Rectangle2D; |
47 | 47 |
import java.io.IOException; |
48 |
import java.sql.Connection; |
|
48 | 49 |
import java.sql.Types; |
49 | 50 |
import java.util.Hashtable; |
50 | 51 |
import java.util.Vector; |
... | ... | |
62 | 63 |
import com.esri.sde.sdk.client.SeShape; |
63 | 64 |
import com.esri.sde.sdk.client.SeShapeFilter; |
64 | 65 |
import com.esri.sde.sdk.client.SeSqlConstruct; |
65 |
import com.esri.sde.sdk.client.SeTable;
|
|
66 |
import com.hardcode.gdbms.engine.data.DataSourceFactory;
|
|
66 | 67 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
67 | 68 |
import com.hardcode.gdbms.engine.data.edition.DataWare; |
68 | 69 |
import com.hardcode.gdbms.engine.values.Value; |
69 | 70 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
70 | 71 |
import com.iver.cit.gvsig.fmap.DriverException; |
72 |
import com.iver.cit.gvsig.fmap.DriverJdbcNotFoundExceptionType; |
|
73 |
import com.iver.cit.gvsig.fmap.Messages; |
|
71 | 74 |
import com.iver.cit.gvsig.fmap.core.FShape; |
75 |
import com.iver.cit.gvsig.fmap.core.ICanReproject; |
|
72 | 76 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
73 | 77 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
78 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
|
74 | 79 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
75 | 80 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
76 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver; |
|
81 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
|
82 |
import com.iver.cit.gvsig.fmap.edition.IWriteable; |
|
83 |
import com.iver.cit.gvsig.fmap.edition.IWriter; |
|
84 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
|
85 |
import com.iver.utiles.XMLEntity; |
|
86 |
import com.iver.utiles.swing.JPasswordDlg; |
|
77 | 87 |
|
78 |
public class ArcSdeDriver implements VectorialDatabaseDriver, ObjectDriver { |
|
79 | 88 |
|
89 |
/** |
|
90 |
* Driver of ArcSDE. |
|
91 |
* @author Vicente Caballero Navarro |
|
92 |
* @uml.dependency supplier="com.iver.cit.gvsig.fmap.drivers.sde.ArcSdeFeatureIterator" |
|
93 |
* @uml.dependency supplier="com.iver.cit.gvsig.fmap.drivers.sde.SDELayerDefinition" |
|
94 |
*/ |
|
95 |
public class ArcSdeDriver implements ICanReproject, IWriteable, VectorialSDEDriver, ObjectDriver{ |
|
96 |
protected static Hashtable poolPassw = new Hashtable(); |
|
80 | 97 |
private SeLayer layer; |
81 | 98 |
private SeQuery query; |
82 | 99 |
private SeQuery queryAux; |
... | ... | |
84 | 101 |
private SeColumnDefinition[] colDefs; |
85 | 102 |
private SeRow row = null; |
86 | 103 |
private int numReg = -1; |
104 |
/** |
|
105 |
* @uml.property name="fullExtent" |
|
106 |
*/ |
|
87 | 107 |
private Rectangle2D fullExtent = null; |
88 | 108 |
private Hashtable hashRelate = null; |
89 | 109 |
private int idSpatialColumn = -1; |
110 |
/** |
|
111 |
* @uml.property name="fields" |
|
112 |
*/ |
|
90 | 113 |
private String[] fields; |
91 | 114 |
private int[] fieldTypes; |
92 | 115 |
private long lastRowServed = -1; |
93 | 116 |
private SeConnection conn = null; |
117 |
private String strEPSG; |
|
118 |
private String originalEPSG = null; |
|
94 | 119 |
/** |
95 |
* Recorre el recordset creando una tabla Hash que usaremos para |
|
96 |
* relacionar el n?mero de un registro con su identificador ?nico. |
|
97 |
* Debe ser llamado en el setData justo despu?s de crear el recorset |
|
98 |
* principal |
|
120 |
* @uml.property name="sqlTotal" |
|
121 |
*/ |
|
122 |
private String sqlTotal; |
|
123 |
private long posActual = -1; |
|
124 |
private SeRow cachedRow = null; |
|
125 |
/** |
|
126 |
* @uml.property name="lyrDef" |
|
127 |
*/ |
|
128 |
protected VectorialSDELayerDefinition lyrDef = null; |
|
129 |
/** |
|
130 |
* @uml.property name="workingArea" |
|
131 |
*/ |
|
132 |
protected Rectangle2D workingArea; |
|
133 |
protected String driverClass; |
|
134 |
protected String className; |
|
135 |
protected String catalogName; |
|
136 |
private ArcSdeWriter writer; |
|
137 |
|
|
138 |
/** |
|
139 |
* Recorre el recordset creando una tabla Hash que usaremos para relacionar |
|
140 |
* el n?mero de un registro con su identificador ?nico. Debe ser llamado |
|
141 |
* en el setData justo despu?s de crear el recorset principal |
|
99 | 142 |
*/ |
100 |
private void doRelateID_FID() |
|
101 |
{ |
|
143 |
protected void doRelateID_FID() { |
|
102 | 144 |
hashRelate = new Hashtable(); |
145 |
|
|
103 | 146 |
try { |
104 |
// query.execute(); |
|
105 |
// row = query.fetch(); |
|
106 |
if( row == null ) { |
|
107 |
|
|
147 |
if (row == null) { |
|
108 | 148 |
System.out.println(" No rows fetched"); |
149 |
|
|
109 | 150 |
return; |
110 | 151 |
} |
152 |
|
|
111 | 153 |
int index = 0; |
112 |
while( row != null )
|
|
113 |
{
|
|
114 |
SeShape shpVal = row.getShape(idSpatialColumn);
|
|
115 |
SeObjectId objID = shpVal.getFeatureId();
|
|
116 |
String theKey = "" + objID.longValue();
|
|
117 |
// System.out.println("Antes de meter en el hash " + theKey);
|
|
154 |
Value value=getFieldValue(index,getLyrDef().getIdFieldID());
|
|
155 |
int fid=getLyrDef().getIdFieldID();
|
|
156 |
while (value != null) {
|
|
157 |
//SeShape shpVal = row.getShape(idSpatialColumn);
|
|
158 |
//SeObjectId objID = shpVal.getFeatureId();
|
|
159 |
String theKey = value.toString();
|
|
118 | 160 |
hashRelate.put(theKey, new Integer(index)); |
119 |
row = query.fetch(); |
|
120 |
index++; |
|
121 |
} |
|
122 |
numReg = index; |
|
123 |
// Close the query. |
|
124 |
// query.close(); |
|
125 |
} catch (SeException e) |
|
126 |
{ |
|
127 |
e.printStackTrace(); |
|
128 |
} |
|
129 |
|
|
130 |
} |
|
131 |
|
|
132 |
public void setData(String host, int port, String db, String userDB, String pwdDB, |
|
133 |
String tableName, String[] cols, |
|
134 |
String whereClause) |
|
135 |
{ |
|
136 |
// Conexi?n: |
|
137 |
|
|
138 |
String server = host; |
|
139 |
int instance = port; |
|
140 |
String database = db; |
|
141 |
String user = userDB; |
|
142 |
String password = pwdDB; |
|
143 |
try { |
|
144 |
conn = new SeConnection(server, instance, database, user, password); |
|
145 |
}catch (SeException e) { |
|
146 |
e.printStackTrace(); |
|
147 |
return; |
|
148 |
} |
|
149 |
|
|
150 |
// Fetching data |
|
151 |
|
|
152 |
String layerName = tableName; |
|
153 |
SeObjectId layerID = null; |
|
154 |
String strSpatialColumn = ""; |
|
155 |
try { |
|
156 |
Vector theLayers = conn.getLayers(); |
|
157 |
for (int i=0; i < theLayers.size(); i++) |
|
158 |
{ |
|
159 |
SeLayer layer = (SeLayer)theLayers.elementAt(i); |
|
160 |
if (layer.getName().compareToIgnoreCase(layerName) == 0 ); |
|
161 |
{ |
|
162 |
layerID = layer.getID(); |
|
163 |
strSpatialColumn = layer.getSpatialColumn(); |
|
164 |
} |
|
165 |
} |
|
166 |
if (layerID == null) |
|
167 |
{ |
|
168 |
System.err.println("Capa no encontrada"); |
|
169 |
return; |
|
161 |
value = getFieldValue(index,fid-1); |
|
162 |
index++; |
|
170 | 163 |
} |
171 |
// layerName = layer.getName(); |
|
172 |
layer = new SeLayer( conn, layerName, strSpatialColumn ); |
|
173 |
|
|
174 |
if (cols != null) |
|
175 |
this.fields = cols; |
|
176 |
else |
|
177 |
{ |
|
178 |
SeSqlConstruct sqlConstruct = new SeSqlConstruct( tableName ); |
|
179 |
SeTable table1 = new SeTable(conn, tableName ); |
|
180 |
/* |
|
181 |
* Get the table's column definition. |
|
182 |
*/ |
|
183 |
SeColumnDefinition[] tableDef = table1.describe(); |
|
184 |
this.fields = new String[tableDef.length]; |
|
185 |
|
|
186 |
/* |
|
187 |
* Store the names of all the table's columns in the |
|
188 |
* String array cols. This array specifies the columns |
|
189 |
* to be retrieved from the database. |
|
190 |
*/ |
|
191 |
int idField=1; |
|
192 |
for( int i = 0 ; i < tableDef.length ; i++ ) { |
|
193 |
if (tableDef[i].getType() == SeColumnDefinition.TYPE_SHAPE) |
|
194 |
{ |
|
195 |
this.fields[0] = tableDef[i].getName(); |
|
196 |
} |
|
197 |
else |
|
198 |
{ |
|
199 |
this.fields[idField] = tableDef[i].getName(); |
|
200 |
idField++; |
|
201 |
} |
|
202 |
} |
|
203 |
} |
|
204 |
|
|
205 |
|
|
206 |
sqlConstruct = new SeSqlConstruct( layerName); |
|
207 |
// Create a query stream between the client and server |
|
208 |
|
|
209 |
query = new SeQuery( conn, fields, sqlConstruct ); |
|
210 |
query.prepareQuery(); |
|
211 |
query.execute(); |
|
212 |
row = query.fetch(); |
|
213 |
if (row == null) |
|
214 |
{ |
|
215 |
System.out.println("La tabla " + getName() + " no tiene registros"); |
|
216 |
return; |
|
217 |
} |
|
218 |
|
|
219 |
colDefs = row.getColumns(); |
|
220 |
fieldTypes = new int[colDefs.length-1]; |
|
221 |
for (int colNum = 0; colNum < colDefs.length; colNum++) |
|
222 |
{ |
|
223 |
SeColumnDefinition colDef = colDefs[colNum]; |
|
224 |
int dataType = colDef.getType(); |
|
225 |
if (dataType == SeColumnDefinition.TYPE_SHAPE) |
|
226 |
{ |
|
227 |
if (colNum != 0) |
|
228 |
{ |
|
229 |
System.err.println("Por favor, el campo de shapes deber ser el primero"); |
|
230 |
return; |
|
231 |
} |
|
232 |
idSpatialColumn = colNum; |
|
233 |
} |
|
234 |
if (dataType == SeColumnDefinition.TYPE_STRING) |
|
235 |
fieldTypes[colNum-1] = Types.VARCHAR; |
|
236 |
if (dataType == SeColumnDefinition.TYPE_FLOAT) |
|
237 |
fieldTypes[colNum-1] = Types.FLOAT; |
|
238 |
if (dataType == SeColumnDefinition.TYPE_DOUBLE) |
|
239 |
fieldTypes[colNum-1] = Types.DOUBLE; |
|
240 |
if (dataType == SeColumnDefinition.TYPE_INTEGER) |
|
241 |
fieldTypes[colNum-1] = Types.INTEGER; |
|
242 |
if (dataType == SeColumnDefinition.TYPE_SMALLINT) |
|
243 |
fieldTypes[colNum-1] = Types.INTEGER; |
|
244 |
if (dataType == SeColumnDefinition.TYPE_DATE) |
|
245 |
fieldTypes[colNum-1] = Types.DATE; |
|
246 |
|
|
247 |
} |
|
248 |
// query.close(); |
|
249 |
SeQuery extentQuery = new SeQuery( conn, fields, sqlConstruct ); |
|
250 |
SeQueryInfo queryInfo = new SeQueryInfo(); |
|
251 |
queryInfo.setConstruct(sqlConstruct); |
|
252 |
// queryInfo.setQueryType(SeQueryInfo.SE_QUERYTYPE_JFA); |
|
253 |
// extentQuery.prepareQueryInfo(queryInfo); |
|
254 |
|
|
255 |
SeExtent seExtent = extentQuery.calculateLayerExtent(queryInfo); |
|
256 |
fullExtent = new Rectangle2D.Double( |
|
257 |
seExtent.getMinX(), seExtent.getMinY(), |
|
258 |
seExtent.getMaxX()- seExtent.getMinX(), |
|
259 |
seExtent.getMaxY()- seExtent.getMinY()); |
|
260 |
extentQuery.close(); |
|
261 |
|
|
262 |
doRelateID_FID(); |
|
263 |
|
|
264 |
} |
|
265 |
catch (SeException e) |
|
266 |
{ |
|
267 |
e.printStackTrace(); |
|
268 |
} |
|
269 | 164 |
|
270 |
|
|
165 |
numReg = index; |
|
166 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
167 |
e.printStackTrace(); |
|
168 |
} |
|
271 | 169 |
} |
272 |
|
|
170 |
/** |
|
171 |
* @return |
|
172 |
* @uml.property name="fullExtent" |
|
173 |
*/ |
|
273 | 174 |
public Rectangle2D getFullExtent() { |
274 |
return fullExtent; |
|
275 |
} |
|
276 |
|
|
277 |
public int getShapeType() { |
|
278 |
// TODO Auto-generated method stub |
|
279 |
int shapeType = -1; |
|
280 |
switch (layer.getShapeTypes()) |
|
281 |
{ |
|
282 |
case SeLayer.TYPE_POINT: |
|
283 |
shapeType = FShape.POINT; |
|
284 |
break; |
|
285 |
case SeLayer.TYPE_LINE: |
|
286 |
case SeLayer.TYPE_MULTI_LINE: |
|
287 |
case SeLayer.TYPE_MULTI_SIMPLE_LINE: |
|
288 |
shapeType = FShape.LINE; |
|
289 |
break; |
|
290 |
case SeLayer.TYPE_POLYGON: |
|
291 |
case SeLayer.TYPE_MULTI_POLYGON: |
|
292 |
shapeType = FShape.POLYGON; |
|
293 |
break; |
|
294 |
|
|
295 |
} |
|
296 |
return FShape.MULTI; |
|
297 |
} |
|
298 |
|
|
175 |
return fullExtent; |
|
176 |
} |
|
299 | 177 |
public IGeometry getShape(int index) { |
300 | 178 |
SeRow row; |
179 |
|
|
301 | 180 |
try { |
302 | 181 |
row = obtainRow(index); |
182 |
|
|
303 | 183 |
SeShape spVal = row.getShape(idSpatialColumn); |
304 | 184 |
IGeometry geom = ArcSdeFeatureIterator.getGeometry(spVal); |
305 |
// queryAux.close(); |
|
306 | 185 |
return geom; |
307 | 186 |
} catch (SeException e) { |
308 |
// TODO Auto-generated catch block |
|
309 | 187 |
e.printStackTrace(); |
310 | 188 |
} |
311 |
return null;
|
|
189 |
return null; |
|
312 | 190 |
} |
313 | 191 |
|
314 | 192 |
public IFeatureIterator getFeatureIterator(String sql) |
315 |
throws DriverException { |
|
316 |
// TODO Auto-generated method stub |
|
193 |
throws DriverException { |
|
317 | 194 |
return null; |
318 | 195 |
} |
319 | 196 |
|
320 | 197 |
public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG) |
321 |
throws DriverException {
|
|
198 |
throws DriverException { |
|
322 | 199 |
/* |
323 | 200 |
* Generate a rectangular shape that will be used as a filter |
324 | 201 |
*/ |
325 | 202 |
try { |
326 | 203 |
SeShape shape = new SeShape(layer.getCoordRef()); |
327 |
|
|
328 |
SeExtent extent = new SeExtent( r.getMinX(),
|
|
329 |
r.getMinY(),r.getMaxX(),r.getMaxY());
|
|
204 |
|
|
205 |
SeExtent extent = new SeExtent(r.getMinX(), r.getMinY(),
|
|
206 |
r.getMaxX(), r.getMaxY());
|
|
330 | 207 |
shape.generateRectangle(extent); |
331 |
|
|
208 |
|
|
332 | 209 |
SeShape[] shapes = new SeShape[1]; |
333 | 210 |
shapes[0] = shape; |
334 |
|
|
211 |
|
|
335 | 212 |
/* |
336 | 213 |
* Retrieve all the shapes that are contained within the |
337 | 214 |
* rectangles envelope. |
338 | 215 |
*/ |
339 |
SeShapeFilter filters[] = new SeShapeFilter[1];
|
|
216 |
SeShapeFilter[] filters = new SeShapeFilter[1];
|
|
340 | 217 |
SeShapeFilter filter = null; |
341 |
|
|
342 |
filter = new SeShapeFilter( layer.getName(), layer.getSpatialColumn(), shape, SeFilter.METHOD_ENVP); |
|
218 |
|
|
219 |
filter = new SeShapeFilter(layer.getName(), |
|
220 |
layer.getSpatialColumn(), shape, SeFilter.METHOD_ENVP); |
|
343 | 221 |
filters[0] = filter; |
344 |
|
|
222 |
|
|
345 | 223 |
SeQuery spatialQuery = null; |
346 |
SeSqlConstruct sqlCons = new SeSqlConstruct( layer.getName() );
|
|
347 |
|
|
224 |
SeSqlConstruct sqlCons = new SeSqlConstruct(layer.getName());
|
|
225 |
|
|
348 | 226 |
spatialQuery = new SeQuery(conn, fields, sqlCons); |
227 |
|
|
349 | 228 |
/* |
350 | 229 |
* Set spatial constraints |
351 | 230 |
*/ |
352 |
spatialQuery.setSpatialConstraints(SeQuery.SE_OPTIMIZE, false, filters); |
|
231 |
spatialQuery.setSpatialConstraints(SeQuery.SE_OPTIMIZE, false, |
|
232 |
filters); |
|
353 | 233 |
|
354 | 234 |
spatialQuery.prepareQuery(); |
355 |
|
|
235 |
|
|
356 | 236 |
spatialQuery.execute(); |
357 |
|
|
237 |
|
|
358 | 238 |
return new ArcSdeFeatureIterator(spatialQuery); |
359 | 239 |
} catch (SeException e) { |
360 |
// TODO Auto-generated catch block |
|
361 | 240 |
e.printStackTrace(); |
362 | 241 |
return null; |
363 | 242 |
} |
364 |
|
|
365 | 243 |
} |
366 | 244 |
|
367 |
|
|
368 | 245 |
public void close() { |
369 |
// TODO Auto-generated method stub |
|
370 |
|
|
371 | 246 |
} |
372 | 247 |
|
373 | 248 |
public void open() throws DriverException { |
374 |
// TODO Auto-generated method stub |
|
375 |
|
|
376 | 249 |
} |
377 | 250 |
|
378 | 251 |
public int getRowIndexByFID(IFeature FID) { |
379 | 252 |
int resul; |
380 | 253 |
String strID = FID.getID(); |
381 |
// System.out.println("Recuperando " + strID + " del hash"); |
|
382 | 254 |
Integer rowIndex = (Integer) hashRelate.get(strID); |
383 |
if (rowIndex == null) |
|
384 |
{ |
|
385 |
System.err.println("Error: No se ha encontrado " + strID + " dentro del Hash"); |
|
255 |
|
|
256 |
if (rowIndex == null) { |
|
257 |
System.err.println("Error: No se ha encontrado " + strID + |
|
258 |
" dentro del Hash"); |
|
386 | 259 |
} |
387 | 260 |
resul = rowIndex.intValue(); |
388 | 261 |
return resul; |
... | ... | |
397 | 270 |
} |
398 | 271 |
|
399 | 272 |
public DriverAttributes getDriverAttributes() { |
400 |
// TODO Auto-generated method stub |
|
401 | 273 |
return null; |
402 | 274 |
} |
403 | 275 |
|
404 | 276 |
public String getName() { |
405 |
return "ArcSDE driver";
|
|
277 |
return "gvSIG SDE driver";
|
|
406 | 278 |
} |
407 | 279 |
|
280 |
/** |
|
281 |
* @return |
|
282 |
* @uml.property name="fields" |
|
283 |
*/ |
|
408 | 284 |
public String[] getFields() { |
409 |
String[] attributes = new String[fields.length-1];
|
|
410 |
for (int i=1; i < fields.length; i++)
|
|
411 |
attributes[i-1] = fields[i];
|
|
412 |
return attributes;
|
|
413 |
}
|
|
285 |
String[] attributes = new String[fields.length - 1];
|
|
286 |
for (int i = 1; i < fields.length; i++)
|
|
287 |
attributes[i - 1] = fields[i];
|
|
288 |
return attributes;
|
|
289 |
}
|
|
414 | 290 |
|
415 |
public String getWhereClause() { |
|
416 |
// TODO Auto-generated method stub |
|
417 |
return ""; |
|
418 |
} |
|
419 |
|
|
420 | 291 |
public String getTableName() { |
421 | 292 |
return layer.getName(); |
422 | 293 |
} |
423 | 294 |
|
424 |
private SeRow obtainRow(long rowIndex) throws SeException |
|
425 |
{ |
|
426 |
if (rowIndex == 0) |
|
427 |
{ |
|
428 |
if (query != null) |
|
429 |
{ |
|
430 |
if (query.inProgress()) |
|
431 |
query.close(); |
|
295 |
private SeRow obtainRow(long rowIndex) throws SeException { |
|
296 |
if (rowIndex != posActual) { |
|
297 |
if (rowIndex == 0) { |
|
298 |
if (query != null) { |
|
299 |
if (query.inProgress()) { |
|
300 |
query.close(); |
|
301 |
} |
|
302 |
} |
|
303 |
query = new SeQuery(conn, fields, sqlConstruct); |
|
304 |
query.prepareQuery(); |
|
305 |
query.execute(); |
|
306 |
|
|
307 |
lastRowServed = -1; |
|
432 | 308 |
} |
433 |
query = new SeQuery( conn, fields, sqlConstruct ); |
|
434 |
query.prepareQuery(); |
|
435 |
query.execute(); |
|
436 |
|
|
437 |
lastRowServed = -1; |
|
309 |
|
|
310 |
if (lastRowServed == (rowIndex - 1)) { |
|
311 |
row = query.fetch(); |
|
312 |
lastRowServed++; |
|
313 |
} else { |
|
314 |
if (queryAux != null) { |
|
315 |
queryAux.close(); |
|
316 |
} |
|
317 |
|
|
318 |
queryAux = new SeQuery(conn, fields, sqlConstruct); |
|
319 |
|
|
320 |
SeObjectId rowID = new SeObjectId(rowIndex + 1); |
|
321 |
row = queryAux.fetchRow(layer.getName(), rowID, fields); |
|
322 |
} |
|
323 |
|
|
324 |
posActual = rowIndex; |
|
325 |
cachedRow = row; |
|
438 | 326 |
} |
439 |
if (lastRowServed == rowIndex-1) |
|
440 |
{ |
|
441 |
row = query.fetch(); |
|
442 |
lastRowServed++; |
|
443 |
} |
|
444 |
else |
|
445 |
{ |
|
446 |
if (queryAux != null) queryAux.close(); |
|
447 |
queryAux = new SeQuery( conn, fields, sqlConstruct ); |
Also available in: Unified diff