Revision 11012
branches/v10/extensions/extSDE/build.xml | ||
---|---|---|
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 | 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="**/*VectorialSDEDriver*" 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}"> |
... | ... | |
41 | 42 |
<fileset dir="./lib" includes="*.jar,*.zip"/> |
42 | 43 |
<!-- <fileset dir="." includes=".keystore"/> --> |
43 | 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 |
<copy todir="${drivers-dir}/sde"> |
|
52 |
<fileset dir="${dist}/lib" includes="j*sdk.jar"/> |
|
53 |
</copy> |
|
54 |
<move todir="${extensionDir}/${plugin}/lib"> |
|
55 |
<fileset dir="${dist}/lib" includes="**"/> |
|
56 |
</move> |
|
44 | 57 |
<move todir="${extensionDir}/${mainplugin}/lib"> |
45 | 58 |
<fileset dir="${dist}" includes="${gvsiglibjar}.jar"/> |
46 | 59 |
<fileset dir="${dist}" includes="${fmapjar}.jar"/> |
47 | 60 |
</move> |
48 |
<move todir="${extensionDir}/${plugin}/"> |
|
49 |
<fileset dir="${dist}" includes="**/**"/> |
|
50 |
</move> |
|
61 |
|
|
62 |
<jar jarfile="${drivers-dir}/sde/sde.jar" basedir="./bin" excludes="**/*VectorialSDEDriver*" |
|
63 |
includes="com/iver/cit/gvsig/fmap/drivers/sde/*.*" |
|
64 |
/> |
|
65 |
<jar jarfile="${extensionDir}/${mainplugin}/lib/gvsig-sde.jar" basedir="./bin" includes="com/iver/cit/gvsig/fmap/drivers/sde/VectorialSDEDriver.*"/> |
|
66 |
|
|
51 | 67 |
</target> |
52 | 68 |
|
53 | 69 |
|
54 |
<target name="generate-with-source" description="generate the distribution with the source file" > |
|
55 |
<!-- Create the distribution directory --> |
|
70 |
<!--target name="generate-with-source" description="generate the distribution with the source file" > |
|
56 | 71 |
<mkdir dir="${dist}"/> |
57 | 72 |
<mkdir dir="${dist}/images"/> |
58 | 73 |
|
59 |
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --> |
|
60 | 74 |
<jar jarfile="${dist}/${plugin}.jar" basedir="${build}"/> |
61 | 75 |
<copy file="config/config.xml" todir="${dist}"/> |
62 | 76 |
<copy todir="${dist}"> |
... | ... | |
72 | 86 |
<move todir="${extensionDir}/${plugin}/images"> |
73 | 87 |
<fileset dir="images/" includes="*"/> |
74 | 88 |
</move> |
75 |
<move todir="${extension-dir}/${plugin}/">
|
|
89 |
<move todir="${extensionDir}/${plugin}/">
|
|
76 | 90 |
<fileset dir="${dist}" includes="**/**" excludes="com/iver/cit/gvsig/fmap/drivers/sde/**"/> |
77 | 91 |
</move> |
78 |
<jar jarfile="${drivers-dir}/sde/sde.jar" basedir="./bin" includes="com/iver/cit/gvsig/fmap/drivers/sde/**" /> |
|
79 |
</target> |
|
92 |
<jar jarfile="${drivers-dir}/sde/sde.jar" basedir="./bin" excludes="**/*VectorialSDEDriver*" |
|
93 |
includes="com/iver/cit/gvsig/fmap/drivers/sde/*.*" |
|
94 |
/> |
|
95 |
<jar jarfile="${extensionDir}/${mainplugin}/lib/gvsig-sde.jar" basedir="./bin" includes="com/iver/cit/gvsig/fmap/drivers/sde/VectorialSDEDriver.*"/> |
|
96 |
</target--> |
|
80 | 97 |
|
81 | 98 |
<target name="clean" |
82 | 99 |
description="clean up" > |
83 |
<!-- Delete the ${build} and ${dist} directory trees --> |
|
84 | 100 |
<delete dir="${dist}"/> |
85 | 101 |
</target> |
86 | 102 |
</project> |
branches/v10/extensions/extSDE/src-test/com/iver/cit/gvsig/sde/SDETest.java | ||
---|---|---|
7 | 7 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
8 | 8 |
import com.hardcode.gdbms.engine.values.NumericValue; |
9 | 9 |
import com.iver.cit.gvsig.fmap.drivers.sde.ArcSdeDriver; |
10 |
import com.iver.cit.gvsig.fmap.drivers.sde.SDELayerDefinition; |
|
10 |
import com.iver.cit.gvsig.fmap.drivers.sde.utils.SDELayerDefinition;
|
|
11 | 11 |
|
12 | 12 |
public class SDETest extends TestCase { |
13 | 13 |
ArcSdeDriver driver = new ArcSdeDriver(); |
branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/SDELayerDefinition.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 class SDELayerDefinition extends DBLayerDefinition { |
|
11 |
/** |
|
12 |
* @uml.property name="host" |
|
13 |
*/ |
|
14 |
private String host; |
|
15 |
/** |
|
16 |
* @uml.property name="port" |
|
17 |
*/ |
|
18 |
private String port; |
|
19 |
/** |
|
20 |
* @uml.property name="schema" |
|
21 |
*/ |
|
22 |
private String schema; |
|
23 |
/** |
|
24 |
* @uml.property name="user" |
|
25 |
*/ |
|
26 |
private String user; |
|
27 |
private String pwd; |
|
28 |
/** |
|
29 |
* @uml.property name="connectionName" |
|
30 |
*/ |
|
31 |
private String connectionName; |
|
32 |
|
|
33 |
public SDELayerDefinition() { |
|
34 |
System.out.println("SDE Layer Definition"); |
|
35 |
} |
|
36 |
|
|
37 |
/** |
|
38 |
* @param dbHost |
|
39 |
* @uml.property name="host" |
|
40 |
*/ |
|
41 |
public void setHost(String dbHost) { |
|
42 |
this.host = dbHost; |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* @return |
|
47 |
* @uml.property name="host" |
|
48 |
*/ |
|
49 |
public String getHost() { |
|
50 |
return host; |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* @param port |
|
55 |
* @uml.property name="port" |
|
56 |
*/ |
|
57 |
public void setPort(String port) { |
|
58 |
this.port = port; |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* @return |
|
63 |
* @uml.property name="port" |
|
64 |
*/ |
|
65 |
public String getPort() { |
|
66 |
return port; |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* @param schema |
|
71 |
* @uml.property name="schema" |
|
72 |
*/ |
|
73 |
public void setSchema(String schema) { |
|
74 |
this.schema = schema; |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* @return |
|
79 |
* @uml.property name="schema" |
|
80 |
*/ |
|
81 |
public String getSchema() { |
|
82 |
return schema; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* @param user |
|
87 |
* @uml.property name="user" |
|
88 |
*/ |
|
89 |
public void setUser(String user) { |
|
90 |
this.user = user; |
|
91 |
} |
|
92 |
|
|
93 |
public void setPassword(String pwd) { |
|
94 |
this.pwd = pwd; |
|
95 |
} |
|
96 |
|
|
97 |
public String getPassword() { |
|
98 |
return pwd; |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* @return |
|
103 |
* @uml.property name="user" |
|
104 |
*/ |
|
105 |
public String getUser() { |
|
106 |
return user; |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* @param connectionName |
|
111 |
* @uml.property name="connectionName" |
|
112 |
*/ |
|
113 |
public void setConnectionName(String connectionName) { |
|
114 |
this.connectionName = connectionName; |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* @return |
|
119 |
* @uml.property name="connectionName" |
|
120 |
*/ |
|
121 |
public String getConnectionName() { |
|
122 |
return connectionName; |
|
123 |
} |
|
124 |
} |
branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/ArcSdeDriver.java | ||
---|---|---|
46 | 46 |
import java.awt.geom.Rectangle2D; |
47 | 47 |
import java.io.IOException; |
48 | 48 |
import java.sql.Connection; |
49 |
import java.sql.SQLException; |
|
50 | 49 |
import java.sql.Types; |
51 | 50 |
import java.util.Hashtable; |
52 |
import java.util.TreeMap; |
|
53 | 51 |
import java.util.Vector; |
54 | 52 |
|
55 | 53 |
import com.esri.sde.sdk.client.SeColumnDefinition; |
... | ... | |
61 | 59 |
import com.esri.sde.sdk.client.SeObjectId; |
62 | 60 |
import com.esri.sde.sdk.client.SeQuery; |
63 | 61 |
import com.esri.sde.sdk.client.SeQueryInfo; |
64 |
import com.esri.sde.sdk.client.SeRegisteredColumn; |
|
65 | 62 |
import com.esri.sde.sdk.client.SeRow; |
66 | 63 |
import com.esri.sde.sdk.client.SeShape; |
67 | 64 |
import com.esri.sde.sdk.client.SeShapeFilter; |
68 | 65 |
import com.esri.sde.sdk.client.SeSqlConstruct; |
69 | 66 |
import com.esri.sde.sdk.client.SeTable; |
70 | 67 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
68 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
|
71 | 69 |
import com.hardcode.gdbms.engine.data.edition.DataWare; |
72 | 70 |
import com.hardcode.gdbms.engine.values.Value; |
73 | 71 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
... | ... | |
81 | 79 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
82 | 80 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
83 | 81 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
84 |
import com.iver.cit.gvsig.fmap.drivers.VectorialSDEDriver; |
|
82 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver; |
|
83 |
import com.iver.cit.gvsig.fmap.drivers.sde.utils.SDELayerDefinition; |
|
84 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
|
85 | 85 |
import com.iver.cit.gvsig.fmap.edition.IWriteable; |
86 | 86 |
import com.iver.cit.gvsig.fmap.edition.IWriter; |
87 | 87 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
... | ... | |
95 | 95 |
* @uml.dependency supplier="com.iver.cit.gvsig.fmap.drivers.sde.ArcSdeFeatureIterator" |
96 | 96 |
* @uml.dependency supplier="com.iver.cit.gvsig.fmap.drivers.sde.SDELayerDefinition" |
97 | 97 |
*/ |
98 |
public class ArcSdeDriver implements ICanReproject, IWriteable, |
|
99 |
VectorialSDEDriver { |
|
98 |
public class ArcSdeDriver implements ICanReproject, IWriteable, VectorialSDEDriver, ObjectDriver{ |
|
100 | 99 |
protected static Hashtable poolPassw = new Hashtable(); |
101 | 100 |
private SeLayer layer; |
102 | 101 |
private SeQuery query; |
... | ... | |
137 | 136 |
protected String driverClass; |
138 | 137 |
protected String className; |
139 | 138 |
protected String catalogName; |
139 |
private ArcSdeWriter writer; |
|
140 | 140 |
|
141 | 141 |
/** |
142 | 142 |
* Recorre el recordset creando una tabla Hash que usaremos para relacionar |
... | ... | |
154 | 154 |
} |
155 | 155 |
|
156 | 156 |
int index = 0; |
157 |
|
|
158 |
while (row != null) { |
|
159 |
SeShape shpVal = row.getShape(idSpatialColumn); |
|
160 |
SeObjectId objID = shpVal.getFeatureId(); |
|
161 |
String theKey = "" + objID.longValue(); |
|
157 |
Value value=getFieldValue(index,getLyrDef().getIdFieldID()); |
|
158 |
int fid=getLyrDef().getIdFieldID(); |
|
159 |
while (value != null) { |
|
160 |
//SeShape shpVal = row.getShape(idSpatialColumn); |
|
161 |
//SeObjectId objID = shpVal.getFeatureId(); |
|
162 |
String theKey = value.toString(); |
|
162 | 163 |
hashRelate.put(theKey, new Integer(index)); |
163 |
row = query.fetch();
|
|
164 |
index++;
|
|
164 |
value = getFieldValue(index,fid);
|
|
165 |
index++;
|
|
165 | 166 |
} |
166 | 167 |
|
167 | 168 |
numReg = index; |
168 |
} catch (SeException e) {
|
|
169 |
e.printStackTrace();
|
|
170 |
}
|
|
169 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
|
170 |
e.printStackTrace();
|
|
171 |
}
|
|
171 | 172 |
} |
172 | 173 |
/** |
173 | 174 |
* @return |
... | ... | |
276 | 277 |
} |
277 | 278 |
|
278 | 279 |
public String getName() { |
279 |
return "ArcSDE driver";
|
|
280 |
return "gvSIG SDE driver";
|
|
280 | 281 |
} |
281 | 282 |
|
282 | 283 |
/** |
... | ... | |
336 | 337 |
Value val = null; |
337 | 338 |
|
338 | 339 |
try { |
339 |
int idFieldArcSDE = fieldId + 1; // SIEMPRE CONTANDO CON
|
|
340 |
int idFieldArcSDE = fieldId; // SIEMPRE CONTANDO CON |
|
340 | 341 |
// QUE NOS HAN PASADO EL PRIMER CAMPO EL DE SHAPE |
341 | 342 |
row = obtainRow(rowIndex); |
342 |
|
|
343 |
if (row==null) |
|
344 |
return null; |
|
343 | 345 |
int dataType = colDefs[idFieldArcSDE].getType(); |
344 | 346 |
|
345 | 347 |
switch (dataType) { |
... | ... | |
533 | 535 |
//TODO aqu? se puede saber la proyecci?n |
534 | 536 |
//layer.getCoordRef().getSrid(); |
535 | 537 |
|
536 |
if ((cols != null) && (cols.length != 0)) { |
|
537 |
if (!cols[0].equals(lyrDef.getFieldGeometry())) { |
|
538 |
this.fields = new String[cols.length + 1]; |
|
539 |
this.fields[0] = lyrDef.getFieldGeometry(); |
|
540 |
|
|
541 |
for (int i = 1; i < fields.length; i++) { |
|
542 |
fields[i] = cols[i - 1]; |
|
543 |
} |
|
544 |
} else { |
|
545 |
fields = cols; |
|
546 |
} |
|
547 |
} else { |
|
548 |
SeSqlConstruct sqlConstruct = new SeSqlConstruct(tableName); |
|
549 |
sqlTotal = sqlConstruct.getWhere(); |
|
550 |
|
|
551 |
SeTable table1 = new SeTable(conn, tableName); |
|
552 |
|
|
553 |
/* |
|
554 |
* Get the table's column definition. |
|
555 |
*/ |
|
556 |
SeColumnDefinition[] tableDef = table1.describe(); |
|
557 |
this.fields = new String[tableDef.length]; |
|
558 |
|
|
559 |
/* |
|
560 |
* Store the names of all the table's columns in the |
|
561 |
* String array cols. This array specifies the columns |
|
562 |
* to be retrieved from the database. |
|
563 |
*/ |
|
564 |
int idField = 1; |
|
565 |
|
|
566 |
for (int i = 0; i < tableDef.length; i++) { |
|
567 |
if (tableDef[i].getType() == SeColumnDefinition.TYPE_SHAPE) { |
|
568 |
this.fields[0] = tableDef[i].getName(); |
|
569 |
} else { |
|
570 |
this.fields[idField] = tableDef[i].getName(); |
|
571 |
idField++; |
|
572 |
} |
|
573 |
} |
|
574 |
|
|
575 |
lyrDef.setFieldNames(fields); |
|
576 |
} |
|
577 |
|
|
538 |
// if ((cols != null) && (cols.length != 0)) {
|
|
539 |
// if (!cols[0].equals(lyrDef.getFieldGeometry())) {
|
|
540 |
// this.fields = new String[cols.length + 1];
|
|
541 |
// this.fields[0] = lyrDef.getFieldGeometry();
|
|
542 |
// |
|
543 |
// for (int i = 1; i < fields.length; i++) {
|
|
544 |
// fields[i] = cols[i - 1];
|
|
545 |
// }
|
|
546 |
// } else {
|
|
547 |
// fields = cols;
|
|
548 |
// }
|
|
549 |
// } else {
|
|
550 |
// SeSqlConstruct sqlConstruct = new SeSqlConstruct(tableName);
|
|
551 |
// sqlTotal = sqlConstruct.getWhere();
|
|
552 |
// |
|
553 |
// SeTable table1 = new SeTable(conn, tableName);
|
|
554 |
// |
|
555 |
// /*
|
|
556 |
// * Get the table's column definition.
|
|
557 |
// */
|
|
558 |
// SeColumnDefinition[] tableDef = table1.describe();
|
|
559 |
// this.fields = new String[tableDef.length];
|
|
560 |
// |
|
561 |
// /*
|
|
562 |
// * Store the names of all the table's columns in the
|
|
563 |
// * String array cols. This array specifies the columns
|
|
564 |
// * to be retrieved from the database.
|
|
565 |
// */
|
|
566 |
// int idField = 1;
|
|
567 |
// |
|
568 |
// for (int i = 0; i < tableDef.length; i++) {
|
|
569 |
// if (tableDef[i].getType() == SeColumnDefinition.TYPE_SHAPE) {
|
|
570 |
// this.fields[0] = tableDef[i].getName();
|
|
571 |
// } else {
|
|
572 |
// this.fields[idField] = tableDef[i].getName();
|
|
573 |
// idField++;
|
|
574 |
// }
|
|
575 |
// }
|
|
576 |
// |
|
577 |
// lyrDef.setFieldNames(fields);
|
|
578 |
// }
|
|
579 |
fields=cols; |
|
578 | 580 |
sqlConstruct = new SeSqlConstruct(layerName); |
579 | 581 |
|
580 | 582 |
// Create a query stream between the client and server |
... | ... | |
640 | 642 |
break; |
641 | 643 |
} |
642 | 644 |
} |
643 |
|
|
645 |
fields=cols; |
|
644 | 646 |
SeQuery extentQuery = new SeQuery(conn, fields, sqlConstruct); |
645 | 647 |
SeQueryInfo queryInfo = new SeQueryInfo(); |
646 | 648 |
queryInfo.setConstruct(sqlConstruct); |
... | ... | |
718 | 720 |
} |
719 | 721 |
|
720 | 722 |
public IWriter getWriter() { |
721 |
return null; |
|
723 |
if (writer == null) { |
|
724 |
writer = new ArcSdeWriter(); |
|
725 |
writer.setDriver(this); |
|
726 |
writer.setSeLayer(layer); |
|
727 |
try { |
|
728 |
writer.initialize(getLyrDef()); |
|
729 |
} |
|
730 |
catch (EditionException e) { |
|
731 |
|
|
732 |
} |
|
733 |
} |
|
734 |
|
|
735 |
return writer; |
|
722 | 736 |
} |
723 | 737 |
|
724 | 738 |
/** |
... | ... | |
878 | 892 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#reLoad() |
879 | 893 |
*/ |
880 | 894 |
public void reload() throws IOException { |
881 |
setData(null, lyrDef); |
|
895 |
try { |
|
896 |
load(); |
|
897 |
} catch (DriverException e) { |
|
898 |
e.printStackTrace(); |
|
899 |
} |
|
900 |
//setData(null, lyrDef); |
|
882 | 901 |
} |
883 | 902 |
|
884 | 903 |
public void setDataSourceFactory(DataSourceFactory dsf) { |
... | ... | |
948 | 967 |
public Object getConnection() { |
949 | 968 |
return conn; |
950 | 969 |
} |
951 |
public String[] getTableNames(Object conex, String dbName) throws SQLException { |
|
952 |
Vector theLayers=null; |
|
953 |
try { |
|
954 |
theLayers = ((SeConnection)conex).getLayers(); |
|
955 |
} catch (SeException e) { |
|
956 |
throw new SQLException(e.getMessage()); |
|
957 |
} |
|
958 |
TreeMap ret = new TreeMap(); |
|
959 |
for (int i = 0; i < theLayers.size(); i++) { |
|
960 |
SeLayer layer = (SeLayer) theLayers.elementAt(i); |
|
961 |
ret.put(layer.getTableName(), layer.getTableName()); |
|
962 |
} |
|
963 |
return (String[]) ret.keySet().toArray(new String[0]); |
|
964 |
} |
|
965 |
public String[] getAllFields(Object conex, String tableName) { |
|
966 |
try { |
|
967 |
SeTable table = new SeTable(((SeConnection)conex),tableName); |
|
968 |
SeRegisteredColumn[] columns=table.getColumnList(); |
|
969 |
String[] fieldNames=new String[columns.length]; |
|
970 |
for (int i=0; i < columns.length; i++){ |
|
971 |
fieldNames[i]=columns[i].getName(); |
|
972 |
} |
|
973 |
return fieldNames; |
|
974 |
} catch (SeException e) { |
|
975 |
e.printStackTrace(); |
|
976 |
} |
|
977 |
return null; |
|
978 |
} |
|
979 |
public String[] getAllFieldTypeNames(Object conex, String tableName) { |
|
980 |
try { |
|
981 |
SeTable table = new SeTable(((SeConnection)conex),tableName); |
|
982 |
SeRegisteredColumn[] columns=table.getColumnList(); |
|
983 |
String[] fieldNames=new String[columns.length]; |
|
984 |
for (int i=0; i < columns.length; i++){ |
|
985 |
fieldNames[i]=String.valueOf(columns[i].getType()); |
|
986 |
} |
|
987 |
return fieldNames; |
|
988 |
} catch (SeException e) { |
|
989 |
e.printStackTrace(); |
|
990 |
} |
|
991 |
return null; |
|
992 |
} |
|
993 |
public String[] getIdFieldsCandidates(Object conn2, String tableName) { |
|
994 |
return getAllFields(conn2,tableName);
|
|
995 |
} |
|
996 |
public String[] getGeometryFieldsCandidates(Object conn2, String tableName) { |
|
997 |
return getAllFields(conn2,tableName);
|
|
998 |
} |
|
970 |
// public String[] getTableNames(Object conex, String dbName) throws SQLException {
|
|
971 |
// Vector theLayers=null;
|
|
972 |
// try {
|
|
973 |
// theLayers = ((SeConnection)conex).getLayers();
|
|
974 |
// } catch (SeException e) {
|
|
975 |
// throw new SQLException(e.getMessage());
|
|
976 |
// }
|
|
977 |
// TreeMap ret = new TreeMap();
|
|
978 |
// for (int i = 0; i < theLayers.size(); i++) {
|
|
979 |
// SeLayer layer = (SeLayer) theLayers.elementAt(i);
|
|
980 |
// ret.put(layer.getTableName(), layer.getTableName());
|
|
981 |
// }
|
|
982 |
// return (String[]) ret.keySet().toArray(new String[0]);
|
|
983 |
// }
|
|
984 |
// public String[] getAllFields(Object conex, String tableName) {
|
|
985 |
// try {
|
|
986 |
// SeTable table = new SeTable(((SeConnection)conex),tableName);
|
|
987 |
// SeRegisteredColumn[] columns=table.getColumnList();
|
|
988 |
// String[] fieldNames=new String[columns.length];
|
|
989 |
// for (int i=0; i < columns.length; i++){
|
|
990 |
// fieldNames[i]=columns[i].getName();
|
|
991 |
// }
|
|
992 |
// return fieldNames;
|
|
993 |
// } catch (SeException e) {
|
|
994 |
// e.printStackTrace();
|
|
995 |
// }
|
|
996 |
// return null;
|
|
997 |
// }
|
|
998 |
// public String[] getAllFieldTypeNames(Object conex, String tableName) {
|
|
999 |
// try {
|
|
1000 |
// SeTable table = new SeTable(((SeConnection)conex),tableName);
|
|
1001 |
// SeRegisteredColumn[] columns=table.getColumnList();
|
|
1002 |
// String[] fieldNames=new String[columns.length];
|
|
1003 |
// for (int i=0; i < columns.length; i++){
|
|
1004 |
// fieldNames[i]=String.valueOf(columns[i].getType());
|
|
1005 |
// }
|
|
1006 |
// return fieldNames;
|
|
1007 |
// } catch (SeException e) {
|
|
1008 |
// e.printStackTrace();
|
|
1009 |
// }
|
|
1010 |
// return null;
|
|
1011 |
// }
|
|
1012 |
// public String[] getIdFieldsCandidates(Object conn2, String tableName) {
|
|
1013 |
// return new String[]{"OBJECTID"};//getAllFields(conn2,tableName);
|
|
1014 |
// }
|
|
1015 |
// public String[] getGeometryFieldsCandidates(Object conn2, String tableName) {
|
|
1016 |
// return new String[]{"SHAPE"};//getAllFields(conn2,tableName);
|
|
1017 |
// }
|
|
999 | 1018 |
public String getConnectionString( |
1000 | 1019 |
String host, |
1001 | 1020 |
String port, |
branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/ArcSdeWriter.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.fmap.drivers.sde; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.sql.SQLException; |
|
5 |
import java.sql.Types; |
|
6 |
import java.util.Calendar; |
|
7 |
import java.util.Date; |
|
8 |
|
|
9 |
import com.esri.sde.sdk.client.SeColumnDefinition; |
|
10 |
import com.esri.sde.sdk.client.SeConnection; |
|
11 |
import com.esri.sde.sdk.client.SeCoordinateReference; |
|
12 |
import com.esri.sde.sdk.client.SeDelete; |
|
13 |
import com.esri.sde.sdk.client.SeException; |
|
14 |
import com.esri.sde.sdk.client.SeInsert; |
|
15 |
import com.esri.sde.sdk.client.SeLayer; |
|
16 |
import com.esri.sde.sdk.client.SeObjectId; |
|
17 |
import com.esri.sde.sdk.client.SeRow; |
|
18 |
import com.esri.sde.sdk.client.SeShape; |
|
19 |
import com.esri.sde.sdk.client.SeUpdate; |
|
20 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
|
21 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
22 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
23 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
24 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
|
25 |
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition; |
|
26 |
import com.iver.cit.gvsig.fmap.drivers.sde.utils.SDELayerDefinition; |
|
27 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
|
28 |
import com.iver.cit.gvsig.fmap.edition.IFieldManager; |
|
29 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
|
30 |
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter; |
|
31 |
import com.iver.cit.gvsig.fmap.edition.writers.AbstractWriter; |
|
32 |
|
|
33 |
public class ArcSdeWriter extends AbstractWriter implements ISpatialWriter, IFieldManager { |
|
34 |
|
|
35 |
private int numRows; |
|
36 |
|
|
37 |
private SDELayerDefinition lyrDef; |
|
38 |
|
|
39 |
private SeConnection conex; |
|
40 |
|
|
41 |
//private Statement st; |
|
42 |
|
|
43 |
private boolean bCreateTable; |
|
44 |
|
|
45 |
private ArcSdeDriver driver; |
|
46 |
|
|
47 |
private SeLayer selayer; |
|
48 |
|
|
49 |
//private ArcSde postGisSQL = new ArcSde(); |
|
50 |
// private double flatness; |
|
51 |
|
|
52 |
//private JdbcFieldManager fieldManager; |
|
53 |
|
|
54 |
/** |
|
55 |
* Useful to create a layer from scratch Call setFile before using this |
|
56 |
* function |
|
57 |
* |
|
58 |
* @param lyrDef |
|
59 |
* @throws IOException |
|
60 |
* @throws DriverException |
|
61 |
*/ |
|
62 |
public void initialize(ITableDefinition lyrD) throws EditionException { |
|
63 |
super.initialize(lyrD); |
|
64 |
this.lyrDef = (SDELayerDefinition) lyrD; |
|
65 |
conex = (SeConnection)lyrDef.getConnection(); |
|
66 |
// |
|
67 |
// try { |
|
68 |
// //st = conex.createStatement(); |
|
69 |
// |
|
70 |
// if (bCreateTable) { |
|
71 |
// try { |
|
72 |
// st.execute("DROP TABLE " + lyrDef.getTableName() + ";"); |
|
73 |
// } catch (SQLException e1) { |
|
74 |
// // Si no existe la tabla, no hay que borrarla. |
|
75 |
// } |
|
76 |
// |
|
77 |
// String sqlCreate = postGisSQL.getSqlCreateSpatialTable(lyrDef, |
|
78 |
// lyrDef.getFieldsDesc(), true); |
|
79 |
// System.out.println("sqlCreate =" + sqlCreate); |
|
80 |
// st.execute(sqlCreate); |
|
81 |
// |
|
82 |
// String sqlAlter = postGisSQL.getSqlAlterTable(lyrDef); |
|
83 |
// System.out.println("sqlAlter =" + sqlAlter); |
|
84 |
// st.execute(sqlAlter); |
|
85 |
// // CREATE TABLE PARKS ( PARK_ID int4, PARK_NAME varchar(128), |
|
86 |
// // PARK_DATE date, PARK_TYPE varchar(2) ); |
|
87 |
// // SELECT AddGeometryColumn('parks_db', 'parks', 'park_geom', |
|
88 |
// // 128, |
|
89 |
// // 'MULTIPOLYGON', 2 ); |
|
90 |
// |
|
91 |
// /* |
|
92 |
// * BEGIN; INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES |
|
93 |
// * (1,GeometryFromText('LINESTRING(191232 243118,191108 |
|
94 |
// * 243242)',-1),'Jeff Rd'); INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) |
|
95 |
// * VALUES (2,GeometryFromText('LINESTRING(189141 244158,189265 |
|
96 |
// * 244817)',-1),'Geordie Rd'); COMMIT; |
|
97 |
// */ |
|
98 |
// conex.commit(); |
|
99 |
// } |
|
100 |
// conex.setAutoCommit(false); |
|
101 |
// fieldManager = new JdbcFieldManager(conex, lyrDef.getTableName()); |
|
102 |
// |
|
103 |
// } catch (SQLException e) { |
|
104 |
// e.printStackTrace(); |
|
105 |
// throw new EditionException(e); |
|
106 |
// } |
|
107 |
|
|
108 |
} |
|
109 |
|
|
110 |
public void preProcess() throws EditionException { |
|
111 |
numRows = 0; |
|
112 |
// ATENTION: We will transform (in PostGIS class; doubleQuote()) |
|
113 |
// to UTF-8 strings. Then, we tell the PostgreSQL server |
|
114 |
// that we will use UTF-8, and it can translate |
|
115 |
// to its charset |
|
116 |
// Note: we have to translate to UTF-8 because |
|
117 |
// the server cannot manage UTF-16 |
|
118 |
|
|
119 |
//ResultSet rsAux; |
|
120 |
try { |
|
121 |
//conex.rollbackTransaction(); |
|
122 |
conex.startTransaction(); |
|
123 |
alterTable(); |
|
124 |
|
|
125 |
//rsAux = conex.getRelease().st.executeQuery("SHOW server_encoding;"); |
|
126 |
//rsAux.next(); |
|
127 |
//String serverEncoding = rsAux.getString(1); |
|
128 |
//System.out.println("Server encoding = " + serverEncoding); |
|
129 |
// st.execute("SET CLIENT_ENCODING TO 'UNICODE';"); |
|
130 |
// Intentamos convertir nuestras cadenas a ese encode. |
|
131 |
// postGisSQL.setEncoding(serverEncoding); |
|
132 |
} catch (SeException e) { |
|
133 |
// TODO Auto-generated catch block |
|
134 |
e.printStackTrace(); |
|
135 |
} |
|
136 |
|
|
137 |
} |
|
138 |
|
|
139 |
public void process(IRowEdited _row) throws EditionException { |
|
140 |
int status = _row.getStatus(); |
|
141 |
try { |
|
142 |
switch (status) { |
|
143 |
case IRowEdited.STATUS_ADDED: |
|
144 |
addRow(_row); |
|
145 |
|
|
146 |
/* |
|
147 |
// TODO when addRowInCreation() is implemented: |
|
148 |
if (tableCreation) { |
|
149 |
addRowInCreation(_row); |
|
150 |
} else { |
|
151 |
addRow(_row); |
|
152 |
} |
|
153 |
*/ |
|
154 |
break; |
|
155 |
|
|
156 |
case IRowEdited.STATUS_DELETED: |
|
157 |
|
|
158 |
deleteRow(_row); |
|
159 |
|
|
160 |
|
|
161 |
break; |
|
162 |
|
|
163 |
case IRowEdited.STATUS_MODIFIED: |
|
164 |
updateRow(_row); |
|
165 |
|
|
166 |
break; |
|
167 |
|
|
168 |
case IRowEdited.STATUS_ORIGINAL: |
|
169 |
originalRow(_row); |
|
170 |
|
|
171 |
break; |
|
172 |
} |
|
173 |
} catch (SeException e) { |
|
174 |
e.printStackTrace(); |
|
175 |
throw new EditionException(); |
|
176 |
} catch (IOException e) { |
|
177 |
e.printStackTrace(); |
|
178 |
throw new EditionException(); |
|
179 |
} |
|
180 |
} |
|
181 |
private void originalRow(IRowEdited _row) { |
|
182 |
// TODO Auto-generated method stub |
|
183 |
|
|
184 |
} |
|
185 |
|
|
186 |
private void updateRow(IRowEdited irow) throws SeException, IOException { |
|
187 |
// the values associated with the given record. |
|
188 |
SeUpdate update = new SeUpdate(conex); |
|
189 |
String[] cols = lyrDef.getFieldNames(); |
|
190 |
// String featureId = feature.getID().substring( |
|
191 |
// feature.getID().lastIndexOf('.') + 1, |
|
192 |
// feature.getID().length()); |
|
193 |
update.toTable(selayer.getQualifiedName(), cols, |
|
194 |
"SHAPE" + " = " + irow.getID()); |
|
195 |
update.setWriteMode(true); |
|
196 |
|
|
197 |
SeRow row = update.getRowToSet(); |
|
198 |
|
|
199 |
// Set values on rows here..... |
|
200 |
for (int i = 0; i < cols.length; i++) { |
|
201 |
if (cols[i].equals("SHAPE")){ |
|
202 |
setRowValue(row,i,((IFeature)irow.getLinkedRow()).getGeometry()); |
|
203 |
}else{ |
|
204 |
setRowValue(row, i, irow.getAttribute(i)); |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
208 |
update.execute(); |
|
209 |
update.close(); |
|
210 |
|
|
211 |
} |
|
212 |
|
|
213 |
private void deleteRow(IRowEdited _row) throws SeException { |
|
214 |
// if ((this.features == null) |
|
215 |
// || (this.currentIndex >= this.features.size())) { |
|
216 |
// throw new IOException("No current feature available."); |
|
217 |
// } |
|
218 |
|
|
219 |
// if (this.notInserted) { |
|
220 |
// this.features.remove(this.currentIndex--); |
|
221 |
// this.notInserted = false; |
|
222 |
// } else { |
|
223 |
// Feature feature = (Feature) this.features.get(this.currentIndex); |
|
224 |
// PooledConnection connection = null; |
|
225 |
|
|
226 |
// connection = getConnection(); |
|
227 |
|
|
228 |
SeDelete seDelete = new SeDelete(conex); |
|
229 |
|
|
230 |
long featureId = Long.parseLong(_row.getID()); |
|
231 |
SeObjectId objectID = new SeObjectId(featureId); |
|
232 |
seDelete.byId(selayer.getQualifiedName(), objectID); |
|
233 |
//this.dataStore.fireRemoved(feature); |
|
234 |
// } catch (Exception e) { |
|
235 |
// throw new SOException(e.getMessage()); |
|
236 |
// } finally { |
|
237 |
conex.close(); |
|
238 |
// } |
|
239 |
// } |
|
240 |
} |
|
241 |
|
|
242 |
private void addRow(IRowEdited irow) throws EditionException { |
|
243 |
try { |
|
244 |
//Feature feature = (Feature) this.features.get(this.currentIndex); |
|
245 |
//FeatureType featureType = feature.getFeatureType(); |
|
246 |
//AttributeType[] attributeTypes = featureType.getAttributeTypes(); |
|
247 |
//connection = getConnection(); |
|
248 |
|
|
249 |
//if (this.notInserted) { |
|
250 |
// We must insert the record into ArcSDE |
|
251 |
SeInsert insert = new SeInsert(conex); |
|
252 |
String[] cols = lyrDef.getFieldNames(); |
|
253 |
insert.intoTable(selayer.getQualifiedName(), cols); |
|
254 |
insert.setWriteMode(true); |
|
255 |
|
|
256 |
SeRow row = insert.getRowToSet(); |
|
257 |
|
|
258 |
// Now set the values for the new row here... |
|
259 |
for (int i = 0; i < cols.length; i++) { |
|
260 |
if (cols[i].equals("SHAPE")){ |
|
261 |
setRowValue(row,i,((IFeature)irow.getLinkedRow()).getGeometry()); |
|
262 |
}else{ |
|
263 |
setRowValue(row, i, irow.getAttribute(i)); |
|
264 |
} |
|
265 |
} |
|
266 |
|
|
267 |
// Now "commit" the changes. |
|
268 |
insert.execute(); |
|
269 |
insert.close(); |
|
270 |
//this.dataStore.fireAdded(feature); |
|
271 |
//} |
|
272 |
|
|
273 |
// else { |
|
274 |
// // The record is already inserted, so we will be updating |
|
275 |
// // the values associated with the given record. |
|
276 |
// SeUpdate update = new SeUpdate(connection); |
|
277 |
// String[] cols = getColumns(attributeTypes, connection); |
|
278 |
// String featureId = feature.getID().substring( |
|
279 |
// feature.getID().lastIndexOf('.') + 1, |
|
280 |
// feature.getID().length()); |
|
281 |
// update.toTable(this.layer.getQualifiedName(), cols, |
|
282 |
// this.spatialColumnName + " = " + featureId); |
|
283 |
// update.setWriteMode(true); |
|
284 |
// |
|
285 |
// SeRow row = update.getRowToSet(); |
|
286 |
// |
|
287 |
// // Set values on rows here..... |
|
288 |
// for (int i = 0; i < cols.length; i++) { |
|
289 |
// Object value = feature |
|
290 |
// .getAttribute(this.mutableAttributeIndexes[i] |
|
291 |
// .intValue()); |
|
292 |
// setRowValue(row, i, value); |
|
293 |
// } |
|
294 |
// |
|
295 |
// update.execute(); |
|
296 |
// update.close(); |
|
297 |
// |
|
298 |
// } |
|
299 |
} catch (Exception e) { |
|
300 |
|
|
301 |
// LOGGER.log(Level.WARNING, e.getMessage(), e); |
|
302 |
// if (LOGGER.isLoggable(Level.FINE)) { |
|
303 |
// e.printStackTrace(); |
|
304 |
// } |
|
305 |
// throw new DataSourceException(e.getMessage(), e); |
|
306 |
} finally { |
|
307 |
try { |
|
308 |
conex.close(); |
|
309 |
} catch (SeException e) { |
|
310 |
// TODO Auto-generated catch block |
|
311 |
e.printStackTrace(); |
|
312 |
} |
|
313 |
} |
|
314 |
} |
|
315 |
|
|
316 |
/** |
|
317 |
* Used to set a value on an SeRow object. The values is converted to the |
|
318 |
* appropriate type based on an inspection of the SeColumnDefintion object. |
|
319 |
* |
|
320 |
* @param row |
|
321 |
* @param index |
|
322 |
* @param value |
|
323 |
* |
|
324 |
* @throws SeException |
|
325 |
* DOCUMENT ME! |
|
326 |
* @throws IOException |
|
327 |
* DOCUMENT ME! |
|
328 |
*/ |
|
329 |
private void setRowValue(SeRow row, int index, Object value) |
|
330 |
throws SeException, IOException { |
|
331 |
SeColumnDefinition seColumnDefinition = null; |
|
332 |
seColumnDefinition = row.getColumnDef(index); |
|
333 |
|
|
334 |
switch (seColumnDefinition.getType()) { |
|
335 |
case SeColumnDefinition.TYPE_INTEGER: { |
|
336 |
if (value != null) { |
|
337 |
row.setInteger(index, new Integer(value.toString())); |
|
338 |
} else { |
|
339 |
row.setInteger(index, null); |
|
340 |
} |
|
341 |
|
|
342 |
break; |
|
343 |
} |
|
344 |
|
|
345 |
case SeColumnDefinition.TYPE_SMALLINT: { |
|
346 |
if (value != null) { |
|
347 |
row.setShort(index, new Short(value.toString())); |
|
348 |
} else { |
|
349 |
row.setShort(index, null); |
|
350 |
} |
|
351 |
|
|
352 |
break; |
|
353 |
} |
|
354 |
|
|
355 |
case SeColumnDefinition.TYPE_FLOAT: { |
|
356 |
if (value != null) { |
|
357 |
row.setFloat(index, new Float(value.toString())); |
|
358 |
} else { |
|
359 |
row.setFloat(index, null); |
|
360 |
} |
|
361 |
|
|
362 |
break; |
|
363 |
} |
|
364 |
|
|
365 |
case SeColumnDefinition.TYPE_DOUBLE: { |
|
366 |
if (value != null) { |
|
367 |
row.setDouble(index, new Double(value.toString())); |
|
368 |
} else { |
|
369 |
row.setDouble(index, null); |
|
370 |
} |
|
371 |
|
|
372 |
break; |
|
373 |
} |
|
374 |
|
|
375 |
case SeColumnDefinition.TYPE_STRING: { |
|
376 |
if (value != null) { |
|
377 |
row.setString(index, value.toString()); |
|
378 |
} else { |
|
379 |
row.setString(index, null); |
|
380 |
} |
|
381 |
|
|
382 |
break; |
|
383 |
} |
|
384 |
|
|
385 |
case SeColumnDefinition.TYPE_DATE: { |
|
386 |
if (value != null) { |
|
387 |
Calendar calendar = Calendar.getInstance(); |
|
388 |
calendar.setTime((Date) value); |
|
389 |
row.setTime(index, calendar); |
|
390 |
} else { |
|
391 |
row.setTime(index, null); |
|
392 |
} |
|
393 |
|
|
394 |
break; |
|
395 |
} |
|
396 |
|
|
397 |
case SeColumnDefinition.TYPE_SHAPE: { |
|
398 |
if (value != null) { |
|
399 |
try { |
|
400 |
SeCoordinateReference coordRef = selayer.getCoordRef(); |
|
401 |
IGeometry geom = (IGeometry) value; |
|
402 |
SeShape shape = ArcSdeFeatureIterator.constructShape(geom, |
|
403 |
coordRef); |
|
404 |
row.setShape(index, shape); |
|
405 |
} catch (Exception e) { |
|
406 |
e.printStackTrace(); |
|
407 |
} |
|
408 |
} else { |
|
409 |
row.setShape(index, null); |
|
410 |
} |
|
411 |
|
|
412 |
break; |
|
413 |
} |
|
414 |
} |
|
415 |
} |
|
416 |
|
|
417 |
public void postProcess() throws EditionException { |
|
418 |
try { |
|
419 |
conex.commitTransaction(); |
|
420 |
} catch (SeException e) { |
|
421 |
e.printStackTrace(); |
|
422 |
throw new EditionException(e); |
|
423 |
} |
|
424 |
} |
|
425 |
|
|
426 |
public String getName() { |
|
427 |
return "gvSIG SDE Writer"; |
|
428 |
} |
|
429 |
|
|
430 |
public boolean canWriteGeometry(int gvSIGgeometryType) { |
|
431 |
switch (gvSIGgeometryType) { |
|
432 |
case FShape.POINT: |
|
433 |
return true; |
|
434 |
case FShape.LINE: |
|
435 |
return true; |
|
436 |
case FShape.POLYGON: |
|
437 |
return true; |
|
438 |
case FShape.ARC: |
|
439 |
return false; |
|
440 |
case FShape.ELLIPSE: |
|
441 |
return false; |
|
442 |
case FShape.MULTIPOINT: |
|
443 |
return true; |
|
444 |
case FShape.TEXT: |
|
445 |
return false; |
|
446 |
} |
|
447 |
return false; |
|
448 |
} |
|
449 |
|
|
450 |
public boolean canWriteAttribute(int sqlType) { |
|
451 |
switch (sqlType) { |
|
452 |
case Types.DOUBLE: |
|
453 |
case Types.FLOAT: |
|
454 |
case Types.INTEGER: |
|
455 |
case Types.BIGINT: |
|
456 |
return true; |
|
457 |
case Types.DATE: |
|
458 |
return true; |
|
459 |
case Types.BIT: |
|
460 |
case Types.BOOLEAN: |
|
461 |
return true; |
|
462 |
case Types.VARCHAR: |
|
463 |
case Types.CHAR: |
|
464 |
case Types.LONGVARCHAR: |
|
465 |
return true; |
|
466 |
|
|
467 |
} |
|
468 |
|
|
469 |
return false; |
|
470 |
} |
|
471 |
|
|
472 |
/** |
|
473 |
* @return Returns the bCreateTable. |
|
474 |
*/ |
|
475 |
public boolean isCreateTable() { |
|
476 |
return bCreateTable; |
|
477 |
} |
|
478 |
|
|
479 |
/** |
|
480 |
* @param createTable |
|
481 |
* The bCreateTable to set. |
|
482 |
*/ |
|
483 |
public void setCreateTable(boolean createTable) { |
|
484 |
bCreateTable = createTable; |
|
485 |
} |
|
486 |
|
|
487 |
public FieldDescription[] getOriginalFields() { |
|
488 |
return lyrDef.getFieldsDesc(); |
|
489 |
} |
|
490 |
|
|
491 |
public void addField(FieldDescription fieldDesc) { |
|
492 |
// fieldManager.addField(fieldDesc); |
|
493 |
|
|
494 |
} |
|
495 |
|
|
496 |
public FieldDescription removeField(String fieldName) { |
|
497 |
// return fieldManager.removeField(fieldName); |
|
498 |
return null; |
|
499 |
} |
|
500 |
|
|
501 |
public void renameField(String antName, String newName) { |
|
502 |
// fieldManager.renameField(antName, newName); |
|
503 |
|
|
504 |
} |
|
505 |
|
|
506 |
public boolean alterTable() throws EditionException { |
|
507 |
// return fieldManager.alterTable(); |
|
508 |
return false; |
|
509 |
} |
|
510 |
|
|
511 |
public FieldDescription[] getFields() { |
|
512 |
// return fieldManager.getFields(); |
|
513 |
return lyrDef.getFieldsDesc(); |
|
514 |
} |
|
515 |
|
|
516 |
public boolean canAlterTable() { |
|
517 |
return true; |
|
518 |
} |
|
519 |
|
|
520 |
public boolean canSaveEdits() { |
|
521 |
// try { |
|
522 |
// return !conex.isReadOnly(); |
|
523 |
// } catch (SQLException e) { |
|
524 |
// // TODO Auto-generated catch block |
|
525 |
// e.printStackTrace(); |
|
526 |
// return false; |
|
527 |
// } |
|
528 |
return false; |
|
529 |
} |
|
530 |
|
|
531 |
public void setDriver(ArcSdeDriver driver) { |
|
532 |
this.driver=driver; |
|
533 |
|
|
534 |
} |
|
535 |
|
|
536 |
public void setSeLayer(SeLayer layer) { |
|
537 |
this.selayer=layer; |
|
538 |
} |
|
539 |
|
|
540 |
} |
|
0 | 541 |
branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/VectorialSDEDriver.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.fmap.drivers.sde; |
|
42 |
|
|
43 |
import java.awt.geom.Rectangle2D; |
|
44 |
import java.sql.Connection; |
|
45 |
import java.sql.SQLException; |
|
46 |
|
|
47 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
|
48 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
49 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
|
50 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
|
51 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver; |
|
52 |
|
|
53 |
public interface VectorialSDEDriver extends VectorialDatabaseDriver{ |
|
54 |
/** |
|
55 |
* @param conn |
|
56 |
* @param lyrDef TODO |
|
57 |
* @param id_FID_field El identificador del campo que contiene una clave ?nica. 1=> primer campo, 2 => segundo campo, etc |
|
58 |
* |
|
59 |
*/ |
|
60 |
public void setData(Connection conn, DBLayerDefinition lyrDef); |
|
61 |
//public Connection getConnection(); |
|
62 |
public IFeatureIterator getFeatureIterator(String sql) throws DriverException; |
|
63 |
//public String getConnectionStringBeginning(); |
|
64 |
public void open() throws com.iver.cit.gvsig.fmap.DriverException; |
|
65 |
public int getDefaultPort(); |
|
66 |
public void setWorkingArea(Rectangle2D rect); |
|
67 |
/** |
|
68 |
* @return |
|
69 |
*/ |
|
70 |
public Rectangle2D getWorkingArea(); |
|
71 |
public String getConnectionString(String _host, String _port, String _db, String _user, String _pw); |
|
72 |
// public String[] getTableNames(Object conex, String dbName) throws SQLException; |
|
73 |
// public String[] getAllFields(Object conn, String tableName); |
|
74 |
// public String[] getAllFieldTypeNames(Object conn, String tableName); |
|
75 |
// public String[] getIdFieldsCandidates(Object conn, String tableName); |
|
76 |
// public String[] getGeometryFieldsCandidates(Object conn, String tableName); |
|
77 |
} |
|
0 | 78 |
branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/ArcSdeFeatureIterator.java | ||
---|---|---|
43 | 43 |
*/ |
44 | 44 |
package com.iver.cit.gvsig.fmap.drivers.sde; |
45 | 45 |
|
46 |
import java.awt.geom.PathIterator; |
|
46 | 47 |
import java.sql.SQLException; |
48 |
import java.util.ArrayList; |
|
49 |
import java.util.List; |
|
47 | 50 |
|
51 |
import com.esri.sde.sdk.client.SDEPoint; |
|
48 | 52 |
import com.esri.sde.sdk.client.SeColumnDefinition; |
53 |
import com.esri.sde.sdk.client.SeCoordinateReference; |
|
49 | 54 |
import com.esri.sde.sdk.client.SeException; |
50 | 55 |
import com.esri.sde.sdk.client.SeQuery; |
51 | 56 |
import com.esri.sde.sdk.client.SeRow; |
... | ... | |
54 | 59 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
55 | 60 |
import com.iver.cit.gvsig.fmap.DriverException; |
56 | 61 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
62 |
import com.iver.cit.gvsig.fmap.core.FMultiPoint2D; |
|
57 | 63 |
import com.iver.cit.gvsig.fmap.core.FNullGeometry; |
58 | 64 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
65 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
59 | 66 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
60 | 67 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
61 | 68 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
... | ... | |
72 | 79 |
private boolean bFirst; |
73 | 80 |
Value[] regAtt; |
74 | 81 |
SeRow row; |
82 |
private int index=0; |
|
75 | 83 |
|
76 | 84 |
static GeneralPathX convertSeShapeToGeneralPathX(SeShape spVal) throws SeException |
77 | 85 |
{ |
... | ... | |
158 | 166 |
return new FNullGeometry(); |
159 | 167 |
} |
160 | 168 |
|
169 |
|
|
170 |
public static SeShape constructShape(IGeometry geometry, SeCoordinateReference seSrs) { |
|
171 |
SeShape shape = null; |
|
172 |
|
|
173 |
try { |
|
174 |
shape = new SeShape(seSrs); |
|
175 |
} catch (SeException ex) { |
|
176 |
|
|
177 |
} |
|
178 |
|
|
179 |
// if (geometry.isEmpty()) { |
|
180 |
// return shape; |
|
181 |
// } |
|
182 |
|
|
183 |
int numParts=1; |
|
184 |
// GeometryCollection gcol = null; |
|
185 |
// |
|
186 |
// if (geometry instanceof GeometryCollection) { |
|
187 |
// gcol = (GeometryCollection) geometry; |
|
188 |
// } else { |
|
189 |
// Geometry[] geoms = { geometry }; |
|
190 |
// gcol = new GeometryFactory().createGeometryCollection(geoms); |
|
191 |
// } |
|
192 |
|
|
193 |
// List allPoints = new ArrayList(); |
|
194 |
// numParts = gcol.getNumGeometries(); |
|
195 |
|
|
196 |
int[] partOffsets = new int[numParts]; |
|
197 |
// Geometry geom; |
|
198 |
// Coordinate[] coords; |
|
199 |
// Coordinate c; |
|
200 |
SDEPoint[] points = getPoints(geometry); |
|
201 |
partOffsets[0]=points.length; |
|
202 |
// for (int currGeom = 0; currGeom < numParts; currGeom++) { |
|
203 |
// partOffsets[currGeom] = allPoints.size(); |
|
204 |
// geom = gcol.getGeometryN(currGeom); |
|
205 |
// |
|
206 |
// coords = geom.getCoordinates(); |
|
207 |
// |
|
208 |
// for (int i = 0; i < coords.length; i++) { |
|
209 |
// c = coords[i]; |
|
210 |
// allPoints.add(new SDEPoint(c.x, c.y)); |
|
211 |
// } |
|
212 |
// } |
|
213 |
|
|
214 |
// SDEPoint[] points = new SDEPoint[allPoints.size()]; |
|
215 |
// allPoints.toArray(points); |
|
216 |
|
|
217 |
try { |
|
218 |
if (geometry.getGeometryType()==FShape.POINT || geometry instanceof FMultiPoint2D) { |
|
219 |
shape.generatePoint(points.length, points); |
|
220 |
} else if (geometry.getGeometryType()==FShape.LINE) { |
|
221 |
shape |
|
222 |
.generateLine(points.length, numParts, partOffsets, |
|
223 |
points); |
|
224 |
} else { |
|
225 |
shape.generatePolygon(points.length, numParts, partOffsets, |
|
226 |
points); |
|
227 |
} |
|
228 |
} catch (SeException e) { |
|
229 |
e.printStackTrace(); |
|
230 |
} |
|
231 |
|
|
232 |
return shape; |
|
233 |
} |
|
234 |
|
|
235 |
private static SDEPoint[] getPoints(IGeometry g) { |
|
236 |
// if (FConstant.SHAPE_TYPE_MULTIPOINTZ == m_type){ |
|
237 |
// zs=((IGeometry3D)g).getZs(); |
|
238 |
// } |
|
239 |
PathIterator theIterator = g.getPathIterator(null); //polyLine.getPathIterator(null, flatness); |
|
240 |
double[] theData = new double[6]; |
|
241 |
ArrayList ps=new ArrayList(); |
|
242 |
while (!theIterator.isDone()) { |
|
243 |
//while not done |
|
244 |
int theType = theIterator.currentSegment(theData); |
|
245 |
|
|
246 |
ps.add(new SDEPoint(theData[0], theData[1])); |
|
247 |
theIterator.next(); |
|
248 |
} //end while loop |
|
249 |
SDEPoint[] points = (SDEPoint[])ps.toArray(new SDEPoint[0]); |
|
250 |
return points; |
|
251 |
} |
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
161 | 256 |
/** |
162 | 257 |
* @throws SQLException |
163 | 258 |
* |
... | ... | |
175 | 270 |
numColumns = row.getNumColumns(); |
176 | 271 |
regAtt = new Value[numColumns-1]; |
177 | 272 |
bFirst = true; |
273 |
SeColumnDefinition[] colDefs = row.getColumns(); |
|
274 |
for (int i=0; i<colDefs.length;i++){ |
|
275 |
if (colDefs[i].getName().equals("OBJECTID")){ |
|
276 |
index=i; |
|
277 |
} |
|
278 |
} |
|
178 | 279 |
} catch (SeException e) { |
179 | 280 |
// TODO Auto-generated catch block |
180 | 281 |
e.printStackTrace(); |
... | ... | |
214 | 315 |
IFeature feat = null; |
215 | 316 |
try |
216 | 317 |
{ |
318 |
|
|
217 | 319 |
if ( row != null ) |
218 | 320 |
{ |
219 | 321 |
for (int colNum = 0; colNum < colDefs.length; colNum++) |
... | ... | |
255 | 357 |
} // End switch |
256 | 358 |
} // End if |
257 | 359 |
} // for |
258 |
// System.out.println("Dentro de next(): " + spVal.getFeatureId().toString() + " " + regAtt[0]);
|
|
360 |
//System.out.println("Dentro de next(): " + spVal.getFeatureId().longValue() + " " + regAtt[0]);
|
|
259 | 361 |
|
260 |
feat = new DefaultFeature(geom, regAtt, "" + spVal.getFeatureId().longValue());
|
|
362 |
feat = new DefaultFeature(geom, regAtt,String.valueOf(regAtt[index-1]));//""+ spVal.getFeatureId().longValue());
|
|
261 | 363 |
} // if |
262 | 364 |
|
263 | 365 |
|
branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/sde/gui/sdewizard/WizardSDEOld.java | ||
---|---|---|
62 | 62 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
63 | 63 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
64 | 64 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver; |
65 |
import com.iver.cit.gvsig.fmap.drivers.VectorialSDEDriver; |
|
66 | 65 |
import com.iver.cit.gvsig.fmap.drivers.sde.ArcSdeDriver; |
67 |
import com.iver.cit.gvsig.fmap.drivers.sde.SDELayerDefinition; |
|
66 |
import com.iver.cit.gvsig.fmap.drivers.sde.utils.SDELayerDefinition;
|
|
68 | 67 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
69 | 68 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
70 | 69 |
import com.iver.cit.gvsig.gui.WizardPanel; |
branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/sde/gui/sdewizard/WizardSDE.java | ||
---|---|---|
26 | 26 |
import com.iver.cit.gvsig.fmap.core.ICanReproject; |
27 | 27 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
28 | 28 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver; |
29 |
import com.iver.cit.gvsig.fmap.drivers.VectorialSDEDriver; |
|
30 | 29 |
import com.iver.cit.gvsig.fmap.drivers.sde.ArcSdeDriver; |
31 |
import com.iver.cit.gvsig.fmap.drivers.sde.SDELayerDefinition; |
|
30 |
import com.iver.cit.gvsig.fmap.drivers.sde.utils.SDELayerDefinition;
|
|
32 | 31 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
33 | 32 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
34 | 33 |
import com.iver.cit.gvsig.gui.WizardPanel; |
... | ... | |
82 | 81 |
/** |
83 | 82 |
* @uml.property name="driver" |
84 | 83 |
*/ |
85 |
private VectorialSDEDriver driver;
|
|
84 |
private ArcSdeDriver driver;
|
|
86 | 85 |
|
87 | 86 |
/** |
88 | 87 |
* @uml.property name="geomFieldSelection" |
... | ... | |
146 | 145 |
} |
147 | 146 |
|
148 | 147 |
private String[] getDriverNames(){ |
149 |
Class[] classes = new Class[] { VectorialSDEDriver.class };
|
|
148 |
Class[] classes = new Class[] { ArcSdeDriver.class };
|
|
150 | 149 |
|
151 | 150 |
ArrayList ret = new ArrayList(); |
152 | 151 |
String[] driverNames = LayerFactory.getDM().getDriverNames(); |
... | ... | |
361 | 360 |
* @throws DriverLoadException |
362 | 361 |
* @uml.property name="driver" |
363 | 362 |
*/ |
Also available in: Unified diff