public class UploadLayerTask extends AbstractIOTask
OsmDataLayer asynchronously.
ExecutorService executorService = ...
UploadLayerTask task = new UploadLayerTask(layer, monitor);
Future<?> taskFuture = executorService.submit(task)
try {
// wait for the task to complete
taskFuture.get();
} catch (Exception e) {
e.printStackTrace();
}
| Modifier and Type | Field and Description |
|---|---|
private Changeset |
changeset |
private OsmDataLayer |
layer |
private ProgressMonitor |
monitor |
private java.util.Set<IPrimitive> |
processedPrimitives |
private UploadStrategySpecification |
strategy |
private java.util.Collection<OsmPrimitive> |
toUpload |
private OsmServerWriter |
writer |
| Constructor and Description |
|---|
UploadLayerTask(UploadStrategySpecification strategy,
OsmDataLayer layer,
ProgressMonitor monitor,
Changeset changeset)
Creates the upload task
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancel the task
|
protected OsmPrimitive |
getPrimitive(OsmPrimitiveType type,
long id) |
protected void |
recoverFromGoneOnServer(OsmApiPrimitiveGoneException e)
Retries to recover the upload operation from an exception which was thrown because
an uploaded primitive was already deleted on the server.
|
void |
run() |
getLastException, isCanceled, isFailed, isSuccessful, setCanceled, setFailed, setLastExceptionprivate OsmServerWriter writer
private final OsmDataLayer layer
private final ProgressMonitor monitor
private java.util.Collection<OsmPrimitive> toUpload
private final java.util.Set<IPrimitive> processedPrimitives
private final UploadStrategySpecification strategy
public UploadLayerTask(UploadStrategySpecification strategy, OsmDataLayer layer, ProgressMonitor monitor, Changeset changeset)
strategy - the upload strategy specificationlayer - the layer. Must not be null.monitor - a progress monitor. If monitor is null, uses NullProgressMonitor.INSTANCEchangeset - the changeset to be usedjava.lang.IllegalArgumentException - if layer is nulljava.lang.IllegalArgumentException - if strategy is nullprotected OsmPrimitive getPrimitive(OsmPrimitiveType type, long id)
protected void recoverFromGoneOnServer(OsmApiPrimitiveGoneException e) throws OsmTransferException
e - the exception throw by the APIOsmTransferException - if we can't recover from the exceptionpublic void run()
public void cancel()
AbstractIOTaskcancel in class AbstractIOTask