Class DownloadNotesTask
- java.lang.Object
-
- org.openstreetmap.josm.actions.downloadtasks.AbstractDownloadTask<NoteData>
-
- org.openstreetmap.josm.actions.downloadtasks.DownloadNotesTask
-
- All Implemented Interfaces:
DownloadTask
- Direct Known Subclasses:
DownloadNotesUrlBoundsTask,DownloadNotesUrlIdTask
public class DownloadNotesTask extends AbstractDownloadTask<NoteData>
General task for downloading OSM notes.It handles two URL patterns: API call and dump file export.
- Since:
- 7531
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classDownloadNotesTask.DownloadBoundingBoxTask(package private) classDownloadNotesTask.DownloadCompressedRawUrlTask(package private) classDownloadNotesTask.DownloadRawUrlTask(package private) classDownloadNotesTask.DownloadTask
-
Field Summary
Fields Modifier and Type Field Description static IntegerPropertyDAYS_CLOSEDProperty defining number of days a bug needs to be closed to no longer be downloadedstatic IntegerPropertyDOWNLOAD_LIMITProperty defining the number of notes to be downloadedprivate DownloadNotesTask.DownloadTaskdownloadTaskprivate static java.lang.StringNO_NOTES_FOUNDprivate NoteLayernoteLayerprivate static java.lang.StringPATTERN_COMPRESSprotected booleanwarnAboutEmptyAreaThis allows subclasses to ignore this warning-
Fields inherited from class org.openstreetmap.josm.actions.downloadtasks.AbstractDownloadTask
downloadedData, zoomAfterDownload
-
-
Constructor Summary
Constructors Constructor Description DownloadNotesTask()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Cancels the asynchronous download task.java.util.concurrent.Future<?>download(long id, ProgressMonitor progressMonitor)Download a specific note by its id.java.util.concurrent.Future<?>download(DownloadParams settings, Bounds downloadArea, ProgressMonitor progressMonitor)Asynchronously launches the download task for a given bounding box.java.lang.StringgetConfirmationMessage(java.net.URL url)Replies the HTML-formatted confirmation message to be shown to user when the given URL needs to be confirmed before loading.ProjectionBoundsgetDownloadProjectionBounds()Returns the projection bounds of downloaded data.java.lang.String[]getPatterns()Returns regular expressions that match the URLsjava.lang.StringgetTitle()Returns human-readable description of the taskbooleanisSafeForRemotecontrolRequests()Check / decide if the task is safe for remotecontrol.java.util.concurrent.Future<?>loadUrl(DownloadParams settings, java.lang.String url, ProgressMonitor progressMonitor)Asynchronously launches the download task for a given bounding URL.-
Methods inherited from class org.openstreetmap.josm.actions.downloadtasks.AbstractDownloadTask
acceptsUrl, acceptsUrl, getDownloadedData, getErrorObjects, isCanceled, isFailed, patterns, rememberDownloadedData, rememberErrorMessage, rememberException, setCanceled, setFailed, setZoomAfterDownload, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.actions.downloadtasks.DownloadTask
acceptsDocumentationSummary, getErrorMessages
-
-
-
-
Field Detail
-
DOWNLOAD_LIMIT
public static final IntegerProperty DOWNLOAD_LIMIT
Property defining the number of notes to be downloaded
-
DAYS_CLOSED
public static final IntegerProperty DAYS_CLOSED
Property defining number of days a bug needs to be closed to no longer be downloaded
-
PATTERN_COMPRESS
private static final java.lang.String PATTERN_COMPRESS
- See Also:
- Constant Field Values
-
NO_NOTES_FOUND
private static final java.lang.String NO_NOTES_FOUND
-
downloadTask
private DownloadNotesTask.DownloadTask downloadTask
-
warnAboutEmptyArea
protected boolean warnAboutEmptyArea
This allows subclasses to ignore this warning
-
-
Constructor Detail
-
DownloadNotesTask
public DownloadNotesTask()
-
-
Method Detail
-
download
public java.util.concurrent.Future<?> download(long id, ProgressMonitor progressMonitor)
Download a specific note by its id.- Parameters:
id- Note identifierprogressMonitor- progress monitor- Returns:
- the future representing the asynchronous task
-
download
public java.util.concurrent.Future<?> download(DownloadParams settings, Bounds downloadArea, ProgressMonitor progressMonitor)
Description copied from interface:DownloadTaskAsynchronously launches the download task for a given bounding box.Set
progressMonitorto null, if the task should create, open, and close a progress monitor. Set progressMonitor toNullProgressMonitor.INSTANCEif progress information is to be discarded.You can wait for the asynchronous download task to finish by synchronizing on the returned
Future, but make sure not to freeze up JOSM. Example:Future<?> future = task.download(...); // DON'T run this on the Swing EDT or JOSM will freeze future.get(); // waits for the dowload task to completeThe following example uses a pattern which is better suited if a task is launched from the Swing EDT:final Future<?> future = task.download(...); Runnable runAfterTask = new Runnable() { public void run() { // this is not strictly necessary because of the type of executor service // Main.worker is initialized with, but it doesn't harm either // future.get(); // wait for the download task to complete doSomethingAfterTheTaskCompleted(); } } MainApplication.worker.submit(runAfterTask);- Parameters:
settings- download settingsdownloadArea- the area to downloadprogressMonitor- the progressMonitor- Returns:
- the future representing the asynchronous task
-
loadUrl
public java.util.concurrent.Future<?> loadUrl(DownloadParams settings, java.lang.String url, ProgressMonitor progressMonitor)
Description copied from interface:DownloadTaskAsynchronously launches the download task for a given bounding URL.Set progressMonitor to null, if the task should create, open, and close a progress monitor. Set progressMonitor to
NullProgressMonitor.INSTANCEif progress information is to be discarded.- Parameters:
settings- download settingsurl- the url to download fromprogressMonitor- the progressMonitor- Returns:
- the future representing the asynchronous task
- See Also:
DownloadTask.download(DownloadParams, Bounds, ProgressMonitor)
-
cancel
public void cancel()
Description copied from interface:DownloadTaskCancels the asynchronous download task.
-
getConfirmationMessage
public java.lang.String getConfirmationMessage(java.net.URL url)
Description copied from interface:DownloadTaskReplies the HTML-formatted confirmation message to be shown to user when the given URL needs to be confirmed before loading.- Parameters:
url- The URL to be confirmed- Returns:
- The HTML-formatted confirmation message to be shown to user
-
getTitle
public java.lang.String getTitle()
Description copied from interface:DownloadTaskReturns human-readable description of the task- Specified by:
getTitlein interfaceDownloadTask- Overrides:
getTitlein classAbstractDownloadTask<NoteData>- Returns:
- The task description
-
getPatterns
public java.lang.String[] getPatterns()
Description copied from interface:DownloadTaskReturns regular expressions that match the URLs- Specified by:
getPatternsin interfaceDownloadTask- Overrides:
getPatternsin classAbstractDownloadTask<NoteData>- Returns:
- The array of accepted URL patterns
-
isSafeForRemotecontrolRequests
public boolean isSafeForRemotecontrolRequests()
Description copied from class:AbstractDownloadTaskCheck / decide if the task is safe for remotecontrol.Keep in mind that a potential attacker has full control over the content of the file that will be downloaded. If it is possible to run arbitrary code or write to the local file system, then the task is (obviously) not save for remote execution.
The default value is false = unsafe. Override in a subclass to allow running the task via remotecontol.
- Overrides:
isSafeForRemotecontrolRequestsin classAbstractDownloadTask<NoteData>- Returns:
- true if it is safe to download and open any file of the corresponding format, false otherwise
-
getDownloadProjectionBounds
public ProjectionBounds getDownloadProjectionBounds()
Description copied from class:AbstractDownloadTaskReturns the projection bounds of downloaded data.- Overrides:
getDownloadProjectionBoundsin classAbstractDownloadTask<NoteData>- Returns:
- the projection bounds of downloaded data or
null
-
-