1 package eu
.etaxonomy
.taxeditor
.editor
.validation
;
5 import org
.apache
.log4j
.Logger
;
6 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
7 import org
.eclipse
.core
.runtime
.IStatus
;
8 import org
.eclipse
.core
.runtime
.Status
;
9 import org
.eclipse
.core
.runtime
.jobs
.Job
;
11 import eu
.etaxonomy
.cdm
.api
.service
.IEntityConstraintViolationService
;
12 import eu
.etaxonomy
.cdm
.api
.service
.IEntityValidationResultService
;
13 import eu
.etaxonomy
.cdm
.model
.validation
.EntityValidationResult
;
14 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
15 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
18 * A job that repeatedly checks the error tables and refreshes the problem
19 * markers created from them.
21 * @author ayco_holleman
24 public class ValidationDaemon
extends Job
{
26 @SuppressWarnings("unused")
27 private static final Logger logger
= Logger
.getLogger(ValidationDaemon
.class);
29 private final IEntityValidationResultService validationResultService
;
31 @SuppressWarnings("unused")
32 /* Not currently needed but present for future use if/when required */
33 private final IEntityConstraintViolationService constraintViolationService
;
35 private boolean cancelRequested
= false;
37 public ValidationDaemon(){
38 super("Initializing validation module");
39 // StoreUtil.info("Initializing validation module");
40 MessagingUtils
.info("Initializing validation module");
41 constraintViolationService
= CdmStore
.getService(IEntityConstraintViolationService
.class);
42 validationResultService
= CdmStore
.getService(IEntityValidationResultService
.class);
47 protected void canceling(){
48 cancelRequested
= true;
53 * This method is called by {@link ValidationContextListener} rather than
54 * {@link Job#cancel()}, because that method does not have the desired
57 public void setCancelRequested(){
58 cancelRequested
= true;
63 protected IStatus
run(IProgressMonitor monitor
){
64 MarkerManager markerManager
;
65 List
<EntityValidationResult
> results
;
67 while (!cancelRequested
) {
68 results
= validationResultService
.getValidationResults();
69 markerManager
= new MarkerManager(results
);
70 markerManager
.deleteObsoleteMarkers();
71 markerManager
.createMarkers();
72 // Might want to make this configurable:
75 // StoreUtil.info("Validation module stopped");
76 MessagingUtils
.info("Validation module stopped");
77 return Status
.OK_STATUS
;
80 // StoreUtil.info("Validation module terminated unexpectedly: " + t.getMessage());
81 MessagingUtils
.info("Validation module terminated unexpectedly: " + t
.getMessage());
82 return Status
.CANCEL_STATUS
;