public class UploadLayerTask extends AbstractIOTask implements java.lang.Runnable
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,
ProgressMonitor monitor)
Retries to recover the upload operation from an exception which was thrown because
an uploaded primitive was already deleted on the server.
|
void |
run()
Runs the task
|
getLastException, isCanceled, isFailed, isSuccessful, setCanceled, setFailed, setLastException
private OsmServerWriter writer
private OsmDataLayer layer
private ProgressMonitor monitor
private java.util.Collection<OsmPrimitive> toUpload
private java.util.Set<IPrimitive> processedPrimitives
private 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.INSTANCE
changeset
- 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, ProgressMonitor monitor) throws OsmTransferException
e
- the exception throw by the APImonitor
- a progress monitorOsmTransferException
- if we can't recover from the exceptionpublic void run()
AbstractIOTask
run
in interface java.lang.Runnable
run
in class AbstractIOTask
public void cancel()
AbstractIOTask
cancel
in class AbstractIOTask