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 booleanbeforeUploadprivate booleancanceledprivate java.util.List<TestError>errorsprivate java.util.Collection<OsmPrimitive>formerValidatedPrimitivesprivate java.util.Collection<OsmPrimitive>initialPrimitivesprivate java.util.function.Consumer<java.util.List<TestError>>onFinishprivate java.util.function.BiConsumer<ValidationTask,Test>testConsumerprivate 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 newValidationTaskValidationTask(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 newValidationTaskprotectedValidationTask(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 voidcancel()User pressed cancel button.protected voidfinish()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 voidrealRun()Called in the worker thread to do the actual work.voidsetTestConsumer(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-trueif 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:PleaseWaitRunnableUser pressed cancel button.- Specified by:
cancelin classPleaseWaitRunnable
-
finish
protected void finish()
Description copied from class:PleaseWaitRunnableFinish 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:
finishin classPleaseWaitRunnable
-
realRun
protected void realRun()
Description copied from class:PleaseWaitRunnableCalled 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:
realRunin 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
-
-