Revision 24961 branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java
DefaultFeatureStore.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.dal.feature.impl; |
2 | 2 |
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Collections; |
|
5 |
import java.util.Iterator; |
|
6 |
import java.util.List; |
|
3 |
import java.util.*; |
|
7 | 4 |
|
8 |
import org.gvsig.fmap.dal.DALLocator; |
|
9 |
import org.gvsig.fmap.dal.DataManager; |
|
10 |
import org.gvsig.fmap.dal.DataQuery; |
|
11 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
12 |
import org.gvsig.fmap.dal.DataSet; |
|
13 |
import org.gvsig.fmap.dal.DataStoreNotification; |
|
14 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
15 |
import org.gvsig.fmap.dal.exception.CloseException; |
|
16 |
import org.gvsig.fmap.dal.exception.DataException; |
|
17 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
18 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
19 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
20 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
21 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
22 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
23 |
import org.gvsig.fmap.dal.feature.Feature; |
|
24 |
import org.gvsig.fmap.dal.feature.FeatureIndex; |
|
25 |
import org.gvsig.fmap.dal.feature.FeatureIndexes; |
|
26 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
27 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
28 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
29 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
30 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
31 |
import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransforms; |
|
33 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
34 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
35 |
import org.gvsig.fmap.dal.feature.exception.AlreadyEditingException; |
|
36 |
import org.gvsig.fmap.dal.feature.exception.ConcurrentDataModificationException; |
|
37 |
import org.gvsig.fmap.dal.feature.exception.CreateFeatureException; |
|
38 |
import org.gvsig.fmap.dal.feature.exception.DataExportException; |
|
39 |
import org.gvsig.fmap.dal.feature.exception.FeatureIndexException; |
|
40 |
import org.gvsig.fmap.dal.feature.exception.FinishEditingException; |
|
41 |
import org.gvsig.fmap.dal.feature.exception.GetFeatureTypeException; |
|
42 |
import org.gvsig.fmap.dal.feature.exception.IllegalFeatureException; |
|
43 |
import org.gvsig.fmap.dal.feature.exception.IllegalFeatureTypeException; |
|
44 |
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException; |
|
45 |
import org.gvsig.fmap.dal.feature.exception.NoNewFeatureInsertException; |
|
46 |
import org.gvsig.fmap.dal.feature.exception.NullFeatureTypeException; |
|
47 |
import org.gvsig.fmap.dal.feature.exception.SelectionNotAllowedException; |
|
48 |
import org.gvsig.fmap.dal.feature.exception.StoreCancelEditingException; |
|
49 |
import org.gvsig.fmap.dal.feature.exception.StoreDeleteEditableFeatureException; |
|
50 |
import org.gvsig.fmap.dal.feature.exception.StoreDeleteFeatureException; |
|
51 |
import org.gvsig.fmap.dal.feature.exception.StoreEditException; |
|
52 |
import org.gvsig.fmap.dal.feature.exception.StoreInsertFeatureException; |
|
53 |
import org.gvsig.fmap.dal.feature.exception.StoreRedoException; |
|
54 |
import org.gvsig.fmap.dal.feature.exception.StoreUndoException; |
|
55 |
import org.gvsig.fmap.dal.feature.exception.StoreUpdateFeatureException; |
|
56 |
import org.gvsig.fmap.dal.feature.exception.StoreUpdateFeatureTypeException; |
|
57 |
import org.gvsig.fmap.dal.feature.exception.ValidateFeaturesException; |
|
58 |
import org.gvsig.fmap.dal.feature.exception.WriteNotAllowedException; |
|
59 |
import org.gvsig.fmap.dal.feature.impl.commands.AbstractCommandsRecord; |
|
60 |
import org.gvsig.fmap.dal.feature.impl.commands.implementation.FeatureCommandsRecord; |
|
5 |
import org.gvsig.fmap.dal.*; |
|
6 |
import org.gvsig.fmap.dal.exception.*; |
|
7 |
import org.gvsig.fmap.dal.feature.*; |
|
8 |
import org.gvsig.fmap.dal.feature.exception.*; |
|
61 | 9 |
import org.gvsig.fmap.dal.feature.impl.expansionadapter.MemoryExpansionAdapter; |
62 | 10 |
import org.gvsig.fmap.dal.feature.impl.featureset.DefaultFeatureSet; |
63 |
import org.gvsig.fmap.dal.feature.spi.DefaultFeatureData; |
|
64 |
import org.gvsig.fmap.dal.feature.spi.FeatureData; |
|
65 |
import org.gvsig.fmap.dal.feature.spi.FeatureLocks; |
|
66 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
|
67 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider; |
|
68 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices; |
|
11 |
import org.gvsig.fmap.dal.feature.impl.undo.DefaultFeatureCommandsStack; |
|
12 |
import org.gvsig.fmap.dal.feature.impl.undo.FeatureCommandsStack; |
|
13 |
import org.gvsig.fmap.dal.feature.spi.*; |
|
69 | 14 |
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProviderServices; |
70 | 15 |
import org.gvsig.fmap.dal.impl.DefaultDataManager; |
71 | 16 |
import org.gvsig.fmap.geom.primitive.Envelope; |
... | ... | |
78 | 23 |
import org.gvsig.tools.operations.OperationContext; |
79 | 24 |
import org.gvsig.tools.operations.OperationException; |
80 | 25 |
import org.gvsig.tools.operations.OperationNotSupportedException; |
81 |
import org.gvsig.tools.persistence.AbstractPersistenceManager; |
|
82 |
import org.gvsig.tools.persistence.PersistenceException; |
|
83 |
import org.gvsig.tools.persistence.PersistenceValueNotFoundException; |
|
84 |
import org.gvsig.tools.persistence.PersistentState; |
|
26 |
import org.gvsig.tools.persistence.*; |
|
27 |
import org.gvsig.tools.undo.RedoException; |
|
28 |
import org.gvsig.tools.undo.UndoException; |
|
85 | 29 |
import org.gvsig.tools.undo.command.Command; |
86 |
import org.gvsig.tools.undo.command.UndoRedoCommandStack; |
|
87 | 30 |
import org.slf4j.Logger; |
88 | 31 |
import org.slf4j.LoggerFactory; |
89 | 32 |
|
... | ... | |
100 | 43 |
|
101 | 44 |
private DelegateWeakReferencingObservable delegateObservable = new DelegateWeakReferencingObservable(this); |
102 | 45 |
|
103 |
private AbstractCommandsRecord commands;
|
|
46 |
private FeatureCommandsStack commands;
|
|
104 | 47 |
private FeatureTypeManager featureTypeManager; |
105 | 48 |
private FeatureManager featureManager; |
106 | 49 |
private SpatialManager spatialManager; |
... | ... | |
413 | 356 |
return this.provider.isLocksSupported(); |
414 | 357 |
} |
415 | 358 |
|
416 |
|
|
417 | 359 |
public FeatureSet getLocks() throws DataException { |
418 | 360 |
if (!this.provider.isLocksSupported()) { |
419 | 361 |
getLogger().warn("Locks not supporteds"); |
... | ... | |
588 | 530 |
new MemoryExpansionAdapter()); |
589 | 531 |
spatialManager = new SpatialManager(); |
590 | 532 |
|
591 |
commands = new FeatureCommandsRecord(featureManager,
|
|
533 |
commands = new DefaultFeatureCommandsStack(featureManager,
|
|
592 | 534 |
spatialManager, featureTypeManager); |
593 | 535 |
this.mode = MODE_FULLEDIT; |
594 | 536 |
hasStrongChanges = false; |
... | ... | |
729 | 671 |
} |
730 | 672 |
} |
731 | 673 |
|
732 |
synchronized public void redo() throws DataException {
|
|
733 |
try {
|
|
734 |
checkInEditingMode();
|
|
735 |
Command redo = commands.getNextRedoCommand();
|
|
736 |
notifyChange(FeatureStoreNotification.BEFORE_REDO, redo);
|
|
737 |
newVersionOfUpdate();
|
|
738 |
commands.redo();
|
|
739 |
hasStrongChanges = true;
|
|
740 |
notifyChange(FeatureStoreNotification.AFTER_REDO, redo);
|
|
741 |
} catch (Exception e) {
|
|
742 |
throw new StoreRedoException(e, this.getName());
|
|
743 |
}
|
|
674 |
synchronized public void redo() throws RedoException {
|
|
675 |
Command redo = commands.getNextRedoCommand();
|
|
676 |
try {
|
|
677 |
checkInEditingMode();
|
|
678 |
} catch (NeedEditingModeException ex) {
|
|
679 |
throw new RedoException(redo, ex);
|
|
680 |
}
|
|
681 |
notifyChange(FeatureStoreNotification.BEFORE_REDO, redo);
|
|
682 |
newVersionOfUpdate();
|
|
683 |
commands.redo();
|
|
684 |
hasStrongChanges = true;
|
|
685 |
notifyChange(FeatureStoreNotification.AFTER_REDO, redo);
|
|
744 | 686 |
} |
745 | 687 |
|
746 |
synchronized public void undo() throws DataException {
|
|
747 |
try {
|
|
748 |
checkInEditingMode();
|
|
749 |
Command undo = commands.getNextUndoCommand();
|
|
750 |
notifyChange(FeatureStoreNotification.BEFORE_UNDO, undo);
|
|
751 |
newVersionOfUpdate();
|
|
752 |
commands.undo();
|
|
753 |
hasStrongChanges = true;
|
|
754 |
notifyChange(FeatureStoreNotification.AFTER_UNDO, undo);
|
|
755 |
} catch (Exception e) {
|
|
756 |
throw new StoreUndoException(e, this.getName());
|
|
757 |
}
|
|
688 |
synchronized public void undo() throws UndoException {
|
|
689 |
Command undo = commands.getNextUndoCommand();
|
|
690 |
try {
|
|
691 |
checkInEditingMode();
|
|
692 |
} catch (NeedEditingModeException ex) {
|
|
693 |
throw new UndoException(undo, ex);
|
|
694 |
}
|
|
695 |
notifyChange(FeatureStoreNotification.BEFORE_UNDO, undo);
|
|
696 |
newVersionOfUpdate();
|
|
697 |
commands.undo();
|
|
698 |
hasStrongChanges = true;
|
|
699 |
notifyChange(FeatureStoreNotification.AFTER_UNDO, undo);
|
|
758 | 700 |
} |
759 | 701 |
|
760 |
synchronized public UndoRedoCommandStack getCommandsRecord() throws DataException { |
|
761 |
checkInEditingMode(); |
|
762 |
return commands; |
|
763 |
} |
|
702 |
public List getRedoInfos() { |
|
703 |
if (isEditing() && commands != null) { |
|
704 |
return commands.getRedoInfos(); |
|
705 |
} else { |
|
706 |
return null; |
|
707 |
} |
|
708 |
} |
|
764 | 709 |
|
710 |
public List getUndoInfos() { |
|
711 |
if (isEditing() && commands != null) { |
|
712 |
return commands.getUndoInfos(); |
|
713 |
} else { |
|
714 |
return null; |
|
715 |
} |
|
716 |
} |
|
717 |
|
|
718 |
public synchronized FeatureCommandsStack getCommandsStack() |
|
719 |
throws DataException { |
|
720 |
checkInEditingMode(); |
|
721 |
return commands; |
|
722 |
} |
|
723 |
|
|
765 | 724 |
synchronized public void cancelEditing() throws DataException { |
766 | 725 |
try { |
767 | 726 |
checkInEditingMode(); |
... | ... | |
1173 | 1132 |
public FeatureStoreTransforms getTransforms() { |
1174 | 1133 |
return this.transforms; |
1175 | 1134 |
} |
1176 |
|
|
1135 |
|
|
1177 | 1136 |
public FeatureQuery createFeatureQuery() { |
1178 |
return new FeatureQuery();
|
|
1179 |
}
|
|
1137 |
return new FeatureQuery();
|
|
1138 |
}
|
|
1180 | 1139 |
|
1181 |
} |
|
1140 |
public boolean canRedo() { |
|
1141 |
return commands.canRedo(); |
|
1142 |
} |
|
1143 |
|
|
1144 |
public boolean canUndo() { |
|
1145 |
return commands.canUndo(); |
|
1146 |
} |
|
1147 |
|
|
1148 |
public void redo(int num) throws RedoException { |
|
1149 |
commands.redo(num); |
|
1150 |
} |
|
1151 |
|
|
1152 |
public void undo(int num) throws UndoException { |
|
1153 |
commands.undo(num); |
|
1154 |
} |
|
1155 |
} |
Also available in: Unified diff