Revision 43215 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java
DefaultFeatureStore.java | ||
---|---|---|
36 | 36 |
import java.util.Map; |
37 | 37 |
import java.util.Map.Entry; |
38 | 38 |
import java.util.Set; |
39 |
import java.util.logging.Level;
|
|
39 |
import org.apache.commons.io.FilenameUtils;
|
|
40 | 40 |
|
41 | 41 |
import org.cresques.cts.IProjection; |
42 | 42 |
|
... | ... | |
78 | 78 |
import org.gvsig.fmap.dal.feature.FeatureType; |
79 | 79 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
80 | 80 |
import org.gvsig.fmap.dal.feature.FeatureStoreTimeSupport; |
81 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransform; |
|
81 | 82 |
import org.gvsig.fmap.dal.feature.exception.AlreadyEditingException; |
82 | 83 |
import org.gvsig.fmap.dal.feature.exception.ConcurrentDataModificationException; |
83 | 84 |
import org.gvsig.fmap.dal.feature.exception.CreateFeatureException; |
... | ... | |
91 | 92 |
import org.gvsig.fmap.dal.feature.exception.NoNewFeatureInsertException; |
92 | 93 |
import org.gvsig.fmap.dal.feature.exception.NullFeatureTypeException; |
93 | 94 |
import org.gvsig.fmap.dal.feature.exception.PerformEditingException; |
94 |
import org.gvsig.fmap.dal.feature.exception.PersistenceCantFindDefaultFeatureTypeException; |
|
95 | 95 |
import org.gvsig.fmap.dal.feature.exception.PersistenceCantFindFeatureTypeException; |
96 | 96 |
import org.gvsig.fmap.dal.feature.exception.PersistenceStoreAlreadyLoadedException; |
97 | 97 |
import org.gvsig.fmap.dal.feature.exception.SelectionNotAllowedException; |
... | ... | |
127 | 127 |
import org.gvsig.metadata.MetadataLocator; |
128 | 128 |
import org.gvsig.metadata.MetadataManager; |
129 | 129 |
import org.gvsig.metadata.exceptions.MetadataException; |
130 |
import org.gvsig.timesupport.DataTypes; |
|
131 | 130 |
import org.gvsig.timesupport.Interval; |
132 | 131 |
import org.gvsig.tools.ToolsLocator; |
133 | 132 |
import org.gvsig.tools.dispose.DisposableIterator; |
... | ... | |
152 | 151 |
import org.gvsig.tools.undo.RedoException; |
153 | 152 |
import org.gvsig.tools.undo.UndoException; |
154 | 153 |
import org.gvsig.tools.undo.command.Command; |
154 |
import org.gvsig.tools.util.HasAFile; |
|
155 | 155 |
import org.gvsig.tools.visitor.Visitor; |
156 | 156 |
|
157 | 157 |
import org.slf4j.Logger; |
... | ... | |
203 | 203 |
|
204 | 204 |
private FeatureCacheProvider cache; |
205 | 205 |
|
206 |
StateInformation state; |
|
207 |
|
|
206 | 208 |
FeatureStoreTimeSupport timeSupport; |
209 |
|
|
210 |
|
|
211 |
private class StateInformation extends HashMap<Object, Object> { |
|
212 |
|
|
213 |
private static final long serialVersionUID = 4109026189635185666L; |
|
214 |
|
|
215 |
private boolean broken; |
|
216 |
private Throwable breakingsCause; |
|
217 |
|
|
218 |
public StateInformation() { |
|
219 |
this.clear(); |
|
220 |
} |
|
221 |
|
|
222 |
@Override |
|
223 |
public void clear() { |
|
224 |
this.broken = false; |
|
225 |
this.breakingsCause = null; |
|
226 |
super.clear(); |
|
227 |
} |
|
228 |
|
|
229 |
public boolean isBroken() { |
|
230 |
return this.broken; |
|
231 |
} |
|
232 |
|
|
233 |
public void broken() { |
|
234 |
this.broken = true; |
|
235 |
} |
|
236 |
|
|
237 |
public Throwable getBreakingsCause() { |
|
238 |
return this.breakingsCause; |
|
239 |
} |
|
240 |
|
|
241 |
public void setBreakingsCause(Throwable cause) { |
|
242 |
if( this.breakingsCause==null ) { |
|
243 |
this.breakingsCause = cause; |
|
244 |
} |
|
245 |
this.broken = true; |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
249 |
|
|
250 |
|
|
207 | 251 |
/* |
208 | 252 |
* TODO: |
209 | 253 |
* |
... | ... | |
214 | 258 |
*/ |
215 | 259 |
|
216 | 260 |
public DefaultFeatureStore() { |
217 |
|
|
261 |
this.state = new StateInformation(); |
|
218 | 262 |
} |
219 | 263 |
|
220 | 264 |
@Override |
... | ... | |
248 | 292 |
this.metadataChildren.add(provider); |
249 | 293 |
} |
250 | 294 |
|
295 |
@Override |
|
251 | 296 |
public DataStoreParameters getParameters() { |
252 | 297 |
return parameters; |
253 | 298 |
} |
... | ... | |
256 | 301 |
return this.mode; |
257 | 302 |
} |
258 | 303 |
|
304 |
@Override |
|
259 | 305 |
public DataManager getManager() { |
260 | 306 |
return this.dataManager; |
261 | 307 |
} |
262 | 308 |
|
309 |
@Override |
|
263 | 310 |
public Iterator getChildren() { |
264 | 311 |
return this.provider.getChilds(); |
265 | 312 |
} |
266 | 313 |
|
314 |
@Override |
|
267 | 315 |
public FeatureStoreProvider getProvider() { |
268 | 316 |
return this.provider; |
269 | 317 |
} |
... | ... | |
272 | 320 |
return this.featureManager; |
273 | 321 |
} |
274 | 322 |
|
323 |
@Override |
|
275 | 324 |
public void setFeatureTypes(List types, FeatureType defaultType) { |
276 | 325 |
this.featureTypes = types; |
277 | 326 |
this.defaultFeatureType = defaultType; |
... | ... | |
291 | 340 |
this.notifyChange(DataStoreNotification.AFTER_OPEN); |
292 | 341 |
} |
293 | 342 |
|
343 |
@Override |
|
294 | 344 |
public void refresh() throws OpenException, InitializeException { |
295 | 345 |
if (this.mode != MODE_QUERY) { |
296 | 346 |
throw new IllegalStateException(); |
297 | 347 |
} |
298 | 348 |
this.notifyChange(FeatureStoreNotification.BEFORE_REFRESH); |
299 |
this.featureCount = null; |
|
300 |
this.provider.refresh(); |
|
349 |
if( state.isBroken() ) { |
|
350 |
this.load(state); |
|
351 |
} else { |
|
352 |
this.featureCount = null; |
|
353 |
this.provider.refresh(); |
|
354 |
} |
|
301 | 355 |
this.notifyChange(FeatureStoreNotification.AFTER_REFRESH); |
302 | 356 |
} |
303 | 357 |
|
... | ... | |
316 | 370 |
this.notifyChange(DataStoreNotification.AFTER_CLOSE); |
317 | 371 |
} |
318 | 372 |
|
373 |
@Override |
|
319 | 374 |
protected void doDispose() throws BaseException { |
320 | 375 |
if (this.mode != MODE_QUERY) { |
321 | 376 |
// TODO: Se puede hacer un dispose estando en edicion ? |
... | ... | |
355 | 410 |
} |
356 | 411 |
} |
357 | 412 |
|
413 |
@Override |
|
358 | 414 |
public boolean allowWrite() { |
359 | 415 |
SimpleIdentityManager identityManager = ToolsLocator.getIdentityManager(); |
360 | 416 |
if( ! identityManager.getCurrentIdentity().isAuthorized(DataManager.WRITE_STORE_AUTHORIZATION,this.getParameters(), this.getName()) ) { |
... | ... | |
363 | 419 |
return this.provider.allowWrite(); |
364 | 420 |
} |
365 | 421 |
|
422 |
@Override |
|
366 | 423 |
public boolean canWriteGeometry(int geometryType) throws DataException { |
367 | 424 |
return this.provider.canWriteGeometry(geometryType, 0); |
368 | 425 |
} |
369 | 426 |
|
427 |
@Override |
|
370 | 428 |
public DataServerExplorer getExplorer() throws ReadException, |
371 | 429 |
ValidateDataParametersException { |
372 |
return this.provider.getExplorer(); |
|
430 |
if( this.state.isBroken() ) { |
|
431 |
try { |
|
432 |
return this.provider.getExplorer(); |
|
433 |
} catch(Throwable th) { |
|
434 |
return null; |
|
435 |
} |
|
436 |
} else { |
|
437 |
return this.provider.getExplorer(); |
|
438 |
} |
|
373 | 439 |
} |
374 | 440 |
|
375 | 441 |
/* |
... | ... | |
384 | 450 |
* } |
385 | 451 |
*/ |
386 | 452 |
|
453 |
@Override |
|
387 | 454 |
public Envelope getEnvelope() throws DataException { |
388 | 455 |
if (this.mode == MODE_FULLEDIT) { |
389 | 456 |
// Just in case another thread tries to write in the store |
... | ... | |
400 | 467 |
/** |
401 | 468 |
* @deprecated use getDefaultFeatureType().getDefaultSRS() |
402 | 469 |
*/ |
470 |
@Override |
|
403 | 471 |
public IProjection getSRSDefaultGeometry() throws DataException { |
404 | 472 |
return this.getDefaultFeatureType().getDefaultSRS(); |
405 | 473 |
} |
406 | 474 |
|
475 |
@Override |
|
407 | 476 |
public FeatureSelection createDefaultFeatureSelection() |
408 | 477 |
throws DataException { |
409 | 478 |
return new DefaultFeatureSelection(this); |
410 | 479 |
} |
411 | 480 |
|
481 |
@Override |
|
412 | 482 |
public FeatureProvider createDefaultFeatureProvider(FeatureType type) |
413 | 483 |
throws DataException { |
414 | 484 |
if (type.hasOID()) { |
... | ... | |
418 | 488 |
return new DefaultFeatureProvider(type); |
419 | 489 |
} |
420 | 490 |
|
491 |
@Override |
|
421 | 492 |
public void saveToState(PersistentState state) throws PersistenceException { |
422 | 493 |
/*if (this.mode != FeatureStore.MODE_QUERY) { |
423 | 494 |
throw new PersistenceException(new IllegalStateException( |
... | ... | |
462 | 533 |
state.set("defaultFeatureTypeId", defaultFeatureType.getId()); |
463 | 534 |
|
464 | 535 |
} |
465 |
|
|
466 |
public void loadFromState(PersistentState state) |
|
536 |
|
|
537 |
@Override |
|
538 |
public void loadFromState(final PersistentState persistentState) |
|
467 | 539 |
throws PersistenceException { |
468 | 540 |
if (this.provider != null) { |
469 | 541 |
throw new PersistenceStoreAlreadyLoadedException(this.getName()); |
... | ... | |
471 | 543 |
if (this.getManager() == null) { |
472 | 544 |
this.dataManager = (DefaultDataManager) DALLocator.getDataManager(); |
473 | 545 |
} |
546 |
state.clear(); |
|
547 |
try { |
|
548 |
state.put("parameters", persistentState.get("parameters")); |
|
549 |
} catch(Throwable th) { |
|
550 |
state.setBreakingsCause(th); |
|
551 |
} |
|
552 |
try { |
|
553 |
state.put("selection", persistentState.get("selection")); |
|
554 |
} catch(Throwable th) { |
|
555 |
state.setBreakingsCause(th); |
|
556 |
} |
|
557 |
try { |
|
558 |
state.put("transforms", persistentState.get("transforms")); |
|
559 |
} catch(Throwable th) { |
|
560 |
state.setBreakingsCause(th); |
|
561 |
} |
|
562 |
try { |
|
563 |
state.put("evaluatedAttributes", persistentState.get("evaluatedAttributes")); |
|
564 |
} catch(Throwable th) { |
|
565 |
state.setBreakingsCause(th); |
|
566 |
} |
|
567 |
try { |
|
568 |
state.put("defaultFeatureTypeId", persistentState.getString("defaultFeatureTypeId")); |
|
569 |
} catch(Throwable th) { |
|
570 |
state.setBreakingsCause(th); |
|
571 |
} |
|
572 |
load(state); |
|
573 |
} |
|
574 |
|
|
575 |
private void load(StateInformation state) { |
|
576 |
this.featureTypes = new ArrayList(); |
|
577 |
this.defaultFeatureType = null; |
|
578 |
this.featureCount = null; |
|
474 | 579 |
|
475 |
DataStoreParameters params = |
|
476 |
(DataStoreParameters) state.get("parameters"); |
|
580 |
DataStoreParameters params = (DataStoreParameters) state.get("parameters"); |
|
581 |
try { |
|
582 |
intialize(dataManager, params); |
|
583 |
} catch(Throwable th) { |
|
584 |
state.setBreakingsCause(th); |
|
585 |
} |
|
477 | 586 |
|
478 |
DataStoreProvider prov; |
|
479 | 587 |
try { |
480 |
this.intialize(this.dataManager, params); |
|
481 |
prov = this.dataManager.createProvider( |
|
482 |
(DataStoreProviderServices) this, |
|
483 |
params |
|
588 |
DataStoreProvider prov = dataManager.createProvider( |
|
589 |
getStoreProviderServices(), |
|
590 |
params |
|
484 | 591 |
); |
485 |
this.setProvider(prov); |
|
592 |
setProvider(prov); |
|
593 |
} catch(Throwable th) { |
|
594 |
state.setBreakingsCause(th); |
|
595 |
} |
|
486 | 596 |
|
487 |
this.selection = (FeatureSelection) state.get("selection"); |
|
488 |
this.transforms = |
|
489 |
(DefaultFeatureStoreTransforms) state.get("transforms"); |
|
597 |
try { |
|
598 |
selection = (FeatureSelection) state.get("selection"); |
|
599 |
} catch(Throwable th) { |
|
600 |
state.setBreakingsCause(th); |
|
601 |
} |
|
602 |
|
|
603 |
try { |
|
604 |
this.transforms = (DefaultFeatureStoreTransforms) state.get("transforms"); |
|
605 |
this.transforms.setFeatureStore(this); |
|
606 |
for( FeatureStoreTransform transform : this.transforms ) { |
|
607 |
try { |
|
608 |
transform.setUp(); |
|
609 |
} catch(Throwable th) { |
|
610 |
state.setBreakingsCause(th); |
|
611 |
} |
|
612 |
} |
|
613 |
} catch(Throwable th) { |
|
614 |
state.setBreakingsCause(th); |
|
615 |
} |
|
616 |
|
|
617 |
try { |
|
490 | 618 |
Map evaluatedAttributes = (Map) state.get("evaluatedAttributes"); |
491 | 619 |
if ((evaluatedAttributes != null) && !evaluatedAttributes.isEmpty()) { |
492 |
List attrs; |
|
493 |
Iterator iterEntries = |
|
494 |
evaluatedAttributes.entrySet().iterator(); |
|
495 |
Entry entry; |
|
496 |
while (iterEntries.hasNext()) { |
|
497 |
entry = (Entry) iterEntries.next(); |
|
498 |
attrs = (List) entry.getValue(); |
|
499 |
if (attrs.isEmpty()) { |
|
500 |
continue; |
|
620 |
Iterator iterEntries = evaluatedAttributes.entrySet().iterator(); |
|
621 |
while (iterEntries.hasNext()) { |
|
622 |
Entry entry = (Entry) iterEntries.next(); |
|
623 |
List attrs = (List) entry.getValue(); |
|
624 |
if (attrs.isEmpty()) { |
|
625 |
continue; |
|
626 |
} |
|
627 |
int fTypePos = -1; |
|
628 |
DefaultFeatureType type = null; |
|
629 |
for (int i = 0; i < featureTypes.size(); i++) { |
|
630 |
type = (DefaultFeatureType) featureTypes.get(i); |
|
631 |
if (type.getId().equals(entry.getKey())) { |
|
632 |
fTypePos = i; |
|
633 |
break; |
|
634 |
} |
|
635 |
} |
|
636 |
if (type == null) { |
|
637 |
throw new PersistenceCantFindFeatureTypeException( |
|
638 |
getName(), (String) entry.getKey()); |
|
639 |
} |
|
640 |
DefaultEditableFeatureType eType = (DefaultEditableFeatureType) type.getEditable(); |
|
641 |
Iterator<FeatureAttributeDescriptor> iterAttr = attrs.iterator(); |
|
642 |
while (iterAttr.hasNext()) { |
|
643 |
FeatureAttributeDescriptor attr = iterAttr.next(); |
|
644 |
eType.addLike(attr); |
|
645 |
} |
|
646 |
featureTypes.set(fTypePos, eType.getNotEditableCopy()); |
|
647 |
|
|
501 | 648 |
} |
502 |
int fTypePos = -1; |
|
503 |
DefaultFeatureType type = null; |
|
504 |
for (int i = 0; i < featureTypes.size(); i++) { |
|
505 |
type = (DefaultFeatureType) featureTypes.get(i); |
|
506 |
if (type.getId().equals(entry.getKey())) { |
|
507 |
fTypePos = i; |
|
508 |
break; |
|
509 |
} |
|
510 |
} |
|
511 |
if (fTypePos < 0) { |
|
512 |
throw new PersistenceCantFindFeatureTypeException( |
|
513 |
this.getName(), (String) entry.getKey()); |
|
514 |
} |
|
515 |
DefaultEditableFeatureType eType = |
|
516 |
(DefaultEditableFeatureType) type.getEditable(); |
|
517 |
Iterator iterAttr = attrs.iterator(); |
|
518 |
FeatureAttributeDescriptor attr; |
|
519 |
while (iterAttr.hasNext()) { |
|
520 |
attr = (FeatureAttributeDescriptor) iterAttr.next(); |
|
521 |
eType.addLike(attr); |
|
522 |
} |
|
523 |
featureTypes.set(fTypePos, eType.getNotEditableCopy()); |
|
524 | 649 |
|
525 |
} |
|
526 |
|
|
527 | 650 |
} |
651 |
} catch(Throwable th) { |
|
652 |
state.setBreakingsCause(th); |
|
653 |
} |
|
528 | 654 |
|
529 |
String defFTypeid = state.getString("defaultFeatureTypeId"); |
|
530 |
FeatureType ftype = null; |
|
655 |
|
|
656 |
try { |
|
657 |
String defaultFeatureTypeId = (String) state.get("defaultFeatureTypeId"); |
|
658 |
FeatureType ftype; |
|
531 | 659 |
|
532 |
if (this.defaultFeatureType == null || |
|
533 |
this.defaultFeatureType.getId() == null || |
|
534 |
!this.defaultFeatureType.getId().equals( |
|
535 |
state.getString("defaultFeatureTypeId"))) { |
|
660 |
if (defaultFeatureType == null || |
|
661 |
defaultFeatureType.getId() == null || |
|
662 |
!defaultFeatureType.getId().equals(defaultFeatureTypeId)) { |
|
536 | 663 |
|
537 |
ftype = getFeatureType(defFTypeid); |
|
538 |
if (ftype == null) { |
|
539 |
/* |
|
540 |
* Un error en el m?todo de PostgresQL getName(), hace que |
|
541 |
* el nombre del featureType sea valor retornado por el getProviderName() |
|
542 |
* De momento se pone este parche para apa?arlo y poder mantener compatibilidad |
|
543 |
* con proyectos antiguos (2.1 y 2.2) |
|
544 |
*/ |
|
545 |
ftype = getFeatureType(prov.getName()); |
|
546 |
if(ftype == null){ |
|
547 |
throw new PersistenceCantFindDefaultFeatureTypeException( |
|
548 |
this.getName(), defFTypeid); |
|
549 |
} |
|
550 |
} |
|
551 |
this.defaultFeatureType = ftype; |
|
664 |
ftype = getFeatureType(defaultFeatureTypeId); |
|
665 |
if (ftype == null) { |
|
666 |
/* |
|
667 |
* Un error en el m?todo de PostgreSQL getName(), hace que |
|
668 |
* el nombre del featureType sea valor retornado por el getProviderName() |
|
669 |
* De momento se pone este parche para apa?arlo y poder mantener compatibilidad |
|
670 |
* con proyectos antiguos (2.1 y 2.2) |
|
671 |
*/ |
|
672 |
ftype = getFeatureType(getName()); |
|
673 |
if(ftype == null ) { |
|
674 |
throw new RuntimeException("Can't locate feature type"); |
|
675 |
} |
|
676 |
} |
|
677 |
defaultFeatureType = ftype; |
|
552 | 678 |
} |
553 |
LOG.info("loadFromState() {} {}.", prov.getProviderName(), parameters.toString()); |
|
554 |
|
|
555 |
} catch (InitializeException e) { |
|
556 |
throw new PersistenceException(e); |
|
557 |
} catch (DataException e) { |
|
558 |
throw new PersistenceException(e); |
|
679 |
} catch(Throwable th) { |
|
680 |
state.setBreakingsCause(th); |
|
559 | 681 |
} |
560 | 682 |
|
683 |
LOG.info("load() broken:{}, {}, {}.", |
|
684 |
new Object[] { state.isBroken(), this.getProviderName(), params } |
|
685 |
); |
|
561 | 686 |
} |
562 | 687 |
|
688 |
public DataStoreProviderServices getStoreProviderServices() { |
|
689 |
return this; |
|
690 |
} |
|
691 |
|
|
563 | 692 |
public static void registerPersistenceDefinition() { |
564 | 693 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
565 | 694 |
if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
... | ... | |
606 | 735 |
// Gestion de la seleccion |
607 | 736 |
// |
608 | 737 |
|
738 |
@Override |
|
609 | 739 |
public void setSelection(DataSet selection) throws DataException { |
610 | 740 |
this.setSelection((FeatureSet) selection); |
611 | 741 |
} |
612 | 742 |
|
743 |
@Override |
|
613 | 744 |
public DataSet createSelection() throws DataException { |
614 | 745 |
return createFeatureSelection(); |
615 | 746 |
} |
616 | 747 |
|
748 |
@Override |
|
617 | 749 |
public DataSet getSelection() throws DataException { |
618 | 750 |
return this.getFeatureSelection(); |
619 | 751 |
} |
620 | 752 |
|
753 |
@Override |
|
621 | 754 |
public void setSelection(FeatureSet selection) throws DataException { |
622 | 755 |
setSelection(selection, true); |
623 | 756 |
} |
624 | 757 |
|
625 |
/** |
|
626 |
* @see #setSelection(FeatureSet) |
|
627 |
* @param undoable |
|
628 |
* if the action must be undoable |
|
629 |
*/ |
|
630 | 758 |
public void setSelection(FeatureSet selection, boolean undoable) |
631 | 759 |
throws DataException { |
632 | 760 |
if (selection == null) { |
... | ... | |
684 | 812 |
this.notifyChange(DataStoreNotification.SELECTION_CHANGE); |
685 | 813 |
} |
686 | 814 |
|
815 |
@Override |
|
687 | 816 |
public FeatureSelection createFeatureSelection() throws DataException { |
688 | 817 |
return this.provider.createFeatureSelection(); |
689 | 818 |
} |
690 | 819 |
|
820 |
@Override |
|
691 | 821 |
public FeatureSelection getFeatureSelection() throws DataException { |
692 | 822 |
if (selection == null) { |
693 | 823 |
this.selection = createFeatureSelection(); |
... | ... | |
755 | 885 |
// Gestion de bloqueos |
756 | 886 |
// |
757 | 887 |
|
888 |
@Override |
|
758 | 889 |
public boolean isLocksSupported() { |
759 | 890 |
return this.provider.isLocksSupported(); |
760 | 891 |
} |
761 | 892 |
|
893 |
@Override |
|
762 | 894 |
public FeatureLocks getLocks() throws DataException { |
763 | 895 |
if (!this.provider.isLocksSupported()) { |
764 | 896 |
LOG.warn("Locks not supported"); |
... | ... | |
775 | 907 |
// Interface Observable |
776 | 908 |
// |
777 | 909 |
|
910 |
@Override |
|
778 | 911 |
public void disableNotifications() { |
779 | 912 |
this.delegateObservable.disableNotifications(); |
780 | 913 |
|
781 | 914 |
} |
782 | 915 |
|
916 |
@Override |
|
783 | 917 |
public void enableNotifications() { |
784 | 918 |
this.delegateObservable.enableNotifications(); |
785 | 919 |
} |
786 | 920 |
|
921 |
@Override |
|
787 | 922 |
public void beginComplexNotification() { |
788 | 923 |
this.delegateObservable.beginComplexNotification(); |
789 | 924 |
|
790 | 925 |
} |
791 | 926 |
|
927 |
@Override |
|
792 | 928 |
public void endComplexNotification() { |
793 | 929 |
this.delegateObservable.endComplexNotification(); |
794 | 930 |
|
795 | 931 |
} |
796 | 932 |
|
933 |
@Override |
|
797 | 934 |
public void addObserver(Observer observer) { |
798 | 935 |
if (delegateObservable != null) { |
799 | 936 |
this.delegateObservable.addObserver(observer); |
800 | 937 |
} |
801 | 938 |
} |
802 | 939 |
|
940 |
@Override |
|
803 | 941 |
public void deleteObserver(Observer observer) { |
804 | 942 |
if (delegateObservable != null) { |
805 | 943 |
this.delegateObservable.deleteObserver(observer); |
806 | 944 |
} |
807 | 945 |
} |
808 | 946 |
|
947 |
@Override |
|
809 | 948 |
public void deleteObservers() { |
810 | 949 |
this.delegateObservable.deleteObservers(); |
811 | 950 |
|
... | ... | |
821 | 960 |
// - sus recursos |
822 | 961 |
// |
823 | 962 |
|
963 |
@Override |
|
824 | 964 |
public void update(Observable observable, Object notification) { |
825 | 965 |
if (observable instanceof FeatureSet) { |
826 | 966 |
if (observable == this.selection) { |
... | ... | |
897 | 1037 |
hasInserts = true; |
898 | 1038 |
} |
899 | 1039 |
|
1040 |
@Override |
|
900 | 1041 |
synchronized public void edit() throws DataException { |
901 | 1042 |
edit(MODE_FULLEDIT); |
902 | 1043 |
} |
903 | 1044 |
|
1045 |
@Override |
|
904 | 1046 |
synchronized public void edit(int mode) throws DataException { |
905 |
LOG.debug("Starting editing in mode: {}", new Integer(mode));
|
|
1047 |
LOG.debug("Starting editing in mode: {}", mode);
|
|
906 | 1048 |
try { |
907 | 1049 |
if (this.mode != MODE_QUERY) { |
908 | 1050 |
throw new AlreadyEditingException(this.getName()); |
... | ... | |
957 | 1099 |
} |
958 | 1100 |
|
959 | 1101 |
private void setIndexesValidStatus(boolean valid) { |
960 |
FeatureIndexes indexes = getIndexes();
|
|
1102 |
FeatureIndexes theIndexes = getIndexes();
|
|
961 | 1103 |
LOG.debug("Setting the store indexes to valid status {}: {}", (valid |
962 |
? Boolean.TRUE : Boolean.FALSE), indexes);
|
|
963 |
for (Iterator iterator = indexes.iterator(); iterator.hasNext();) {
|
|
1104 |
? Boolean.TRUE : Boolean.FALSE), theIndexes);
|
|
1105 |
for (Iterator iterator = theIndexes.iterator(); iterator.hasNext();) {
|
|
964 | 1106 |
FeatureIndex index = (FeatureIndex) iterator.next(); |
965 | 1107 |
if (index instanceof FeatureIndexProviderServices) { |
966 | 1108 |
FeatureIndexProviderServices indexServices = |
... | ... | |
971 | 1113 |
} |
972 | 1114 |
|
973 | 1115 |
private void updateIndexes() throws FeatureIndexException { |
974 |
FeatureIndexes indexes = getIndexes();
|
|
975 |
LOG.debug("Refilling indexes: {}", indexes);
|
|
976 |
for (Iterator iterator = indexes.iterator(); iterator.hasNext();) {
|
|
1116 |
FeatureIndexes theIndexes = getIndexes();
|
|
1117 |
LOG.debug("Refilling indexes: {}", theIndexes);
|
|
1118 |
for (Iterator iterator = theIndexes.iterator(); iterator.hasNext();) {
|
|
977 | 1119 |
FeatureIndex index = (FeatureIndex) iterator.next(); |
978 | 1120 |
if (index instanceof FeatureIndexProviderServices) { |
979 | 1121 |
FeatureIndexProviderServices indexServices = |
... | ... | |
984 | 1126 |
} |
985 | 1127 |
|
986 | 1128 |
private void waitForIndexes() { |
987 |
FeatureIndexes indexes = getIndexes();
|
|
988 |
LOG.debug("Waiting for indexes to finish filling: {}", indexes);
|
|
989 |
for (Iterator iterator = indexes.iterator(); iterator.hasNext();) {
|
|
1129 |
FeatureIndexes theIndexes = getIndexes();
|
|
1130 |
LOG.debug("Waiting for indexes to finish filling: {}", theIndexes);
|
|
1131 |
for (Iterator iterator = theIndexes.iterator(); iterator.hasNext();) {
|
|
990 | 1132 |
FeatureIndex index = (FeatureIndex) iterator.next(); |
991 | 1133 |
if (index instanceof FeatureIndexProviderServices) { |
992 | 1134 |
FeatureIndexProviderServices indexServices = |
... | ... | |
997 | 1139 |
} |
998 | 1140 |
|
999 | 1141 |
private void disposeIndexes() { |
1000 |
FeatureIndexes indexes = getIndexes();
|
|
1001 |
LOG.debug("Disposing indexes: {}", indexes);
|
|
1002 |
for (Iterator iterator = indexes.iterator(); iterator.hasNext();) {
|
|
1142 |
FeatureIndexes theIndexes = getIndexes();
|
|
1143 |
LOG.debug("Disposing indexes: {}", theIndexes);
|
|
1144 |
for (Iterator iterator = theIndexes.iterator(); iterator.hasNext();) {
|
|
1003 | 1145 |
FeatureIndex index = (FeatureIndex) iterator.next(); |
1004 | 1146 |
if (index instanceof FeatureIndexProviderServices) { |
1005 | 1147 |
FeatureIndexProviderServices indexServices = |
... | ... | |
1009 | 1151 |
} |
1010 | 1152 |
} |
1011 | 1153 |
|
1154 |
@Override |
|
1012 | 1155 |
public boolean isEditing() { |
1013 | 1156 |
return mode == MODE_FULLEDIT; |
1014 | 1157 |
} |
1015 | 1158 |
|
1159 |
@Override |
|
1016 | 1160 |
public boolean isAppending() { |
1017 | 1161 |
return mode == MODE_APPEND; |
1018 | 1162 |
} |
1019 | 1163 |
|
1164 |
@Override |
|
1020 | 1165 |
synchronized public void update(EditableFeatureType type) |
1021 | 1166 |
throws DataException { |
1022 | 1167 |
try { |
... | ... | |
1041 | 1186 |
} |
1042 | 1187 |
} |
1043 | 1188 |
|
1189 |
@Override |
|
1044 | 1190 |
public void delete(Feature feature) throws DataException { |
1045 | 1191 |
this.commands.delete(feature); |
1046 | 1192 |
} |
... | ... | |
1068 | 1214 |
|
1069 | 1215 |
private static EditableFeature lastChangedFeature = null; |
1070 | 1216 |
|
1217 |
@Override |
|
1071 | 1218 |
public synchronized void insert(EditableFeature feature) |
1072 | 1219 |
throws DataException { |
1073 |
LOG.debug("In editing mode {}, insert feature: {}", new Integer(mode), |
|
1074 |
feature); |
|
1220 |
LOG.debug("In editing mode {}, insert feature: {}", mode, feature); |
|
1075 | 1221 |
try { |
1076 | 1222 |
switch (mode) { |
1077 | 1223 |
case MODE_QUERY: |
... | ... | |
1129 | 1275 |
notifyChange(FeatureStoreNotification.AFTER_INSERT, feature); |
1130 | 1276 |
} |
1131 | 1277 |
|
1278 |
@Override |
|
1132 | 1279 |
public void update(EditableFeature feature) |
1133 | 1280 |
throws DataException { |
1134 | 1281 |
if ((feature).getSource() == null) { |
... | ... | |
1164 | 1311 |
} |
1165 | 1312 |
} |
1166 | 1313 |
|
1314 |
@Override |
|
1167 | 1315 |
synchronized public void redo() throws RedoException { |
1168 | 1316 |
Command redo = commands.getNextRedoCommand(); |
1169 | 1317 |
try { |
... | ... | |
1178 | 1326 |
notifyChange(FeatureStoreNotification.AFTER_REDO, redo); |
1179 | 1327 |
} |
1180 | 1328 |
|
1329 |
@Override |
|
1181 | 1330 |
synchronized public void undo() throws UndoException { |
1182 | 1331 |
Command undo = commands.getNextUndoCommand(); |
1183 | 1332 |
try { |
... | ... | |
1192 | 1341 |
notifyChange(FeatureStoreNotification.AFTER_UNDO, undo); |
1193 | 1342 |
} |
1194 | 1343 |
|
1344 |
@Override |
|
1195 | 1345 |
public List getRedoInfos() { |
1196 | 1346 |
if (isEditing() && (commands != null)) { |
1197 | 1347 |
return commands.getRedoInfos(); |
... | ... | |
1200 | 1350 |
} |
1201 | 1351 |
} |
1202 | 1352 |
|
1353 |
@Override |
|
1203 | 1354 |
public List getUndoInfos() { |
1204 | 1355 |
if (isEditing() && (commands != null)) { |
1205 | 1356 |
return commands.getUndoInfos(); |
... | ... | |
1214 | 1365 |
return commands; |
1215 | 1366 |
} |
1216 | 1367 |
|
1368 |
@Override |
|
1217 | 1369 |
synchronized public void cancelEditing() throws DataException { |
1218 | 1370 |
spatialManager.cancelModifies(); |
1219 | 1371 |
try { |
... | ... | |
1235 | 1387 |
} |
1236 | 1388 |
} |
1237 | 1389 |
|
1390 |
@Override |
|
1238 | 1391 |
synchronized public void finishEditing() throws DataException { |
1239 |
LOG.debug("finish editing of mode: {}", new Integer(mode));
|
|
1392 |
LOG.debug("finish editing of mode: {}", mode);
|
|
1240 | 1393 |
try { |
1241 | 1394 |
|
1242 | 1395 |
/* |
... | ... | |
1301 | 1454 |
* |
1302 | 1455 |
* @throws DataException |
1303 | 1456 |
*/ |
1457 |
@Override |
|
1304 | 1458 |
synchronized public void commitChanges() throws DataException { |
1305 |
LOG.debug("commitChanges of mode: {}", new Integer(mode));
|
|
1459 |
LOG.debug("commitChanges of mode: {}", mode);
|
|
1306 | 1460 |
if( !canCommitChanges() ) { |
1307 | 1461 |
throw new WriteNotAllowedException(getName()); |
1308 | 1462 |
} |
... | ... | |
1351 | 1505 |
} |
1352 | 1506 |
} |
1353 | 1507 |
|
1508 |
@Override |
|
1354 | 1509 |
synchronized public boolean canCommitChanges() throws DataException { |
1355 | 1510 |
if ( !this.allowWrite()) { |
1356 | 1511 |
return false; |
... | ... | |
1377 | 1532 |
} |
1378 | 1533 |
} |
1379 | 1534 |
|
1535 |
@Override |
|
1380 | 1536 |
public void beginEditingGroup(String description) |
1381 | 1537 |
throws NeedEditingModeException { |
1382 | 1538 |
checkInEditingMode(); |
1383 | 1539 |
commands.startComplex(description); |
1384 | 1540 |
} |
1385 | 1541 |
|
1542 |
@Override |
|
1386 | 1543 |
public void endEditingGroup() throws NeedEditingModeException { |
1387 | 1544 |
checkInEditingMode(); |
1388 | 1545 |
commands.endComplex(); |
1389 | 1546 |
} |
1390 | 1547 |
|
1548 |
@Override |
|
1391 | 1549 |
public boolean isAppendModeSupported() { |
1392 | 1550 |
return this.provider.supportsAppendMode(); |
1393 | 1551 |
} |
1394 | 1552 |
|
1553 |
@Override |
|
1395 | 1554 |
public void export(DataServerExplorer explorer, String provider, |
1396 | 1555 |
NewFeatureStoreParameters params) throws DataException { |
1397 | 1556 |
|
... | ... | |
1453 | 1612 |
// getDataCollection, getFeatureCollection |
1454 | 1613 |
// |
1455 | 1614 |
|
1615 |
@Override |
|
1456 | 1616 |
public DataSet getDataSet() throws DataException { |
1457 | 1617 |
checkNotInAppendMode(); |
1458 | 1618 |
FeatureQuery query = |
... | ... | |
1460 | 1620 |
return new DefaultFeatureSet(this, query); |
1461 | 1621 |
} |
1462 | 1622 |
|
1623 |
@Override |
|
1463 | 1624 |
public DataSet getDataSet(DataQuery dataQuery) throws DataException { |
1464 | 1625 |
checkNotInAppendMode(); |
1465 | 1626 |
return new DefaultFeatureSet(this, (FeatureQuery) dataQuery); |
1466 | 1627 |
} |
1467 | 1628 |
|
1629 |
@Override |
|
1468 | 1630 |
public void getDataSet(Observer observer) throws DataException { |
1469 | 1631 |
checkNotInAppendMode(); |
1470 | 1632 |
this.getFeatureSet(null, observer); |
1471 | 1633 |
} |
1472 | 1634 |
|
1635 |
@Override |
|
1473 | 1636 |
public void getDataSet(DataQuery dataQuery, Observer observer) |
1474 | 1637 |
throws DataException { |
1475 | 1638 |
checkNotInAppendMode(); |
... | ... | |
1506 | 1669 |
return this.getFeatures(null, 500); |
1507 | 1670 |
} |
1508 | 1671 |
|
1672 |
@Override |
|
1509 | 1673 |
public void accept(Visitor visitor) throws BaseException { |
1510 | 1674 |
FeatureSet set = getFeatureSet(); |
1511 | 1675 |
try { |
... | ... | |
1515 | 1679 |
} |
1516 | 1680 |
} |
1517 | 1681 |
|
1682 |
@Override |
|
1518 | 1683 |
public void accept(Visitor visitor, DataQuery dataQuery) |
1519 | 1684 |
throws BaseException { |
1520 | 1685 |
FeatureSet set = getFeatureSet((FeatureQuery) dataQuery); |
... | ... | |
1536 | 1701 |
return fType; |
1537 | 1702 |
} |
1538 | 1703 |
|
1704 |
@Override |
|
1539 | 1705 |
public void getFeatureSet(Observer observer) throws DataException { |
1540 | 1706 |
checkNotInAppendMode(); |
1541 | 1707 |
this.getFeatureSet(null, observer); |
1542 | 1708 |
} |
1543 | 1709 |
|
1710 |
@Override |
|
1544 | 1711 |
public void getFeatureSet(FeatureQuery query, Observer observer) |
1545 | 1712 |
throws DataException { |
1546 | 1713 |
class LoadInBackGround implements Runnable { |
1547 | 1714 |
|
1548 |
private FeatureStore store; |
|
1549 |
private FeatureQuery query; |
|
1550 |
private Observer observer; |
|
1715 |
private final FeatureStore store;
|
|
1716 |
private final FeatureQuery query;
|
|
1717 |
private final Observer observer;
|
|
1551 | 1718 |
|
1552 | 1719 |
public LoadInBackGround(FeatureStore store, FeatureQuery query, |
1553 | 1720 |
Observer observer) { |
... | ... | |
1558 | 1725 |
|
1559 | 1726 |
void notify(FeatureStoreNotification theNotification) { |
1560 | 1727 |
observer.update(store, theNotification); |
1561 |
return; |
|
1562 | 1728 |
} |
1563 | 1729 |
|
1730 |
@Override |
|
1564 | 1731 |
public void run() { |
1565 | 1732 |
FeatureSet set = null; |
1566 | 1733 |
try { |
... | ... | |
1585 | 1752 |
thread.start(); |
1586 | 1753 |
} |
1587 | 1754 |
|
1755 |
@Override |
|
1588 | 1756 |
public Feature getFeatureByReference(FeatureReference reference) |
1589 | 1757 |
throws DataException { |
1590 | 1758 |
checkNotInAppendMode(); |
... | ... | |
1598 | 1766 |
return this.getFeatureByReference(reference, featureType); |
1599 | 1767 |
} |
1600 | 1768 |
|
1769 |
@Override |
|
1601 | 1770 |
public Feature getFeatureByReference(FeatureReference reference, |
1602 | 1771 |
FeatureType featureType) throws DataException { |
1603 | 1772 |
checkNotInAppendMode(); |
... | ... | |
1710 | 1879 |
return type; |
1711 | 1880 |
} |
1712 | 1881 |
|
1882 |
@Override |
|
1713 | 1883 |
public void validateFeatures(int mode) throws DataException { |
1714 | 1884 |
FeatureSet collection = null; |
1715 | 1885 |
DisposableIterator iter = null; |
... | ... | |
1732 | 1902 |
} |
1733 | 1903 |
} |
1734 | 1904 |
|
1905 |
@Override |
|
1735 | 1906 |
public FeatureType getDefaultFeatureType() throws DataException { |
1736 | 1907 |
try { |
1737 | 1908 |
|
... | ... | |
1762 | 1933 |
} |
1763 | 1934 |
} |
1764 | 1935 |
|
1936 |
@Override |
|
1765 | 1937 |
public FeatureType getFeatureType(String featureTypeId) |
1766 | 1938 |
throws DataException { |
1767 | 1939 |
if (featureTypeId == null) { |
... | ... | |
1796 | 1968 |
return defaultFeatureType; |
1797 | 1969 |
} |
1798 | 1970 |
|
1971 |
@Override |
|
1799 | 1972 |
public List getFeatureTypes() throws DataException { |
1800 | 1973 |
try { |
1801 | 1974 |
List types; |
... | ... | |
1833 | 2006 |
return Collections.unmodifiableList(this.featureTypes); |
1834 | 2007 |
} |
1835 | 2008 |
|
2009 |
@Override |
|
1836 | 2010 |
public Feature createFeature(FeatureProvider data) throws DataException { |
1837 | 2011 |
DefaultFeature feature = new DefaultFeature(this, data); |
1838 | 2012 |
return feature; |
... | ... | |
1847 | 2021 |
throw new NotYetImplemented(); |
1848 | 2022 |
} |
1849 | 2023 |
|
2024 |
@Override |
|
1850 | 2025 |
public EditableFeature createNewFeature(FeatureType type, |
1851 | 2026 |
Feature defaultValues) throws DataException { |
1852 | 2027 |
try { |
... | ... | |
1876 | 2051 |
|
1877 | 2052 |
} |
1878 | 2053 |
|
2054 |
@Override |
|
1879 | 2055 |
public EditableFeature createNewFeature(FeatureType type, |
1880 | 2056 |
boolean defaultValues) throws DataException { |
1881 | 2057 |
try { |
... | ... | |
1891 | 2067 |
} |
1892 | 2068 |
} |
1893 | 2069 |
|
2070 |
@Override |
|
1894 | 2071 |
public EditableFeature createNewFeature(boolean defaultValues) |
1895 | 2072 |
throws DataException { |
1896 | 2073 |
return this.createNewFeature(this.getDefaultFeatureType(), |
1897 | 2074 |
defaultValues); |
1898 | 2075 |
} |
1899 | 2076 |
|
2077 |
@Override |
|
1900 | 2078 |
public EditableFeature createNewFeature() throws DataException { |
1901 | 2079 |
return this.createNewFeature(this.getDefaultFeatureType(), true); |
1902 | 2080 |
} |
1903 | 2081 |
|
2082 |
@Override |
|
1904 | 2083 |
public EditableFeature createNewFeature(Feature defaultValues) throws DataException { |
1905 | 2084 |
FeatureType ft = this.getDefaultFeatureType(); |
1906 | 2085 |
EditableFeature f = this.createNewFeature(ft, false); |
1907 |
Iterator it = ft.iterator(); |
|
1908 |
while(it.hasNext()) { |
|
1909 |
FeatureAttributeDescriptor desc = (FeatureAttributeDescriptor) it.next(); |
|
1910 |
try { |
|
1911 |
f.set(desc.getName(), defaultValues.get(desc.getName())); |
|
1912 |
} catch(Throwable th) { |
|
1913 |
// Ignore |
|
1914 |
} |
|
1915 |
} |
|
2086 |
for( FeatureAttributeDescriptor desc : ft ) { |
|
2087 |
try { |
|
2088 |
f.set(desc.getName(), defaultValues.get(desc.getName())); |
|
2089 |
} catch(Throwable th) { |
|
2090 |
// Ignore |
|
2091 |
} |
|
2092 |
} |
|
1916 | 2093 |
return f; |
1917 | 2094 |
} |
1918 | 2095 |
|
2096 |
@Override |
|
1919 | 2097 |
public EditableFeatureType createFeatureType() { |
1920 | 2098 |
DefaultEditableFeatureType ftype = new DefaultEditableFeatureType(); |
1921 | 2099 |
return ftype; |
1922 | 2100 |
} |
1923 | 2101 |
|
2102 |
@Override |
|
1924 | 2103 |
public EditableFeatureType createFeatureType(String id) { |
1925 | 2104 |
DefaultEditableFeatureType ftype = new DefaultEditableFeatureType(id); |
1926 | 2105 |
return ftype; |
... | ... | |
1931 | 2110 |
// Index related methods |
1932 | 2111 |
// |
1933 | 2112 |
|
2113 |
@Override |
|
1934 | 2114 |
public FeatureIndexes getIndexes() { |
1935 | 2115 |
return this.indexes; |
1936 | 2116 |
} |
1937 | 2117 |
|
2118 |
@Override |
|
1938 | 2119 |
public FeatureIndex createIndex(FeatureType featureType, |
1939 | 2120 |
String attributeName, String indexName) throws DataException { |
1940 | 2121 |
return createIndex(null, featureType, attributeName, indexName); |
1941 | 2122 |
} |
1942 | 2123 |
|
2124 |
@Override |
|
1943 | 2125 |
public FeatureIndex createIndex(String indexTypeName, |
1944 | 2126 |
FeatureType featureType, String attributeName, String indexName) |
1945 | 2127 |
throws DataException { |
... | ... | |
1948 | 2130 |
indexName, false, null); |
1949 | 2131 |
} |
1950 | 2132 |
|
2133 |
@Override |
|
1951 | 2134 |
public FeatureIndex createIndex(FeatureType featureType, |
1952 | 2135 |
String attributeName, String indexName, Observer observer) |
1953 | 2136 |
throws DataException { |
... | ... | |
1955 | 2138 |
observer); |
1956 | 2139 |
} |
1957 | 2140 |
|
2141 |
@Override |
|
1958 | 2142 |
public FeatureIndex createIndex(String indexTypeName, |
1959 | 2143 |
FeatureType featureType, String attributeName, String indexName, |
1960 | 2144 |
final Observer observer) throws DataException { |
... | ... | |
1968 | 2152 |
boolean background, final Observer observer) throws DataException { |
1969 | 2153 |
|
1970 | 2154 |
checkNotInAppendMode(); |
1971 |
FeatureIndexProviderServices index = null; |
|
1972 |
index = |
|
1973 |
dataManager.createFeatureIndexProvider(indexTypeName, this, |
|
2155 |
FeatureIndexProviderServices index; |
|
2156 |
index = dataManager.createFeatureIndexProvider(indexTypeName, this, |
|
1974 | 2157 |
featureType, indexName, |
1975 | 2158 |
featureType.getAttributeDescriptor(attributeName)); |
1976 | 2159 |
|
... | ... | |
1989 | 2172 |
// Transforms related methods |
1990 | 2173 |
// |
1991 | 2174 |
|
2175 |
@Override |
|
1992 | 2176 |
public FeatureStoreTransforms getTransforms() { |
1993 | 2177 |
return this.transforms; |
1994 | 2178 |
} |
1995 | 2179 |
|
2180 |
@Override |
|
1996 | 2181 |
public FeatureQuery createFeatureQuery() { |
1997 | 2182 |
return new DefaultFeatureQuery(); |
1998 | 2183 |
} |
1999 | 2184 |
|
2185 |
@Override |
|
2000 | 2186 |
public DataQuery createQuery() { |
2001 | 2187 |
return createFeatureQuery(); |
2002 | 2188 |
} |
... | ... | |
2006 | 2192 |
// UndoRedo related methods |
2007 | 2193 |
// |
2008 | 2194 |
|
2195 |
@Override |
|
2009 | 2196 |
public boolean canRedo() { |
2010 | 2197 |
return commands.canRedo(); |
2011 | 2198 |
} |
2012 | 2199 |
|
2200 |
@Override |
|
2013 | 2201 |
public boolean canUndo() { |
2014 | 2202 |
return commands.canUndo(); |
2015 | 2203 |
} |
2016 | 2204 |
|
2205 |
@Override |
|
2017 | 2206 |
public void redo(int num) throws RedoException { |
2018 | 2207 |
for (int i = 0; i < num; i++) { |
2019 | 2208 |
redo(); |
2020 | 2209 |
} |
2021 | 2210 |
} |
2022 | 2211 |
|
2212 |
@Override |
|
2023 | 2213 |
public void undo(int num) throws UndoException { |
2024 | 2214 |
for (int i = 0; i < num; i++) { |
2025 | 2215 |
undo(); |
... | ... | |
2031 | 2221 |
// Metadata related methods |
2032 | 2222 |
// |
2033 | 2223 |
|
2224 |
@Override |
|
2034 | 2225 |
public Object getMetadataID() { |
2035 | 2226 |
return this.provider.getSourceId(); |
2036 | 2227 |
} |
2037 | 2228 |
|
2229 |
@Override |
|
2038 | 2230 |
public void delegate(DynObject dynObject) { |
2039 | 2231 |
this.metadata.delegate(dynObject); |
2040 | 2232 |
} |
2041 | 2233 |
|
2234 |
@Override |
|
2042 | 2235 |
public DynClass getDynClass() { |
2043 | 2236 |
return this.metadata.getDynClass(); |
2044 | 2237 |
} |
2045 | 2238 |
|
2239 |
@Override |
|
2046 | 2240 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
2047 | 2241 |
if( this.transforms.hasDynValue(name) ) { |
2048 | 2242 |
return this.transforms.getDynValue(name); |
... | ... | |
2064 | 2258 |
return this.metadata.getDynValue(name); |
2065 | 2259 |
} |
2066 | 2260 |
|
2261 |
@Override |
|
2067 | 2262 |
public boolean hasDynValue(String name) { |
2068 | 2263 |
if( this.transforms.hasDynValue(name) ) { |
2069 | 2264 |
return true; |
... | ... | |
2071 | 2266 |
return this.metadata.hasDynValue(name); |
2072 | 2267 |
} |
2073 | 2268 |
|
2269 |
@Override |
|
2074 | 2270 |
public void implement(DynClass dynClass) { |
2075 | 2271 |
this.metadata.implement(dynClass); |
2076 | 2272 |
} |
2077 | 2273 |
|
2274 |
@Override |
|
2078 | 2275 |
public Object invokeDynMethod(String name, Object[] args) |
2079 | 2276 |
throws DynMethodException { |
2080 | 2277 |
return this.metadata.invokeDynMethod(this, name, args); |
2081 | 2278 |
} |
2082 | 2279 |
|
2280 |
@Override |
|
2083 | 2281 |
public Object invokeDynMethod(int code, Object[] args) |
2084 | 2282 |
throws DynMethodException { |
2085 | 2283 |
return this.metadata.invokeDynMethod(this, code, args); |
2086 | 2284 |
} |
2087 | 2285 |
|
2286 |
@Override |
|
2088 | 2287 |
public void setDynValue(String name, Object value) |
2089 | 2288 |
throws DynFieldNotFoundException { |
2090 | 2289 |
if( this.transforms.hasDynValue(name) ) { |
... | ... | |
2100 | 2299 |
* |
2101 | 2300 |
* @see org.gvsig.metadata.Metadata#getMetadataChildren() |
2102 | 2301 |
*/ |
2302 |
@Override |
|
2103 | 2303 |
public Set getMetadataChildren() { |
2104 | 2304 |
return this.metadataChildren; |
2105 | 2305 |
} |
... | ... | |
2109 | 2309 |
* |
2110 | 2310 |
* @see org.gvsig.metadata.Metadata#getMetadataName() |
2111 | 2311 |
*/ |
2312 |
@Override |
|
2112 | 2313 |
public String getMetadataName() { |
2113 | 2314 |
return this.provider.getProviderName(); |
2114 | 2315 |
} |
... | ... | |
2117 | 2318 |
return this.featureTypeManager; |
2118 | 2319 |
} |
2119 | 2320 |
|
2321 |
@Override |
|
2120 | 2322 |
public long getFeatureCount() throws DataException { |
2121 | 2323 |
if (featureCount == null) { |
2122 |
featureCount = new Long(this.provider.getFeatureCount());
|
|
2324 |
featureCount = this.provider.getFeatureCount();
|
|
2123 | 2325 |
} |
2124 | 2326 |
if (this.isEditing()) { |
2125 | 2327 |
if(this.isAppending()) { |
... | ... | |
2131 | 2333 |
} |
2132 | 2334 |
return -1; |
2133 | 2335 |
} else { |
2134 |
return featureCount.longValue()
|
|
2336 |
return featureCount |
|
2135 | 2337 |
+ this.featureManager.getDeltaSize(); |
2136 | 2338 |
} |
2137 | 2339 |
} |
2138 |
return featureCount.longValue();
|
|
2340 |
return featureCount; |
|
2139 | 2341 |
} |
2140 | 2342 |
|
2141 | 2343 |
private Long getTemporalOID() { |
2142 |
return new Long(this.temporalOid++);
|
|
2344 |
return this.temporalOid++;
|
|
2143 | 2345 |
} |
2144 | 2346 |
|
2347 |
@Override |
|
2145 | 2348 |
public FeatureType getProviderFeatureType(String featureTypeId) { |
2146 | 2349 |
if (featureTypeId == null) { |
2147 | 2350 |
return this.defaultFeatureType; |
... | ... | |
2157 | 2360 |
return null; |
2158 | 2361 |
} |
2159 | 2362 |
|
2363 |
@Override |
|
2160 | 2364 |
public FeatureProvider getFeatureProviderFromFeature(Feature feature) { |
2161 | 2365 |
return ((DefaultFeature) feature).getData(); |
2162 | 2366 |
} |
2163 | 2367 |
|
2368 |
@Override |
|
2164 | 2369 |
public DataStore getStore() { |
2165 | 2370 |
return this; |
2166 | 2371 |
} |
2167 | 2372 |
|
2373 |
@Override |
|
2168 | 2374 |
public FeatureStore getFeatureStore() { |
2169 | 2375 |
return this; |
2170 | 2376 |
} |
2171 | 2377 |
|
2378 |
@Override |
|
2172 | 2379 |
public void createCache(String name, DynObject parameters) |
2173 | 2380 |
throws DataException { |
2174 | 2381 |
cache = dataManager.createFeatureCacheProvider(name, parameters); |
... | ... | |
2181 | 2388 |
featureCount = null; |
2182 | 2389 |
} |
2183 | 2390 |
|
2391 |
@Override |
|
2184 | 2392 |
public FeatureCache getCache() { |
2185 | 2393 |
return cache; |
2186 | 2394 |
} |
2187 | 2395 |
|
2396 |
@Override |
|
2188 | 2397 |
public void clear() { |
2189 | 2398 |
if (metadata != null) { |
2190 | 2399 |
metadata.clear(); |
2191 | 2400 |
} |
2192 | 2401 |
} |
2193 | 2402 |
|
2403 |
@Override |
|
2194 | 2404 |
public String getName() { |
2195 |
return this.provider.getName(); |
|
2405 |
if( this.provider != null ) { |
|
2406 |
return this.provider.getName(); |
|
2407 |
} |
|
2408 |
if( this.parameters instanceof HasAFile ) { |
|
2409 |
return FilenameUtils.getName(((HasAFile)this.parameters).getFile().getName()); |
|
2410 |
} |
|
2411 |
return "unknow"; |
|
2196 | 2412 |
} |
2197 | 2413 |
|
2414 |
@Override |
|
2198 | 2415 |
public String getFullName() { |
2199 | 2416 |
try { |
2200 |
return this.provider.getFullName(); |
|
2417 |
if( this.provider!=null ) { |
|
2418 |
return this.provider.getFullName(); |
|
2419 |
} |
|
2420 |
if( this.parameters instanceof HasAFile ) { |
|
2421 |
return (((HasAFile)this.parameters).getFile().getAbsolutePath()); |
|
2422 |
} |
|
2423 |
return null; |
|
2201 | 2424 |
} catch(Throwable th) { |
2202 | 2425 |
return null; |
2203 | 2426 |
} |
2204 | 2427 |
} |
2205 | 2428 |
|
2429 |
@Override |
|
2206 | 2430 |
public String getProviderName() { |
2207 |
return this.provider.getProviderName(); |
|
2431 |
if( this.provider!=null ) { |
|
2432 |
return this.provider.getProviderName(); |
|
2433 |
} |
|
2434 |
if( this.parameters != null ) { |
|
2435 |
return this.parameters.getDataStoreName(); |
|
2436 |
} |
|
2437 |
return null; |
|
2438 |
|
|
2208 | 2439 |
} |
2209 | 2440 |
|
2441 |
@Override |
|
2210 | 2442 |
public boolean isKnownEnvelope() { |
2211 | 2443 |
return this.provider.isKnownEnvelope(); |
2212 | 2444 |
} |
2213 | 2445 |
|
2446 |
@Override |
|
2214 | 2447 |
public boolean hasRetrievedFeaturesLimit() { |
2215 | 2448 |
return this.provider.hasRetrievedFeaturesLimit(); |
2216 | 2449 |
} |
2217 | 2450 |
|
2451 |
@Override |
|
2218 | 2452 |
public int getRetrievedFeaturesLimit() { |
2219 | 2453 |
return this.provider.getRetrievedFeaturesLimit(); |
2220 | 2454 |
} |
2221 | 2455 |
|
2456 |
@Override |
|
2222 | 2457 |
public Interval getInterval() { |
2223 | 2458 |
if( this.timeSupport!=null ) { |
2224 | 2459 |
return this.timeSupport.getInterval(); |
... | ... | |
2226 | 2461 |
return this.provider.getInterval(); |
2227 | 2462 |
} |
2228 | 2463 |
|
2464 |
@Override |
|
2229 | 2465 |
public Collection getTimes() { |
2230 | 2466 |
if( this.timeSupport!=null ) { |
2231 | 2467 |
return this.timeSupport.getTimes(); |
... | ... | |
2233 | 2469 |
return this.provider.getTimes(); |
2234 | 2470 |
} |
2235 | 2471 |
|
2472 |
@Override |
|
2236 | 2473 |
public Collection getTimes(Interval interval) { |
2237 | 2474 |
if( this.timeSupport!=null ) { |
2238 | 2475 |
return this.timeSupport.getTimes(interval); |
... | ... | |
2265 | 2502 |
this.timeSupport = timeSupport; |
2266 | 2503 |
} |
2267 | 2504 |
|
2268 |
/* (non-Javadoc) |
|
2269 |
* @see java.lang.Object#clone() |
|
2270 |
*/ |
|
2505 |
@Override |
|
2271 | 2506 |
public Object clone() throws CloneNotSupportedException { |
2272 | 2507 |
|
2273 | 2508 |
DataStoreParameters dsp = getParameters(); |
... | ... | |
2288 | 2523 |
|
2289 | 2524 |
} |
2290 | 2525 |
|
2526 |
@Override |
|
2291 | 2527 |
public Feature getFeature(DynObject dynobject) { |
2292 | 2528 |
if (dynobject instanceof DynObjectFeatureFacade){ |
2293 | 2529 |
Feature f = ((DynObjectFeatureFacade)dynobject).getFeature(); |
... | ... | |
2296 | 2532 |
return null; |
2297 | 2533 |
} |
2298 | 2534 |
|
2535 |
@Override |
|
2299 | 2536 |
public Iterator iterator() { |
2300 | 2537 |
try { |
2301 | 2538 |
return this.getFeatureSet().fastIterator(); |
... | ... | |
2329 | 2566 |
public void useCache(String providerName, DynObject parameters) throws DataException { |
2330 | 2567 |
throw new UnsupportedOperationException(); |
2331 | 2568 |
} |
2569 |
|
|
2570 |
@Override |
|
2571 |
public boolean isBroken() { |
|
2572 |
return this.state.isBroken(); |
|
2573 |
} |
|
2574 |
|
|
2575 |
@Override |
|
2576 |
public Throwable getBreakingsCause() { |
|
2577 |
return this.state.getBreakingsCause(); |
|
2578 |
} |
|
2332 | 2579 |
} |
Also available in: Unified diff