public class UploadLayerTask extends AbstractIOTask implements java.lang.Runnable
OsmDataLayer asynchronously.
ExecutorService executorService = ...
UploadLayerTask task = new UploadLayerTask(layer, monitor);
Future<?> taskFuture = executorServce.submit(task)
try {
// wait for the task to complete
taskFuture.get();
} catch(Exception e) {
e.printStackTracek();
}
| 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, setLastExceptionprivate 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.INSTANCEchangeset - the changeset to be usedjava.lang.IllegalArgumentException - thrown, if layer is nulljava.lang.IllegalArgumentException - thrown 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 - thrown if we can't recover from the exceptionpublic void run()
AbstractIOTaskrun in interface java.lang.Runnablerun in class AbstractIOTaskpublic void cancel()
AbstractIOTaskcancel in class AbstractIOTask