SEEG-Oxford/ABRAID-MP — pull request #194 by helena-patching-tessella (2014-09-16 15:55:02+00:00)
Title: Trigger model on distinct locations of new occurrences (filtered by validation parameters)

Some important changes in this PR, please verify the behaviour (especially of ModelRunGatekeeper) is as you expect...

Instead of a model run being triggered mid-week by n new occurrences since last model run, it is triggered if the number of distinct locations extracted from these "new" occurrences is greater than a specified threshold on the disease group (minNewLocationsTrigger replaces minNewOccurrencesTrigger). Additionally, in the named query:
- the occurrences are filtered by their environmentalSuitability and distanceFromExtent (according to two more thresholds on the disease group - these are nullable in the DB).
- "new" is defined as "more than a week ago" from "now" (with DateTime.now() as a parameter to the query)

To clarify, model should run if:
- automatic model runs is enabled, AND
- - it has never before (lastModelRunPrepDate is null) - regardless of whether enough locations or not, or thresholds on disease group are defined, OR
- - it has been a week since last run, OR
- - the 3 thresholds (minNewLocationsTrigger, minEnvSuitability, minDistanceFromExtent) are defined on disease group and satisified.