Revision 21148

View differences:

trunk/extensions/extArcims/src/es/prodevelop/cit/gvsig/arcims/fmap/drivers/ArcImsInMemoryAttsTableDriver.java
279 279
        return ((Integer) idToIndex.get(new Integer(id))).intValue();
280 280
    }
281 281

  
282
    //	public int getRowId(DataSourceFactory dsf, int row) throws DriverException {
283
    //		/*
284
    //		 SELECT * FROM Customers WHERE LastName = 'Smith'
285
    //		 */
286
    //		String sqlStr = "select " + idFieldName + " from " + tableName + " where ";
287
    //		sqlStr = sqlStr + rowIndexFieldName + " = ";
288
    //		sqlStr = sqlStr + row + ";";
289
    //		/*
290
    //		* INSERT INTO Table1 (Column1, Column2, Column3?)
291
    //		* VALUES (Value1, Value2, Value3?)
292
    //		*/
293
    //		DataSource ds = null;
294
    //		try {
295
    //			
296
    //			ds = dsf.executeSQL(sqlStr, DataSourceFactory.AUTOMATIC_OPENING);
297
    //			// int respind = ds.getFieldIndexByName(idFieldName);
298
    //			IntValue resp = (IntValue) ds.getFieldValue(0, 0);
299
    //			return resp.intValue();
300
    //		} catch (Exception e) {
301
    //			DriverException de = new DriverException(e.getMessage());
302
    //			throw de;
303
    //		}
304
    //	}
305
    //	
306
    //	public int getRowIndex(DataSourceFactory dsf, int id) throws DriverException {
307
    //		String sqlStr = "select " + rowIndexFieldName + " from " + tableName + " where ";
308
    //		sqlStr = sqlStr + idFieldName + " = ";
309
    //		sqlStr = sqlStr + id + ";";
310
    //		/*
311
    //		* INSERT INTO Table1 (Column1, Column2, Column3?)
312
    //		* VALUES (Value1, Value2, Value3?)
313
    //		*/
314
    //		DataSource ds = null;
315
    //		try {
316
    //			ds = dsf.executeSQL(sqlStr, DataSourceFactory.AUTOMATIC_OPENING);
317
    //
318
    //			System.err.println("getRowIndex of id = " + id);
319
    //			System.err.println(ds.getAsString());
320
    //			System.err.println("------------------------------");
321
    //			// int respind = ds.getFieldIndexByName(idFieldName);
322
    //			IntValue resp = (IntValue) ds.getFieldValue(0, 0);
323
    //			return resp.intValue();
324
    //		} catch (Exception e) {
325
    //			DriverException de = new DriverException(e.getMessage());
326
    //			throw de;
327
    //		}
328
    //	}
282

  
329 283
    public boolean isNonRequestedRow(int rowind) {
330 284
        // TODO Auto-generated method stub
331 285
        return (!requested.get(rowind));
332 286
    }
333 287

  
334
    // public void updateRow(DataSourceFactory dsf, Value[] new_row, String[] fld_q) throws DriverException {
335 288
    // TODO so far, this method is called with
336 289
    // a full field query (except rowindex)
337 290
    public void updateRow(Value[] upd_row, String[] fld_q, int rowind)
......
378 331
            }
379 332
        }
380 333

  
381
        //		data.set()
382
        //		String[] fld_query = null;
383
        //		if (fld_q[0].compareTo("#ALL#") == 0) {
384
        //			
385
        //			int count = getFieldCount() - 1;
386
        //			fld_query = new String[count];
387
        //			for (int i=0; i<count; i++) {
388
        //				fld_query[i] = getFieldName(i);
389
        //			}
390
        //			
391
        //			
392
        //		} else {
393
        //			fld_query = new String[fld_q.length];
394
        //			for (int i=0; i<fld_q.length; i++) {
395
        //				fld_query[i] = ArcImsSqlUtils.getSqlCompliantFieldName(fld_q[i]);
396
        //			}
397
        //		}
398
        //		
399
        //		IntValue id = null;
400
        //		for (int i=0; i<fld_query.length; i++) {
401
        //			if (fld_query[i].compareTo(idFieldName) == 0) {
402
        //				id = (IntValue) new_row[i];
403
        //			}
404
        //		}
405
        //		if (id == null) {
406
        //			DriverException de = new DriverException("id_not_found");
407
        //			throw de;
408
        //		}
409
        //		int intid = id.intValue();
410
        //		
411
        //		String sqlStr = "update " + tableName + " set ";
412
        //		String nthFieldName, nthFieldValue;
413
        //		for (int i=0; i<fld_query.length; i++) {
414
        //			nthFieldName = fld_query[i];
415
        //			nthFieldValue = this.getValueInSqlFormat(new_row[i]);
416
        //			sqlStr = sqlStr + nthFieldName + " = ";
417
        //			sqlStr = sqlStr + nthFieldValue + ", ";
418
        //		}
419
        //		sqlStr = sqlStr.substring(0, sqlStr.length() - 2);
420
        //		sqlStr = sqlStr + " where " + idFieldName + " = " + intid + ";";
421
        //		try {
422
        //			// dsf.executeSQL(sqlStr, DataSourceFactory.AUTOMATIC_OPENING);
423
        //			execute(sqlStr);
424
        //		} catch (Exception e) {
425
        //			DriverException de = new DriverException(e.getMessage());
426
        //			throw de;
427
        //		}
428 334
    }
429 335

  
430 336
    public int getFieldIndexByName(String arg0) throws DriverException {
......
450 356
        throws DriverException {
451 357
        return (Value[]) data.get(n);
452 358

  
453
        //		String sqlStr = "select * from " + tableName + " where ";
454
        //		sqlStr = sqlStr + rowIndexFieldName + " = " + n + ";";
455
        //
456
        //		try {
457
        //			DataSource ds =
458
        //				dsf.executeSQL(sqlStr, DataSourceFactory.AUTOMATIC_OPENING);
459
        //			// int respind = ds.getFieldIndexByName(idFieldName);
460
        //			int count = ds.getFieldCount();
461
        //			Value[] resp = new Value[count];
462
        //			for (int i=0; i<count; i++) {
463
        //				resp[i] = ds.getFieldValue(0, i);
464
        //			}
465
        //			return resp;
466
        //		} catch (Exception e) {
467
        //			DriverException de = new DriverException(e.getMessage());
468
        //			throw de;
469
        //		}
470 359
    }
471 360

  
472
    //	public String getRowIndexFieldName() {
473
    //		return rowIndexFieldName;
474
    //	}
475 361
    public void setRequested(int n, boolean req) {
476 362
        requested.set(n, req);
477 363
    }
......
496 382
        return ((Integer) columnTypes.get(i)).intValue();
497 383
    }
498 384

  
499
    //	public void addInIndexToIdHashMap(int rwcount, int i) {
500
    //		indexToId.put(new Integer(rwcount), new Integer (i));
501
    //	}
502 385
    public void addInIdToIndexHashMap(int i, int rwcount) {
503 386
        idToIndex.put(new Integer(i), new Integer(rwcount));
504 387
    }
505 388

  
506
    //	public String getColumnName(int i) {
507
    //		return (String) columnNames.get(i);
508
    //	}
509

  
510
    //	public void increaseRowCount(boolean req) {
511
    //		requested.set(data.size(), req);
512
    //		theRowCount++;
513
    //	}
514 389
    public void addAsRequested(FBitSet fbs) {
515 390
        requested.or(fbs);
516 391
    }
......
598 473
            lastRequest.width + " ]");
599 474
    }
600 475

  
601
    //	public Value getCachedValue(int row, int attind) {
602
    //		return attsCache.getAttribute(row, attind);
603
    //	}
604
    //	
605
    //	public void setCachedValue(int row, int attind, Value v) {
606
    //		attsCache.addToCache(row, attind, v);
607
    //	}
608 476
    public int getIdColumnInd(ArrayList col_Types) {
609 477
        int coltype;
610 478
        int idindex = -1;
trunk/extensions/extArcims/src/es/prodevelop/cit/gvsig/arcims/fmap/drivers/ArcImsAttributesDataSourceAdapter.java
159 159

  
160 160
            logger.info("Stored " + ids.length + " IDs");
161 161
            setRowsPerRequest();
162

  
163
            // String idcolname = dataDriver.executeCreateTableWithFieldsAndTypes(tableName, col_Names, col_Types);
164
            // dataDriver.executeSetEmptyRowsWithIds(tableName, ids, idcolname);
165
            // System.err.println("dataDriver.getFieldValue(0, 0) = " + dataDriver.getFieldValue(0, 0).getStringValue(dataDriver.internalValueWriter));
166
            // getRowId(5);
167
            // stop();
168
            // logger.debug("Done: dataDriver.close();");
169 162
        }
170 163
        catch (Exception e) {
171 164
            logger.error("While creating in-memory database ", e);
......
176 169
        // DriverException de = new DriverException("cannot_delete");
177 170
        logger.warn("So far, you cannot delete ");
178 171

  
179
        // throw de;
180
        //		// dataDriver.setRequested((int) rowInd, false);
181
        //		start();
182
        //		dataDriver.deleteRow(dsFactory, (int) rowInd);
183
        //		stop();
184
        //		// dataDriver.deleteRow(dsFactory, (int) rowInd);
185 172
    }
186 173

  
187 174
    public void insertFilledRowAt(long index, Value[] values)
......
219 206
    }
220 207

  
221 208
    public void start() throws ReadDriverException {
222
        //		try {
223
        //			// dataDriver.open("");
224
        //			dataDriver.open("select * from " + tableName);
225
        //		} catch (SQLException e) {
226
        //			DriverException de = new DriverException(e.getMessage());
227
        //			logger.error("While starting datasource ", e);
228
        //			throw de;
229
        //		}
230
        //		// logger.debug("start()");
231
        //		// dataDriver.open("");
232 209
    }
233 210

  
234 211
    public void stop() throws ReadDriverException {
235
        //		try {
236
        //			dataDriver.close();
237
        //		} catch (SQLException e) {
238
        //			DriverException de = new DriverException(e.getMessage());
239
        //			throw de;
240
        //		}
241 212
    }
242 213

  
243 214
    public String getName() {
trunk/extensions/extArcims/src/es/prodevelop/cit/gvsig/arcims/fmap/drivers/FMapFeatureArcImsDriver.java
276 276
        osi.name = attsDataSourceAdapter.getTableName();
277 277
        osi.driverName = "ArcImsAttributesDataSourceAdapter";
278 278

  
279
        //		String tablename = attsDataSourceAdapter.getTableName();
280
        //		String sqlstr = "select * from " + tablename + " where " + ArcImsSqlUtils.rowIndexFieldName + " = 8;";
281
        //		DataSource result = null;
282
        //		int n = -1;
283 279
        try {
284
            //			attsDataSourceAdapter.start();
285
            //			result = dataSourceFactory.executeSQL(sqlstr, DataSourceFactory.AUTOMATIC_OPENING);
286
            //			attsDataSourceAdapter.stop();
287
            //			
288
            //			n = (int) result.getRowCount();
289 280
            dataSource = new SelectableDataSource(attsDataSourceAdapter);
290 281
        }
291 282
        catch (ReadDriverException e) {
......
367 358
            logger.error("While loading selectable data source");
368 359
        }
369 360

  
370
        //		try {
371
        //			dataSource = new SelectableDataSource(attsDataSourceAdapter);
372
        //			View v = PluginServices.getMDIManager().getActiveView();
373
        //			
374
        //			if (v == null) {
375
        //				ProjectView newprojview = ProjectView.createView("Nueva");
376
        //				com.iver.cit.gvsig.gui.View newview = new com.iver.cit.gvsig.gui.View();
377
        //				newview.setModel(newprojview);
378
        //				Project newproj = new Project();
379
        //				newproj.setName("nuevo");
380
        //				newproj.addView(newprojview);
381
        //				v = newview;
382
        //			}
383
        //			ProjectView pv = ((com.iver.cit.gvsig.gui.View) v).getModel();
384
        //			ProjectTable pt = ProjectTable.createTable(attsDataSourceAdapter.getName(), dataSource);
385
        //			pv.getProject().addTable(pt);
386
        //		} catch (Exception e) {
387
        //			logger.error("While creating DataSource ", e);
388
        //			e.printStackTrace();
389
        //		}
390 361
    }
391 362

  
392 363
    private Value[] getAsValueArray(ArrayList ids) {
......
466 437
                added_row_ind = attsDataSourceAdapter.getRowIndex(id.getValue());
467 438

  
468 439
                addPseudoGeometry(ifeat.getGeometry(), added_row_ind);
469

  
470
                //				Value[] newrow = new Value[n_of_fields];
471
                //				for (int j = 0; j < n_of_fields; j++)
472
                //					newrow[j] = ifeat.getAttribute(j); 
473
                //				// System.err.println("Updating row with id = " + ((IntValue) newrow[1]).getValue());
474
                //				attsDataSourceAdapter..getRowIndex()
475
                //				added_row_ind = attsDataSourceAdapter.updateRow(newrow, f_query);
476

  
477
                // logger.debug("Added pair:  Visible: " + i + ", Overall: " + added_row_ind);
478 440
                overallIndexToVisibleIndex.put(new Integer(added_row_ind),
479 441
                    new Integer(i));
480 442
                visibleIndexToOverallIndex.put(new Integer(i),
......
494 456
        return "";
495 457
    }
496 458

  
497
    //	public ArrayList getGeometries() {
498
    //		if (geometries == null) {
499
    //			// geometris = client.get.....
500
    //			setTestGeometries();
501
    //		}
502
    //		return geometries;
503
    //	}
504
    //	
505 459
    public boolean connect(ICancellable cancel) {
506 460
        return client.connect(false, cancel);
507

  
508
        //		File csvFile = null;
509
        //		// This method is in libArcIMS
510
        //		// csvFile = client....connect(); (por ejemplo)
511
        //		
512
        //		JFileChooser jfc = new JFileChooser();
513
        //		jfc.setDialogTitle("Indice archivo CSV con los atributos de las geometrias");
514
        //	    int returnVal = jfc.showOpenDialog(null);
515
        //	    if (returnVal != JFileChooser.APPROVE_OPTION) {
516
        //	    	return false;
517
        //	    }
518
        //	    csvFile = jfc.getSelectedFile();
519
        //		if (! jfc.accept(csvFile)) return false;
520
        //		
521
        //		// csv = 
522
        //		// .....
523
        //		dataSource = getRecordSet(csvFile);
524
        //		// return client.connect();
525
        //		return true;
526 461
    }
527 462

  
528 463
    /**
......
532 467
     */
533 468
    public TreeMap getLayers() {
534 469
        return null;
535

  
536 470
        // This method is in libArcIMS
537 471
        // return client.getLayers();
538 472
    }
......
712 646
            return;
713 647
        }
714 648

  
715
        int[] ids = new int[length];
716 649
        int[] rowinds = new int[length];
717
        int idind = 0;
718 650

  
719 651
        try {
720
            for (int i = fbs.nextSetBit(0); i >= 0;
721
                    i = fbs.nextSetBit(i + 1)) {
722
                ids[idind] = attsDataSourceAdapter.getRowId(i);
723
                rowinds[idind] = i;
724
                idind++;
725
            }
652
        	int[] req_indices = enumarate(indlimits[0], indlimits[1]);
653
        	int sz = req_indices.length;
654
        	int[] req_ids = new int[sz];
655
        	for (int i=0; i<sz; i++)
656
        		req_ids[i] = attsDataSourceAdapter.getRowId(req_indices[i]);
726 657

  
727
            String minval = Integer.toString(attsDataSourceAdapter.getRowId(
728
                        indlimits[0]));
729
            String maxval = Integer.toString(attsDataSourceAdapter.getRowId(
730
                        indlimits[1]));
731

  
732 658
            int idcolindex = attsDataSourceAdapter.getIdIndex();
733 659
            String idFieldName = attsDataSourceAdapter.getOriginalFieldName(idcolindex);
734
            String whereClause = idFieldName + " &gt;= " + minval + " and " +
735
                idFieldName + " &lt;= " + maxval;
660
            String inParenthesis = getInIntParenthesis(req_ids);
661
            String whereClause = idFieldName + " " + inParenthesis;
736 662

  
737
            System.err.println("WHERE = " + whereClause);
738

  
739 663
            String[] subflds = new String[1];
740 664
            subflds[0] = "#ALL#";
741 665

  
742 666
            logger.debug("Justo antes de llamar a client.getAttributes(...)");
743 667

  
744
            // ---------------- with geometries -----------------------
745
            //			ArrayList atts = client.getAttributes(layer.getArcimsStatus(),
746
            //					subflds, whereClause, null);
747 668
            ArrayList atts = client.getAttributesWithEnvelope(layer.getArcimsStatus(),
748 669
                    subflds, whereClause, null);
670
            
671
            rowinds = getRowIndicesFromResponse(atts, idcolindex);
749 672

  
750 673
            // --------------------------------------------------------
751 674
            logger.debug("Justo despues de llamar a client.getAttributes(...)");
......
757 680
            for (int i = (atts.size() - 1); i >= 0; i--) {
758 681
                Value[] newrow = ((DefaultFeature) atts.get(i)).getAttributes();
759 682

  
760
                // Value[] newrow = (Value[]) atts.get(i);
761 683
                attsDataSourceAdapter.updateRow(newrow, subflds, rowinds[i]);
762 684
            }
763 685

  
......
785 707
        }
786 708
    }
787 709

  
788
    public void requestFeatureAttributesWithoutChecking(FBitSet fbs)
710
    private int[] enumarate(int a, int b) {
711

  
712
    	int[] resp = null;
713
    	if (a == b) {
714
    		resp = new int[1];
715
    		resp[0] = a;
716
    	} else {
717
    		
718
    		resp = new int[Math.abs(b-a+1)];
719
    		if (a < b) {
720
        		for (int i=a; i<=b; i++) resp[i-a] = i;
721
    		} else {
722
        		for (int i=b; i<=a; i++) resp[i-b] = i;
723
    		}
724
    	}
725
    	return resp;
726
    	
727
	}
728

  
729
	private int[] getRowIndicesFromResponse(ArrayList resp_list, int id_col_ind) {
730
    	
731
    	int sz = resp_list.size();
732
    	int[] resp = new int[sz];
733
    	int row_ind = 0;
734
    	for (int i=0; i<sz; i++) {
735
    		Value[] item_row = ((DefaultFeature) resp_list.get(i)).getAttributes();
736
    		IntValue idv = (IntValue) item_row[id_col_ind];
737
    		row_ind = idToRow(idv.intValue());
738
    		resp[i] = row_ind;
739
    	}
740
		return resp;
741
	}
742

  
743
	private int idToRow(int i) {
744
		try {
745
			return attsDataSourceAdapter.getRowIndex(i);
746
		} catch (DriverException e) {
747
			logger.error("While getting row index of id: " + i + " : " + e.getMessage());
748
			return 0;
749
		}
750
	}
751

  
752
	public void requestFeatureAttributesWithoutChecking(FBitSet fbs)
789 753
        throws ArcImsException {
790 754
        int length = fbs.cardinality();
791 755

  
trunk/extensions/extArcims/src/es/prodevelop/cit/gvsig/arcims/fmap/layers/FFeatureLyrArcIMSCollection.java
106 106

  
107 107
    public FFeatureLyrArcIMSCollection(MapContext fmap, FLayers parent,
108 108
        boolean willbesep) {
109
        super(fmap, parent);
109
        super();
110
        setParentLayer(parent);
111
        setMapContext(fmap);
110 112
        myFMap = fmap;
111 113
        mustBeSeparated = willbesep;
112 114
    }
113 115

  
114 116
    public FFeatureLyrArcIMSCollection() {
115
        super(null, null);
117
        // super(null, null);
118
    	super();
116 119
    }
117 120

  
118 121
    /**
......
131 134
     * @throws ConnectionException
132 135
     */
133 136
    public FFeatureLyrArcIMSCollection(Map m) throws ConnectionException {
134
        super(null, null);
137
        super();
135 138

  
136 139
        try {
137 140
            String _host = (String) m.get("host");
trunk/extensions/extArcims/src/es/prodevelop/cit/gvsig/arcims/fmap/layers/FFeatureLyrArcIMS.java
64 64
import com.iver.cit.gvsig.fmap.layers.FBitSet;
65 65
import com.iver.cit.gvsig.fmap.layers.FLyrText;
66 66
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
67
import com.iver.cit.gvsig.fmap.layers.LegendListener;
67
import com.iver.cit.gvsig.fmap.rendering.LegendListener;
68 68
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial;
69 69
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
70 70
import com.iver.cit.gvsig.fmap.layers.XMLException;
......
72 72
import com.iver.cit.gvsig.fmap.operations.Cancel;
73 73
import com.iver.cit.gvsig.fmap.rendering.ILegend;
74 74
import com.iver.cit.gvsig.fmap.rendering.IVectorLegend;
75
import com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent;
75
import com.iver.cit.gvsig.fmap.layers.LegendChangedEvent;
76 76

  
77 77
import com.iver.utiles.XMLEntity;
78 78
import com.iver.utiles.connections.ConnectionException;
trunk/extensions/extArcims/src/es/prodevelop/cit/gvsig/arcims/gui/panels/LayerScaleDrawPanel.java
196 196

  
197 197
        Graphics2D g2d = (Graphics2D) g;
198 198

  
199
        System.err.println("WIDTH = " + getWidth());
200 199
        maxScaleX = getWidth() - 20;
201 200

  
202 201
        if (getParentWidth() < parentDialogMinLimitForNormalTitle) {
trunk/extensions/extArcims/src/es/prodevelop/cit/gvsig/arcims/gui/panels/ImageServicePanel.java
112 112

  
113 113
    protected void updateWizardLayerQuery() {
114 114
        super.updateWizardLayerQuery();
115
        System.err.println("Image - updateWizardLayerQuery()");
116 115
        parentWizard.setImageFormat(getArcIMSImageFormat());
117 116
    }
118 117

  

Also available in: Unified diff