Skip to content
Snippets Groups Projects
Commit 564ebfb3 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Added decision for warning status

parent a914acf2
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,10 @@ public class NaerstadModel extends I18nImpl implements Model{
private final static ModelId MODEL_ID = new ModelId("NAERSTADMO");
private final static Double THRESHOLD_MINOR_RISK = 1d;
private final static Double THRESHOLD_HIGH_RISK = 2.5;
public NaerstadModel(){
// Setting the file name of the resource bundle
super("no.bioforsk.vips.model.naerstadmodel.texts");
......@@ -90,6 +94,7 @@ public class NaerstadModel extends I18nImpl implements Model{
if(this.DEBUG)
System.out.println("RISK(" + thePresent + ")=" + RISK);
result.setValue("RISK", dFormat.format(RISK));
result.setWarningStatus(this.getWarningStatus(RISK));
results.add(result);
// Moving on
......@@ -108,6 +113,30 @@ public class NaerstadModel extends I18nImpl implements Model{
throw new ModelExcecutionException("An exception occurred. Message is " + e.getMessage() + " See logs for details");
}
}
/**
* Calculates the warning status
* @param RISK
* @return
*/
private Integer getWarningStatus(Double RISK) {
if(RISK == null)
{
return Result.WARNING_STATUS_NO_WARNING_MISSING_DATA;
}
else if(RISK < THRESHOLD_MINOR_RISK)
{
return Result.WARNING_STATUS_NO_RISK;
}
else if(RISK >=THRESHOLD_MINOR_RISK && RISK < THRESHOLD_HIGH_RISK)
{
return Result.WARNING_STATUS_MINOR_RISK;
}
else
{
return Result.WARNING_STATUS_HIGH_RISK;
}
}
@Override
public ModelId getModelId() {
......@@ -529,5 +558,7 @@ public class NaerstadModel extends I18nImpl implements Model{
return this.weatherUtil;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment