Revision 22916

View differences:

branches/v2_0_0_prep/libraries/libFMap_dataFile/src-test/org/gvsig/fmap/data/feature/joinstore/JoinStoreTest.java
35 35
import org.gvsig.fmap.data.DataManager;
36 36
import org.gvsig.fmap.data.InitializeException;
37 37
import org.gvsig.fmap.data.ReadException;
38
import org.gvsig.fmap.data.feature.AttributeDescriptor;
38 39
import org.gvsig.fmap.data.feature.FeatureCollection;
39 40
import org.gvsig.fmap.data.feature.FeatureStore;
40 41
import org.gvsig.fmap.data.feature.FeatureType;
......
101 102
		// num columnas: shp 4(3+geo) + dbg 3 = 7
102 103
		assertEquals(7, fType.size());
103 104

  
105
		//Comprobaci?n de atributos
106
		AttributeDescriptor attr;
107
		// 0 - LEVEL (Int)
108
		attr = (AttributeDescriptor) fType.get(0);
109
		assertTrue(attr.getName().equals("LEVEL"));
110
		assertEquals(AttributeDescriptor.TYPE_INT, attr.getDataType());
111

  
112
		// 1 - COLOR (Int)
113
		attr = (AttributeDescriptor) fType.get(1);
114
		assertTrue(attr.getName().equals("COLOR"));
115
		assertEquals(AttributeDescriptor.TYPE_INT, attr.getDataType());
116

  
117
		// 2 - CODIGO (Int)
118
		attr = (AttributeDescriptor) fType.get(2);
119
		assertTrue(attr.getName().equals("CODIGO"));
120
		assertEquals(AttributeDescriptor.TYPE_INT, attr.getDataType());
121

  
122
		// 3 - GEOMETRY (geom)
123
		attr = (AttributeDescriptor) fType.get(3);
124
		assertTrue(attr.getName().equals("GEOMETRY"));
125
		assertEquals(AttributeDescriptor.TYPE_GEOMETRY, attr.getDataType());
126

  
127
		// 4 - {pref}CODIGO (int)
128
		attr = (AttributeDescriptor) fType.get(4);
129
		assertTrue(attr.getName().equals(
130
				join_params.getFieldNamePrefix() + "CODIGO"));
131
		assertEquals(AttributeDescriptor.TYPE_INT, attr.getDataType());
132

  
133
		// 5 - {pref}CALLE (Str)
134
		attr = (AttributeDescriptor) fType.get(5);
135
		assertTrue(attr.getName().equals(
136
				join_params.getFieldNamePrefix() + "CALLE"));
137
		assertEquals(AttributeDescriptor.TYPE_STRING, attr.getDataType());
138

  
139
		// 6 - {pref}EC_2000 (int)
140
		attr = (AttributeDescriptor) fType.get(6);
141
		assertTrue(attr.getName().equals(
142
				join_params.getFieldNamePrefix() + "EC_2000"));
143
		assertEquals(AttributeDescriptor.TYPE_INT, attr.getDataType());
144

  
104 145
		FeatureCollection fColl = null;
105 146
		try {
106 147
			fColl = (FeatureCollection) join.getDataCollection();
......
123 164
		fColl = null;
124 165

  
125 166

  
167
		//Comprobar los coleccion de "subtipo"
168
		try {
169
			fColl = (FeatureCollection) join.getDataCollection(
170
					new String[] {"CODIGO", join_params.getFieldNamePrefix() + "CALLE" },
171
					null,
172
					null);
173
		} catch (ReadException e) {
174
			e.printStackTrace();
175
			fail();
176
		}
177

  
178
		// numero de elementos: shp 43
179
		assertEquals(43, fColl.size());
180

  
181
		assertEquals(2, fColl.getFeatureType().size());
182

  
183

  
184
		// numero de elementos: shp 43
185
		assertEquals(43, fColl.size());
186
		try {
187
			fColl.accept(new PrintlnFeaturesVisitor(fColl.getFeatureType()));
188
		} catch (BaseException e) {
189
			e.printStackTrace();
190
			fail();
191
		}
192

  
193
		fColl.dispose();
194
		fColl = null;
195

  
126 196
	}
127 197

  
128 198
}
branches/v2_0_0_prep/libraries/libFMap_dataFile/src/org/gvsig/fmap/data/feature/file/dbf/DBFFeatureCollectionBitSet.java
214 214
		return this.store.equals(store);
215 215
	}
216 216

  
217
	public FeatureType getFeatureType() {
218
		return this.featureType;
219
	}
217 220
}
branches/v2_0_0_prep/libraries/libFMap_dataFile/src/org/gvsig/fmap/data/feature/file/dbf/DBFFeatureCollection.java
265 265
		return this.store.equals(store);
266 266
	}
267 267

  
268
	public FeatureType getFeatureType() {
269
		return this.featureType;
270
	}
268 271

  
272

  
269 273
}
branches/v2_0_0_prep/libraries/libFMap_dataFile/src/org/gvsig/fmap/data/feature/file/dbf/DBFFeatureCollectionWithFeatureID.java
164 164
		return this.store.equals(store);
165 165
	}
166 166

  
167
	public FeatureType getFeatureType() {
168
		return this.featureType;
169
	}
167 170
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/MemoryFeatureCollection.java
418 418
	public boolean isFromStore(DataStore store) {
419 419
		return this.store.equals(store);
420 420
	}
421

  
422
	public FeatureType getFeatureType() {
423
		return this.featureType;
424
	}
421 425
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/FeatureCollection.java
8 8

  
9 9
	public Feature getFeature(int index) throws ReadException;
10 10

  
11
	public FeatureType getFeatureType();
12

  
11 13
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/visitor/PrintlnFeaturesVisitor.java
74 74
		System.out.println("CLASS = " + feature.getClass().toString());
75 75
		System.out.println("ATTRIBUTES = ");
76 76
		Iterator iterator=featureType.iterator();
77
		String name = null;
78
		String type = null;
79
		Object value = null;
80
		int i;
81

  
77 82
		while (iterator.hasNext()) {
78 83
			FeatureAttributeDescriptor descriptor = (FeatureAttributeDescriptor) iterator.next();
79
			int i=((AttributeDescriptor)descriptor).originalPosition();
80
			String type = descriptor.getDataType();
84
			name = descriptor.getName();
85
			type = descriptor.getDataType();
86
			i=((AttributeDescriptor)descriptor).originalPosition();
87
			System.out.print(name);
81 88
			if (type.equals(FeatureAttributeDescriptor.TYPE_BOOLEAN)){
82 89
				System.out.print(" ----" + feature.getBoolean(i) +"\t" + "Boolean");
83 90
			}else if (type.equals(FeatureAttributeDescriptor.TYPE_BYTE)){
......
95 102
			}else if (type.equals(FeatureAttributeDescriptor.TYPE_STRING)){
96 103
				 System.out.print(" ---- " + feature.getString(i)+ " ---- String");
97 104
			}else if (type.equals(FeatureAttributeDescriptor.TYPE_GEOMETRY)){
98
				if (feature.getGeometry(i) == null){
99
					System.out.print(" ---- " + feature.getGeometry(i)+ " ---- Geometry");
105
				value = feature.getGeometry(i);
106
				if (value == null) {
107
					System.out.print(" ---- " + value + " ---- Geometry");
100 108
				}else {
101
					System.out.print(" ---- " + feature.getGeometry(i).getClass()+ " ---- Geometry");
109
					System.out.print(" ---- " + value.getClass()
110
							+ " ---- Geometry");
102 111
				}
103 112
			}else {
104 113
				System.out.print(" ---- " + "TYPE UNKNOWN");
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/joinstore/JoinFeatureCollection.java
130 130
	public Object[] toArray(Object[] arg0) {
131 131
		throw new UnsupportedOperationException();
132 132
	}
133

  
134
	public FeatureType getFeatureType() {
135
		return this.featureType;
136
	}
133 137
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/joinstore/JoinFeatureStore.java
277 277
		this.observeStore(this.storeSecondary);
278 278

  
279 279
		this.initFeatureType();
280
		this.changed = false;
280 281
	}
281 282

  
282 283
	/* (non-Javadoc)
283 284
	 * @see org.gvsig.fmap.data.DataStore#refresh()
284 285
	 */
285 286
	protected void doRefresh() throws OpenException,InitializeException {
286
		this.init(this.parameters);
287
		this.clearResourceObservers();
288
		this.storePrimary.refresh();
289
		this.storeSecondary.refresh();
290

  
291
		this.mapValues = null;
292

  
293
		this.observeStore(this.storePrimary);
294
		this.observeStore(this.storeSecondary);
295

  
296
		this.initFeatureType();
297
		this.changed = false;
287 298
	}
288

  
299
	/**
300
	 * @deprecated
301
	 */
289 302
	public boolean canWriteGeometry(int gvSIGgeometryType) {
290 303
		return false;
291 304
	}
292 305

  
293
	public FeatureStore getPrimaryStore() {
306
	protected FeatureStore getPrimaryStore() {
294 307
		return storePrimary;
295 308
	}
296 309

  
......
306 319
	}
307 320
	private class StoreResourceChangedObserver implements Observer {
308 321

  
322
		private JoinFeatureStore joinFeatureStore = null;
309 323
		public StoreResourceChangedObserver(JoinFeatureStore joinFeatureStore) {
310
			// TODO Auto-generated constructor stub
324
			this.joinFeatureStore = joinFeatureStore;
311 325
		}
312 326

  
313 327
		public void update(Observable observable, Object notification) {
314
			// TODO Auto-generated constructor stub
328
			this.joinFeatureStore.changed = true;
315 329
		}
316 330

  
317 331
	}
......
381 395
		}
382 396
		return this.mapValues;
383 397
	}
384
	public DataCollection getSelection() {
385
		this.selection = createSelection();
386
		this.setSelectionObserver();
387
		return selection;
388
	}
398
	//	public DataCollection getSelection() {
399
	//		this.selection = createSelection();
400
	//		this.setSelectionObserver();
401
	//		return selection;
402
	//	}
389 403
}
390 404

  
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/joinstore/JoinFeatureType.java
36 36
import org.gvsig.fmap.data.feature.IsNotAttributeSettingException;
37 37

  
38 38
public class JoinFeatureType extends DefaultFeatureType {
39

  
40 39
	/**
41 40
	 *
42 41
	 */
......
98 97
		return this.fTypeSecondary;
99 98
	}
100 99

  
100
	protected FeatureType newFeatureType() {
101
		return new JoinFeatureType();
102

  
103
	}
101 104
	protected void fillFeatureType(DefaultFeatureType type) {
102 105
		super.fillFeatureType(type);
103 106
		if (type instanceof JoinFeatureType) {
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/joinstore/JoinAttributeDescriptor.java
46 46
		super.fillAttributeDescriptor(newFD);
47 47
		if (newFD instanceof JoinAttributeDescriptor) {
48 48
			((JoinAttributeDescriptor) newFD).fromSecondarySource = this.fromSecondarySource;
49
			((JoinAttributeDescriptor) newFD).originalName = this.originalName;
49 50
		}
50 51
	}
51 52

  
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/AbstractFeatureStore.java
70 70
		this.resouceObservers.add(observer);
71 71
	}
72 72

  
73
	protected final void clearResourceObservers() {
74
		this.resouceObservers.clear();
75
	}
76

  
73 77
	protected void initSpatialManager(){
74 78
		spatialManager=new SpatialManager();
75 79
	}
......
606 610
		this.featureManager = null;
607 611
		this.spatialManager = null;
608 612
		this.attributeManager = null;
609
		this.resouceObservers.clear();
613
		this.clearResourceObservers();
610 614
		this.resouceObservers = null;
611 615
	}
612 616

  
......
752 756

  
753 757
		SpatialIndex index = null;
754 758

  
755
		FeatureStore fstore = (FeatureStore) this;
759
		FeatureStore fstore = this;
756 760

  
757 761
		try {
758 762
			SpatialIndexFactory factory = SpatialIndexFactory.getFactory(SpatialIndexFactory.Factories.GT2_QUADTREE);
......
761 765
			param.setEnvelope((Envelope) fstore.getMetadata().get("extent"));
762 766

  
763 767
			DataCollection data = getDataCollection();
764
			param.setFeatureCount((int) data.size());
768
			param.setFeatureCount(data.size());
765 769
			//param.setFilename(((FileStoreParameters) getParameters()).getFile().getAbsolutePath());
766 770
			param.setFilename(filename);
767 771
			param.setOverwrite(true);
768 772

  
769
			index = (SpatialIndex) factory.createSpatialIndex(param);
773
			index = factory.createSpatialIndex(param);
770 774

  
771 775
			Iterator it = data.iterator();
772 776

  
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/h2/H2FeatureCollection.java
10 10
import org.gvsig.fmap.data.DataStore;
11 11
import org.gvsig.fmap.data.ReadException;
12 12
import org.gvsig.fmap.data.feature.Feature;
13
import org.gvsig.fmap.data.feature.FeatureType;
13 14
import org.gvsig.fmap.data.feature.db.DBDataFeatureCollection;
14 15
import org.gvsig.fmap.data.feature.db.DBFeatureType;
15 16
import org.gvsig.fmap.data.feature.db.jdbc.AbstractJDBCIterator;
......
164 165
		return this.store.equals(store);
165 166
	}
166 167

  
168
	public FeatureType getFeatureType() {
169
		return this.featureType;
170
	}
167 171
}
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/h2/H2FeatureCollectionEditing.java
136 136
		return this.store.equals(store);
137 137
	}
138 138

  
139
	public FeatureType getFeatureType() {
140
		return this.featureType;
141
	}
139 142
}
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/h2/H2FeatureCollectionEditingFiltered.java
238 238
		return this.store.equals(store);
239 239
	}
240 240

  
241
	public FeatureType getFeatureType() {
242
		return this.featureType;
243
	}
241 244
}
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/postgresqlbin/PostgresqlBinFeatureCollection.java
234 234
		return this.store.equals(store);
235 235
	}
236 236

  
237
	public FeatureType getFeatureType() {
238
		return this.featureType;
239
	}
237 240
}
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/postgresql/PostgresqlFeatureCollectionEditingFiltered.java
129 129
		return this.store.equals(store);
130 130
	}
131 131

  
132
	public FeatureType getFeatureType() {
133
		return this.featureType;
134
	}
132 135
}
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/postgresql/PostgresqlFeatureCollection.java
192 192
		return this.store.equals(store);
193 193
	}
194 194

  
195
	public FeatureType getFeatureType() {
196
		return this.featureType;
197
	}
195 198
}
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/postgresql/PostgresqlFeatureCollectionEditing.java
132 132
		return this.store.equals(store);
133 133
	}
134 134

  
135
	public FeatureType getFeatureType() {
136
		return this.featureType;
137
	}
135 138
}
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/DBDataFeatureCollectionWithFeatureID.java
123 123
		return this.store.equals(store);
124 124
	}
125 125

  
126
	public FeatureType getFeatureType() {
127
		return this.featureType;
128
	}
126 129
}

Also available in: Unified diff