Revision 11197

View differences:

branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/ArcSdeWriter.java
1 1
package com.iver.cit.gvsig.fmap.drivers.sde;
2 2

  
3 3
import java.io.IOException;
4
import java.sql.SQLException;
5 4
import java.sql.Types;
6 5
import java.util.Calendar;
7 6
import java.util.Date;
......
17 16
import com.esri.sde.sdk.client.SeRow;
18 17
import com.esri.sde.sdk.client.SeShape;
19 18
import com.esri.sde.sdk.client.SeUpdate;
20
import com.hardcode.gdbms.engine.data.driver.DriverException;
21 19
import com.iver.cit.gvsig.fmap.core.FShape;
22 20
import com.iver.cit.gvsig.fmap.core.IFeature;
23 21
import com.iver.cit.gvsig.fmap.core.IGeometry;
24 22
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
25 23
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition;
26
import com.iver.cit.gvsig.fmap.drivers.sde.utils.SDELayerDefinition;
27 24
import com.iver.cit.gvsig.fmap.edition.EditionException;
28 25
import com.iver.cit.gvsig.fmap.edition.IFieldManager;
29 26
import com.iver.cit.gvsig.fmap.edition.IRowEdited;
30 27
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter;
31 28
import com.iver.cit.gvsig.fmap.edition.writers.AbstractWriter;
32 29

  
33
public class ArcSdeWriter extends AbstractWriter implements ISpatialWriter, IFieldManager {
34 30

  
35
	private int numRows;
31
/**
32
 * DOCUMENT ME!
33
 *
34
 * @author Vicente Caballero Navarro
35
 */
36
public class ArcSdeWriter extends AbstractWriter implements ISpatialWriter,
37
    IFieldManager {
38
    private int numRows;
39
    private ArcSDELayerDefinition lyrDef;
40
    private SeConnection conex;
36 41

  
37
	private SDELayerDefinition lyrDef;
42
    //private Statement st;
43
    private boolean bCreateTable;
44
    private ArcSdeDriver driver;
45
    private SeLayer selayer;
38 46

  
39
	private SeConnection conex;
47
    //private ArcSde postGisSQL = new ArcSde();
48
    // private double flatness;
49
    //private JdbcFieldManager fieldManager;
40 50

  
41
	//private Statement st;
51
    /**
52
     * Useful to create a layer from scratch Call setFile before using this
53
     * function
54
     *
55
     * @param lyrD
56
     *
57
     * @throws EditionException
58
     */
59
    public void initialize(ITableDefinition lyrD) throws EditionException {
60
        super.initialize(lyrD);
61
        this.lyrDef = (ArcSDELayerDefinition) lyrD;
62
        conex = (SeConnection) lyrDef.getConnection();
42 63

  
43
	private boolean bCreateTable;
64
        //
65
        //		try {
66
        //			//st = conex.createStatement();
67
        //
68
        //			if (bCreateTable) {
69
        //				try {
70
        //					st.execute("DROP TABLE " + lyrDef.getTableName() + ";");
71
        //				} catch (SQLException e1) {
72
        //					// Si no existe la tabla, no hay que borrarla.
73
        //				}
74
        //
75
        //				String sqlCreate = postGisSQL.getSqlCreateSpatialTable(lyrDef,
76
        //						lyrDef.getFieldsDesc(), true);
77
        //				System.out.println("sqlCreate =" + sqlCreate);
78
        //				st.execute(sqlCreate);
79
        //
80
        //				String sqlAlter = postGisSQL.getSqlAlterTable(lyrDef);
81
        //				System.out.println("sqlAlter =" + sqlAlter);
82
        //				st.execute(sqlAlter);
83
        //				// CREATE TABLE PARKS ( PARK_ID int4, PARK_NAME varchar(128),
84
        //				// PARK_DATE date, PARK_TYPE varchar(2) );
85
        //				// SELECT AddGeometryColumn('parks_db', 'parks', 'park_geom',
86
        //				// 128,
87
        //				// 'MULTIPOLYGON', 2 );
88
        //
89
        //				/*
90
        //				 * BEGIN; INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES
91
        //				 * (1,GeometryFromText('LINESTRING(191232 243118,191108
92
        //				 * 243242)',-1),'Jeff Rd'); INSERT INTO ROADS_GEOM (ID,GEOM,NAME )
93
        //				 * VALUES (2,GeometryFromText('LINESTRING(189141 244158,189265
94
        //				 * 244817)',-1),'Geordie Rd'); COMMIT;
95
        //				 */
96
        //				conex.commit();
97
        //			}
98
        //			conex.setAutoCommit(false);
99
        //			fieldManager = new JdbcFieldManager(conex, lyrDef.getTableName());
100
        //
101
        //		} catch (SQLException e) {
102
        //			e.printStackTrace();
103
        //			throw new EditionException(e);
104
        //		}
105
    }
44 106

  
45
	private ArcSdeDriver driver;
107
    /**
108
     * DOCUMENT ME!
109
     *
110
     * @throws EditionException DOCUMENT ME!
111
     */
112
    public void preProcess() throws EditionException {
113
        numRows = 0;
46 114

  
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 115
        // ATENTION: We will transform (in PostGIS class; doubleQuote())
113 116
        // to UTF-8 strings. Then, we tell the PostgreSQL server
114 117
        // that we will use UTF-8, and it can translate
115 118
        // to its charset
116 119
        // Note: we have to translate to UTF-8 because
117 120
        // the server cannot manage UTF-16
118

  
119 121
        //ResultSet rsAux;
120
		try {
121
			//conex.rollbackTransaction();
122
			conex.startTransaction();
123
			alterTable();
122
        try {
123
            //conex.rollbackTransaction();
124
            conex.startTransaction();
125
            alterTable();
124 126

  
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
		}
127
            //rsAux = conex.getRelease().st.executeQuery("SHOW server_encoding;");
128
            //rsAux.next();
129
            //String serverEncoding = rsAux.getString(1);
130
            //System.out.println("Server encoding = " + serverEncoding);
131
            // st.execute("SET CLIENT_ENCODING TO 'UNICODE';");
132
            // Intentamos convertir nuestras cadenas a ese encode.
133
            //	        postGisSQL.setEncoding(serverEncoding);
134
        } catch (SeException e) {
135
            // TODO Auto-generated catch block
136
            e.printStackTrace();
137
        }
138
    }
136 139

  
137
	}
140
    /**
141
     * DOCUMENT ME!
142
     *
143
     * @param _row DOCUMENT ME!
144
     *
145
     * @throws EditionException DOCUMENT ME!
146
     */
147
    public void process(IRowEdited _row) throws EditionException {
148
        int status = _row.getStatus();
138 149

  
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);
150
        try {
151
            switch (status) {
152
            case IRowEdited.STATUS_ADDED:
153
                addRow(_row);
145 154

  
146
	            /*
147
	             // TODO when addRowInCreation() is implemented:
148
	            if (tableCreation) {
149
	                    addRowInCreation(_row);
150
	            } else {
151
	                    addRow(_row);
152
	            }
153
	            */
154
	            break;
155
                /*
156
                 // TODO when addRowInCreation() is implemented:
157
                if (tableCreation) {
158
                        addRowInCreation(_row);
159
                } else {
160
                        addRow(_row);
161
                }
162
                */
163
                break;
155 164

  
156
	        case IRowEdited.STATUS_DELETED:
165
            case IRowEdited.STATUS_DELETED:
166
                deleteRow(_row);
157 167

  
158
						deleteRow(_row);
168
                break;
159 169

  
170
            case IRowEdited.STATUS_MODIFIED:
171
                updateRow(_row);
160 172

  
161
	            break;
173
                break;
162 174

  
163
	        case IRowEdited.STATUS_MODIFIED:
164
	            updateRow(_row);
175
            case IRowEdited.STATUS_ORIGINAL:
176
                originalRow(_row);
165 177

  
166
	            break;
178
                break;
179
            }
180
        } catch (SeException e) {
181
            e.printStackTrace();
182
            throw new EditionException();
183
        } catch (IOException e) {
184
            e.printStackTrace();
185
            throw new EditionException();
186
        }
187
    }
167 188

  
168
	        case IRowEdited.STATUS_ORIGINAL:
169
	            originalRow(_row);
189
    /**
190
     * DOCUMENT ME!
191
     *
192
     * @param _row DOCUMENT ME!
193
     */
194
    private void originalRow(IRowEdited _row) {
195
        // TODO Auto-generated method stub
196
    }
170 197

  
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
198
    /**
199
     * DOCUMENT ME!
200
     *
201
     * @param irow DOCUMENT ME!
202
     *
203
     * @throws SeException DOCUMENT ME!
204
     * @throws IOException DOCUMENT ME!
205
     */
206
    private void updateRow(IRowEdited irow) throws SeException, IOException {
207
        //		 the values associated with the given record.
208
        SeUpdate update = new SeUpdate(conex);
209
        String[] cols = lyrDef.getFieldNames();
183 210

  
184
	}
211
        //			String featureId = feature.getID().substring(
212
        //					feature.getID().lastIndexOf('.') + 1,
213
        //					feature.getID().length());
214
        update.toTable(selayer.getQualifiedName(), cols,
215
            "SHAPE" + " = " + irow.getID());
216
        update.setWriteMode(true);
185 217

  
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);
218
        SeRow row = update.getRowToSet();
196 219

  
197
			SeRow row = update.getRowToSet();
220
        // Set values on rows here.....
221
        for (int i = 0; i < cols.length; i++) {
222
            if (cols[i].equals("SHAPE")) {
223
                setRowValue(row, i,
224
                    ((IFeature) irow.getLinkedRow()).getGeometry());
225
            } else {
226
                setRowValue(row, i, irow.getAttribute(i));
227
            }
228
        }
198 229

  
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
			}
230
        update.execute();
231
        update.close();
232
    }
207 233

  
208
			update.execute();
209
			update.close();
234
    /**
235
     * DOCUMENT ME!
236
     *
237
     * @param _row DOCUMENT ME!
238
     *
239
     * @throws SeException DOCUMENT ME!
240
     */
241
    private void deleteRow(IRowEdited _row) throws SeException {
242
        //				if ((this.features == null)
243
        //						|| (this.currentIndex >= this.features.size())) {
244
        //					throw new IOException("No current feature available.");
245
        //				}
246
        //				if (this.notInserted) {
247
        //					this.features.remove(this.currentIndex--);
248
        //					this.notInserted = false;
249
        //				} else {
250
        //					Feature feature = (Feature) this.features.get(this.currentIndex);
251
        //					PooledConnection connection = null;
252
        //						connection = getConnection();
253
        SeDelete seDelete = new SeDelete(conex);
210 254

  
211
	}
255
        long featureId = Long.parseLong(_row.getID());
256
        SeObjectId objectID = new SeObjectId(featureId);
257
        seDelete.byId(selayer.getQualifiedName(), objectID);
212 258

  
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
//				}
259
        //this.dataStore.fireRemoved(feature);
260
        //					} catch (Exception e) {
261
        //						throw new SOException(e.getMessage());
262
        //					} finally {
263
        conex.close();
218 264

  
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;
265
        //					}
266
        //				}
267
    }
225 268

  
226
//						connection = getConnection();
269
    /**
270
     * DOCUMENT ME!
271
     *
272
     * @param irow DOCUMENT ME!
273
     *
274
     * @throws EditionException DOCUMENT ME!
275
     */
276
    private void addRow(IRowEdited irow) throws EditionException {
277
        try {
278
            //Feature feature = (Feature) this.features.get(this.currentIndex);
279
            //FeatureType featureType = feature.getFeatureType();
280
            //AttributeType[] attributeTypes = featureType.getAttributeTypes();
281
            //connection = getConnection();
282
            //if (this.notInserted) {
283
            // We must insert the record into ArcSDE
284
            SeInsert insert = new SeInsert(conex);
285
            String[] cols = lyrDef.getFieldNames();
286
            insert.intoTable(selayer.getQualifiedName(), cols);
287
            insert.setWriteMode(true);
227 288

  
228
						SeDelete seDelete = new SeDelete(conex);
289
            SeRow row = insert.getRowToSet();
229 290

  
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
			}
291
            // Now set the values for the new row here...
292
            for (int i = 0; i < cols.length; i++) {
293
                if (cols[i].equals("SHAPE")) {
294
                    setRowValue(row, i,
295
                        ((IFeature) irow.getLinkedRow()).getGeometry());
296
                } else {
297
                    setRowValue(row, i, irow.getAttribute(i));
298
                }
299
            }
241 300

  
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();
301
            // Now "commit" the changes.
302
            insert.execute();
303
            insert.close();
248 304

  
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);
305
            //this.dataStore.fireAdded(feature);
306
            //}
307
            //		 else {
308
            //					// The record is already inserted, so we will be updating
309
            //					// the values associated with the given record.
310
            //					SeUpdate update = new SeUpdate(connection);
311
            //					String[] cols = getColumns(attributeTypes, connection);
312
            //					String featureId = feature.getID().substring(
313
            //							feature.getID().lastIndexOf('.') + 1,
314
            //							feature.getID().length());
315
            //					update.toTable(this.layer.getQualifiedName(), cols,
316
            //							this.spatialColumnName + " = " + featureId);
317
            //					update.setWriteMode(true);
318
            //
319
            //					SeRow row = update.getRowToSet();
320
            //
321
            //					// Set values on rows here.....
322
            //					for (int i = 0; i < cols.length; i++) {
323
            //						Object value = feature
324
            //								.getAttribute(this.mutableAttributeIndexes[i]
325
            //										.intValue());
326
            //						setRowValue(row, i, value);
327
            //					}
328
            //
329
            //					update.execute();
330
            //					update.close();
331
            //
332
            //				}
333
        } catch (Exception e) {
334
            //				LOGGER.log(Level.WARNING, e.getMessage(), e);
335
            //				if (LOGGER.isLoggable(Level.FINE)) {
336
            //					e.printStackTrace();
337
            //				}
338
            //				throw new DataSourceException(e.getMessage(), e);
339
        } finally {
340
            try {
341
                conex.close();
342
            } catch (SeException e) {
343
                // TODO Auto-generated catch block
344
                e.printStackTrace();
345
            }
346
        }
347
    }
255 348

  
256
					SeRow row = insert.getRowToSet();
349
    /**
350
     * Used to set a value on an SeRow object. The values is converted to the
351
     * appropriate type based on an inspection of the SeColumnDefintion
352
     * object.
353
     *
354
     * @param row
355
     * @param index
356
     * @param value
357
     *
358
     * @throws SeException DOCUMENT ME!
359
     * @throws IOException DOCUMENT ME!
360
     */
361
    private void setRowValue(SeRow row, int index, Object value)
362
        throws SeException, IOException {
363
        SeColumnDefinition seColumnDefinition = null;
364
        seColumnDefinition = row.getColumnDef(index);
257 365

  
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
					}
366
        switch (seColumnDefinition.getType()) {
367
        case SeColumnDefinition.TYPE_INTEGER: {
368
            if (value != null) {
369
                row.setInteger(index, new Integer(value.toString()));
370
            } else {
371
                row.setInteger(index, null);
372
            }
266 373

  
267
					// Now "commit" the changes.
268
					insert.execute();
269
					insert.close();
270
					//this.dataStore.fireAdded(feature);
271
				//}
374
            break;
375
        }
272 376

  
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) {
377
        case SeColumnDefinition.TYPE_SMALLINT: {
378
            if (value != null) {
379
                row.setShort(index, new Short(value.toString()));
380
            } else {
381
                row.setShort(index, null);
382
            }
300 383

  
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
	    }
384
            break;
385
        }
315 386

  
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);
387
        case SeColumnDefinition.TYPE_FLOAT: {
388
            if (value != null) {
389
                row.setFloat(index, new Float(value.toString()));
390
            } else {
391
                row.setFloat(index, null);
392
            }
333 393

  
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
				}
394
            break;
395
        }
341 396

  
342
				break;
343
			}
397
        case SeColumnDefinition.TYPE_DOUBLE: {
398
            if (value != null) {
399
                row.setDouble(index, new Double(value.toString()));
400
            } else {
401
                row.setDouble(index, null);
402
            }
344 403

  
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
				}
404
            break;
405
        }
351 406

  
352
				break;
353
			}
407
        case SeColumnDefinition.TYPE_STRING: {
408
            if (value != null) {
409
                row.setString(index, value.toString());
410
            } else {
411
                row.setString(index, null);
412
            }
354 413

  
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
				}
414
            break;
415
        }
361 416

  
362
				break;
363
			}
417
        case SeColumnDefinition.TYPE_DATE: {
418
            if (value != null) {
419
                Calendar calendar = Calendar.getInstance();
420
                calendar.setTime((Date) value);
421
                row.setTime(index, calendar);
422
            } else {
423
                row.setTime(index, null);
424
            }
364 425

  
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
				}
426
            break;
427
        }
371 428

  
372
				break;
373
			}
429
        case SeColumnDefinition.TYPE_SHAPE: {
430
            if (value != null) {
431
                try {
432
                    SeCoordinateReference coordRef = selayer.getCoordRef();
433
                    IGeometry geom = (IGeometry) value;
434
                    SeShape shape = ArcSdeFeatureIterator.constructShape(geom,
435
                            coordRef);
436
                    row.setShape(index, shape);
437
                } catch (Exception e) {
438
                    e.printStackTrace();
439
                }
440
            } else {
441
                row.setShape(index, null);
442
            }
374 443

  
375
			case SeColumnDefinition.TYPE_STRING: {
376
				if (value != null) {
377
					row.setString(index, value.toString());
378
				} else {
379
					row.setString(index, null);
380
				}
444
            break;
445
        }
446
        }
447
    }
381 448

  
382
				break;
383
			}
449
    /**
450
     * DOCUMENT ME!
451
     *
452
     * @throws EditionException DOCUMENT ME!
453
     */
454
    public void postProcess() throws EditionException {
455
        try {
456
            conex.commitTransaction();
457
        } catch (SeException e) {
458
            e.printStackTrace();
459
            throw new EditionException(e);
460
        }
461
    }
384 462

  
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
				}
463
    /**
464
     * DOCUMENT ME!
465
     *
466
     * @return DOCUMENT ME!
467
     */
468
    public String getName() {
469
        return "gvSIG SDE Writer";
470
    }
393 471

  
394
				break;
395
			}
472
    /**
473
     * DOCUMENT ME!
474
     *
475
     * @param gvSIGgeometryType DOCUMENT ME!
476
     *
477
     * @return DOCUMENT ME!
478
     */
479
    public boolean canWriteGeometry(int gvSIGgeometryType) {
480
        switch (gvSIGgeometryType) {
481
        case FShape.POINT:
482
            return true;
396 483

  
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
				}
484
        case FShape.LINE:
485
            return true;
411 486

  
412
				break;
413
			}
414
			}
415
		}
487
        case FShape.POLYGON:
488
            return true;
416 489

  
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
	}
490
        case FShape.ARC:
491
            return false;
425 492

  
426
	public String getName() {
427
		return "gvSIG SDE Writer";
428
	}
493
        case FShape.ELLIPSE:
494
            return false;
429 495

  
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
	}
496
        case FShape.MULTIPOINT:
497
            return true;
449 498

  
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;
499
        case FShape.TEXT:
500
            return false;
501
        }
466 502

  
467
		}
503
        return false;
504
    }
468 505

  
469
		return false;
470
	}
506
    /**
507
     * DOCUMENT ME!
508
     *
509
     * @param sqlType DOCUMENT ME!
510
     *
511
     * @return DOCUMENT ME!
512
     */
513
    public boolean canWriteAttribute(int sqlType) {
514
        switch (sqlType) {
515
        case Types.DOUBLE:
516
        case Types.FLOAT:
517
        case Types.INTEGER:
518
        case Types.BIGINT:
519
            return true;
471 520

  
472
	/**
473
	 * @return Returns the bCreateTable.
474
	 */
475
	public boolean isCreateTable() {
476
		return bCreateTable;
477
	}
521
        case Types.DATE:
522
            return true;
478 523

  
479
	/**
480
	 * @param createTable
481
	 *            The bCreateTable to set.
482
	 */
483
	public void setCreateTable(boolean createTable) {
484
		bCreateTable = createTable;
485
	}
524
        case Types.BIT:
525
        case Types.BOOLEAN:
526
            return true;
486 527

  
487
	public FieldDescription[] getOriginalFields() {
488
		return lyrDef.getFieldsDesc();
489
	}
528
        case Types.VARCHAR:
529
        case Types.CHAR:
530
        case Types.LONGVARCHAR:
531
            return true;
532
        }
490 533

  
491
	public void addField(FieldDescription fieldDesc) {
492
//		fieldManager.addField(fieldDesc);
534
        return false;
535
    }
493 536

  
494
	}
537
    /**
538
     * DOCUMENT ME!
539
     *
540
     * @return Returns the bCreateTable.
541
     */
542
    public boolean isCreateTable() {
543
        return bCreateTable;
544
    }
495 545

  
496
	public FieldDescription removeField(String fieldName) {
497
//		return fieldManager.removeField(fieldName);
498
		return null;
499
	}
546
    /**
547
     * DOCUMENT ME!
548
     *
549
     * @param createTable The bCreateTable to set.
550
     */
551
    public void setCreateTable(boolean createTable) {
552
        bCreateTable = createTable;
553
    }
500 554

  
501
	public void renameField(String antName, String newName) {
502
//		fieldManager.renameField(antName, newName);
555
    /**
556
     * DOCUMENT ME!
557
     *
558
     * @return DOCUMENT ME!
559
     */
560
    public FieldDescription[] getOriginalFields() {
561
        return lyrDef.getFieldsDesc();
562
    }
503 563

  
504
	}
564
    /**
565
     * DOCUMENT ME!
566
     *
567
     * @param fieldDesc DOCUMENT ME!
568
     */
569
    public void addField(FieldDescription fieldDesc) {
570
        //		fieldManager.addField(fieldDesc);
571
    }
505 572

  
506
	public boolean alterTable() throws EditionException {
507
//		return fieldManager.alterTable();
508
		return false;
509
	}
573
    /**
574
     * DOCUMENT ME!
575
     *
576
     * @param fieldName DOCUMENT ME!
577
     *
578
     * @return DOCUMENT ME!
579
     */
580
    public FieldDescription removeField(String fieldName) {
581
        //		return fieldManager.removeField(fieldName);
582
        return null;
583
    }
510 584

  
511
	public FieldDescription[] getFields() {
512
//		return fieldManager.getFields();
513
		return lyrDef.getFieldsDesc();
514
	}
585
    /**
586
     * DOCUMENT ME!
587
     *
588
     * @param antName DOCUMENT ME!
589
     * @param newName DOCUMENT ME!
590
     */
591
    public void renameField(String antName, String newName) {
592
        //		fieldManager.renameField(antName, newName);
593
    }
515 594

  
516
	public boolean canAlterTable() {
517
		return true;
518
	}
595
    /**
596
     * DOCUMENT ME!
597
     *
598
     * @return DOCUMENT ME!
599
     *
600
     * @throws EditionException DOCUMENT ME!
601
     */
602
    public boolean alterTable() throws EditionException {
603
        //		return fieldManager.alterTable();
604
        return false;
605
    }
519 606

  
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
	}
607
    /**
608
     * DOCUMENT ME!
609
     *
610
     * @return DOCUMENT ME!
611
     */
612
    public FieldDescription[] getFields() {
613
        //		return fieldManager.getFields();
614
        return lyrDef.getFieldsDesc();
615
    }
530 616

  
531
	public void setDriver(ArcSdeDriver driver) {
532
		this.driver=driver;
617
    /**
618
     * DOCUMENT ME!
619
     *
620
     * @return DOCUMENT ME!
621
     */
622
    public boolean canAlterTable() {
623
        return true;
624
    }
533 625

  
534
	}
626
    /**
627
     * DOCUMENT ME!
628
     *
629
     * @return DOCUMENT ME!
630
     */
631
    public boolean canSaveEdits() {
632
        //		try {
633
        //			return !conex.isReadOnly();
634
        //		} catch (SQLException e) {
635
        //			// TODO Auto-generated catch block
636
        //			e.printStackTrace();
637
        //			return false;
638
        //		}
639
        return false;
640
    }
535 641

  
536
	public void setSeLayer(SeLayer layer) {
537
		this.selayer=layer;
538
	}
642
    /**
643
     * DOCUMENT ME!
644
     *
645
     * @param driver DOCUMENT ME!
646
     */
647
    public void setDriver(ArcSdeDriver driver) {
648
        this.driver = driver;
649
    }
539 650

  
651
    /**
652
     * DOCUMENT ME!
653
     *
654
     * @param layer DOCUMENT ME!
655
     */
656
    public void setSeLayer(SeLayer layer) {
657
        this.selayer = layer;
658
    }
540 659
}
branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/VectorialSDEDriver.java
42 42

  
43 43
import java.awt.geom.Rectangle2D;
44 44
import java.sql.Connection;
45
import java.sql.SQLException;
46 45

  
47
import com.hardcode.gdbms.engine.data.driver.ObjectDriver;
48 46
import com.iver.cit.gvsig.fmap.DriverException;
47
import com.iver.cit.gvsig.fmap.core.IFeature;
49 48
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition;
50 49
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator;
51 50
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver;
51
import com.iver.cit.gvsig.fmap.layers.XMLException;
52
import com.iver.utiles.XMLEntity;
52 53

  
53
public interface VectorialSDEDriver extends  VectorialDatabaseDriver{
54

  
55
/**
56
 * DOCUMENT ME!
57
 *
58
 * @author Vicente Caballero Navarro
59
 */
60
public interface VectorialSDEDriver extends VectorialDatabaseDriver {
54 61
    /**
62
     * DOCUMENT ME!
63
     *
55 64
     * @param conn
56 65
     * @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 66
     */
60 67
    public void setData(Connection conn, DBLayerDefinition lyrDef);
68

  
61 69
    //public Connection getConnection();
62
    public IFeatureIterator getFeatureIterator(String sql) throws DriverException;
63
	//public String getConnectionStringBeginning();
70
    public IFeatureIterator getFeatureIterator(String sql)
71
        throws DriverException;
72

  
73
    //public String getConnectionStringBeginning();
64 74
    public void open() throws com.iver.cit.gvsig.fmap.DriverException;
75

  
76
    /**
77
     * DOCUMENT ME!
78
     *
79
     * @return DOCUMENT ME!
80
     */
65 81
    public int getDefaultPort();
82

  
83
    /**
84
     * DOCUMENT ME!
85
     *
86
     * @param rect DOCUMENT ME!
87
     */
66 88
    public void setWorkingArea(Rectangle2D rect);
89

  
67 90
    /**
91
     * DOCUMENT ME!
92
     *
68 93
     * @return
69 94
     */
70 95
    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);
96

  
97
    /**
98
     * DOCUMENT ME!
99
     *
100
     * @param _host DOCUMENT ME!
101
     * @param _port DOCUMENT ME!
102
     * @param _db DOCUMENT ME!
103
     * @param _user DOCUMENT ME!
104
     * @param _pw DOCUMENT ME!
105
     *
106
     * @return DOCUMENT ME!
107
     */
108
    public String getConnectionString(String _host, String _port, String _db,
109
        String _user, String _pw);
110

  
111
	public String getTableName();
112

  
113
	public XMLEntity getXMLEntity();
114

  
115
	public void setXMLEntity(XMLEntity entity) throws XMLException;
116

  
117
	public void close();
118

  
119
	public int getRowIndexByFID(IFeature feat);
120

  
121
	public DBLayerDefinition getLyrDef();
122

  
123
	public String getWhereClause();
124

  
125
	public String[] getFields();
126

  
127
	public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG, String[] alphaNumericFieldsNeeded) throws DriverException;
128

  
129
	public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG) throws DriverException;
130

  
131
    //	public String[] getTableNames(Object conex, String dbName) throws SQLException;
132
    //	public String[] getAllFields(Object conn, String tableName);
133
    //	public String[] getAllFieldTypeNames(Object conn, String tableName);
134
    //	public String[] getIdFieldsCandidates(Object conn, String tableName);
135
    //	public String[] getGeometryFieldsCandidates(Object conn, String tableName);
77 136
}
branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/ArcSdeFeatureIterator.java
46 46
import java.awt.geom.PathIterator;
47 47
import java.sql.SQLException;
48 48
import java.util.ArrayList;
49
import java.util.List;
50 49

  
51 50
import com.esri.sde.sdk.client.SDEPoint;
52 51
import com.esri.sde.sdk.client.SeColumnDefinition;
branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/testSDE.java
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     = "192.168.0.114";
65
        int instance      = 5151;
66
        String database   = "ProvinciasPruebas";
67
        String user       = "sde";
68
        String password   = "iver";
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 81
            conn = new SeConnection(server, instance, database, user, password);
71
        }catch (SeException e) {
82
        } catch (SeException e) {
72 83
            e.printStackTrace();
84

  
73 85
            return;
74 86
        }
75 87

  
76 88
        // Fetching data
77

  
78 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().equals(layerName)){
95

  
96
            for (int i = 0; i < theLayers.size(); i++) {
97
                SeLayer layer = (SeLayer) theLayers.elementAt(i);
98

  
99
                if (layer.getName().equals(layerName)) {
87 100
                    layerID = layer.getID();
88 101
                    strSpatialColumn = layer.getSpatialColumn();
89 102
                    System.err.println("Nombre de la capa= " + layer.getName());
90
                    for (int k=0;k<layerID.longValue();k++){
91
                    	layer.getAccess();
92
                    	layer.getQualifiedName();
93
                    	layer.getArraySize();
94
                    	layer.getDescription();
95
                    	layer.getInfo();
96
                    	layer.getShapeTypes();
97
//                    	try{
98
                    		System.err.println("Nombre campo= " + layerID.longValue());
99
//                    	} catch( SeException e ) {
100
//                    		//System.out.println(e.getSeError().getErrDesc());
101
//                    	}
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
                        //                    	}
102 119
                    }
103 120
                }
104 121
            }
105
            if (layerID == null)
106
            {
122

  
123
            if (layerID == null) {
107 124
                System.err.println("Capa no encontrada");
125

  
108 126
                return;
109 127
            }
110 128

  
111
            SeLayer layer = new SeLayer( conn, layerName, strSpatialColumn );
112
            SeSqlConstruct sqlConstruct = new SeSqlConstruct( layerName);
129
            SeLayer layer = new SeLayer(conn, layerName, strSpatialColumn);
130
            SeSqlConstruct sqlConstruct = new SeSqlConstruct(layerName);
113 131
            long t1 = System.currentTimeMillis();
114
    //      Create a query stream between the client and server
132

  
133
            //      Create a query stream between the client and server
115 134
            String[] cols = new String[2];
116 135
            cols[0] = new String("FID");
117 136
            cols[1] = layer.getSpatialColumn();
118
            SeQuery query = new SeQuery( conn, cols, sqlConstruct );
137

  
138
            SeQuery query = new SeQuery(conn, cols, sqlConstruct);
119 139
            query.prepareQuery();
120 140
            query.execute();
141

  
121 142
            long t2 = System.currentTimeMillis();
122 143

  
123
            System.out.println("Tiempo de consulta:" + (t2 - t1) + " milisegundos");
144
            System.out.println("Tiempo de consulta:" + (t2 - t1) +
145
                " milisegundos");
124 146
            t1 = System.currentTimeMillis();
147

  
125 148
            int cont = 0;
126 149
            SeRow row = query.fetch();
127
            if( row == null ) {
128 150

  
151
            if (row == null) {
129 152
                System.out.println(" No rows fetched");
153

  
130 154
                return;
131 155
            }
156

  
132 157
            // String rowID = "2";
133

  
134 158
            // Get the definitions of all the columns retrieved
135 159
            SeColumnDefinition[] colDefs = row.getColumns();
136
            while (row != null)
137
            {
160

  
161
            while (row != null) {
138 162
                evaluateRow(row, colDefs);
139 163
                row = query.fetch();
140 164
                cont++;
141 165
            }
166

  
142 167
            // Close the query.
143

  
144 168
            query.close();
145 169
            t2 = System.currentTimeMillis();
146 170

  
147
            System.out.println("Tiempo de recorrido:"  + (t2 - t1) + " milisegundos. " + cont + " registros.");
171
            System.out.println("Tiempo de recorrido:" + (t2 - t1) +
172
                " milisegundos. " + cont + " registros.");
148 173

  
149 174
            /* SeQuery extentQuery = new SeQuery( conn, cols, sqlConstruct );
150 175
            SeQueryInfo queryInfo = new SeQueryInfo();
......
172 197
            // queryAux.close();
173 198
            t2 = System.currentTimeMillis();
174 199
            System.out.println("Tiempo de recorrido:"  + (t2 - t1) + " milisegundos. "); */
175

  
176 200
            /* queryAux = new SeQuery( conn, cols, sqlConstruct );
177 201
            SeObjectId rowID = new SeObjectId(1);
178 202
            row = queryAux.fetchRow("provin", rowID, cols);
......
181 205
            evaluateRow(row, colDefs);
182 206

  
183 207
            queryAux.close(); */
184

  
185
        } catch( SeException e ) {
208
        } catch (SeException e) {
186 209
            System.out.println(e.getSeError().getErrDesc());
187 210
        }
188

  
189

  
190 211
    }
191 212

  
192
    static GeneralPathX convertSeShapeToGeneralPathX(SeShape spVal) throws SeException
193
    {
213
    static GeneralPathX convertSeShapeToGeneralPathX(SeShape spVal)
214
        throws SeException {
194 215
        double[][][] points = spVal.getAllCoords();
195 216
        GeneralPathX gpx = new GeneralPathX();
217

  
196 218
        // Display the X and Y values
197 219
        boolean bStartPart;
198
        for( int partNo = 0 ; partNo < points.length ; partNo++)
199
        {
220

  
221
        for (int partNo = 0; partNo < points.length; partNo++) {
200 222
            bStartPart = true;
201
            for( int subPartNo = 0 ; subPartNo < points[partNo].length ; subPartNo++)
202
                for( int pointNo = 0 ; pointNo < points[partNo][subPartNo].length ; pointNo+=2)
203
                {
204
                    if (bStartPart)
205
                    {
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) {
206 230
                        bStartPart = false;
207 231
                        gpx.moveTo(points[partNo][subPartNo][pointNo],
208
                                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)]);
209 236
                    }
210
                    else
211
                        gpx.lineTo(points[partNo][subPartNo][pointNo],
212
                                points[partNo][subPartNo][(pointNo+1)]);
213

  
214 237
                }
215 238
        }
239

  
216 240
        return gpx;
217 241
    }
218
    static void evaluateRow(SeRow row, SeColumnDefinition[] colDefs)
219
    {
220
        try
221
        {
222
            for (int colNum = 0; colNum < colDefs.length; colNum++)
223
            {
242

  
243
    static void evaluateRow(SeRow row, SeColumnDefinition[] colDefs) {
244
        try {
245
            for (int colNum = 0; colNum < colDefs.length; colNum++) {
224 246
                SeColumnDefinition colDef = colDefs[colNum];
225 247
                int dataType = colDef.getType();
226
                if ( row.getIndicator((short)colNum) != SeRow.SE_IS_NULL_VALUE)
227
                {
228
                    switch( dataType )
229
                    {
230
                        case SeColumnDefinition.TYPE_SMALLINT:
231
                            break;
232 248

  
233
                        case SeColumnDefinition.TYPE_DATE:
234
                            break;
249
                if (row.getIndicator((short) colNum) != SeRow.SE_IS_NULL_VALUE) {
250
                    switch (dataType) {
251
                    case SeColumnDefinition.TYPE_SMALLINT:
252
                        break;
235 253

  
236
                        case SeColumnDefinition.TYPE_INTEGER:
237
                            break;
254
                    case SeColumnDefinition.TYPE_DATE:
255
                        break;
238 256

  
239
                        case SeColumnDefinition.TYPE_FLOAT:
240
                            break;
257
                    case SeColumnDefinition.TYPE_INTEGER:
258
                        break;
241 259

  
242
                        case SeColumnDefinition.TYPE_DOUBLE:
243
                            break;
260
                    case SeColumnDefinition.TYPE_FLOAT:
261
                        break;
244 262

  
245
                        case SeColumnDefinition.TYPE_STRING:
246
                            // System.out.println(row.getString(colNum));
247
                            break;
263
                    case SeColumnDefinition.TYPE_DOUBLE:
264
                        break;
248 265

  
249
                        case SeColumnDefinition.TYPE_SHAPE:
250
                            SeShape spVal = row.getShape(colNum);
251
                            convertSeShapeToGeneralPathX(spVal);
266
                    case SeColumnDefinition.TYPE_STRING:
252 267

  
253
                            // GeneralPath gp = spVal.toGeneralPath();
254
                            // GeneralPathX gpx = new GeneralPathX(gp);
255
                            // System.out.println("spVal.FID = " + spVal.getFeatureId().longValue());
256
                            // getShapeDetails(spVal);
257
                            break;
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);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff