Revision 3310 org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.lib/org.gvsig.vcsgis.lib.impl/src/main/java/org/gvsig/vcsgis/lib/workspace/VCSGisWorkspaceImpl.java
VCSGisWorkspaceImpl.java | ||
---|---|---|
14 | 14 |
import java.util.Map; |
15 | 15 |
import java.util.Objects; |
16 | 16 |
import java.util.Set; |
17 |
import java.util.function.Consumer; |
|
17 | 18 |
import javax.json.JsonObject; |
18 | 19 |
import org.apache.commons.lang3.StringUtils; |
19 | 20 |
import org.apache.commons.lang3.mutable.MutableObject; |
... | ... | |
1419 | 1420 |
status.setCurValue(0); |
1420 | 1421 |
for (Feature fchange : changesGroupedByEntity) { |
1421 | 1422 |
WorkspaceChangeRow change = new WorkspaceChangeRow(this, fchange); |
1422 |
VCSGisEntity localEntity = change.getEntity(); |
|
1423 |
VCSGisWorkspaceEntity localEntity = change.getEntity();
|
|
1423 | 1424 |
LOGGER.debug("===: COMMIT: add used entity = " + fchange.toJson().toString().replace('\n', ' ')); |
1424 | 1425 |
if (change.isSelected()) { |
1425 | 1426 |
request.add(request.createEntity(localEntity)); |
... | ... | |
1479 | 1480 |
|
1480 | 1481 |
LOGGER.debug("===: COMMIT: Adding changed local entities"); |
1481 | 1482 |
status.message("Searching changed entities"); |
1482 |
//TODO: |
|
1483 |
// adicionamos las entidades que vamos a actualizar con las revisiones que tenemos. |
|
1484 |
DisposableFeatureSetIterable changesGroupedByEntity = changesTable.getGroupedByEntity(this); |
|
1485 |
// status.setRangeOfValues(0, changesGroupedByEntity.size64()); |
|
1486 |
status.setCurValue(0); |
|
1487 |
for (Feature fchange : changesGroupedByEntity) { |
|
1488 |
WorkspaceChangeRow change = new WorkspaceChangeRow(this, fchange); |
|
1489 |
VCSGisEntity localEntity = change.getEntity(); |
|
1490 |
LOGGER.debug("===: COMMIT: add used entity = " + fchange.toJson().toString().replace('\n', ' ')); |
|
1491 |
if (change.isSelected()) { |
|
1492 |
request.add(request.createEntity(localEntity)); |
|
1493 |
} |
|
1494 |
status.incrementCurrentValue(); |
|
1495 |
} |
|
1496 |
changesGroupedByEntity.dispose(); |
|
1497 | 1483 |
|
1484 |
VCSGisWorkspaceEntity localEntity = this.getWorkspaceEntity(entity); |
|
1485 |
request.add(request.createEntity(localEntity)); |
|
1486 |
|
|
1498 | 1487 |
LOGGER.debug("===: COMMIT: Mark new local entities"); |
1499 | 1488 |
status.message("Searching new entities"); |
1500 |
//TODO |
|
1489 |
|
|
1501 | 1490 |
// Marcamos como nuevas las entidades que se han dado de alta. |
1502 |
DisposableFeatureSetIterable changesOfAddEntities = changesTable.getByOperation(this, OP_ADD_ENTITY); |
|
1491 |
DisposableFeatureSetIterable changesOfAddEntities = changesTable.getByOperation(this, localEntity.getEntityCode(), OP_ADD_ENTITY);
|
|
1503 | 1492 |
for (Feature fchange : changesOfAddEntities) { |
1504 | 1493 |
WorkspaceChangeRow change = new WorkspaceChangeRow(this, fchange); |
1505 | 1494 |
if (change.isSelected()) { |
... | ... | |
1512 | 1501 |
status.message("Searching changed data"); |
1513 | 1502 |
// adicionamos los datos |
1514 | 1503 |
boolean useSeleccion = true; |
1515 |
//TODO |
|
1516 |
DisposableFeatureSetIterable changes = changesTable.getSelectedsWithoutAddEntity(this, entity);
|
|
1504 |
|
|
1505 |
DisposableFeatureSetIterable changes = changesTable.getSelectedsWithoutAddEntity(this, localEntity.getEntityCode());
|
|
1517 | 1506 |
if (changes != null) { |
1518 | 1507 |
request.add(new DisposableIterableAdapter( |
1519 | 1508 |
changes, |
... | ... | |
1646 | 1635 |
try { |
1647 | 1636 |
entitiesStore = this.openFeatureStore(EntitiesTable.TABLE_NAME); |
1648 | 1637 |
entitiesStore.edit(FeatureStore.MODE_FULLEDIT); |
1649 |
List<VCSGisEntityEditable> changedLocalentities = request.getChangedLocalEntities();
|
|
1638 |
List<VCSGisWorkspaceEntity> changedLocalentities = request.getChangedLocalEntities();
|
|
1650 | 1639 |
status.setRangeOfValues(0, changedLocalentities.size()); |
1651 | 1640 |
status.setCurValue(0); |
1652 | 1641 |
for (VCSGisEntity rentity : changedLocalentities) { |
... | ... | |
1721 | 1710 |
try { |
1722 | 1711 |
entitiesStore = this.openFeatureStore(EntitiesTable.TABLE_NAME); |
1723 | 1712 |
entitiesStore.edit(FeatureStore.MODE_FULLEDIT); |
1724 |
List<VCSGisEntityEditable> changedLocalentities = request.getChangedLocalEntities();
|
|
1713 |
List<VCSGisWorkspaceEntity> changedLocalentities = request.getChangedLocalEntities();
|
|
1725 | 1714 |
status.setRangeOfValues(0, changedLocalentities.size()); |
1726 | 1715 |
status.setCurValue(0); |
1727 |
for (VCSGisEntity rentity : changedLocalentities) { |
|
1716 |
for (VCSGisWorkspaceEntity rentity : changedLocalentities) {
|
|
1728 | 1717 |
EntityRow entityRow = entitiesTable.getByEntityName(this, rentity.getEntityName()); |
1729 | 1718 |
if (entityRow != null) { |
1730 | 1719 |
entityRow.copyfrom(rentity); |
... | ... | |
2360 | 2349 |
case STATE_CONFLICT: |
2361 | 2350 |
DisposableFeatureSetIterable feats = getUserFeaturesConflictWithRemoteChange(lentity, remoteChangeRow, userStore); |
2362 | 2351 |
if (feats != null) { |
2352 |
List<Feature> featuresToDelete = new ArrayList<Feature>(); |
|
2363 | 2353 |
for (Feature feat : feats) { |
2364 | 2354 |
if (feat != null) { |
2365 |
userStore.delete(feat); |
|
2355 |
// userStore.delete(feat); |
|
2356 |
featuresToDelete.add(feat); |
|
2366 | 2357 |
workspaceChangesStore.delete("\"" + WorkspaceChangesTable.FEATUREID + "\" = '" + feat.getString(lentity.getFeatureIdFieldName()) + "'"); |
2367 | 2358 |
} |
2368 | 2359 |
} |
2360 |
for (Feature feat : featuresToDelete) { |
|
2361 |
userStore.delete(feat); |
|
2362 |
} |
|
2369 | 2363 |
DisposeUtils.disposeQuietly(feats); |
2370 | 2364 |
} |
2371 | 2365 |
//Don't break to do the default case |
Also available in: Unified diff