Revision 34112

View differences:

branches/v2_0_0_prep/extensions/org.gvsig.symbology/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/TestIClassifiedLegend.java
634 634
			return null;
635 635
		}
636 636

  
637
        public boolean isKnownEnvelope() {
638
            // TODO Auto-generated method stub
639
            return false;
640
        }
641

  
642
        public boolean hasRetrievedFeaturesLimit() {
643
            // TODO Auto-generated method stub
644
            return false;
645
        }
646

  
647
        public int getRetrievedFeaturesLimit() {
648
            // TODO Auto-generated method stub
649
            return 0;
650
        }
651

  
637 652
	}
638 653

  
639 654
	//private static final FInterval interval0=new FInterval(0,2);
branches/v2_0_0_prep/extensions/org.gvsig.symbology/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/TestAbstractIntervalLegend.java
631 631
			// TODO Auto-generated method stub
632 632
			return null;
633 633
		}
634

  
635
        public boolean isKnownEnvelope() {
636
            // TODO Auto-generated method stub
637
            return false;
638
        }
639

  
640
        public boolean hasRetrievedFeaturesLimit() {
641
            // TODO Auto-generated method stub
642
            return false;
643
        }
644

  
645
        public int getRetrievedFeaturesLimit() {
646
            // TODO Auto-generated method stub
647
            return 0;
648
        }
634 649
	}
635 650

  
636 651
	 private static final FInterval interval0=new FInterval(0,2);
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src-test/org/gvsig/fmap/mapcontext/persistence/DummyDBFeatureStore.java
544 544
		// TODO Auto-generated method stub
545 545
		return null;
546 546
	}
547

  
548
    public boolean isKnownEnvelope() {
549
        // TODO Auto-generated method stub
550
        return false;
551
    }
552

  
553
    public boolean hasRetrievedFeaturesLimit() {
554
        // TODO Auto-generated method stub
555
        return false;
556
    }
557

  
558
    public int getRetrievedFeaturesLimit() {
559
        // TODO Auto-generated method stub
560
        return 0;
561
    }
547 562
}
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src-test/org/gvsig/fmap/mapcontext/persistence/DummyFileFeatureStore.java
1229 1229
		// TODO Auto-generated method stub
1230 1230
		return null;
1231 1231
	}
1232

  
1233
    public boolean isKnownEnvelope() {
1234
        // TODO Auto-generated method stub
1235
        return false;
1236
    }
1237

  
1238
    public boolean hasRetrievedFeaturesLimit() {
1239
        // TODO Auto-generated method stub
1240
        return false;
1241
    }
1242

  
1243
    public int getRetrievedFeaturesLimit() {
1244
        // TODO Auto-generated method stub
1245
        return 0;
1246
    }
1232 1247
}
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/FeatureStore.java
4 4
import java.util.List;
5 5

  
6 6
import org.cresques.cts.IProjection;
7

  
7 8
import org.gvsig.fmap.dal.DataServerExplorer;
8 9
import org.gvsig.fmap.dal.DataStore;
9 10
import org.gvsig.fmap.dal.DataStoreParameters;
......
11 12
import org.gvsig.fmap.dal.exception.ReadException;
12 13
import org.gvsig.fmap.dal.feature.exception.FeatureIndexException;
13 14
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException;
15
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider;
14 16
import org.gvsig.fmap.geom.Geometry;
15 17
import org.gvsig.fmap.geom.primitive.Envelope;
18
import org.gvsig.tools.dispose.DisposableIterator;
16 19
import org.gvsig.tools.dynobject.DynObject;
17 20
import org.gvsig.tools.observer.Observer;
18 21
import org.gvsig.tools.undo.UndoRedoStack;
......
628 631
	 * @return the vectorial cache
629 632
	 */
630 633
	public FeatureCache getCache();
634
	
635
	 /**
636
     * Return if the provider knows the real envelope of a layer. If not,
637
     * the {@link FeatureStoreProvider#getEnvelope()} method doesn't return
638
     * the full envelope.
639
     * 
640
     * @return
641
     * <true> if it knows the real envelope.
642
     */
643
    public boolean isKnownEnvelope(); 
644
    
645
    /**
646
     * Return if the maximum number of features provided by the
647
     * provider are limited.
648
     * 
649
     * @return
650
     * <true> if there is a limit of features.
651
     */
652
    public boolean hasRetrievedFeaturesLimit();
653
    
654
    /**
655
     * If the {@link FeatureStoreProvider#hasRetrievedFeaturesLimit()} returns true,
656
     * it returns the limit of features retrieved from the provider.
657
     * @return
658
     * The limit of the retrieved features.
659
     */
660
    public int getRetrievedFeaturesLimit();
631 661
}
632 662

  
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java
146 146
import org.gvsig.tools.visitor.Visitor;
147 147

  
148 148
public final class DefaultFeatureStore extends AbstractDisposable implements
149
		DataStoreImplementation, FeatureStoreProviderServices, FeatureStore,
150
		Observer {
149
DataStoreImplementation, FeatureStoreProviderServices, FeatureStore,
150
Observer {
151 151

  
152
	final static private Logger logger = LoggerFactory
153
			.getLogger(DefaultFeatureStore.class);
152
    final static private Logger logger = LoggerFactory
153
    .getLogger(DefaultFeatureStore.class);
154 154

  
155
	private static final String PERSISTENCE_DEFINITION_NAME = "FeatureStore";
155
    private static final String PERSISTENCE_DEFINITION_NAME = "FeatureStore";
156 156

  
157
	private DataStoreParameters parameters = null;
158
	private FeatureSelection selection;
159
	private FeatureLocks locks;
157
    private DataStoreParameters parameters = null;
158
    private FeatureSelection selection;
159
    private FeatureLocks locks;
160 160

  
161
	private DelegateWeakReferencingObservable delegateObservable = new DelegateWeakReferencingObservable(this);
161
    private DelegateWeakReferencingObservable delegateObservable = new DelegateWeakReferencingObservable(this);
162 162

  
163
	private FeatureCommandsStack commands;
164
	private FeatureTypeManager featureTypeManager;
165
	private FeatureManager featureManager;
166
	private SpatialManager spatialManager;
163
    private FeatureCommandsStack commands;
164
    private FeatureTypeManager featureTypeManager;
165
    private FeatureManager featureManager;
166
    private SpatialManager spatialManager;
167 167

  
168
	private FeatureType defaultFeatureType = null;
169
	private List featureTypes = new ArrayList();
168
    private FeatureType defaultFeatureType = null;
169
    private List featureTypes = new ArrayList();
170 170

  
171
	private int mode = MODE_QUERY;
172
	private long versionOfUpdate = 0;
173
	private boolean hasStrongChanges = true;
174
	private boolean hasInserts = true;
171
    private int mode = MODE_QUERY;
172
    private long versionOfUpdate = 0;
173
    private boolean hasStrongChanges = true;
174
    private boolean hasInserts = true;
175 175

  
176
	private DefaultDataManager dataManager = null;
176
    private DefaultDataManager dataManager = null;
177 177

  
178
	private FeatureStoreProvider provider = null;
178
    private FeatureStoreProvider provider = null;
179 179

  
180
	private DefaultFeatureIndexes indexes;
180
    private DefaultFeatureIndexes indexes;
181 181

  
182
	private DefaultFeatureStoreTransforms transforms;
182
    private DefaultFeatureStoreTransforms transforms;
183 183

  
184
	private DelegatedDynObject metadata;
185
	private Set metadataChildren;
184
    private DelegatedDynObject metadata;
185
    private Set metadataChildren;
186 186

  
187
	private Long featureCount = null;
187
    private Long featureCount = null;
188 188

  
189
	private long temporalOid = 0;
189
    private long temporalOid = 0;
190 190

  
191
	private FeatureCacheProvider cache;
191
    private FeatureCacheProvider cache;
192 192

  
193
	/*
194
	 * TODO:
195
	 *
196
	 * - Comprobar que solo se pueden a�adir reglas de validacion sobre un
197
	 * EditableFeatureType. - Comprobar que solo se puede hacer un update con un
198
	 * featureType al que se le han cambiado las reglas de validacion cuando
199
	 * hasStrongChanges=false.
200
	 */
193
    /*
194
     * TODO:
195
     *
196
     * - Comprobar que solo se pueden a�adir reglas de validacion sobre un
197
     * EditableFeatureType. - Comprobar que solo se puede hacer un update con un
198
     * featureType al que se le han cambiado las reglas de validacion cuando
199
     * hasStrongChanges=false.
200
     */
201 201

  
202 202
    public DefaultFeatureStore() {
203 203

  
204
	}
204
    }
205 205

  
206
	public void intializePhase1(DefaultDataManager dataManager,
207
			DataStoreParameters parameters) throws InitializeException {
206
    public void intializePhase1(DefaultDataManager dataManager,
207
        DataStoreParameters parameters) throws InitializeException {
208 208

  
209
		DynObjectManager dynManager = ToolsLocator.getDynObjectManager();
209
        DynObjectManager dynManager = ToolsLocator.getDynObjectManager();
210 210

  
211
		this.metadata = (DelegatedDynObject) dynManager
212
				.createDynObject(
213
						METADATA_DEFINITION_NAME,
214
						MetadataManager.METADATA_NAMESPACE
215
				);
216
						
217
						
218
		this.dataManager = dataManager;
211
        this.metadata = (DelegatedDynObject) dynManager
212
        .createDynObject(
213
            METADATA_DEFINITION_NAME,
214
            MetadataManager.METADATA_NAMESPACE
215
        );
219 216

  
220
		this.parameters = parameters;
221
		this.transforms = new DefaultFeatureStoreTransforms(this);
222
		try {
223
			indexes = new DefaultFeatureIndexes(this);
224
		} catch (DataException e) {
225
			throw new InitializeException(e);
226
		}
227 217

  
228
	}
218
        this.dataManager = dataManager;
229 219

  
230
	public void intializePhase2(DataStoreProvider provider) {
231
		this.provider = (FeatureStoreProvider) provider;
232
		this.delegate(provider);
233
		this.metadataChildren = new HashSet();
234
		this.metadataChildren.add(provider);
235
	}
220
        this.parameters = parameters;
221
        this.transforms = new DefaultFeatureStoreTransforms(this);
222
        try {
223
            indexes = new DefaultFeatureIndexes(this);
224
        } catch (DataException e) {
225
            throw new InitializeException(e);
226
        }
236 227

  
237
	public DataStoreParameters getParameters() {
238
		return parameters;
239
	}
228
    }
240 229

  
241
	public int getMode() {
242
		return this.mode;
243
	}
230
    public void intializePhase2(DataStoreProvider provider) {
231
        this.provider = (FeatureStoreProvider) provider;
232
        this.delegate(provider);
233
        this.metadataChildren = new HashSet();
234
        this.metadataChildren.add(provider);
235
    }
244 236

  
245
	public DataManager getManager() {
246
		return this.dataManager;
247
	}
237
    public DataStoreParameters getParameters() {
238
        return parameters;
239
    }
248 240

  
249
	public Iterator getChildren() {
250
		return this.provider.getChilds();
251
	}
241
    public int getMode() {
242
        return this.mode;
243
    }
252 244

  
253
	public FeatureStoreProvider getProvider() {
254
		return this.provider;
255
	}
245
    public DataManager getManager() {
246
        return this.dataManager;
247
    }
256 248

  
257
	public FeatureManager getFeatureManager() {
258
		return this.featureManager;
259
	}
249
    public Iterator getChildren() {
250
        return this.provider.getChilds();
251
    }
260 252

  
261
	public void setFeatureTypes(List types, FeatureType defaultType) {
262
		this.featureTypes = types;
263
		this.defaultFeatureType = defaultType;
264
	}
253
    public FeatureStoreProvider getProvider() {
254
        return this.provider;
255
    }
265 256

  
266
	public void open() throws OpenException {
267
		// TODO: Se puede hacer un open estando en edicion ?
268
		this.notifyChange(FeatureStoreNotification.BEFORE_OPEN);
269
		this.provider.open();
270
		this.notifyChange(FeatureStoreNotification.AFTER_OPEN);
271
	}
257
    public FeatureManager getFeatureManager() {
258
        return this.featureManager;
259
    }
272 260

  
273
	public void refresh() throws OpenException, InitializeException {
274
		if (this.mode != MODE_QUERY) {
275
			throw new IllegalStateException();
276
		}
277
		this.notifyChange(FeatureStoreNotification.BEFORE_REFRESH);
278
		this.featureCount = null;
279
		this.provider.refresh();
280
		this.notifyChange(FeatureStoreNotification.AFTER_REFRESH);
281
	}
261
    public void setFeatureTypes(List types, FeatureType defaultType) {
262
        this.featureTypes = types;
263
        this.defaultFeatureType = defaultType;
264
    }
282 265

  
283
	public void close() throws CloseException {
284
		// TODO: Se puede hacer un close estando en edicion ?
285
		this.notifyChange(FeatureStoreNotification.BEFORE_CLOSE);
286
		this.featureCount = null;
287
		this.provider.close();
288
		this.notifyChange(FeatureStoreNotification.AFTER_CLOSE);
289
	}
266
    public void open() throws OpenException {
267
        // TODO: Se puede hacer un open estando en edicion ?
268
        this.notifyChange(FeatureStoreNotification.BEFORE_OPEN);
269
        this.provider.open();
270
        this.notifyChange(FeatureStoreNotification.AFTER_OPEN);
271
    }
290 272

  
291
	protected void doDispose() throws BaseException {
292
		this.notifyChange(FeatureStoreNotification.BEFORE_DISPOSE);
293
		this.provider.dispose();
294
		if (this.selection != null) {
295
			this.selection.dispose();
296
			this.selection = null;
297
		}
298
		this.commands = null;
299
		this.featureCount = null;
300
		if (this.locks != null) {
301
			//this.locks.dispose();
302
			this.locks = null;
303
		}
273
    public void refresh() throws OpenException, InitializeException {
274
        if (this.mode != MODE_QUERY) {
275
            throw new IllegalStateException();
276
        }
277
        this.notifyChange(FeatureStoreNotification.BEFORE_REFRESH);
278
        this.featureCount = null;
279
        this.provider.refresh();
280
        this.notifyChange(FeatureStoreNotification.AFTER_REFRESH);
281
    }
304 282

  
305
		if (this.featureTypeManager != null) {
306
			this.featureTypeManager.dispose();
307
			this.featureTypeManager = null;
308
		}
283
    public void close() throws CloseException {
284
        // TODO: Se puede hacer un close estando en edicion ?
285
        this.notifyChange(FeatureStoreNotification.BEFORE_CLOSE);
286
        this.featureCount = null;
287
        this.provider.close();
288
        this.notifyChange(FeatureStoreNotification.AFTER_CLOSE);
289
    }
309 290

  
310
		this.featureManager = null;
311
		this.spatialManager = null;
291
    protected void doDispose() throws BaseException {
292
        this.notifyChange(FeatureStoreNotification.BEFORE_DISPOSE);
293
        this.provider.dispose();
294
        if (this.selection != null) {
295
            this.selection.dispose();
296
            this.selection = null;
297
        }
298
        this.commands = null;
299
        this.featureCount = null;
300
        if (this.locks != null) {
301
            //this.locks.dispose();
302
            this.locks = null;
303
        }
312 304

  
313
		this.parameters = null;
314
		this.notifyChange(FeatureStoreNotification.AFTER_DISPOSE);
315
		if (delegateObservable != null) {
316
			this.delegateObservable.deleteObservers();
317
			this.delegateObservable = null;
318
		}
319
	}
305
        if (this.featureTypeManager != null) {
306
            this.featureTypeManager.dispose();
307
            this.featureTypeManager = null;
308
        }
320 309

  
321
	public boolean allowWrite() {
322
		return this.provider.allowWrite();
323
	}
310
        this.featureManager = null;
311
        this.spatialManager = null;
324 312

  
325
	public boolean canWriteGeometry(int geometryType) throws DataException {
326
		return this.provider.canWriteGeometry(geometryType, 0);
327
	}
313
        this.parameters = null;
314
        this.notifyChange(FeatureStoreNotification.AFTER_DISPOSE);
315
        if (delegateObservable != null) {
316
            this.delegateObservable.deleteObservers();
317
            this.delegateObservable = null;
318
        }
319
    }
328 320

  
329
	public DataServerExplorer getExplorer() throws ReadException,
330
			ValidateDataParametersException {
331
		return this.provider.getExplorer();
332
	}
321
    public boolean allowWrite() {
322
        return this.provider.allowWrite();
323
    }
333 324

  
334
	/*
325
    public boolean canWriteGeometry(int geometryType) throws DataException {
326
        return this.provider.canWriteGeometry(geometryType, 0);
327
    }
328

  
329
    public DataServerExplorer getExplorer() throws ReadException,
330
    ValidateDataParametersException {
331
        return this.provider.getExplorer();
332
    }
333

  
334
    /*
335 335
	public Metadata getMetadata() throws MetadataNotFoundException {
336 336
		// TODO:
337 337
		// Si el provider devuelbe null habria que ver de construir aqui
......
341 341
		// actualizarse usando el spatialManager
342 342
		return this.provider.getMetadata();
343 343
	}
344
	 */
344
     */
345 345

  
346
	public Envelope getEnvelope() throws DataException {
347
		if (this.mode == MODE_FULLEDIT) {
348
			return this.spatialManager.getEnvelope();
349
		}
350
		return this.provider.getEnvelope();
351
	}
346
    public Envelope getEnvelope() throws DataException {
347
        if (this.mode == MODE_FULLEDIT) {
348
            return this.spatialManager.getEnvelope();
349
        }
350
        return this.provider.getEnvelope();
351
    }
352 352

  
353
	/**
354
	 * @deprecated use getDefaultFeatureType().getDefaultSRS()
355
	 */
356
	public IProjection getSRSDefaultGeometry() throws DataException {
357
		return this.getDefaultFeatureType().getDefaultSRS();
358
	}
353
    /**
354
     * @deprecated use getDefaultFeatureType().getDefaultSRS()
355
     */
356
    public IProjection getSRSDefaultGeometry() throws DataException {
357
        return this.getDefaultFeatureType().getDefaultSRS();
358
    }
359 359

  
360
	public FeatureSelection createDefaultFeatureSelection()
361
	throws DataException {
362
		return new DefaultFeatureSelection(this);
363
	}
360
    public FeatureSelection createDefaultFeatureSelection()
361
    throws DataException {
362
        return new DefaultFeatureSelection(this);
363
    }
364 364

  
365
	public FeatureProvider createDefaultFeatureProvider(FeatureType type)
366
	throws DataException {
367
		if( type.hasOID() ) {
368
			return new DefaultFeatureProvider(type, this.provider.createNewOID());
369
		}
370
		return new DefaultFeatureProvider(type);
371
	}
365
    public FeatureProvider createDefaultFeatureProvider(FeatureType type)
366
    throws DataException {
367
        if( type.hasOID() ) {
368
            return new DefaultFeatureProvider(type, this.provider.createNewOID());
369
        }
370
        return new DefaultFeatureProvider(type);
371
    }
372 372

  
373
	public void saveToState(PersistentState state) throws PersistenceException {
374
		if (this.mode != FeatureStore.MODE_QUERY){
375
			throw new PersistenceException(
376
					new IllegalStateException(this
377
					.getName()));
378
		}
379
		state.set("dataStoreName", this.getName());
380
		state.set("parameters", this.parameters);
381
		state.set("selection", this.selection);
382
		state.set("transforms", this.transforms);
383
		// TODO locks persistence
384
		// state.set("locks", this.locks);
385
		// TODO indexes persistence
386
		// state.set("indexes", this.indexes);
387
		Map evaluatedAttr = new HashMap(1);
388
		Iterator iterType = featureTypes.iterator();
389
		Iterator iterAttr;
390
		FeatureType type;
391
		DefaultFeatureAttributeDescriptor attr;
392
		List attrs;
393
		while (iterType.hasNext()) {
394
			type = (FeatureType) iterType.next();
395
			attrs = new ArrayList();
396
			iterAttr = type.iterator();
397
			while (iterAttr.hasNext()) {
398
				attr = (DefaultFeatureAttributeDescriptor) iterAttr.next();
399
				if (attr.getEvaluator() != null
400
						&& attr.getEvaluator() instanceof Persistent) {
401
					attrs.add(attr);
402
				}
403
			}
404
			if (!attrs.isEmpty()) {
405
				evaluatedAttr.put(type.getId(), attrs);
406
			}
373
    public void saveToState(PersistentState state) throws PersistenceException {
374
        if (this.mode != FeatureStore.MODE_QUERY){
375
            throw new PersistenceException(
376
                new IllegalStateException(this
377
                    .getName()));
378
        }
379
        state.set("dataStoreName", this.getName());
380
        state.set("parameters", this.parameters);
381
        state.set("selection", this.selection);
382
        state.set("transforms", this.transforms);
383
        // TODO locks persistence
384
        // state.set("locks", this.locks);
385
        // TODO indexes persistence
386
        // state.set("indexes", this.indexes);
387
        Map evaluatedAttr = new HashMap(1);
388
        Iterator iterType = featureTypes.iterator();
389
        Iterator iterAttr;
390
        FeatureType type;
391
        DefaultFeatureAttributeDescriptor attr;
392
        List attrs;
393
        while (iterType.hasNext()) {
394
            type = (FeatureType) iterType.next();
395
            attrs = new ArrayList();
396
            iterAttr = type.iterator();
397
            while (iterAttr.hasNext()) {
398
                attr = (DefaultFeatureAttributeDescriptor) iterAttr.next();
399
                if (attr.getEvaluator() != null
400
                    && attr.getEvaluator() instanceof Persistent) {
401
                    attrs.add(attr);
402
                }
403
            }
404
            if (!attrs.isEmpty()) {
405
                evaluatedAttr.put(type.getId(), attrs);
406
            }
407 407

  
408 408

  
409
		}
409
        }
410 410

  
411
		if (evaluatedAttr.isEmpty()) {
412
			evaluatedAttr = null;
413
		}
411
        if (evaluatedAttr.isEmpty()) {
412
            evaluatedAttr = null;
413
        }
414 414

  
415
		state.set("evaluatedAttributes", evaluatedAttr);
416
		state.set("defaultFeatureTypeId", defaultFeatureType.getId());
415
        state.set("evaluatedAttributes", evaluatedAttr);
416
        state.set("defaultFeatureTypeId", defaultFeatureType.getId());
417 417

  
418
	}
418
    }
419 419

  
420
	public void loadFromState(PersistentState state) throws PersistenceException {
421
		if (this.provider != null) {
422
			throw new PersistenceStoreAlreadyLoadedException(this.getName());
423
		}
424
		if (this.getManager() == null) {
425
			this.dataManager = (DefaultDataManager) DALLocator.getDataManager();
426
		}
420
    public void loadFromState(PersistentState state) throws PersistenceException {
421
        if (this.provider != null) {
422
            throw new PersistenceStoreAlreadyLoadedException(this.getName());
423
        }
424
        if (this.getManager() == null) {
425
            this.dataManager = (DefaultDataManager) DALLocator.getDataManager();
426
        }
427 427

  
428
		DataStoreParameters params = (DataStoreParameters) state.get("parameters");
428
        DataStoreParameters params = (DataStoreParameters) state.get("parameters");
429 429

  
430
		try {
430
        try {
431 431

  
432
			this.dataManager.intializeDataStore(this, params);
433
			this.selection = (FeatureSelection) state.get("selection");
434
			this.transforms = (DefaultFeatureStoreTransforms) state.get("transforms");
435
			Map evaluatedAttributes = (Map) state.get("evaluatedAttributes");
436
			if (evaluatedAttributes != null && !evaluatedAttributes.isEmpty()) {
437
				List attrs;
438
				Iterator iterEntries = evaluatedAttributes.entrySet().iterator();
439
				Entry entry;
440
				while (iterEntries.hasNext()){
441
					entry = (Entry) iterEntries.next();
442
					attrs = (List) entry.getValue();
443
					if (attrs.isEmpty()){
444
						continue;
445
					}
446
					int fTypePos = -1;
447
					DefaultFeatureType type = null;
448
					for (int i=0;i<featureTypes.size();i++){
449
						type = (DefaultFeatureType) featureTypes.get(i);
450
						if (type.getId().equals(entry.getKey())){
451
							fTypePos = i;
452
							break;
453
						}
454
					}
455
					if (fTypePos < 0){
456
						throw new PersistenceCantFindFeatureTypeException(this.getName(), (String)entry.getKey());
457
					}
458
					DefaultEditableFeatureType eType = (DefaultEditableFeatureType) type
459
							.getEditable();
460
					Iterator iterAttr = attrs.iterator();
461
					FeatureAttributeDescriptor attr;
462
					while (iterAttr.hasNext()) {
463
						attr = (FeatureAttributeDescriptor) iterAttr.next();
464
						eType.addLike(attr);
465
					}
466
					featureTypes.set(fTypePos, eType.getNotEditableCopy());
432
            this.dataManager.intializeDataStore(this, params);
433
            this.selection = (FeatureSelection) state.get("selection");
434
            this.transforms = (DefaultFeatureStoreTransforms) state.get("transforms");
435
            Map evaluatedAttributes = (Map) state.get("evaluatedAttributes");
436
            if (evaluatedAttributes != null && !evaluatedAttributes.isEmpty()) {
437
                List attrs;
438
                Iterator iterEntries = evaluatedAttributes.entrySet().iterator();
439
                Entry entry;
440
                while (iterEntries.hasNext()){
441
                    entry = (Entry) iterEntries.next();
442
                    attrs = (List) entry.getValue();
443
                    if (attrs.isEmpty()){
444
                        continue;
445
                    }
446
                    int fTypePos = -1;
447
                    DefaultFeatureType type = null;
448
                    for (int i=0;i<featureTypes.size();i++){
449
                        type = (DefaultFeatureType) featureTypes.get(i);
450
                        if (type.getId().equals(entry.getKey())){
451
                            fTypePos = i;
452
                            break;
453
                        }
454
                    }
455
                    if (fTypePos < 0){
456
                        throw new PersistenceCantFindFeatureTypeException(this.getName(), (String)entry.getKey());
457
                    }
458
                    DefaultEditableFeatureType eType = (DefaultEditableFeatureType) type
459
                    .getEditable();
460
                    Iterator iterAttr = attrs.iterator();
461
                    FeatureAttributeDescriptor attr;
462
                    while (iterAttr.hasNext()) {
463
                        attr = (FeatureAttributeDescriptor) iterAttr.next();
464
                        eType.addLike(attr);
465
                    }
466
                    featureTypes.set(fTypePos, eType.getNotEditableCopy());
467 467

  
468
				}
468
                }
469 469

  
470 470

  
471
			}
471
            }
472 472

  
473
			String defFTypeid = state.getString("defaultFeatureTypeId");
474
			FeatureType ftype = null;
475
			if (!this.defaultFeatureType.getId().equals(
476
					state.getString("defaultFeatureTypeId"))) {
473
            String defFTypeid = state.getString("defaultFeatureTypeId");
474
            FeatureType ftype = null;
475
            if (!this.defaultFeatureType.getId().equals(
476
                state.getString("defaultFeatureTypeId"))) {
477 477

  
478
				ftype = getFeatureType(defFTypeid);
479
				if (ftype == null) {
480
					throw new PersistenceCantFindDefaultFeatureTypeException(this.getName(), defFTypeid);
481
				}
482
				this.defaultFeatureType = ftype;
483
			}
478
                ftype = getFeatureType(defFTypeid);
479
                if (ftype == null) {
480
                    throw new PersistenceCantFindDefaultFeatureTypeException(this.getName(), defFTypeid);
481
                }
482
                this.defaultFeatureType = ftype;
483
            }
484 484

  
485 485

  
486
		} catch (InitializeException e) {
487
			throw new PersistenceException(e);
488
		} catch (DataException e) {
489
			throw new PersistenceException(e);
490
		}
486
        } catch (InitializeException e) {
487
            throw new PersistenceException(e);
488
        } catch (DataException e) {
489
            throw new PersistenceException(e);
490
        }
491 491

  
492
	}
492
    }
493 493

  
494
	public static void registerPersistenceDefinition() {
495
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
496
		if( manager.getDefinition(PERSISTENCE_DEFINITION_NAME)==null ) {
497
			DynStruct definition = manager.addDefinition(
498
					DefaultFeatureStore.class, 
499
					PERSISTENCE_DEFINITION_NAME, 
500
					PERSISTENCE_DEFINITION_NAME+" Persistent definition",
501
					null, 
502
					null
503
				);
504
			definition.addDynFieldString("dataStoreName")
505
				.setMandatory(true)
506
				.setPersistent(true);
507
			
508
			definition.addDynFieldObject("parameters")
509
				.setClassOfValue(DynObject.class)
510
				.setMandatory(true)
511
				.setPersistent(true);
512
	
513
			definition.addDynFieldObject("selection")
514
					.setClassOfValue(FeatureSelection.class)
515
					.setMandatory(false)
516
					.setPersistent(true);
517
	
518
			definition.addDynFieldObject("transforms")
519
					.setClassOfValue(DefaultFeatureStoreTransforms.class)
520
					.setMandatory(true)
521
					.setPersistent(true);
522
	
523
			definition.addDynFieldMap("evaluatedAttributes")
524
					.setClassOfItems(List.class) // List<DefaultFeatureAttributeDescriptor>
525
					.setMandatory(false)
526
					.setPersistent(true);
527
	
528
			definition.addDynFieldString("defaultFeatureTypeId")
529
					.setMandatory(true)
530
					.setPersistent(true);
531
		}
532
	}
494
    public static void registerPersistenceDefinition() {
495
        PersistenceManager manager = ToolsLocator.getPersistenceManager();
496
        if( manager.getDefinition(PERSISTENCE_DEFINITION_NAME)==null ) {
497
            DynStruct definition = manager.addDefinition(
498
                DefaultFeatureStore.class, 
499
                PERSISTENCE_DEFINITION_NAME, 
500
                PERSISTENCE_DEFINITION_NAME+" Persistent definition",
501
                null, 
502
                null
503
            );
504
            definition.addDynFieldString("dataStoreName")
505
            .setMandatory(true)
506
            .setPersistent(true);
533 507

  
534
	public static void registerMetadataDefinition() throws MetadataException {
535
		MetadataManager manager = MetadataLocator.getMetadataManager();
536
		if( manager.getDefinition(METADATA_DEFINITION_NAME)==null ) {
537
			DynStruct metadataDefinition = manager.addDefinition(
538
					METADATA_DEFINITION_NAME,
539
					null
540
			);
541
			metadataDefinition.extend(
542
					manager.getDefinition(
543
						DataStore.METADATA_DEFINITION_NAME
544
					)
545
			);
546
		}
547
	}
548
	
549
	//
550
	// ====================================================================
551
	// Gestion de la seleccion
552
	//
508
            definition.addDynFieldObject("parameters")
509
            .setClassOfValue(DynObject.class)
510
            .setMandatory(true)
511
            .setPersistent(true);
553 512

  
554
	public void setSelection(DataSet selection)
555
	throws DataException {
556
		this.setSelection((FeatureSet) selection);
557
	}
513
            definition.addDynFieldObject("selection")
514
            .setClassOfValue(FeatureSelection.class)
515
            .setMandatory(false)
516
            .setPersistent(true);
558 517

  
559
	public DataSet createSelection() throws DataException {
560
		return createFeatureSelection();
561
	}
518
            definition.addDynFieldObject("transforms")
519
            .setClassOfValue(DefaultFeatureStoreTransforms.class)
520
            .setMandatory(true)
521
            .setPersistent(true);
562 522

  
563
	public DataSet getSelection() throws DataException {
564
		return this.getFeatureSelection();
565
	}
523
            definition.addDynFieldMap("evaluatedAttributes")
524
            .setClassOfItems(List.class) // List<DefaultFeatureAttributeDescriptor>
525
            .setMandatory(false)
526
            .setPersistent(true);
566 527

  
528
            definition.addDynFieldString("defaultFeatureTypeId")
529
            .setMandatory(true)
530
            .setPersistent(true);
531
        }
532
    }
533

  
534
    public static void registerMetadataDefinition() throws MetadataException {
535
        MetadataManager manager = MetadataLocator.getMetadataManager();
536
        if( manager.getDefinition(METADATA_DEFINITION_NAME)==null ) {
537
            DynStruct metadataDefinition = manager.addDefinition(
538
                METADATA_DEFINITION_NAME,
539
                null
540
            );
541
            metadataDefinition.extend(
542
                manager.getDefinition(
543
                    DataStore.METADATA_DEFINITION_NAME
544
                )
545
            );
546
        }
547
    }
548

  
549
    //
550
    // ====================================================================
551
    // Gestion de la seleccion
552
    //
553

  
554
    public void setSelection(DataSet selection)
555
    throws DataException {
556
        this.setSelection((FeatureSet) selection);
557
    }
558

  
559
    public DataSet createSelection() throws DataException {
560
        return createFeatureSelection();
561
    }
562

  
563
    public DataSet getSelection() throws DataException {
564
        return this.getFeatureSelection();
565
    }
566

  
567 567
    public void setSelection(FeatureSet selection) throws DataException {
568 568
        setSelection(selection, true);
569 569
    }
......
574 574
     *            if the action must be undoable
575 575
     */
576 576
    public void setSelection(FeatureSet selection, boolean undoable)
577
	throws DataException {
578
    	if (selection == null) {
579
			if (undoable) {
580
				throw new SelectionNotAllowedException(getName());
581
			}
577
    throws DataException {
578
        if (selection == null) {
579
            if (undoable) {
580
                throw new SelectionNotAllowedException(getName());
581
            }
582 582

  
583
		} else {
584
			if (selection.equals(this.selection)) {
585
				return;
586
			}
587
			if (!selection.isFromStore(this)) {
588
				throw new SelectionNotAllowedException(getName());
589
			}
590
		}
583
        } else {
584
            if (selection.equals(this.selection)) {
585
                return;
586
            }
587
            if (!selection.isFromStore(this)) {
588
                throw new SelectionNotAllowedException(getName());
589
            }
590
        }
591 591

  
592
    	if (this.selection != null) {
593
			this.selection.deleteObserver(this);
594
		}
595
		if (selection == null) {
596
			if (this.selection != null) {
597
				this.selection.dispose();
598
			}
599
			this.selection = null;
600
			return;
601
		}
602
		if (selection instanceof FeatureSelection) {
603
			if (undoable && isEditing()) {
604
				commands.selectionSet(this, this.selection,
605
						(FeatureSelection) selection);
606
			}
607
			if (this.selection != null) {
608
				this.selection.dispose();
609
			}
610
			this.selection = (FeatureSelection) selection;
611
		} else {
612
			if (undoable && isEditing()) {
613
				commands.startComplex("_selectionSet");
614
			}
615
			if (selection instanceof DefaultFeatureSelection) {
592
        if (this.selection != null) {
593
            this.selection.deleteObserver(this);
594
        }
595
        if (selection == null) {
596
            if (this.selection != null) {
597
                this.selection.dispose();
598
            }
599
            this.selection = null;
600
            return;
601
        }
602
        if (selection instanceof FeatureSelection) {
603
            if (undoable && isEditing()) {
604
                commands.selectionSet(this, this.selection,
605
                    (FeatureSelection) selection);
606
            }
607
            if (this.selection != null) {
608
                this.selection.dispose();
609
            }
610
            this.selection = (FeatureSelection) selection;
611
        } else {
612
            if (undoable && isEditing()) {
613
                commands.startComplex("_selectionSet");
614
            }
615
            if (selection instanceof DefaultFeatureSelection) {
616 616
                DefaultFeatureSelection defSelection = (DefaultFeatureSelection) selection;
617 617
                defSelection.deselectAll(undoable);
618 618
                defSelection.select(selection, undoable);
......
620 620
                this.selection.deselectAll();
621 621
                this.selection.select(selection);
622 622
            }
623
			if (undoable && isEditing()) {
624
				commands.endComplex();
625
			}
626
		}
627
		this.selection.addObserver(this);
623
            if (undoable && isEditing()) {
624
                commands.endComplex();
625
            }
626
        }
627
        this.selection.addObserver(this);
628 628

  
629
		this.notifyChange(DataStoreNotification.SELECTION_CHANGE);
630
	}
629
        this.notifyChange(DataStoreNotification.SELECTION_CHANGE);
630
    }
631 631

  
632
	public FeatureSelection createFeatureSelection() throws DataException {
633
		return this.provider.createFeatureSelection();
634
	}
632
    public FeatureSelection createFeatureSelection() throws DataException {
633
        return this.provider.createFeatureSelection();
634
    }
635 635

  
636
	public FeatureSelection getFeatureSelection() throws DataException {
637
		if (selection == null) {
638
			this.selection = createFeatureSelection();
639
			this.selection.addObserver(this);
640
		}
641
		return selection;
642
	}
636
    public FeatureSelection getFeatureSelection() throws DataException {
637
        if (selection == null) {
638
            this.selection = createFeatureSelection();
639
            this.selection.addObserver(this);
640
        }
641
        return selection;
642
    }
643 643

  
644
	//
645
	// ====================================================================
646
	// Gestion de notificaciones
647
	//
644
    //
645
    // ====================================================================
646
    // Gestion de notificaciones
647
    //
648 648

  
649
	public void notifyChange(String notification) {
650
		if (delegateObservable != null) {
651
			delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(
652
					this, notification));
653
		}
649
    public void notifyChange(String notification) {
650
        if (delegateObservable != null) {
651
            delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(
652
                this, notification));
653
        }
654 654

  
655
	}
655
    }
656 656

  
657
	public void notifyChange(String notification, Feature feature) {
658
		delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(
659
				this, notification, feature));
660
	}
657
    public void notifyChange(String notification, Feature feature) {
658
        delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(
659
            this, notification, feature));
660
    }
661 661

  
662
	public void notifyChange(String notification, Command command) {
663
		delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(
664
				this, notification, command));
665
	}
662
    public void notifyChange(String notification, Command command) {
663
        delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(
664
            this, notification, command));
665
    }
666 666

  
667
	public void notifyChange(String notification, EditableFeatureType type) {
668
		delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(this,
669
				notification, type));
670
	}
667
    public void notifyChange(String notification, EditableFeatureType type) {
668
        delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(this,
669
            notification, type));
670
    }
671 671

  
672
	/*
673
	 * (non-Javadoc)
674
	 *
675
	 * @see
676
	 * org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices#notifyChange
677
	 * (java.lang.String, org.gvsig.fmap.dal.resource.Resource)
678
	 */
679
	public void notifyChange(String notification, Resource resource) {
680
		delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(this,
681
				FeatureStoreNotification.RESOURCE_CHANGED));
682
	}
672
    /*
673
     * (non-Javadoc)
674
     *
675
     * @see
676
     * org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices#notifyChange
677
     * (java.lang.String, org.gvsig.fmap.dal.resource.Resource)
678
     */
679
    public void notifyChange(String notification, Resource resource) {
680
        delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(this,
681
            FeatureStoreNotification.RESOURCE_CHANGED));
682
    }
683 683

  
684 684

  
685
	//
686
	// ====================================================================
687
	// Gestion de bloqueos
688
	//
685
    //
686
    // ====================================================================
687
    // Gestion de bloqueos
688
    //
689 689

  
690
	public boolean isLocksSupported() {
691
		return this.provider.isLocksSupported();
692
	}
690
    public boolean isLocksSupported() {
691
        return this.provider.isLocksSupported();
692
    }
693 693

  
694
	public FeatureLocks getLocks() throws DataException {
695
		if (!this.provider.isLocksSupported()) {
696
			logger.warn("Locks not supporteds");
697
			return null;
698
		}
699
		if (locks == null) {
700
			this.locks = this.provider.createFeatureLocks();
701
		}
702
		return locks;
703
	}
694
    public FeatureLocks getLocks() throws DataException {
695
        if (!this.provider.isLocksSupported()) {
696
            logger.warn("Locks not supporteds");
697
            return null;
698
        }
699
        if (locks == null) {
700
            this.locks = this.provider.createFeatureLocks();
701
        }
702
        return locks;
703
    }
704 704

  
705
	//
706
	// ====================================================================
707
	// Interface Observable
708
	//
705
    //
706
    // ====================================================================
707
    // Interface Observable
708
    //
709 709

  
710
	public void disableNotifications() {
711
		this.delegateObservable.disableNotifications();
710
    public void disableNotifications() {
711
        this.delegateObservable.disableNotifications();
712 712

  
713
	}
713
    }
714 714

  
715
	public void enableNotifications() {
716
		this.delegateObservable.enableNotifications();
717
	}
715
    public void enableNotifications() {
716
        this.delegateObservable.enableNotifications();
717
    }
718 718

  
719
	public void beginComplexNotification() {
720
		this.delegateObservable.beginComplexNotification();
719
    public void beginComplexNotification() {
720
        this.delegateObservable.beginComplexNotification();
721 721

  
722
	}
722
    }
723 723

  
724
	public void endComplexNotification() {
725
		this.delegateObservable.endComplexNotification();
724
    public void endComplexNotification() {
725
        this.delegateObservable.endComplexNotification();
726 726

  
727
	}
727
    }
728 728

  
729
	public void addObserver(Observer observer) {
730
		this.delegateObservable.addObserver(observer);
729
    public void addObserver(Observer observer) {
730
        this.delegateObservable.addObserver(observer);
731 731

  
732
	}
732
    }
733 733

  
734
	public void deleteObserver(Observer observer) {
735
		if (delegateObservable != null) {
736
			this.delegateObservable.deleteObserver(observer);
737
		}
738
	}
734
    public void deleteObserver(Observer observer) {
735
        if (delegateObservable != null) {
736
            this.delegateObservable.deleteObserver(observer);
737
        }
738
    }
739 739

  
740
	public void deleteObservers() {
741
		this.delegateObservable.deleteObservers();
740
    public void deleteObservers() {
741
        this.delegateObservable.deleteObservers();
742 742

  
743
	}
743
    }
744 744

  
745
	//
746
	// ====================================================================
747
	// Interface Observer
748
	//
749
	// Usado para observar:
750
	// - su seleccion
751
	// - sus bloqueos
752
	// - sus recursos
753
	//
745
    //
746
    // ====================================================================
747
    // Interface Observer
748
    //
749
    // Usado para observar:
750
    // - su seleccion
751
    // - sus bloqueos
752
    // - sus recursos
753
    //
754 754

  
755
	public void update(Observable observable, Object notification) {
756
		if (observable instanceof FeatureSet) {
757
			if (observable == this.selection) {
758
				this.notifyChange(FeatureStoreNotification.SELECTION_CHANGE);
759
			} else if (observable == this.locks) {
760
				this.notifyChange(FeatureStoreNotification.LOCKS_CHANGE);
761
			}
755
    public void update(Observable observable, Object notification) {
756
        if (observable instanceof FeatureSet) {
757
            if (observable == this.selection) {
758
                this.notifyChange(FeatureStoreNotification.SELECTION_CHANGE);
759
            } else if (observable == this.locks) {
760
                this.notifyChange(FeatureStoreNotification.LOCKS_CHANGE);
761
            }
762 762

  
763
		} else if (observable instanceof FeatureStoreProvider) {
764
			if (observable == this.provider) {
763
        } else if (observable instanceof FeatureStoreProvider) {
764
            if (observable == this.provider) {
765 765

  
766
			}
766
            }
767 767

  
768
		}
769
	}
768
        }
769
    }
770 770

  
771
	//
772
	// ====================================================================
773
	// Edicion
774
	//
771
    //
772
    // ====================================================================
773
    // Edicion
774
    //
775 775

  
776
	private void newVersionOfUpdate() {
777
		this.versionOfUpdate++;
778
	}
776
    private void newVersionOfUpdate() {
777
        this.versionOfUpdate++;
778
    }
779 779

  
780
	private long currentVersionOfUpdate() {
781
		return this.versionOfUpdate;
782
	}
780
    private long currentVersionOfUpdate() {
781
        return this.versionOfUpdate;
782
    }
783 783

  
784
	private void checkInEditingMode()
785
	throws NeedEditingModeException {
786
		if (mode != MODE_FULLEDIT) {
787
			throw new NeedEditingModeException(this.getName());
788
		}
789
	}
784
    private void checkInEditingMode()
785
    throws NeedEditingModeException {
786
        if (mode != MODE_FULLEDIT) {
787
            throw new NeedEditingModeException(this.getName());
788
        }
789
    }
790 790

  
791
	private void checkNotInAppendMode() throws IllegalStateException {
792
		if (mode == MODE_APPEND) {
793
			throw new IllegalStateException(this.getName());
794
		}
795
	}
791
    private void checkNotInAppendMode() throws IllegalStateException {
792
        if (mode == MODE_APPEND) {
793
            throw new IllegalStateException(this.getName());
794
        }
795
    }
796 796

  
797
	private void checkIsOwnFeature(Feature feature)
798
	throws IllegalFeatureException {
799
		if (((DefaultFeature) feature).getStore() != this) {
800
			throw new IllegalFeatureException(this.getName());
801
		}
802
		// FIXME: fixFeatureType no vale para el checkIsOwnFeature
803
		// fixFeatureType((DefaultFeatureType) feature.getType());
804
	}
797
    private void checkIsOwnFeature(Feature feature)
798
    throws IllegalFeatureException {
799
        if (((DefaultFeature) feature).getStore() != this) {
800
            throw new IllegalFeatureException(this.getName());
801
        }
802
        // FIXME: fixFeatureType no vale para el checkIsOwnFeature
803
        // fixFeatureType((DefaultFeatureType) feature.getType());
804
    }
805 805

  
806
	private void exitEditingMode() {
807
		if (commands != null) {
808
			commands.clear();
809
			commands = null;
810
		}
806
    private void exitEditingMode() {
807
        if (commands != null) {
808
            commands.clear();
809
            commands = null;
810
        }
811 811

  
812
		if (featureTypeManager != null) {
813
			featureTypeManager.dispose();
814
			featureTypeManager = null;
812
        if (featureTypeManager != null) {
813
            featureTypeManager.dispose();
814
            featureTypeManager = null;
815 815

  
816
		}
816
        }
817 817

  
818
		// TODO implementar un dispose para estos dos
819
		featureManager = null;
820
		spatialManager = null;
818
        // TODO implementar un dispose para estos dos
819
        featureManager = null;
820
        spatialManager = null;
821 821

  
822
		featureCount = null;
822
        featureCount = null;
823 823

  
824
		mode = MODE_QUERY;
825
		hasStrongChanges = true; // Lo deja a true por si las moscas
826
		hasInserts = true;
827
	}
824
        mode = MODE_QUERY;
825
        hasStrongChanges = true; // Lo deja a true por si las moscas
826
        hasInserts = true;
827
    }
828 828

  
829
	synchronized public void edit() throws DataException {
830
		edit(MODE_FULLEDIT);
831
	}
829
    synchronized public void edit() throws DataException {
830
        edit(MODE_FULLEDIT);
831
    }
832 832

  
833
	synchronized public void edit(int mode) throws DataException {
834
		try {
835
			if ( this.mode != MODE_QUERY ) {
836
				throw new AlreadyEditingException(this.getName());
837
			}
838
			if (!this.provider.supportsAppendMode()) {
839
				mode = MODE_FULLEDIT;
840
			}
841
			switch (mode) {
842
			case MODE_QUERY:
843
				throw new IllegalStateException(this.getName());
833
    synchronized public void edit(int mode) throws DataException {
834
        try {
835
            if ( this.mode != MODE_QUERY ) {
836
                throw new AlreadyEditingException(this.getName());
837
            }
838
            if (!this.provider.supportsAppendMode()) {
839
                mode = MODE_FULLEDIT;
840
            }
841
            switch (mode) {
842
            case MODE_QUERY:
843
                throw new IllegalStateException(this.getName());
844 844

  
845
			case MODE_FULLEDIT:
846
				if (!this.transforms.isEmpty()) {
847
					throw new IllegalStateException(this.getName());
848
				}
849
				notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING);
850
				featureManager = new FeatureManager(new MemoryExpansionAdapter());
851
				featureTypeManager = new FeatureTypeManager(this,
852
						new MemoryExpansionAdapter());
853
				spatialManager = new SpatialManager(this, provider
854
						.getEnvelope());
845
            case MODE_FULLEDIT:
846
                if (!this.transforms.isEmpty()) {
847
                    throw new IllegalStateException(this.getName());
848
                }
849
                notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING);
850
                featureManager = new FeatureManager(new MemoryExpansionAdapter());
851
                featureTypeManager = new FeatureTypeManager(this,
852
                    new MemoryExpansionAdapter());
853
                spatialManager = new SpatialManager(this, provider
854
                    .getEnvelope());
855 855

  
856
				commands = new DefaultFeatureCommandsStack(featureManager,
857
						spatialManager, featureTypeManager);
858
				this.mode = MODE_FULLEDIT;
859
				hasStrongChanges = false;
860
				hasInserts = false;
861
				notifyChange(FeatureStoreNotification.AFTER_STARTEDITING);
862
				break;
863
			case MODE_APPEND:
864
				if (!this.transforms.isEmpty()) {
865
					throw new IllegalStateException(this.getName());
866
				}
867
				notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING);
868
				this.provider.beginAppend();
869
				this.mode = MODE_APPEND;
870
				hasInserts = false;
871
				notifyChange(FeatureStoreNotification.AFTER_STARTEDITING);
872
				break;
873
			}
874
		} catch (Exception e) {
875
			throw new StoreEditException(e, this.getName());
876
		}
877
	}
856
                commands = new DefaultFeatureCommandsStack(featureManager,
857
                    spatialManager, featureTypeManager);
858
                this.mode = MODE_FULLEDIT;
859
                hasStrongChanges = false;
860
                hasInserts = false;
861
                notifyChange(FeatureStoreNotification.AFTER_STARTEDITING);
862
                break;
863
            case MODE_APPEND:
864
                if (!this.transforms.isEmpty()) {
865
                    throw new IllegalStateException(this.getName());
866
                }
867
                notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING);
868
                this.provider.beginAppend();
869
                this.mode = MODE_APPEND;
870
                hasInserts = false;
871
                notifyChange(FeatureStoreNotification.AFTER_STARTEDITING);
872
                break;
873
            }
874
        } catch (Exception e) {
875
            throw new StoreEditException(e, this.getName());
876
        }
877
    }
878 878

  
879
	public boolean isEditing() {
880
		return mode == MODE_FULLEDIT;
881
	}
879
    public boolean isEditing() {
880
        return mode == MODE_FULLEDIT;
881
    }
882 882

  
883
	public boolean isAppending() {
884
		return mode == MODE_APPEND;
885
	}
883
    public boolean isAppending() {
884
        return mode == MODE_APPEND;
885
    }
886 886

  
887
	synchronized public void update(EditableFeatureType type)
888
	throws DataException {
889
		try {
890
			checkInEditingMode();
891
			if (type == null) {
892
				throw new NullFeatureTypeException(getName());
893
			}
894
			// FIXME: Comprobar que es un featureType aceptable.
895
			notifyChange(FeatureStoreNotification.BEFORE_UPDATE_TYPE, type);
896
			newVersionOfUpdate();
887
    synchronized public void update(EditableFeatureType type)
888
    throws DataException {
889
        try {
890
            checkInEditingMode();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff