Revision 35115 branches/dal_time_support/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java
DefaultFeatureStore.java | ||
---|---|---|
25 | 25 |
* 2008 IVER T.I. S.A. {{Task}} |
26 | 26 |
*/ |
27 | 27 |
|
28 |
|
|
29 | 28 |
package org.gvsig.fmap.dal.feature.impl; |
30 | 29 |
|
31 | 30 |
import java.util.ArrayList; |
... | ... | |
36 | 35 |
import java.util.Iterator; |
37 | 36 |
import java.util.List; |
38 | 37 |
import java.util.Map; |
39 |
import java.util.Map.Entry; |
|
40 | 38 |
import java.util.Set; |
39 |
import java.util.Map.Entry; |
|
41 | 40 |
|
42 | 41 |
import org.cresques.cts.IProjection; |
43 | 42 |
import org.slf4j.Logger; |
... | ... | |
56 | 55 |
import org.gvsig.fmap.dal.exception.DataException; |
57 | 56 |
import org.gvsig.fmap.dal.exception.InitializeException; |
58 | 57 |
import org.gvsig.fmap.dal.exception.OpenException; |
59 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
60 | 58 |
import org.gvsig.fmap.dal.exception.ReadException; |
61 | 59 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
62 | 60 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
... | ... | |
122 | 120 |
import org.gvsig.metadata.MetadataManager; |
123 | 121 |
import org.gvsig.metadata.exceptions.MetadataException; |
124 | 122 |
import org.gvsig.timesupport.Interval; |
125 |
import org.gvsig.timesupport.RelativeInterval; |
|
126 | 123 |
import org.gvsig.tools.ToolsLocator; |
127 | 124 |
import org.gvsig.tools.dispose.DisposableIterator; |
128 | 125 |
import org.gvsig.tools.dispose.impl.AbstractDisposable; |
... | ... | |
142 | 139 |
import org.gvsig.tools.persistence.Persistent; |
143 | 140 |
import org.gvsig.tools.persistence.PersistentState; |
144 | 141 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
145 |
import org.gvsig.tools.task.Executor; |
|
146 | 142 |
import org.gvsig.tools.undo.RedoException; |
147 | 143 |
import org.gvsig.tools.undo.UndoException; |
148 | 144 |
import org.gvsig.tools.undo.command.Command; |
149 | 145 |
import org.gvsig.tools.visitor.Visitor; |
150 | 146 |
|
151 | 147 |
public final class DefaultFeatureStore extends AbstractDisposable implements |
152 |
DataStoreImplementation, FeatureStoreProviderServices, FeatureStore, |
|
153 |
Observer { |
|
148 |
DataStoreImplementation, FeatureStoreProviderServices, FeatureStore,
|
|
149 |
Observer {
|
|
154 | 150 |
|
155 |
final static private Logger logger = LoggerFactory
|
|
156 |
.getLogger(DefaultFeatureStore.class); |
|
151 |
final static private Logger logger = |
|
152 |
LoggerFactory.getLogger(DefaultFeatureStore.class);
|
|
157 | 153 |
|
158 | 154 |
private static final String PERSISTENCE_DEFINITION_NAME = "FeatureStore"; |
159 | 155 |
|
... | ... | |
161 | 157 |
private FeatureSelection selection; |
162 | 158 |
private FeatureLocks locks; |
163 | 159 |
|
164 |
private DelegateWeakReferencingObservable delegateObservable = new DelegateWeakReferencingObservable(this); |
|
160 |
private DelegateWeakReferencingObservable delegateObservable = |
|
161 |
new DelegateWeakReferencingObservable(this); |
|
165 | 162 |
|
166 | 163 |
private FeatureCommandsStack commands; |
167 | 164 |
private FeatureTypeManager featureTypeManager; |
... | ... | |
195 | 192 |
|
196 | 193 |
/* |
197 | 194 |
* TODO: |
198 |
* |
|
195 |
*
|
|
199 | 196 |
* - Comprobar que solo se pueden a�adir reglas de validacion sobre un |
200 | 197 |
* EditableFeatureType. - Comprobar que solo se puede hacer un update con un |
201 | 198 |
* featureType al que se le han cambiado las reglas de validacion cuando |
... | ... | |
211 | 208 |
|
212 | 209 |
DynObjectManager dynManager = ToolsLocator.getDynObjectManager(); |
213 | 210 |
|
214 |
this.metadata = (DelegatedDynObject) dynManager |
|
215 |
.createDynObject( |
|
216 |
METADATA_DEFINITION_NAME, |
|
217 |
MetadataManager.METADATA_NAMESPACE |
|
218 |
); |
|
211 |
this.metadata = |
|
212 |
(DelegatedDynObject) dynManager.createDynObject( |
|
213 |
METADATA_DEFINITION_NAME, MetadataManager.METADATA_NAMESPACE); |
|
219 | 214 |
|
220 |
|
|
221 | 215 |
this.dataManager = dataManager; |
222 | 216 |
|
223 | 217 |
this.parameters = parameters; |
... | ... | |
268 | 262 |
|
269 | 263 |
public void open() throws OpenException { |
270 | 264 |
// TODO: Se puede hacer un open estando en edicion ? |
271 |
this.notifyChange(FeatureStoreNotification.BEFORE_OPEN);
|
|
265 |
this.notifyChange(DataStoreNotification.BEFORE_OPEN);
|
|
272 | 266 |
this.provider.open(); |
273 |
this.notifyChange(FeatureStoreNotification.AFTER_OPEN);
|
|
267 |
this.notifyChange(DataStoreNotification.AFTER_OPEN);
|
|
274 | 268 |
} |
275 | 269 |
|
276 | 270 |
public void refresh() throws OpenException, InitializeException { |
... | ... | |
285 | 279 |
|
286 | 280 |
public void close() throws CloseException { |
287 | 281 |
// TODO: Se puede hacer un close estando en edicion ? |
288 |
this.notifyChange(FeatureStoreNotification.BEFORE_CLOSE);
|
|
282 |
this.notifyChange(DataStoreNotification.BEFORE_CLOSE);
|
|
289 | 283 |
this.featureCount = null; |
290 | 284 |
this.provider.close(); |
291 |
this.notifyChange(FeatureStoreNotification.AFTER_CLOSE);
|
|
285 |
this.notifyChange(DataStoreNotification.AFTER_CLOSE);
|
|
292 | 286 |
} |
293 | 287 |
|
294 | 288 |
protected void doDispose() throws BaseException { |
295 |
this.notifyChange(FeatureStoreNotification.BEFORE_DISPOSE);
|
|
289 |
this.notifyChange(DataStoreNotification.BEFORE_DISPOSE);
|
|
296 | 290 |
this.provider.dispose(); |
297 | 291 |
if (this.selection != null) { |
298 | 292 |
this.selection.dispose(); |
... | ... | |
301 | 295 |
this.commands = null; |
302 | 296 |
this.featureCount = null; |
303 | 297 |
if (this.locks != null) { |
304 |
//this.locks.dispose(); |
|
298 |
// this.locks.dispose();
|
|
305 | 299 |
this.locks = null; |
306 | 300 |
} |
307 | 301 |
|
... | ... | |
314 | 308 |
this.spatialManager = null; |
315 | 309 |
|
316 | 310 |
this.parameters = null; |
317 |
this.notifyChange(FeatureStoreNotification.AFTER_DISPOSE);
|
|
311 |
this.notifyChange(DataStoreNotification.AFTER_DISPOSE);
|
|
318 | 312 |
if (delegateObservable != null) { |
319 | 313 |
this.delegateObservable.deleteObservers(); |
320 | 314 |
this.delegateObservable = null; |
... | ... | |
330 | 324 |
} |
331 | 325 |
|
332 | 326 |
public DataServerExplorer getExplorer() throws ReadException, |
333 |
ValidateDataParametersException { |
|
327 |
ValidateDataParametersException {
|
|
334 | 328 |
return this.provider.getExplorer(); |
335 | 329 |
} |
336 | 330 |
|
337 | 331 |
/* |
338 |
public Metadata getMetadata() throws MetadataNotFoundException {
|
|
339 |
// TODO:
|
|
340 |
// Si el provider devuelbe null habria que ver de construir aqui
|
|
341 |
// los metadatos basicos, como el Envelope y el SRS.
|
|
342 |
|
|
343 |
// TODO: Estando en edicion el Envelope deberia de
|
|
344 |
// actualizarse usando el spatialManager
|
|
345 |
return this.provider.getMetadata();
|
|
346 |
}
|
|
332 |
* public Metadata getMetadata() throws MetadataNotFoundException {
|
|
333 |
* // TODO:
|
|
334 |
* // Si el provider devuelbe null habria que ver de construir aqui
|
|
335 |
* // los metadatos basicos, como el Envelope y el SRS.
|
|
336 |
* |
|
337 |
* // TODO: Estando en edicion el Envelope deberia de
|
|
338 |
* // actualizarse usando el spatialManager
|
|
339 |
* return this.provider.getMetadata();
|
|
340 |
* }
|
|
347 | 341 |
*/ |
348 | 342 |
|
349 | 343 |
public Envelope getEnvelope() throws DataException { |
... | ... | |
361 | 355 |
} |
362 | 356 |
|
363 | 357 |
public FeatureSelection createDefaultFeatureSelection() |
364 |
throws DataException { |
|
358 |
throws DataException {
|
|
365 | 359 |
return new DefaultFeatureSelection(this); |
366 | 360 |
} |
367 | 361 |
|
368 | 362 |
public FeatureProvider createDefaultFeatureProvider(FeatureType type) |
369 |
throws DataException { |
|
370 |
if( type.hasOID() ) { |
|
371 |
return new DefaultFeatureProvider(type, this.provider.createNewOID()); |
|
363 |
throws DataException { |
|
364 |
if (type.hasOID()) { |
|
365 |
return new DefaultFeatureProvider(type, this.provider |
|
366 |
.createNewOID()); |
|
372 | 367 |
} |
373 | 368 |
return new DefaultFeatureProvider(type); |
374 | 369 |
} |
375 | 370 |
|
376 | 371 |
public void saveToState(PersistentState state) throws PersistenceException { |
377 |
if (this.mode != FeatureStore.MODE_QUERY){ |
|
378 |
throw new PersistenceException( |
|
379 |
new IllegalStateException(this |
|
380 |
.getName())); |
|
372 |
if (this.mode != FeatureStore.MODE_QUERY) { |
|
373 |
throw new PersistenceException(new IllegalStateException(this |
|
374 |
.getName())); |
|
381 | 375 |
} |
382 | 376 |
state.set("dataStoreName", this.getName()); |
383 | 377 |
state.set("parameters", this.parameters); |
... | ... | |
399 | 393 |
iterAttr = type.iterator(); |
400 | 394 |
while (iterAttr.hasNext()) { |
401 | 395 |
attr = (DefaultFeatureAttributeDescriptor) iterAttr.next(); |
402 |
if (attr.getEvaluator() != null
|
|
403 |
&& attr.getEvaluator() instanceof Persistent) {
|
|
396 |
if ((attr.getEvaluator() != null)
|
|
397 |
&& (attr.getEvaluator() instanceof Persistent)) {
|
|
404 | 398 |
attrs.add(attr); |
405 | 399 |
} |
406 | 400 |
} |
... | ... | |
408 | 402 |
evaluatedAttr.put(type.getId(), attrs); |
409 | 403 |
} |
410 | 404 |
|
411 |
|
|
412 | 405 |
} |
413 | 406 |
|
414 | 407 |
if (evaluatedAttr.isEmpty()) { |
... | ... | |
420 | 413 |
|
421 | 414 |
} |
422 | 415 |
|
423 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
416 |
public void loadFromState(PersistentState state) |
|
417 |
throws PersistenceException { |
|
424 | 418 |
if (this.provider != null) { |
425 | 419 |
throw new PersistenceStoreAlreadyLoadedException(this.getName()); |
426 | 420 |
} |
... | ... | |
428 | 422 |
this.dataManager = (DefaultDataManager) DALLocator.getDataManager(); |
429 | 423 |
} |
430 | 424 |
|
431 |
DataStoreParameters params = (DataStoreParameters) state.get("parameters"); |
|
425 |
DataStoreParameters params = |
|
426 |
(DataStoreParameters) state.get("parameters"); |
|
432 | 427 |
|
433 | 428 |
try { |
434 | 429 |
|
435 | 430 |
this.dataManager.intializeDataStore(this, params); |
436 | 431 |
this.selection = (FeatureSelection) state.get("selection"); |
437 |
this.transforms = (DefaultFeatureStoreTransforms) state.get("transforms"); |
|
432 |
this.transforms = |
|
433 |
(DefaultFeatureStoreTransforms) state.get("transforms"); |
|
438 | 434 |
Map evaluatedAttributes = (Map) state.get("evaluatedAttributes"); |
439 |
if (evaluatedAttributes != null && !evaluatedAttributes.isEmpty()) {
|
|
435 |
if ((evaluatedAttributes != null) && !evaluatedAttributes.isEmpty()) {
|
|
440 | 436 |
List attrs; |
441 |
Iterator iterEntries = evaluatedAttributes.entrySet().iterator(); |
|
437 |
Iterator iterEntries = |
|
438 |
evaluatedAttributes.entrySet().iterator(); |
|
442 | 439 |
Entry entry; |
443 |
while (iterEntries.hasNext()){ |
|
440 |
while (iterEntries.hasNext()) {
|
|
444 | 441 |
entry = (Entry) iterEntries.next(); |
445 | 442 |
attrs = (List) entry.getValue(); |
446 |
if (attrs.isEmpty()){ |
|
443 |
if (attrs.isEmpty()) {
|
|
447 | 444 |
continue; |
448 | 445 |
} |
449 | 446 |
int fTypePos = -1; |
450 | 447 |
DefaultFeatureType type = null; |
451 |
for (int i=0;i<featureTypes.size();i++){
|
|
448 |
for (int i = 0; i < featureTypes.size(); i++) {
|
|
452 | 449 |
type = (DefaultFeatureType) featureTypes.get(i); |
453 |
if (type.getId().equals(entry.getKey())){ |
|
450 |
if (type.getId().equals(entry.getKey())) {
|
|
454 | 451 |
fTypePos = i; |
455 | 452 |
break; |
456 | 453 |
} |
457 | 454 |
} |
458 |
if (fTypePos < 0){ |
|
459 |
throw new PersistenceCantFindFeatureTypeException(this.getName(), (String)entry.getKey()); |
|
455 |
if (fTypePos < 0) { |
|
456 |
throw new PersistenceCantFindFeatureTypeException(this |
|
457 |
.getName(), (String) entry.getKey()); |
|
460 | 458 |
} |
461 |
DefaultEditableFeatureType eType = (DefaultEditableFeatureType) type
|
|
462 |
.getEditable(); |
|
459 |
DefaultEditableFeatureType eType = |
|
460 |
(DefaultEditableFeatureType) type.getEditable();
|
|
463 | 461 |
Iterator iterAttr = attrs.iterator(); |
464 | 462 |
FeatureAttributeDescriptor attr; |
465 | 463 |
while (iterAttr.hasNext()) { |
... | ... | |
470 | 468 |
|
471 | 469 |
} |
472 | 470 |
|
473 |
|
|
474 | 471 |
} |
475 | 472 |
|
476 | 473 |
String defFTypeid = state.getString("defaultFeatureTypeId"); |
... | ... | |
480 | 477 |
|
481 | 478 |
ftype = getFeatureType(defFTypeid); |
482 | 479 |
if (ftype == null) { |
483 |
throw new PersistenceCantFindDefaultFeatureTypeException(this.getName(), defFTypeid); |
|
480 |
throw new PersistenceCantFindDefaultFeatureTypeException( |
|
481 |
this.getName(), defFTypeid); |
|
484 | 482 |
} |
485 | 483 |
this.defaultFeatureType = ftype; |
486 | 484 |
} |
487 | 485 |
|
488 |
|
|
489 | 486 |
} catch (InitializeException e) { |
490 | 487 |
throw new PersistenceException(e); |
491 | 488 |
} catch (DataException e) { |
... | ... | |
496 | 493 |
|
497 | 494 |
public static void registerPersistenceDefinition() { |
498 | 495 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
499 |
if( manager.getDefinition(PERSISTENCE_DEFINITION_NAME)==null ) { |
|
500 |
DynStruct definition = manager.addDefinition( |
|
501 |
DefaultFeatureStore.class, |
|
502 |
PERSISTENCE_DEFINITION_NAME, |
|
503 |
PERSISTENCE_DEFINITION_NAME+" Persistent definition", |
|
504 |
null, |
|
505 |
null |
|
506 |
); |
|
507 |
definition.addDynFieldString("dataStoreName") |
|
508 |
.setMandatory(true) |
|
509 |
.setPersistent(true); |
|
496 |
if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
|
497 |
DynStruct definition = |
|
498 |
manager.addDefinition(DefaultFeatureStore.class, |
|
499 |
PERSISTENCE_DEFINITION_NAME, PERSISTENCE_DEFINITION_NAME |
|
500 |
+ " Persistent definition", null, null); |
|
501 |
definition.addDynFieldString("dataStoreName").setMandatory(true) |
|
502 |
.setPersistent(true); |
|
510 | 503 |
|
511 |
definition.addDynFieldObject("parameters") |
|
512 |
.setClassOfValue(DynObject.class) |
|
513 |
.setMandatory(true) |
|
514 |
.setPersistent(true); |
|
504 |
definition.addDynFieldObject("parameters").setClassOfValue( |
|
505 |
DynObject.class).setMandatory(true).setPersistent(true); |
|
515 | 506 |
|
516 |
definition.addDynFieldObject("selection") |
|
517 |
.setClassOfValue(FeatureSelection.class) |
|
518 |
.setMandatory(false) |
|
519 |
.setPersistent(true); |
|
507 |
definition.addDynFieldObject("selection").setClassOfValue( |
|
508 |
FeatureSelection.class).setMandatory(false).setPersistent(true); |
|
520 | 509 |
|
521 |
definition.addDynFieldObject("transforms") |
|
522 |
.setClassOfValue(DefaultFeatureStoreTransforms.class) |
|
523 |
.setMandatory(true) |
|
524 |
.setPersistent(true); |
|
510 |
definition.addDynFieldObject("transforms").setClassOfValue( |
|
511 |
DefaultFeatureStoreTransforms.class).setMandatory(true) |
|
512 |
.setPersistent(true); |
|
525 | 513 |
|
526 |
definition.addDynFieldMap("evaluatedAttributes") |
|
527 |
.setClassOfItems(List.class) // List<DefaultFeatureAttributeDescriptor> |
|
528 |
.setMandatory(false) |
|
529 |
.setPersistent(true); |
|
514 |
definition.addDynFieldMap("evaluatedAttributes").setClassOfItems( |
|
515 |
List.class) // List<DefaultFeatureAttributeDescriptor> |
|
516 |
.setMandatory(false).setPersistent(true); |
|
530 | 517 |
|
531 |
definition.addDynFieldString("defaultFeatureTypeId") |
|
532 |
.setMandatory(true) |
|
533 |
.setPersistent(true); |
|
518 |
definition.addDynFieldString("defaultFeatureTypeId").setMandatory( |
|
519 |
true).setPersistent(true); |
|
534 | 520 |
} |
535 | 521 |
} |
536 | 522 |
|
537 | 523 |
public static void registerMetadataDefinition() throws MetadataException { |
538 | 524 |
MetadataManager manager = MetadataLocator.getMetadataManager(); |
539 |
if( manager.getDefinition(METADATA_DEFINITION_NAME)==null ) { |
|
540 |
DynStruct metadataDefinition = manager.addDefinition( |
|
541 |
METADATA_DEFINITION_NAME, |
|
542 |
null |
|
543 |
); |
|
544 |
metadataDefinition.extend( |
|
545 |
manager.getDefinition( |
|
546 |
DataStore.METADATA_DEFINITION_NAME |
|
547 |
) |
|
548 |
); |
|
525 |
if (manager.getDefinition(METADATA_DEFINITION_NAME) == null) { |
|
526 |
DynStruct metadataDefinition = |
|
527 |
manager.addDefinition(METADATA_DEFINITION_NAME, null); |
|
528 |
metadataDefinition.extend(manager |
|
529 |
.getDefinition(DataStore.METADATA_DEFINITION_NAME)); |
|
549 | 530 |
} |
550 | 531 |
} |
551 | 532 |
|
... | ... | |
554 | 535 |
// Gestion de la seleccion |
555 | 536 |
// |
556 | 537 |
|
557 |
public void setSelection(DataSet selection) |
|
558 |
throws DataException { |
|
538 |
public void setSelection(DataSet selection) throws DataException { |
|
559 | 539 |
this.setSelection((FeatureSet) selection); |
560 | 540 |
} |
561 | 541 |
|
... | ... | |
577 | 557 |
* if the action must be undoable |
578 | 558 |
*/ |
579 | 559 |
public void setSelection(FeatureSet selection, boolean undoable) |
580 |
throws DataException { |
|
560 |
throws DataException {
|
|
581 | 561 |
if (selection == null) { |
582 | 562 |
if (undoable) { |
583 | 563 |
throw new SelectionNotAllowedException(getName()); |
... | ... | |
616 | 596 |
commands.startComplex("_selectionSet"); |
617 | 597 |
} |
618 | 598 |
if (selection instanceof DefaultFeatureSelection) { |
619 |
DefaultFeatureSelection defSelection = (DefaultFeatureSelection) selection; |
|
599 |
DefaultFeatureSelection defSelection = |
|
600 |
(DefaultFeatureSelection) selection; |
|
620 | 601 |
defSelection.deselectAll(undoable); |
621 | 602 |
defSelection.select(selection, undoable); |
622 | 603 |
} else { |
... | ... | |
651 | 632 |
|
652 | 633 |
public void notifyChange(String notification) { |
653 | 634 |
if (delegateObservable != null) { |
654 |
notifyChange(new DefaultFeatureStoreNotification( |
|
655 |
this, notification)); |
|
635 |
notifyChange(new DefaultFeatureStoreNotification(this, notification)); |
|
656 | 636 |
} |
657 | 637 |
|
658 | 638 |
} |
659 | 639 |
|
660 |
public void notifyChange(String notification, FeatureProvider data) {
|
|
661 |
try {
|
|
662 |
notifyChange(notification, createFeature(data));
|
|
663 |
} catch (DataException ex) {
|
|
664 |
logger.error("Error notifying about the notification: "
|
|
665 |
+ notification + ", with the data: " + data, ex);
|
|
666 |
}
|
|
667 |
}
|
|
640 |
public void notifyChange(String notification, FeatureProvider data) {
|
|
641 |
try {
|
|
642 |
notifyChange(notification, createFeature(data));
|
|
643 |
} catch (DataException ex) {
|
|
644 |
logger.error("Error notifying about the notification: "
|
|
645 |
+ notification + ", with the data: " + data, ex);
|
|
646 |
}
|
|
647 |
}
|
|
668 | 648 |
|
669 | 649 |
public void notifyChange(String notification, Feature feature) { |
670 |
notifyChange(new DefaultFeatureStoreNotification(
|
|
671 |
this, notification, feature));
|
|
650 |
notifyChange(new DefaultFeatureStoreNotification(this, notification,
|
|
651 |
feature)); |
|
672 | 652 |
} |
673 | 653 |
|
674 | 654 |
public void notifyChange(String notification, Command command) { |
675 |
notifyChange(new DefaultFeatureStoreNotification(
|
|
676 |
this, notification, command));
|
|
655 |
notifyChange(new DefaultFeatureStoreNotification(this, notification,
|
|
656 |
command)); |
|
677 | 657 |
} |
678 | 658 |
|
679 | 659 |
public void notifyChange(String notification, EditableFeatureType type) { |
680 |
notifyChange(new DefaultFeatureStoreNotification(this,
|
|
681 |
notification, type));
|
|
660 |
notifyChange(new DefaultFeatureStoreNotification(this, notification,
|
|
661 |
type)); |
|
682 | 662 |
} |
683 | 663 |
|
684 |
public void notifyChange(FeatureStoreNotification storeNotification) {
|
|
685 |
delegateObservable.notifyObservers(storeNotification);
|
|
686 |
}
|
|
664 |
public void notifyChange(FeatureStoreNotification storeNotification) {
|
|
665 |
delegateObservable.notifyObservers(storeNotification);
|
|
666 |
}
|
|
687 | 667 |
|
688 | 668 |
public void notifyChange(String notification, Resource resource) { |
689 |
notifyChange(new DefaultFeatureStoreNotification(this,
|
|
690 |
FeatureStoreNotification.RESOURCE_CHANGED));
|
|
669 |
notifyChange(new DefaultFeatureStoreNotification(this,
|
|
670 |
DataStoreNotification.RESOURCE_CHANGED));
|
|
691 | 671 |
} |
692 | 672 |
|
693 |
|
|
694 | 673 |
// |
695 | 674 |
// ==================================================================== |
696 | 675 |
// Gestion de bloqueos |
... | ... | |
764 | 743 |
public void update(Observable observable, Object notification) { |
765 | 744 |
if (observable instanceof FeatureSet) { |
766 | 745 |
if (observable == this.selection) { |
767 |
this.notifyChange(FeatureStoreNotification.SELECTION_CHANGE); |
|
768 |
} else if (observable == this.locks) { |
|
769 |
this.notifyChange(FeatureStoreNotification.LOCKS_CHANGE); |
|
770 |
} |
|
746 |
this.notifyChange(DataStoreNotification.SELECTION_CHANGE); |
|
747 |
} else |
|
748 |
if (observable == this.locks) { |
|
749 |
this.notifyChange(FeatureStoreNotification.LOCKS_CHANGE); |
|
750 |
} |
|
771 | 751 |
|
772 |
} else if (observable instanceof FeatureStoreProvider) { |
|
773 |
if (observable == this.provider) { |
|
752 |
} else |
|
753 |
if (observable instanceof FeatureStoreProvider) { |
|
754 |
if (observable == this.provider) { |
|
774 | 755 |
|
775 |
} |
|
756 |
}
|
|
776 | 757 |
|
777 |
} |
|
758 |
}
|
|
778 | 759 |
} |
779 | 760 |
|
780 | 761 |
// |
... | ... | |
790 | 771 |
return this.versionOfUpdate; |
791 | 772 |
} |
792 | 773 |
|
793 |
private void checkInEditingMode() |
|
794 |
throws NeedEditingModeException { |
|
774 |
private void checkInEditingMode() throws NeedEditingModeException { |
|
795 | 775 |
if (mode != MODE_FULLEDIT) { |
796 | 776 |
throw new NeedEditingModeException(this.getName()); |
797 | 777 |
} |
... | ... | |
804 | 784 |
} |
805 | 785 |
|
806 | 786 |
private void checkIsOwnFeature(Feature feature) |
807 |
throws IllegalFeatureException { |
|
787 |
throws IllegalFeatureException {
|
|
808 | 788 |
if (((DefaultFeature) feature).getStore() != this) { |
809 | 789 |
throw new IllegalFeatureException(this.getName()); |
810 | 790 |
} |
... | ... | |
841 | 821 |
|
842 | 822 |
synchronized public void edit(int mode) throws DataException { |
843 | 823 |
try { |
844 |
if ( this.mode != MODE_QUERY ) {
|
|
824 |
if (this.mode != MODE_QUERY) {
|
|
845 | 825 |
throw new AlreadyEditingException(this.getName()); |
846 | 826 |
} |
847 | 827 |
if (!this.provider.supportsAppendMode()) { |
... | ... | |
856 | 836 |
throw new IllegalStateException(this.getName()); |
857 | 837 |
} |
858 | 838 |
notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING); |
859 |
featureManager = new FeatureManager(new MemoryExpansionAdapter()); |
|
860 |
featureTypeManager = new FeatureTypeManager(this, |
|
861 |
new MemoryExpansionAdapter()); |
|
862 |
spatialManager = new SpatialManager(this, provider |
|
863 |
.getEnvelope()); |
|
839 |
featureManager = |
|
840 |
new FeatureManager(new MemoryExpansionAdapter()); |
|
841 |
featureTypeManager = |
|
842 |
new FeatureTypeManager(this, new MemoryExpansionAdapter()); |
|
843 |
spatialManager = |
|
844 |
new SpatialManager(this, provider.getEnvelope()); |
|
864 | 845 |
|
865 |
commands = new DefaultFeatureCommandsStack(featureManager, |
|
866 |
spatialManager, featureTypeManager); |
|
846 |
commands = |
|
847 |
new DefaultFeatureCommandsStack(featureManager, |
|
848 |
spatialManager, featureTypeManager); |
|
867 | 849 |
this.mode = MODE_FULLEDIT; |
868 | 850 |
hasStrongChanges = false; |
869 | 851 |
hasInserts = false; |
... | ... | |
894 | 876 |
} |
895 | 877 |
|
896 | 878 |
synchronized public void update(EditableFeatureType type) |
897 |
throws DataException { |
|
879 |
throws DataException {
|
|
898 | 880 |
try { |
899 | 881 |
checkInEditingMode(); |
900 | 882 |
if (type == null) { |
... | ... | |
937 | 919 |
private static EditableFeature lastChangedFeature = null; |
938 | 920 |
|
939 | 921 |
synchronized public void insert(EditableFeature feature) |
940 |
throws DataException { |
|
922 |
throws DataException {
|
|
941 | 923 |
try { |
942 | 924 |
switch (mode) { |
943 | 925 |
case MODE_QUERY: |
... | ... | |
964 | 946 |
} |
965 | 947 |
notifyChange(FeatureStoreNotification.BEFORE_INSERT, feature); |
966 | 948 |
newVersionOfUpdate(); |
967 |
if (lastChangedFeature ==null || lastChangedFeature.getSource() != feature.getSource()) { |
|
949 |
if ((lastChangedFeature == null) |
|
950 |
|| (lastChangedFeature.getSource() != feature.getSource())) { |
|
968 | 951 |
lastChangedFeature = feature; |
969 | 952 |
feature.validate(Feature.UPDATE); |
970 | 953 |
lastChangedFeature = null; |
... | ... | |
981 | 964 |
} |
982 | 965 |
|
983 | 966 |
synchronized public void update(EditableFeature feature) |
984 |
throws DataException { |
|
967 |
throws DataException {
|
|
985 | 968 |
try { |
986 | 969 |
if ((feature).getSource() == null) { |
987 | 970 |
insert(feature); |
... | ... | |
991 | 974 |
checkIsOwnFeature(feature); |
992 | 975 |
notifyChange(FeatureStoreNotification.BEFORE_UPDATE, feature); |
993 | 976 |
newVersionOfUpdate(); |
994 |
if (lastChangedFeature==null || lastChangedFeature.getSource() != feature.getSource()) { |
|
977 |
if ((lastChangedFeature == null) |
|
978 |
|| (lastChangedFeature.getSource() != feature.getSource())) { |
|
995 | 979 |
lastChangedFeature = feature; |
996 | 980 |
feature.validate(Feature.UPDATE); |
997 | 981 |
lastChangedFeature = null; |
... | ... | |
1037 | 1021 |
} |
1038 | 1022 |
|
1039 | 1023 |
public List getRedoInfos() { |
1040 |
if (isEditing() && commands != null) {
|
|
1024 |
if (isEditing() && (commands != null)) {
|
|
1041 | 1025 |
return commands.getRedoInfos(); |
1042 | 1026 |
} else { |
1043 | 1027 |
return null; |
... | ... | |
1045 | 1029 |
} |
1046 | 1030 |
|
1047 | 1031 |
public List getUndoInfos() { |
1048 |
if (isEditing() && commands != null) {
|
|
1032 |
if (isEditing() && (commands != null)) {
|
|
1049 | 1033 |
return commands.getUndoInfos(); |
1050 | 1034 |
} else { |
1051 | 1035 |
return null; |
... | ... | |
1053 | 1037 |
} |
1054 | 1038 |
|
1055 | 1039 |
public synchronized FeatureCommandsStack getCommandsStack() |
1056 |
throws DataException { |
|
1040 |
throws DataException {
|
|
1057 | 1041 |
checkInEditingMode(); |
1058 | 1042 |
return commands; |
1059 | 1043 |
} |
... | ... | |
1101 | 1085 |
validateFeatures(Feature.FINISH_EDITING); |
1102 | 1086 |
provider.performChanges(featureManager.getDeleted(), |
1103 | 1087 |
featureManager.getInserted(), featureManager |
1104 |
.getUpdated(), featureTypeManager |
|
1105 |
.getFeatureTypesChanged()); |
|
1088 |
.getUpdated(), featureTypeManager
|
|
1089 |
.getFeatureTypesChanged());
|
|
1106 | 1090 |
} |
1107 | 1091 |
exitEditingMode(); |
1108 | 1092 |
notifyChange(FeatureStoreNotification.AFTER_FINISHEDITING); |
... | ... | |
1114 | 1098 |
} |
1115 | 1099 |
|
1116 | 1100 |
public void beginEditingGroup(String description) |
1117 |
throws NeedEditingModeException { |
|
1101 |
throws NeedEditingModeException {
|
|
1118 | 1102 |
checkInEditingMode(); |
1119 | 1103 |
commands.startComplex(description); |
1120 | 1104 |
} |
... | ... | |
1128 | 1112 |
return this.provider.supportsAppendMode(); |
1129 | 1113 |
} |
1130 | 1114 |
|
1115 |
public void export(DataServerExplorer explorer, String provider, |
|
1116 |
NewFeatureStoreParameters params) throws DataException { |
|
1131 | 1117 |
|
1132 |
public void export(DataServerExplorer explorer, String provider, NewFeatureStoreParameters params) |
|
1133 |
throws DataException { |
|
1134 |
|
|
1135 | 1118 |
if (this.getFeatureTypes().size() != 1) { |
1136 | 1119 |
throw new NotYetImplemented( |
1137 |
"export whith more than one type not yet implemented"); |
|
1120 |
"export whith more than one type not yet implemented");
|
|
1138 | 1121 |
} |
1139 |
FeatureSelection featureSelection=(FeatureSelection)getSelection();
|
|
1122 |
FeatureSelection featureSelection = (FeatureSelection) getSelection();
|
|
1140 | 1123 |
FeatureStore target = null; |
1141 | 1124 |
FeatureSet features = null; |
1142 | 1125 |
DisposableIterator iterator = null; |
1143 | 1126 |
try { |
1144 | 1127 |
FeatureType type = this.getDefaultFeatureType(); |
1145 |
if (params.getDefaultFeatureType() == null
|
|
1146 |
|| params.getDefaultFeatureType().size() == 0) {
|
|
1128 |
if ((params.getDefaultFeatureType() == null)
|
|
1129 |
|| (params.getDefaultFeatureType().size() == 0)) {
|
|
1147 | 1130 |
params.setDefaultFeatureType(type.getEditable()); |
1148 | 1131 |
|
1149 | 1132 |
} |
... | ... | |
1155 | 1138 |
|
1156 | 1139 |
target.edit(MODE_APPEND); |
1157 | 1140 |
FeatureAttributeDescriptor[] pk = type.getPrimaryKey(); |
1158 |
if (featureSelection.getSize()>0){
|
|
1141 |
if (featureSelection.getSize() > 0) {
|
|
1159 | 1142 |
features = this.getFeatureSelection(); |
1160 |
}else{
|
|
1161 |
if (pk != null && pk.length > 0){
|
|
1143 |
} else {
|
|
1144 |
if ((pk != null) && (pk.length > 0)) {
|
|
1162 | 1145 |
FeatureQuery query = createFeatureQuery(); |
1163 | 1146 |
for (int i = 0; i < pk.length; i++) { |
1164 | 1147 |
query.getOrder().add(pk[i].getName(), true); |
... | ... | |
1192 | 1175 |
|
1193 | 1176 |
public DataSet getDataSet() throws DataException { |
1194 | 1177 |
checkNotInAppendMode(); |
1195 |
FeatureQuery query = new DefaultFeatureQuery(this
|
|
1196 |
.getDefaultFeatureType()); |
|
1178 |
FeatureQuery query = |
|
1179 |
new DefaultFeatureQuery(this.getDefaultFeatureType());
|
|
1197 | 1180 |
return new DefaultFeatureSet(this, query); |
1198 | 1181 |
} |
1199 | 1182 |
|
1200 |
public DataSet getDataSet(DataQuery dataQuery) |
|
1201 |
throws DataException { |
|
1183 |
public DataSet getDataSet(DataQuery dataQuery) throws DataException { |
|
1202 | 1184 |
checkNotInAppendMode(); |
1203 | 1185 |
return new DefaultFeatureSet(this, (FeatureQuery) dataQuery); |
1204 | 1186 |
} |
... | ... | |
1209 | 1191 |
} |
1210 | 1192 |
|
1211 | 1193 |
public void getDataSet(DataQuery dataQuery, Observer observer) |
1212 |
throws DataException { |
|
1194 |
throws DataException {
|
|
1213 | 1195 |
checkNotInAppendMode(); |
1214 | 1196 |
this.getFeatureSet((FeatureQuery) dataQuery, observer); |
1215 | 1197 |
} |
1216 | 1198 |
|
1217 | 1199 |
public FeatureSet getFeatureSet() throws DataException { |
1218 | 1200 |
checkNotInAppendMode(); |
1219 |
FeatureQuery query = new DefaultFeatureQuery(this
|
|
1220 |
.getDefaultFeatureType()); |
|
1201 |
FeatureQuery query = |
|
1202 |
new DefaultFeatureQuery(this.getDefaultFeatureType());
|
|
1221 | 1203 |
return new DefaultFeatureSet(this, query); |
1222 | 1204 |
} |
1223 | 1205 |
|
1224 | 1206 |
public FeatureSet getFeatureSet(FeatureQuery featureQuery) |
1225 |
throws DataException { |
|
1207 |
throws DataException {
|
|
1226 | 1208 |
checkNotInAppendMode(); |
1227 | 1209 |
return new DefaultFeatureSet(this, featureQuery); |
1228 | 1210 |
} |
... | ... | |
1237 | 1219 |
} |
1238 | 1220 |
|
1239 | 1221 |
public void accept(Visitor visitor, DataQuery dataQuery) |
1240 |
throws BaseException { |
|
1222 |
throws BaseException {
|
|
1241 | 1223 |
FeatureSet set = getFeatureSet((FeatureQuery) dataQuery); |
1242 | 1224 |
try { |
1243 | 1225 |
set.accept(visitor); |
... | ... | |
1247 | 1229 |
} |
1248 | 1230 |
|
1249 | 1231 |
public FeatureType getFeatureType(FeatureQuery featureQuery) |
1250 |
throws DataException { |
|
1251 |
DefaultFeatureType fType = (DefaultFeatureType) this |
|
1252 |
.getFeatureType(featureQuery.getFeatureTypeId()); |
|
1253 |
if (featureQuery.getAttributeNames() != null){ |
|
1232 |
throws DataException { |
|
1233 |
DefaultFeatureType fType = |
|
1234 |
(DefaultFeatureType) this.getFeatureType(featureQuery |
|
1235 |
.getFeatureTypeId()); |
|
1236 |
if (featureQuery.getAttributeNames() != null) { |
|
1254 | 1237 |
return fType.getSubtype(featureQuery.getAttributeNames()); |
1255 | 1238 |
} |
1256 | 1239 |
return fType; |
1257 | 1240 |
} |
1258 | 1241 |
|
1259 |
public void getFeatureSet(Observer observer) |
|
1260 |
throws DataException { |
|
1242 |
public void getFeatureSet(Observer observer) throws DataException { |
|
1261 | 1243 |
checkNotInAppendMode(); |
1262 | 1244 |
this.getFeatureSet(null, observer); |
1263 | 1245 |
} |
1264 | 1246 |
|
1265 | 1247 |
public void getFeatureSet(FeatureQuery query, Observer observer) |
1266 |
throws DataException { |
|
1248 |
throws DataException {
|
|
1267 | 1249 |
class LoadInBackGround implements Runnable { |
1250 |
|
|
1268 | 1251 |
private FeatureStore store; |
1269 | 1252 |
private FeatureQuery query; |
1270 | 1253 |
private Observer observer; |
1271 |
private Executor executor; |
|
1272 |
private FeatureStoreNotification notification; |
|
1273 | 1254 |
|
1274 | 1255 |
public LoadInBackGround(FeatureStore store, FeatureQuery query, |
1275 |
Observer observer, Executor executor) {
|
|
1256 |
Observer observer) { |
|
1276 | 1257 |
this.store = store; |
1277 | 1258 |
this.query = query; |
1278 | 1259 |
this.observer = observer; |
1279 |
this.executor = executor; |
|
1280 | 1260 |
} |
1281 | 1261 |
|
1282 | 1262 |
void notify(FeatureStoreNotification theNotification) { |
1283 |
if (executor == null) { |
|
1284 |
observer.update(store, theNotification); |
|
1285 |
return; |
|
1286 |
} |
|
1287 |
this.notification = theNotification; |
|
1288 |
executor.execute(new Runnable() { |
|
1289 |
public void run() { |
|
1290 |
observer.update(store, notification); |
|
1291 |
} |
|
1292 |
}); |
|
1293 |
|
|
1263 |
observer.update(store, theNotification); |
|
1264 |
return; |
|
1294 | 1265 |
} |
1295 | 1266 |
|
1296 | 1267 |
public void run() { |
... | ... | |
1312 | 1283 |
if (query == null) { |
1313 | 1284 |
query = new DefaultFeatureQuery(this.getDefaultFeatureType()); |
1314 | 1285 |
} |
1315 |
Executor executor = ToolsLocator.getTaskManager().getExecutor(); |
|
1316 |
LoadInBackGround task = new LoadInBackGround(this, query, observer, |
|
1317 |
executor); |
|
1286 |
LoadInBackGround task = new LoadInBackGround(this, query, observer); |
|
1318 | 1287 |
Thread thread = new Thread(task); |
1319 | 1288 |
thread.run(); |
1320 | 1289 |
} |
1321 | 1290 |
|
1322 |
public Feature getFeatureByReference(FeatureReference reference) throws DataException { |
|
1291 |
public Feature getFeatureByReference(FeatureReference reference) |
|
1292 |
throws DataException { |
|
1323 | 1293 |
checkNotInAppendMode(); |
1324 | 1294 |
DefaultFeatureReference ref = (DefaultFeatureReference) reference; |
1325 | 1295 |
FeatureType featureType; |
... | ... | |
1331 | 1301 |
return this.getFeatureByReference(reference, featureType); |
1332 | 1302 |
} |
1333 | 1303 |
|
1334 |
public Feature getFeatureByReference(FeatureReference reference, FeatureType featureType)
|
|
1335 |
throws DataException { |
|
1304 |
public Feature getFeatureByReference(FeatureReference reference, |
|
1305 |
FeatureType featureType) throws DataException {
|
|
1336 | 1306 |
checkNotInAppendMode(); |
1337 | 1307 |
featureType = fixFeatureType((DefaultFeatureType) featureType); |
1338 | 1308 |
if (!this.transforms.isEmpty()) { |
1339 | 1309 |
|
1340 |
featureType = this.transforms |
|
1341 |
.getSourceFeatureTypeFrom(featureType); |
|
1310 |
featureType = this.transforms.getSourceFeatureTypeFrom(featureType); |
|
1342 | 1311 |
|
1343 | 1312 |
} |
1344 | 1313 |
// TODO comprobar que el id es de este store |
1345 | 1314 |
|
1346 | 1315 |
if (this.mode == MODE_FULLEDIT) { |
1347 | 1316 |
Feature f = featureManager.get(reference, this, featureType); |
1348 |
if (f!=null) {
|
|
1317 |
if (f != null) {
|
|
1349 | 1318 |
return f; |
1350 | 1319 |
} |
1351 | 1320 |
} |
1352 |
DefaultFeature feature = new DefaultFeature( |
|
1353 |
this, |
|
1354 |
this.provider |
|
1355 |
.getFeatureProviderByReference( |
|
1356 |
(FeatureReferenceProviderServices) reference, |
|
1357 |
featureType)); |
|
1321 |
DefaultFeature feature = |
|
1322 |
new DefaultFeature(this, this.provider |
|
1323 |
.getFeatureProviderByReference( |
|
1324 |
(FeatureReferenceProviderServices) reference, featureType)); |
|
1358 | 1325 |
|
1359 | 1326 |
if (!this.transforms.isEmpty()) { |
1360 | 1327 |
return this.transforms.applyTransform(feature, featureType); |
... | ... | |
1368 | 1335 |
// |
1369 | 1336 |
|
1370 | 1337 |
private FeatureType fixFeatureType(DefaultFeatureType type) |
1371 |
throws DataException { |
|
1338 |
throws DataException {
|
|
1372 | 1339 |
FeatureType original = this.getDefaultFeatureType(); |
1373 | 1340 |
|
1374 |
if (type == null || type.equals(original)) {
|
|
1341 |
if ((type == null) || type.equals(original)) {
|
|
1375 | 1342 |
return original; |
1376 | 1343 |
} else { |
1377 | 1344 |
if (!type.isSubtypeOf(original)) { |
... | ... | |
1383 | 1350 |
if (type.equals(tmpType)) { |
1384 | 1351 |
return type; |
1385 | 1352 |
|
1386 |
}else if (type.isSubtypeOf(tmpType)) { |
|
1387 |
found = true; |
|
1388 |
original = tmpType; |
|
1389 |
break; |
|
1390 |
} |
|
1353 |
} else |
|
1354 |
if (type.isSubtypeOf(tmpType)) { |
|
1355 |
found = true; |
|
1356 |
original = tmpType; |
|
1357 |
break; |
|
1358 |
} |
|
1391 | 1359 |
|
1392 | 1360 |
} |
1393 | 1361 |
if (!found) { |
... | ... | |
1400 | 1368 |
// else add the missing attributes at the end. |
1401 | 1369 |
if (!original.hasOID()) { |
1402 | 1370 |
// Gets original pk attributes |
1403 |
DefaultEditableFeatureType edOriginal = (DefaultEditableFeatureType) original
|
|
1404 |
.getEditable(); |
|
1371 |
DefaultEditableFeatureType edOriginal = |
|
1372 |
(DefaultEditableFeatureType) original.getEditable();
|
|
1405 | 1373 |
FeatureAttributeDescriptor orgAttr; |
1406 | 1374 |
Iterator edOriginalIter = edOriginal.iterator(); |
1407 | 1375 |
while (edOriginalIter.hasNext()) { |
... | ... | |
1430 | 1398 |
// add missing pk attributes if any |
1431 | 1399 |
if (edOriginal.size() > 0) { |
1432 | 1400 |
boolean isEditable = type instanceof DefaultEditableFeatureType; |
1433 |
DefaultEditableFeatureType edType = (DefaultEditableFeatureType) original
|
|
1434 |
.getEditable(); |
|
1401 |
DefaultEditableFeatureType edType = |
|
1402 |
(DefaultEditableFeatureType) original.getEditable();
|
|
1435 | 1403 |
edType.clear(); |
1436 | 1404 |
edType.addAll(type); |
1437 | 1405 |
edType.addAll(edOriginal); |
... | ... | |
1442 | 1410 |
|
1443 | 1411 |
} |
1444 | 1412 |
|
1445 |
|
|
1446 | 1413 |
return type; |
1447 | 1414 |
} |
1448 | 1415 |
|
... | ... | |
1471 | 1438 |
public FeatureType getDefaultFeatureType() throws DataException { |
1472 | 1439 |
try { |
1473 | 1440 |
if (isEditing()) { |
1474 |
FeatureType auxFeatureType=featureTypeManager.getType(defaultFeatureType.getId()); |
|
1475 |
if (auxFeatureType!=null) { |
|
1441 |
FeatureType auxFeatureType = |
|
1442 |
featureTypeManager.getType(defaultFeatureType.getId()); |
|
1443 |
if (auxFeatureType != null) { |
|
1476 | 1444 |
return auxFeatureType; |
1477 | 1445 |
} |
1478 | 1446 |
} |
... | ... | |
1487 | 1455 |
} |
1488 | 1456 |
|
1489 | 1457 |
public FeatureType getFeatureType(String featureTypeId) |
1490 |
throws DataException { |
|
1458 |
throws DataException {
|
|
1491 | 1459 |
if (featureTypeId == null) { |
1492 | 1460 |
return this.getDefaultFeatureType(); |
1493 | 1461 |
} |
1494 | 1462 |
try { |
1495 | 1463 |
if (isEditing()) { |
1496 |
FeatureType auxFeatureType = featureTypeManager
|
|
1497 |
.getType(featureTypeId); |
|
1464 |
FeatureType auxFeatureType = |
|
1465 |
featureTypeManager.getType(featureTypeId);
|
|
1498 | 1466 |
if (auxFeatureType != null) { |
1499 | 1467 |
return auxFeatureType; |
1500 | 1468 |
} |
... | ... | |
1504 | 1472 |
return type; |
1505 | 1473 |
} |
1506 | 1474 |
Iterator iter = this.featureTypes.iterator(); |
1507 |
while (iter.hasNext()){ |
|
1475 |
while (iter.hasNext()) {
|
|
1508 | 1476 |
type = (FeatureType) iter.next(); |
1509 | 1477 |
if (type.getId().equals(featureTypeId)) { |
1510 | 1478 |
return type; |
... | ... | |
1516 | 1484 |
} |
1517 | 1485 |
} |
1518 | 1486 |
|
1519 |
|
|
1520 | 1487 |
public FeatureType getProviderDefaultFeatureType() { |
1521 | 1488 |
return defaultFeatureType; |
1522 | 1489 |
} |
... | ... | |
1525 | 1492 |
try { |
1526 | 1493 |
List types; |
1527 | 1494 |
if (isEditing()) { |
1528 |
types=new ArrayList();
|
|
1529 |
Iterator it=featureTypes.iterator();
|
|
1495 |
types = new ArrayList();
|
|
1496 |
Iterator it = featureTypes.iterator();
|
|
1530 | 1497 |
while (it.hasNext()) { |
1531 | 1498 |
FeatureType type = (FeatureType) it.next(); |
1532 |
FeatureType typeaux = featureTypeManager.getType(type.getId()); |
|
1533 |
if (typeaux!=null) { |
|
1499 |
FeatureType typeaux = |
|
1500 |
featureTypeManager.getType(type.getId()); |
|
1501 |
if (typeaux != null) { |
|
1534 | 1502 |
types.add(typeaux); |
1535 |
}else{
|
|
1503 |
} else {
|
|
1536 | 1504 |
types.add(type); |
1537 | 1505 |
} |
1538 | 1506 |
} |
... | ... | |
1557 | 1525 |
return Collections.unmodifiableList(this.featureTypes); |
1558 | 1526 |
} |
1559 | 1527 |
|
1560 |
public Feature createFeature(FeatureProvider data) |
|
1561 |
throws DataException { |
|
1528 |
public Feature createFeature(FeatureProvider data) throws DataException { |
|
1562 | 1529 |
DefaultFeature feature = new DefaultFeature(this, data); |
1563 | 1530 |
return feature; |
1564 | 1531 |
} |
1565 | 1532 |
|
1566 | 1533 |
public Feature createFeature(FeatureProvider data, FeatureType type) |
1567 |
throws DataException { |
|
1534 |
throws DataException {
|
|
1568 | 1535 |
// FIXME: falta por implementar |
1569 | 1536 |
// Comprobar si es un subtipo del feature de data |
1570 | 1537 |
// y construir un feature usando el subtipo. |
... | ... | |
1573 | 1540 |
} |
1574 | 1541 |
|
1575 | 1542 |
public EditableFeature createNewFeature(FeatureType type, |
1576 |
Feature defaultValues) |
|
1577 |
throws DataException { |
|
1543 |
Feature defaultValues) throws DataException { |
|
1578 | 1544 |
try { |
1579 | 1545 |
FeatureProvider data = createNewFeatureProvider(type); |
1580 |
DefaultEditableFeature feature = new DefaultEditableFeature(this, data); |
|
1546 |
DefaultEditableFeature feature = |
|
1547 |
new DefaultEditableFeature(this, data); |
|
1581 | 1548 |
feature.initializeValues(defaultValues); |
1582 | 1549 |
return feature; |
1583 | 1550 |
} catch (Exception e) { |
... | ... | |
1586 | 1553 |
} |
1587 | 1554 |
|
1588 | 1555 |
private FeatureProvider createNewFeatureProvider(FeatureType type) |
1589 |
throws DataException { |
|
1556 |
throws DataException {
|
|
1590 | 1557 |
type = this.fixFeatureType((DefaultFeatureType) type); |
1591 | 1558 |
FeatureProvider data = this.provider.createFeatureProvider(type); |
1592 | 1559 |
data.setNew(true); |
1593 |
if (type.hasOID() && data.getOID() == null) {
|
|
1560 |
if (type.hasOID() && (data.getOID() == null)) {
|
|
1594 | 1561 |
data.setOID(this.provider.createNewOID()); |
1595 | 1562 |
} else { |
1596 | 1563 |
data.setOID(this.getTemporalOID()); |
... | ... | |
1600 | 1567 |
} |
1601 | 1568 |
|
1602 | 1569 |
public EditableFeature createNewFeature(FeatureType type, |
1603 |
boolean defaultValues) |
|
1604 |
throws DataException { |
|
1570 |
boolean defaultValues) throws DataException { |
|
1605 | 1571 |
try { |
1606 | 1572 |
FeatureProvider data = createNewFeatureProvider(type); |
1607 |
DefaultEditableFeature feature = new DefaultEditableFeature(this, data); |
|
1573 |
DefaultEditableFeature feature = |
|
1574 |
new DefaultEditableFeature(this, data); |
|
1608 | 1575 |
if (defaultValues) { |
1609 | 1576 |
feature.initializeValues(); |
1610 | 1577 |
} |
... | ... | |
1615 | 1582 |
} |
1616 | 1583 |
|
1617 | 1584 |
public EditableFeature createNewFeature(boolean defaultValues) |
1618 |
throws DataException { |
|
1619 |
return this.createNewFeature(this.getDefaultFeatureType(), defaultValues); |
|
1585 |
throws DataException { |
|
1586 |
return this.createNewFeature(this.getDefaultFeatureType(), |
|
1587 |
defaultValues); |
|
1620 | 1588 |
} |
1621 | 1589 |
|
1622 | 1590 |
public EditableFeature createNewFeature() throws DataException { |
... | ... | |
1633 | 1601 |
return ftype; |
1634 | 1602 |
} |
1635 | 1603 |
|
1636 |
|
|
1637 | 1604 |
// |
1638 | 1605 |
// ==================================================================== |
1639 | 1606 |
// Index related methods |
... | ... | |
1644 | 1611 |
} |
1645 | 1612 |
|
1646 | 1613 |
public FeatureIndex createIndex(FeatureType featureType, |
1647 |
String attributeName, String indexName) throws ProviderNotRegisteredException, InitializeException { |
|
1614 |
String attributeName, String indexName) throws DataException { |
|
1615 |
return createIndex(null, featureType, attributeName, indexName); |
|
1616 |
} |
|
1617 |
|
|
1618 |
public FeatureIndex createIndex(String indexTypeName, |
|
1619 |
FeatureType featureType, String attributeName, String indexName) |
|
1620 |
throws DataException { |
|
1648 | 1621 |
checkNotInAppendMode(); |
1649 | 1622 |
FeatureIndexProviderServices index = null; |
1650 |
index = dataManager.createFeatureIndexProvider(null, this, featureType, |
|
1651 |
indexName, featureType.getAttributeDescriptor(attributeName)); |
|
1623 |
index = |
|
1624 |
dataManager.createFeatureIndexProvider(indexTypeName, this, |
|
1625 |
featureType, indexName, featureType |
|
1626 |
.getAttributeDescriptor(attributeName)); |
|
1652 | 1627 |
try { |
1653 | 1628 |
index.fill(); |
1654 | 1629 |
} catch (FeatureIndexException e) { |
... | ... | |
1660 | 1635 |
|
1661 | 1636 |
public FeatureIndex createIndex(FeatureType featureType, |
1662 | 1637 |
String attributeName, String indexName, Observer observer) { |
1638 |
return createIndex(null, featureType, attributeName, indexName, |
|
1639 |
observer); |
|
1640 |
} |
|
1641 |
|
|
1642 |
public FeatureIndex createIndex(String indexTypeName, |
|
1643 |
FeatureType featureType, String attributeName, String indexName, |
|
1644 |
Observer observer) { |
|
1663 | 1645 |
// TODO Implement observer interaction |
1664 | 1646 |
throw new UnsupportedOperationException(); |
1665 | 1647 |
} |
... | ... | |
1720 | 1702 |
} |
1721 | 1703 |
|
1722 | 1704 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
1723 |
if( this.metadata.hasDynValue(name) ) {
|
|
1724 |
return this.metadata.getDynValue(name);
|
|
1705 |
if (this.metadata.hasDynValue(name)) {
|
|
1706 |
return this.metadata.getDynValue(name); |
|
1725 | 1707 |
} |
1726 |
if( METADATA_PROVIDER.equalsIgnoreCase(name) ) {
|
|
1708 |
if (METADATA_PROVIDER.equalsIgnoreCase(name)) {
|
|
1727 | 1709 |
return this.provider.getProviderName(); |
1728 |
} else if( METADATA_CONTAINERNAME.equalsIgnoreCase(name) ) { |
|
1729 |
return this.provider.getSourceId(); |
|
1730 |
} else if( METADATA_FEATURETYPE.equalsIgnoreCase(name) ) { |
|
1731 |
try { |
|
1732 |
return this.getDefaultFeatureType(); |
|
1733 |
} catch (DataException e) { |
|
1734 |
return null; |
|
1735 |
} |
|
1736 |
} |
|
1710 |
} else |
|
1711 |
if (METADATA_CONTAINERNAME.equalsIgnoreCase(name)) { |
|
1712 |
return this.provider.getSourceId(); |
|
1713 |
} else |
|
1714 |
if (METADATA_FEATURETYPE.equalsIgnoreCase(name)) { |
|
1715 |
try { |
|
1716 |
return this.getDefaultFeatureType(); |
|
1717 |
} catch (DataException e) { |
|
1718 |
return null; |
|
1719 |
} |
|
1720 |
} |
|
1737 | 1721 |
return this.metadata.getDynValue(name); |
1738 | 1722 |
} |
1739 | 1723 |
|
... | ... | |
1746 | 1730 |
} |
1747 | 1731 |
|
1748 | 1732 |
public Object invokeDynMethod(String name, DynObject context) |
1749 |
throws DynMethodException { |
|
1733 |
throws DynMethodException {
|
|
1750 | 1734 |
return this.metadata.invokeDynMethod(this, name, context); |
1751 | 1735 |
} |
1752 | 1736 |
|
1753 | 1737 |
public Object invokeDynMethod(int code, DynObject context) |
1754 |
throws DynMethodException { |
|
1738 |
throws DynMethodException {
|
|
1755 | 1739 |
return this.metadata.invokeDynMethod(this, code, context); |
1756 | 1740 |
} |
1757 | 1741 |
|
1758 | 1742 |
public void setDynValue(String name, Object value) |
1759 |
throws DynFieldNotFoundException { |
|
1743 |
throws DynFieldNotFoundException {
|
|
1760 | 1744 |
this.metadata.setDynValue(name, value); |
1761 | 1745 |
|
1762 | 1746 |
} |
1763 | 1747 |
|
1764 | 1748 |
/* |
1765 | 1749 |
* (non-Javadoc) |
1766 |
* |
|
1750 |
*
|
|
1767 | 1751 |
* @see org.gvsig.metadata.Metadata#getMetadataChildren() |
1768 | 1752 |
*/ |
1769 | 1753 |
public Set getMetadataChildren() { |
... | ... | |
1772 | 1756 |
|
1773 | 1757 |
/* |
1774 | 1758 |
* (non-Javadoc) |
1775 |
* |
|
1759 |
*
|
|
1776 | 1760 |
* @see org.gvsig.metadata.Metadata#getMetadataName() |
1777 | 1761 |
*/ |
1778 | 1762 |
public String getMetadataName() { |
... | ... | |
1789 | 1773 |
} |
1790 | 1774 |
if (this.isEditing() && !this.isAppending()) { |
1791 | 1775 |
return featureCount.longValue() |
1792 |
- this.featureManager.getDeltaSize(); |
|
1776 |
- this.featureManager.getDeltaSize();
|
|
1793 | 1777 |
} |
1794 | 1778 |
return featureCount.longValue(); |
1795 | 1779 |
} |
... | ... | |
1826 | 1810 |
} |
1827 | 1811 |
|
1828 | 1812 |
public void createCache(String name, DynObject parameters) |
1829 |
throws DataException { |
|
1813 |
throws DataException {
|
|
1830 | 1814 |
cache = dataManager.createFeatureCacheProvider(name, parameters); |
1831 |
if (cache == null){ |
|
1815 |
if (cache == null) {
|
|
1832 | 1816 |
throw new CreateException("FeaureCacheProvider", null); |
1833 | 1817 |
} |
1834 | 1818 |
cache.apply(this, provider); |
... | ... | |
1871 | 1855 |
return this.provider.getRetrievedFeaturesLimit(); |
1872 | 1856 |
} |
1873 | 1857 |
|
1874 |
public Interval getInterval() {
|
|
1858 |
public Interval getInterval() { |
|
1875 | 1859 |
return provider.getInterval(); |
1876 | 1860 |
} |
1877 |
|
|
1878 |
public Collection getInstants() { |
|
1879 |
return provider.getInstants(); |
|
1880 |
} |
|
1881 | 1861 |
|
1882 |
public Collection getInstants(Interval interval) { |
|
1883 |
return provider.getInstants(interval); |
|
1884 |
} |
|
1885 |
} |
|
1862 |
public Collection getInstants() { |
|
1863 |
return provider.getInstants(); |
|
1864 |
} |
|
1865 |
|
|
1866 |
public Collection getInstants(Interval interval) { |
|
1867 |
return provider.getInstants(); |
|
1868 |
} |
|
1869 |
} |
Also available in: Unified diff