Class ValidationTask
- java.lang.Object
-
- org.openstreetmap.josm.gui.PleaseWaitRunnable
-
- org.openstreetmap.josm.data.validation.ValidationTask
-
- All Implemented Interfaces:
java.lang.Runnable
,ProgressMonitor.CancelListener
public class ValidationTask extends PleaseWaitRunnable
Asynchronous task for running a collection of tests against a collection of primitives
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
beforeUpload
private boolean
canceled
private java.util.List<TestError>
errors
private java.util.Collection<OsmPrimitive>
formerValidatedPrimitives
private java.util.Collection<OsmPrimitive>
initialPrimitives
private java.util.function.Consumer<java.util.List<TestError>>
onFinish
private java.util.function.BiConsumer<ValidationTask,Test>
testConsumer
private java.util.Collection<Test>
tests
-
Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor
-
-
Constructor Summary
Constructors Modifier Constructor Description ValidationTask(java.util.Collection<Test> tests, java.util.Collection<OsmPrimitive> validatedPrimitives, java.util.Collection<OsmPrimitive> formerValidatedPrimitives)
Constructs a newValidationTask
ValidationTask(java.util.function.Consumer<java.util.List<TestError>> onFinish, ProgressMonitor progressMonitor, java.util.Collection<Test> tests, java.util.Collection<OsmPrimitive> validatedPrimitives, java.util.Collection<OsmPrimitive> formerValidatedPrimitives, boolean beforeUpload)
Constructs a newValidationTask
protected
ValidationTask(ProgressMonitor progressMonitor, java.util.Collection<Test> tests, java.util.Collection<OsmPrimitive> validatedPrimitives, java.util.Collection<OsmPrimitive> formerValidatedPrimitives)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
cancel()
User pressed cancel button.protected void
finish()
Finish up the data work.java.util.List<TestError>
getErrors()
Gets the validation errors accumulated until this moment.private static java.util.Set<OsmPrimitive>
getRelevantParents(java.util.Collection<OsmPrimitive> primitives)
Find objects parent objects of given objects which should be checked for geometry problems or mismatches between child tags and parent tags.protected void
realRun()
Called in the worker thread to do the actual work.void
setTestConsumer(java.util.function.BiConsumer<ValidationTask,Test> testConsumer)
A test consumer to avoid filling up memory.-
Methods inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
-
-
-
-
Field Detail
-
initialPrimitives
private final java.util.Collection<OsmPrimitive> initialPrimitives
-
formerValidatedPrimitives
private final java.util.Collection<OsmPrimitive> formerValidatedPrimitives
-
beforeUpload
private final boolean beforeUpload
-
canceled
private boolean canceled
-
testConsumer
private java.util.function.BiConsumer<ValidationTask,Test> testConsumer
-
-
Constructor Detail
-
ValidationTask
public ValidationTask(java.util.Collection<Test> tests, java.util.Collection<OsmPrimitive> validatedPrimitives, java.util.Collection<OsmPrimitive> formerValidatedPrimitives)
Constructs a newValidationTask
- Parameters:
tests
- the tests to runvalidatedPrimitives
- the collection of primitives to validate.formerValidatedPrimitives
- the last collection of primitives being validated. May be null.
-
ValidationTask
public ValidationTask(java.util.function.Consumer<java.util.List<TestError>> onFinish, ProgressMonitor progressMonitor, java.util.Collection<Test> tests, java.util.Collection<OsmPrimitive> validatedPrimitives, java.util.Collection<OsmPrimitive> formerValidatedPrimitives, boolean beforeUpload)
Constructs a newValidationTask
- Parameters:
onFinish
- called when the tests are finishedprogressMonitor
- the progress monitor to update with test progresstests
- the tests to runvalidatedPrimitives
- the collection of primitives to validate.formerValidatedPrimitives
- the last collection of primitives being validated. May be null.beforeUpload
-true
if this is being run prior to upload- Since:
- 18752
-
ValidationTask
protected ValidationTask(ProgressMonitor progressMonitor, java.util.Collection<Test> tests, java.util.Collection<OsmPrimitive> validatedPrimitives, java.util.Collection<OsmPrimitive> formerValidatedPrimitives)
-
-
Method Detail
-
getRelevantParents
private static java.util.Set<OsmPrimitive> getRelevantParents(java.util.Collection<OsmPrimitive> primitives)
Find objects parent objects of given objects which should be checked for geometry problems or mismatches between child tags and parent tags.- Parameters:
primitives
- the given objects- Returns:
- the collection of relevant parent objects
-
cancel
protected void cancel()
Description copied from class:PleaseWaitRunnable
User pressed cancel button.- Specified by:
cancel
in classPleaseWaitRunnable
-
finish
protected void finish()
Description copied from class:PleaseWaitRunnable
Finish up the data work. Is guaranteed to be called if realRun is called. Finish is called in the gui thread just after the dialog disappeared.- Specified by:
finish
in classPleaseWaitRunnable
-
realRun
protected void realRun()
Description copied from class:PleaseWaitRunnable
Called in the worker thread to do the actual work. When any of the exception is thrown, a message box will be displayed and closeDialog is called. finish() is called in any case.- Specified by:
realRun
in classPleaseWaitRunnable
-
getErrors
public java.util.List<TestError> getErrors()
Gets the validation errors accumulated until this moment.- Returns:
- The list of errors
-
setTestConsumer
public void setTestConsumer(java.util.function.BiConsumer<ValidationTask,Test> testConsumer)
A test consumer to avoid filling up memory. A test consumer may remove tests it has consumed.- Parameters:
testConsumer
- The consumer which takes aValidationTask
(this
) and the test that finished.- Since:
- 18752
-
-