Revision 25267 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.*; |
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Collections; |
|
5 |
import java.util.Iterator; |
|
6 |
import java.util.List; |
|
4 | 7 |
|
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.*; |
|
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.StoreUpdateFeatureException; |
|
54 |
import org.gvsig.fmap.dal.feature.exception.StoreUpdateFeatureTypeException; |
|
55 |
import org.gvsig.fmap.dal.feature.exception.ValidateFeaturesException; |
|
56 |
import org.gvsig.fmap.dal.feature.exception.WriteNotAllowedException; |
|
9 | 57 |
import org.gvsig.fmap.dal.feature.impl.expansionadapter.MemoryExpansionAdapter; |
10 | 58 |
import org.gvsig.fmap.dal.feature.impl.featureset.DefaultFeatureSet; |
11 | 59 |
import org.gvsig.fmap.dal.feature.impl.undo.DefaultFeatureCommandsStack; |
12 | 60 |
import org.gvsig.fmap.dal.feature.impl.undo.FeatureCommandsStack; |
13 |
import org.gvsig.fmap.dal.feature.spi.*; |
|
61 |
import org.gvsig.fmap.dal.feature.spi.DefaultFeatureData; |
|
62 |
import org.gvsig.fmap.dal.feature.spi.FeatureData; |
|
63 |
import org.gvsig.fmap.dal.feature.spi.FeatureLocks; |
|
64 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
|
65 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider; |
|
66 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices; |
|
14 | 67 |
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProviderServices; |
15 | 68 |
import org.gvsig.fmap.dal.impl.DefaultDataManager; |
16 | 69 |
import org.gvsig.fmap.geom.primitive.Envelope; |
17 | 70 |
import org.gvsig.metadata.Metadata; |
71 |
import org.gvsig.tools.ToolsLocator; |
|
18 | 72 |
import org.gvsig.tools.exception.BaseException; |
19 | 73 |
import org.gvsig.tools.exception.NotYetImplemented; |
20 | 74 |
import org.gvsig.tools.observer.Observable; |
... | ... | |
23 | 77 |
import org.gvsig.tools.operations.OperationContext; |
24 | 78 |
import org.gvsig.tools.operations.OperationException; |
25 | 79 |
import org.gvsig.tools.operations.OperationNotSupportedException; |
26 |
import org.gvsig.tools.persistence.*; |
|
80 |
import org.gvsig.tools.persistence.AbstractPersistenceManager; |
|
81 |
import org.gvsig.tools.persistence.PersistenceException; |
|
82 |
import org.gvsig.tools.persistence.PersistenceValueNotFoundException; |
|
83 |
import org.gvsig.tools.persistence.PersistentState; |
|
84 |
import org.gvsig.tools.task.Executor; |
|
27 | 85 |
import org.gvsig.tools.undo.RedoException; |
28 | 86 |
import org.gvsig.tools.undo.UndoException; |
29 | 87 |
import org.gvsig.tools.undo.command.Command; |
... | ... | |
893 | 951 |
private FeatureStore store; |
894 | 952 |
private FeatureQuery query; |
895 | 953 |
private Observer observer; |
954 |
private Executor executor; |
|
955 |
private FeatureStoreNotification notification; |
|
896 | 956 |
|
897 | 957 |
public LoadInBackGround(FeatureStore store, FeatureQuery query, |
898 |
Observer observer) { |
|
958 |
Observer observer, Executor executor) {
|
|
899 | 959 |
this.store = store; |
900 | 960 |
this.query = query; |
901 | 961 |
this.observer = observer; |
962 |
this.executor = executor; |
|
902 | 963 |
} |
903 | 964 |
|
965 |
void notify(FeatureStoreNotification theNotification) { |
|
966 |
if (executor == null) { |
|
967 |
observer.update(store, theNotification); |
|
968 |
return; |
|
969 |
} |
|
970 |
this.notification = theNotification; |
|
971 |
executor.execute(new Runnable() { |
|
972 |
public void run() { |
|
973 |
observer.update(store, notification); |
|
974 |
} |
|
975 |
}); |
|
976 |
|
|
977 |
} |
|
978 |
|
|
904 | 979 |
public void run() { |
905 | 980 |
try { |
906 |
FeatureSet collection = store.getFeatureSet(query); |
|
907 |
observer.update( |
|
908 |
store, |
|
909 |
new DefaultFeatureStoreNotification( |
|
910 |
store, |
|
911 |
FeatureStoreNotification.LOAD_FINISHED, |
|
912 |
collection |
|
913 |
) |
|
914 |
); |
|
981 |
FeatureSet set = store.getFeatureSet(query); |
|
982 |
notify(new DefaultFeatureStoreNotification(store, |
|
983 |
FeatureStoreNotification.LOAD_FINISHED, set)); |
|
915 | 984 |
} catch (Exception e) { |
916 |
observer.update( |
|
917 |
store, |
|
918 |
new DefaultFeatureStoreNotification( |
|
919 |
store, |
|
920 |
FeatureStoreNotification.LOAD_FINISHED, |
|
921 |
e |
|
922 |
) |
|
923 |
); |
|
985 |
notify(new DefaultFeatureStoreNotification(store, |
|
986 |
FeatureStoreNotification.LOAD_FINISHED, e)); |
|
924 | 987 |
} |
925 | 988 |
} |
926 | 989 |
} |
... | ... | |
929 | 992 |
if (query == null) { |
930 | 993 |
query = new FeatureQuery(this.getDefaultFeatureType()); |
931 | 994 |
} |
932 |
LoadInBackGround task = new LoadInBackGround(this, query, observer); |
|
995 |
Executor executor = ToolsLocator.getTaskManager().getExecutor(); |
|
996 |
LoadInBackGround task = new LoadInBackGround(this, query, observer, |
|
997 |
executor); |
|
933 | 998 |
Thread thread = new Thread(task); |
934 | 999 |
thread.run(); |
935 | 1000 |
} |
Also available in: Unified diff