Revision 41818 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 | ||
---|---|---|
102 | 102 |
import org.gvsig.fmap.dal.feature.exception.WriteNotAllowedException; |
103 | 103 |
import org.gvsig.fmap.dal.feature.impl.expansionadapter.MemoryExpansionAdapter; |
104 | 104 |
import org.gvsig.fmap.dal.feature.impl.featureset.DefaultFeatureSet; |
105 |
import org.gvsig.fmap.dal.feature.impl.featureset.DynObjectFeatureFacade; |
|
105 | 106 |
import org.gvsig.fmap.dal.feature.impl.undo.DefaultFeatureCommandsStack; |
106 | 107 |
import org.gvsig.fmap.dal.feature.impl.undo.FeatureCommandsStack; |
107 | 108 |
import org.gvsig.fmap.dal.feature.spi.DefaultFeatureProvider; |
... | ... | |
181 | 182 |
private DefaultFeatureStoreTransforms transforms; |
182 | 183 |
|
183 | 184 |
DelegatedDynObject metadata; |
184 |
|
|
185 |
|
|
185 | 186 |
private Set metadataChildren; |
186 | 187 |
|
187 | 188 |
private Long featureCount = null; |
... | ... | |
192 | 193 |
|
193 | 194 |
/* |
194 | 195 |
* TODO: |
195 |
*
|
|
196 |
* |
|
196 | 197 |
* - Comprobar que solo se pueden a�adir reglas de validacion sobre un |
197 | 198 |
* EditableFeatureType. - Comprobar que solo se puede hacer un update con un |
198 | 199 |
* featureType al que se le han cambiado las reglas de validacion cuando |
... | ... | |
334 | 335 |
* // TODO: |
335 | 336 |
* // Si el provider devuelbe null habria que ver de construir aqui |
336 | 337 |
* // los metadatos basicos, como el Envelope y el SRS. |
337 |
*
|
|
338 |
* |
|
338 | 339 |
* // TODO: Estando en edicion el Envelope deberia de |
339 | 340 |
* // actualizarse usando el spatialManager |
340 | 341 |
* return this.provider.getMetadata(); |
... | ... | |
344 | 345 |
public Envelope getEnvelope() throws DataException { |
345 | 346 |
if (this.mode == MODE_FULLEDIT) { |
346 | 347 |
// Just in case another thread tries to write in the store |
347 |
synchronized (this) {
|
|
348 |
synchronized (this) { |
|
348 | 349 |
return this.spatialManager.getEnvelope(); |
349 | 350 |
} |
350 | 351 |
} |
... | ... | |
479 | 480 |
|
480 | 481 |
String defFTypeid = state.getString("defaultFeatureTypeId"); |
481 | 482 |
FeatureType ftype = null; |
482 |
|
|
483 |
|
|
483 | 484 |
if (this.defaultFeatureType == null || |
484 | 485 |
this.defaultFeatureType.getId() == null || |
485 | 486 |
!this.defaultFeatureType.getId().equals( |
... | ... | |
973 | 974 |
} |
974 | 975 |
} |
975 | 976 |
|
976 |
public void delete(Feature feature) throws DataException {
|
|
977 |
public void delete(Feature feature) throws DataException { |
|
977 | 978 |
this.commands.delete(feature); |
978 | 979 |
} |
979 |
|
|
980 |
|
|
980 | 981 |
synchronized public void doDelete(Feature feature) throws DataException { |
981 | 982 |
try { |
982 | 983 |
checkInEditingMode(); |
... | ... | |
984 | 985 |
if (feature instanceof EditableFeature) { |
985 | 986 |
throw new StoreDeleteEditableFeatureException(getName()); |
986 | 987 |
} |
987 |
notifyChange(FeatureStoreNotification.BEFORE_DELETE, feature);
|
|
988 |
|
|
988 |
notifyChange(FeatureStoreNotification.BEFORE_DELETE, feature); |
|
989 |
|
|
989 | 990 |
//Update the featureManager and the spatialManager |
990 | 991 |
featureManager.delete(feature.getReference()); |
991 | 992 |
spatialManager.deleteFeature(feature); |
992 |
|
|
993 |
|
|
993 | 994 |
newVersionOfUpdate(); |
994 | 995 |
hasStrongChanges = true; |
995 | 996 |
notifyChange(FeatureStoreNotification.AFTER_DELETE, feature); |
... | ... | |
1000 | 1001 |
|
1001 | 1002 |
private static EditableFeature lastChangedFeature = null; |
1002 | 1003 |
|
1003 |
public synchronized void insert(EditableFeature feature)
|
|
1004 |
public synchronized void insert(EditableFeature feature) |
|
1004 | 1005 |
throws DataException { |
1005 | 1006 |
LOG.debug("In editing mode {}, insert feature: {}", new Integer(mode), |
1006 | 1007 |
feature); |
... | ... | |
1023 | 1024 |
notifyChange(FeatureStoreNotification.AFTER_INSERT, feature); |
1024 | 1025 |
break; |
1025 | 1026 |
|
1026 |
case MODE_FULLEDIT:
|
|
1027 |
case MODE_FULLEDIT: |
|
1027 | 1028 |
if (feature.getSource() != null) { |
1028 | 1029 |
throw new NoNewFeatureInsertException(this.getName()); |
1029 | 1030 |
} |
1030 |
commands.insert(feature);
|
|
1031 |
commands.insert(feature); |
|
1031 | 1032 |
} |
1032 | 1033 |
} catch (Exception e) { |
1033 | 1034 |
throw new StoreInsertFeatureException(e, this.getName()); |
1034 | 1035 |
} |
1035 | 1036 |
} |
1036 |
|
|
1037 |
|
|
1037 | 1038 |
synchronized public void doInsert(EditableFeature feature) |
1038 | 1039 |
throws DataException { |
1039 | 1040 |
checkIsOwnFeature(feature); |
1040 |
|
|
1041 |
|
|
1041 | 1042 |
waitForIndexes(); |
1042 | 1043 |
|
1043 | 1044 |
notifyChange(FeatureStoreNotification.BEFORE_INSERT, feature); |
... | ... | |
1051 | 1052 |
//Update the featureManager and the spatialManager |
1052 | 1053 |
((DefaultEditableFeature) feature).setInserted(true); |
1053 | 1054 |
DefaultFeature newFeature = (DefaultFeature) feature.getNotEditableCopy(); |
1054 |
|
|
1055 |
|
|
1055 |
|
|
1056 |
|
|
1056 | 1057 |
featureManager.add(newFeature); |
1057 | 1058 |
spatialManager.insertFeature(newFeature); |
1058 |
|
|
1059 |
|
|
1059 | 1060 |
hasStrongChanges = true; |
1060 | 1061 |
hasInserts = true; |
1061 |
notifyChange(FeatureStoreNotification.AFTER_INSERT, feature);
|
|
1062 |
notifyChange(FeatureStoreNotification.AFTER_INSERT, feature); |
|
1062 | 1063 |
} |
1063 |
|
|
1064 |
|
|
1064 | 1065 |
public void update(EditableFeature feature) |
1065 |
throws DataException {
|
|
1066 |
throws DataException { |
|
1066 | 1067 |
if ((feature).getSource() == null) { |
1067 | 1068 |
insert(feature); |
1068 | 1069 |
return; |
... | ... | |
1072 | 1073 |
|
1073 | 1074 |
synchronized public void doUpdate(EditableFeature feature, Feature oldFeature) |
1074 | 1075 |
throws DataException { |
1075 |
try {
|
|
1076 |
try { |
|
1076 | 1077 |
checkInEditingMode(); |
1077 | 1078 |
checkIsOwnFeature(feature); |
1078 | 1079 |
notifyChange(FeatureStoreNotification.BEFORE_UPDATE, feature); |
... | ... | |
1083 | 1084 |
feature.validate(Feature.UPDATE); |
1084 | 1085 |
lastChangedFeature = null; |
1085 | 1086 |
} |
1086 |
|
|
1087 |
|
|
1087 | 1088 |
//Update the featureManager and the spatialManager |
1088 | 1089 |
Feature newf = feature.getNotEditableCopy(); |
1089 | 1090 |
featureManager.update(newf, oldFeature); |
1090 | 1091 |
spatialManager.updateFeature(newf, oldFeature); |
1091 |
|
|
1092 |
|
|
1092 | 1093 |
hasStrongChanges = true; |
1093 | 1094 |
notifyChange(FeatureStoreNotification.AFTER_UPDATE, feature); |
1094 | 1095 |
} catch (Exception e) { |
... | ... | |
1170 | 1171 |
synchronized public void finishEditing() throws DataException { |
1171 | 1172 |
LOG.debug("finish editing of mode: {}", new Integer(mode)); |
1172 | 1173 |
try { |
1173 |
|
|
1174 |
|
|
1174 | 1175 |
/* |
1175 | 1176 |
* Selection needs to be cleared when editing stops |
1176 | 1177 |
* to prevent conflicts with selection remaining from |
1177 | 1178 |
* editing mode. |
1178 | 1179 |
*/ |
1179 | 1180 |
((FeatureSelection) this.getSelection()).deselectAll(); |
1180 |
|
|
1181 |
|
|
1181 | 1182 |
switch (mode) { |
1182 | 1183 |
case MODE_QUERY: |
1183 | 1184 |
throw new NeedEditingModeException(this.getName()); |
... | ... | |
1197 | 1198 |
notifyChange(FeatureStoreNotification.BEFORE_FINISHEDITING); |
1198 | 1199 |
if (hasStrongChanges) { |
1199 | 1200 |
validateFeatures(Feature.FINISH_EDITING); |
1200 |
|
|
1201 |
|
|
1201 | 1202 |
/* |
1202 | 1203 |
* This will throw a PerformEditingExceptionif the provider |
1203 | 1204 |
* does not accept the changes (for example, an invalid field name) |
... | ... | |
1285 | 1286 |
default: |
1286 | 1287 |
case MODE_QUERY: |
1287 | 1288 |
return false; |
1288 |
|
|
1289 |
|
|
1289 | 1290 |
case MODE_APPEND: |
1290 | 1291 |
return true; |
1291 |
|
|
1292 |
|
|
1292 | 1293 |
case MODE_FULLEDIT: |
1293 | 1294 |
List types = this.getFeatureTypes(); |
1294 | 1295 |
for( int i=0; i<types.size(); i++ ) { |
... | ... | |
1302 | 1303 |
return true; |
1303 | 1304 |
} |
1304 | 1305 |
} |
1305 |
|
|
1306 |
|
|
1306 | 1307 |
public void beginEditingGroup(String description) |
1307 | 1308 |
throws NeedEditingModeException { |
1308 | 1309 |
checkInEditingMode(); |
... | ... | |
1524 | 1525 |
return f; |
1525 | 1526 |
} |
1526 | 1527 |
} |
1527 |
|
|
1528 |
|
|
1528 |
|
|
1529 |
|
|
1529 | 1530 |
DefaultFeature feature = |
1530 | 1531 |
new DefaultFeature(this, |
1531 | 1532 |
this.provider.getFeatureProviderByReference( |
... | ... | |
1645 | 1646 |
|
1646 | 1647 |
public FeatureType getDefaultFeatureType() throws DataException { |
1647 | 1648 |
try { |
1648 |
|
|
1649 |
|
|
1649 | 1650 |
if (isEditing()) { |
1650 | 1651 |
FeatureType auxFeatureType = |
1651 | 1652 |
featureTypeManager.getType(defaultFeatureType.getId()); |
... | ... | |
1657 | 1658 |
if (type != null) { |
1658 | 1659 |
return avoidEditable(type); |
1659 | 1660 |
} |
1660 |
|
|
1661 |
|
|
1661 | 1662 |
return avoidEditable(defaultFeatureType); |
1662 |
|
|
1663 |
|
|
1663 | 1664 |
} catch (Exception e) { |
1664 | 1665 |
throw new GetFeatureTypeException(e, getName()); |
1665 | 1666 |
} |
1666 | 1667 |
} |
1667 |
|
|
1668 |
|
|
1668 | 1669 |
private FeatureType avoidEditable(FeatureType ft) { |
1669 | 1670 |
if (ft instanceof EditableFeatureType) { |
1670 | 1671 |
return ((EditableFeatureType) ft).getNotEditableCopy(); |
... | ... | |
1766 | 1767 |
new DefaultEditableFeature(this, data); |
1767 | 1768 |
feature.initializeValues(defaultValues); |
1768 | 1769 |
data.setNew(true); |
1769 |
|
|
1770 |
|
|
1770 | 1771 |
return feature; |
1771 | 1772 |
} catch (Exception e) { |
1772 | 1773 |
throw new CreateFeatureException(e, getName()); |
... | ... | |
1993 | 1994 |
|
1994 | 1995 |
/* |
1995 | 1996 |
* (non-Javadoc) |
1996 |
*
|
|
1997 |
* |
|
1997 | 1998 |
* @see org.gvsig.metadata.Metadata#getMetadataChildren() |
1998 | 1999 |
*/ |
1999 | 2000 |
public Set getMetadataChildren() { |
... | ... | |
2002 | 2003 |
|
2003 | 2004 |
/* |
2004 | 2005 |
* (non-Javadoc) |
2005 |
*
|
|
2006 |
* |
|
2006 | 2007 |
* @see org.gvsig.metadata.Metadata#getMetadataName() |
2007 | 2008 |
*/ |
2008 | 2009 |
public String getMetadataName() { |
... | ... | |
2101 | 2102 |
return this.provider.getRetrievedFeaturesLimit(); |
2102 | 2103 |
} |
2103 | 2104 |
|
2104 |
public Interval getInterval() {
|
|
2105 |
public Interval getInterval() { |
|
2105 | 2106 |
return this.provider.getInterval(); |
2106 | 2107 |
} |
2107 | 2108 |
|
2108 |
public Collection getTimes() {
|
|
2109 |
public Collection getTimes() { |
|
2109 | 2110 |
return this.provider.getTimes(); |
2110 | 2111 |
} |
2111 | 2112 |
|
2112 |
public Collection getTimes(Interval interval) {
|
|
2113 |
public Collection getTimes(Interval interval) { |
|
2113 | 2114 |
return this.provider.getTimes(interval); |
2114 | 2115 |
} |
2115 |
|
|
2116 |
|
|
2116 | 2117 |
/* (non-Javadoc) |
2117 | 2118 |
* @see java.lang.Object#clone() |
2118 | 2119 |
*/ |
2119 | 2120 |
public Object clone() throws CloneNotSupportedException { |
2120 |
|
|
2121 |
|
|
2121 | 2122 |
DataStoreParameters dsp = getParameters(); |
2122 |
|
|
2123 |
|
|
2123 | 2124 |
DefaultFeatureStore cloned_store = null; |
2124 |
|
|
2125 |
|
|
2125 | 2126 |
try { |
2126 | 2127 |
cloned_store = (DefaultFeatureStore) DALLocator.getDataManager(). |
2127 | 2128 |
openStore(this.getProviderName(), dsp); |
... | ... | |
2131 | 2132 |
} |
2132 | 2133 |
} catch (Exception e) { |
2133 | 2134 |
throw new CloneException(e); |
2134 |
}
|
|
2135 |
} |
|
2135 | 2136 |
return cloned_store; |
2136 |
|
|
2137 |
|
|
2137 | 2138 |
} |
2139 |
|
|
2140 |
public Feature getFeature(DynObject dynobject) { |
|
2141 |
if (dynobject instanceof DynObjectFeatureFacade){ |
|
2142 |
Feature f = ((DynObjectFeatureFacade)dynobject).getFeature(); |
|
2143 |
return f; |
|
2144 |
} |
|
2145 |
return null; |
|
2146 |
} |
|
2138 | 2147 |
} |
Also available in: Unified diff