Revision 2722 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 | ||
---|---|---|
13 | 13 |
import java.util.Map; |
14 | 14 |
import java.util.Set; |
15 | 15 |
import javax.json.JsonObject; |
16 |
import org.apache.commons.lang3.Range; |
|
16 | 17 |
import org.apache.commons.lang3.StringUtils; |
17 | 18 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
18 | 19 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
... | ... | |
43 | 44 |
import org.gvsig.tools.logger.FilteredLogger; |
44 | 45 |
import org.gvsig.tools.task.SimpleTaskStatus; |
45 | 46 |
import org.gvsig.tools.util.ContainerUtils; |
47 |
import org.gvsig.tools.util.GetItemWithSizeAndIterator64; |
|
46 | 48 |
import org.gvsig.tools.util.HasAFile; |
47 | 49 |
import org.gvsig.vcsgis.lib.DisposableIterableAdapter; |
48 | 50 |
import org.gvsig.vcsgis.lib.VCSGisChange; |
... | ... | |
149 | 151 |
|
150 | 152 |
VarsTable varsTable = new VarsTable(); |
151 | 153 |
this.code = varsTable.get(this, "WORKSPACE_CODE"); |
152 |
this.label = varsTable.get(this, "WORKSPACE_LABEL"); |
|
154 |
if (this.code == null) { |
|
155 |
throw new RuntimeException("Can't retrieve code from workspace '" + this.getMessageLabel() + "'"); |
|
156 |
} |
|
153 | 157 |
this.repository = (VCSGisRepository) Json.toObject(varsTable.get(this, "REPOSITORY")); |
154 | 158 |
if (this.repository == null) { |
155 | 159 |
throw new RuntimeException("Can't retrieve repository from workspace '" + this.getMessageLabel() + "'"); |
156 | 160 |
} |
161 |
this.label = varsTable.get(this, "WORKSPACE_LABEL"); |
|
157 | 162 |
// LOGGER.debug("===: CREATE WORKSPACE "+ hexId(this)+ " (open code='"+this.code+"', label='"+this.label+"')"); |
158 | 163 |
} |
159 | 164 |
|
... | ... | |
436 | 441 |
return store; |
437 | 442 |
} catch (Exception ex) { |
438 | 443 |
String msg = "can't open store from '" + this.getMessageLabel() + "'."; |
439 |
LOGGER.warn(msg, ex); |
|
440 | 444 |
throw new RuntimeException(msg, ex); |
441 | 445 |
} |
442 | 446 |
} |
... | ... | |
463 | 467 |
return store; |
464 | 468 |
} catch (Exception ex) { |
465 | 469 |
String msg = "can't open store from '" + this.getMessageLabel() + "'."; |
466 |
LOGGER.warn(msg, ex); |
|
467 | 470 |
throw new RuntimeException(msg, ex); |
468 | 471 |
} |
469 | 472 |
} |
... | ... | |
1527 | 1530 |
reloadRepositoryEntities(status); |
1528 | 1531 |
|
1529 | 1532 |
//TODO calcular las revisiones que tengo para excluirlas |
1533 |
EntityRow lentity = this.getWorkspaceEntityByName(tableName); |
|
1534 |
if(lentity == null){ |
|
1535 |
status.message("Can't find table '"+tableName+"'"); |
|
1536 |
status.abort(); |
|
1537 |
return ERR_ENTITY_NOT_EXISTS; |
|
1538 |
} |
|
1539 |
|
|
1540 |
|
|
1541 |
LocalRevisionsTable localRevisionsTable = new LocalRevisionsTable(); |
|
1542 |
GetItemWithSizeAndIterator64<Feature> lrevisions = localRevisionsTable.getAllRevisions(this, lentity.getEntityCode()); |
|
1543 |
//Asumimos que lrevisions est? ordenado ascendentemente por numero de revision |
|
1544 |
// Long prevRevNumber = null; |
|
1545 |
Long minRevision = null; |
|
1546 |
Long maxRevision = null; |
|
1547 |
for (Feature lrevision : lrevisions) { |
|
1548 |
LocalRevisionRow x = new LocalRevisionRow(this, lrevision); |
|
1549 |
Long revNumber = x.getNumber(); |
|
1550 |
//Asumimos que las revisiones que tenemos son consecutivas |
|
1551 |
// if(prevRevNumber != null && revNumber != prevRevNumber+1){ //Salto |
|
1552 |
//Borrar la tabla completamente ??? |
|
1553 |
// target = this.getFeatureStore(LocalRevisionsTable.TABLE_NAME); |
|
1554 |
// target.edit(MODE_PASS_THROUGH); |
|
1555 |
// target.delete |
|
1556 |
// } |
|
1557 |
if(minRevision == null){ |
|
1558 |
minRevision = revNumber; |
|
1559 |
} |
|
1560 |
maxRevision = revNumber; |
|
1561 |
} |
|
1562 |
|
|
1530 | 1563 |
status.message("Executing log request"); |
1531 | 1564 |
request = this.repository.createLogRequest(tableName); |
1565 |
if(minRevision != null && maxRevision != null){ |
|
1566 |
request.setExcludeRevisionsRange(Range.between(minRevision, maxRevision)); |
|
1567 |
} |
|
1568 |
request.setOperation(operation); |
|
1569 |
request.setMaxRevisions(maxRevisions); |
|
1570 |
|
|
1532 | 1571 |
if( request.execute()!=ERR_OK ) { |
1533 | 1572 |
status.message("Can't retriev history of "+tableName+" (error "+request.getLastErrorCode()+")"); |
1534 | 1573 |
status.abort(); |
... | ... | |
1536 | 1575 |
} |
1537 | 1576 |
|
1538 | 1577 |
status.message("Deleting previous local revision information"); |
1539 |
//TODO: OJO CON EL SALTO |
|
1540 |
|
|
1541 | 1578 |
errcode = ERR_CANT_OPEN_STORE; |
1542 | 1579 |
target = this.getFeatureStore(LocalRevisionsTable.TABLE_NAME); |
1543 | 1580 |
errcode = ERR_CANT_RETRIEVE_SOURCE_FEATURES; |
... | ... | |
1548 | 1585 |
status.setCurValue(0); |
1549 | 1586 |
|
1550 | 1587 |
errcode = ERR_CANT_INSERT_FEATURES; |
1551 |
target.edit(FeatureStore.MODE_APPEND);
|
|
1588 |
target.edit(FeatureStore.MODE_PASS_THROUGH);
|
|
1552 | 1589 |
for (VCSGisRevision revision : revisions) { |
1590 |
if(operation == VCSGisLogRequest.LOG_OP_LAST && revision.getNumber()!=maxRevision+1){ |
|
1591 |
//Borrar todo el target ??? |
|
1592 |
} |
|
1553 | 1593 |
EditableFeature f = target.createNewFeature(); |
1554 | 1594 |
LocalRevisionRow row = new LocalRevisionRow(this, f); |
1555 | 1595 |
row.copyFrom(revision); |
Also available in: Unified diff