Revision 47779 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 | ||
---|---|---|
84 | 84 |
import static org.gvsig.fmap.dal.feature.Feature.CHECK_RULES_AT_EDITING; |
85 | 85 |
import static org.gvsig.fmap.dal.feature.Feature.CHECK_RULES_AT_FINISH; |
86 | 86 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
87 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
|
88 | 87 |
import org.gvsig.fmap.dal.feature.FeatureCache; |
89 | 88 |
import org.gvsig.fmap.dal.feature.FeatureIndex; |
90 | 89 |
import org.gvsig.fmap.dal.feature.FeatureIndexes; |
... | ... | |
225 | 224 |
private List<FeatureType> featureTypes = new ArrayList<>(); |
226 | 225 |
|
227 | 226 |
private int mode = MODE_QUERY; |
227 |
private int submode = SUBMODE_NONE; |
|
228 |
|
|
228 | 229 |
private int lastMode = MODE_QUERY; |
229 | 230 |
|
230 | 231 |
private long versionOfUpdate = 0; |
... | ... | |
1353 | 1354 |
} |
1354 | 1355 |
|
1355 | 1356 |
@Override |
1357 |
public int getSubmode() { |
|
1358 |
return this.submode; |
|
1359 |
} |
|
1360 |
|
|
1361 |
@Override |
|
1356 | 1362 |
synchronized public void edit() throws DataException { |
1357 | 1363 |
edit(MODE_FULLEDIT); |
1358 | 1364 |
} |
1365 |
|
|
1366 |
@Override |
|
1367 |
synchronized public void edit(int mode) throws DataException { |
|
1368 |
this.edit(mode, SUBMODE_NONE); |
|
1369 |
} |
|
1359 | 1370 |
|
1360 | 1371 |
@Override |
1361 |
synchronized public void edit(int mode) throws DataException { |
|
1372 |
synchronized public void edit(int mode, int submode) throws DataException {
|
|
1362 | 1373 |
LOGGER.debug("Starting editing in mode: {}", mode); |
1363 | 1374 |
if (this.mode != MODE_QUERY) { |
1364 | 1375 |
throw new AlreadyEditingException(this.getName()); |
... | ... | |
1391 | 1402 |
this, featureManager, |
1392 | 1403 |
spatialManager, featureTypeManager); |
1393 | 1404 |
this.mode = MODE_FULLEDIT; |
1405 |
this.submode = submode; |
|
1394 | 1406 |
hasStrongChanges = false; |
1395 | 1407 |
notifyChange(FeatureStoreNotification.AFTER_STARTEDITING, newSessionCode, this.mode); |
1396 | 1408 |
break; |
... | ... | |
1402 | 1414 |
} |
1403 | 1415 |
this.editingSessionCode = newSessionCode; |
1404 | 1416 |
invalidateIndexes(); |
1405 |
this.provider.beginAppend(); |
|
1417 |
this.provider.beginAppend(submode);
|
|
1406 | 1418 |
this.mode = MODE_APPEND; |
1419 |
this.submode = submode; |
|
1407 | 1420 |
notifyChange(FeatureStoreNotification.AFTER_STARTEDITING, |
1408 | 1421 |
newSessionCode, this.mode); |
1409 | 1422 |
break; |
... | ... | |
1418 | 1431 |
this.editingSessionCode = newSessionCode; |
1419 | 1432 |
invalidateIndexes(); |
1420 | 1433 |
this.mode = MODE_PASS_THROUGH; |
1434 |
this.submode = submode; |
|
1421 | 1435 |
notifyChange(FeatureStoreNotification.AFTER_STARTEDITING, |
1422 | 1436 |
newSessionCode, this.mode); |
1423 | 1437 |
break; |
... | ... | |
1708 | 1722 |
break; |
1709 | 1723 |
|
1710 | 1724 |
case MODE_FULLEDIT: |
1711 |
if (feature.isUpdatable()) { |
|
1712 |
throw new NoNewFeatureInsertException(this.getName()); |
|
1725 |
if( this.submode == SUBMODE_MERGE ) { |
|
1726 |
Expression filter = feature.createFilter(); |
|
1727 |
Feature f = this.findFirst(filter); |
|
1728 |
if( f == null ) { |
|
1729 |
this.insert(feature); |
|
1730 |
} else { |
|
1731 |
this.update(feature); |
|
1732 |
} |
|
1733 |
} else { |
|
1734 |
if (feature.isUpdatable()) { |
|
1735 |
throw new NoNewFeatureInsertException(this.getName()); |
|
1736 |
} |
|
1737 |
feature.validate(CHECK_RULES_AT_EDITING); |
|
1738 |
commands.insert(feature); |
|
1713 | 1739 |
} |
1714 |
feature.validate(CHECK_RULES_AT_EDITING); |
|
1715 |
commands.insert(feature); |
|
1716 | 1740 |
break; |
1717 | 1741 |
|
1718 | 1742 |
case MODE_PASS_THROUGH: |
... | ... | |
1724 | 1748 |
return; |
1725 | 1749 |
} |
1726 | 1750 |
feature.validate(CHECK_RULES_AT_EDITING); |
1727 |
this.provider.passThroughInsert(((DefaultEditableFeature) feature).getData()); |
|
1751 |
if( this.submode == SUBMODE_MERGE ) { |
|
1752 |
this.provider.passThroughInsertOrUpdate(((DefaultEditableFeature) feature).getData()); |
|
1753 |
} else { |
|
1754 |
this.provider.passThroughInsert(((DefaultEditableFeature) feature).getData()); |
|
1755 |
} |
|
1728 | 1756 |
notifyChange(FeatureStoreNotification.AFTER_INSERT, feature); |
1729 | 1757 |
break; |
1730 | 1758 |
} |
Also available in: Unified diff