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

Refactoring Result Object

parent 62ae974e
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@ import no.bioforsk.vips.model.ConfigValidationException;
import no.bioforsk.vips.model.Model;
import no.bioforsk.vips.model.ModelExcecutionException;
import no.bioforsk.vips.model.ModelId;
import no.bioforsk.vips.util.CommonNamespaces;
import no.bioforsk.vips.util.WeatherElements;
import no.bioforsk.vips.util.WeatherUtil;
import org.codehaus.jackson.map.ObjectMapper;
......@@ -107,23 +108,26 @@ public class NaerstadModel extends I18nImpl implements Model{
}
if(this.DEBUG)
System.out.println("RISK(" + thePresent + ")=" + RISK);
result.setValue("RISK", dFormat.format(RISK));
result.setValue("TSHH", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.TSHH)));
result.setValue("SPH", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.SPH)));
result.setValue("VAS", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.VAS)));
result.setValue("VRS", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.VRS)));
result.setValue("WHS", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.WHS)));
result.setValue("WD", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.WD)));
result.setValue("WH", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.WH)));
result.setValue("IR", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.IR)));
result.setValue(this.getModelId().toString(), "THRESHOLD_LOW", THRESHOLD_MINOR_RISK.toString());
result.setValue(this.getModelId().toString(), "THRESHOLD_HIGH", THRESHOLD_HIGH_RISK.toString());
result.setValue(this.getModelId().toString(), "RISK", dFormat.format(RISK));
result.setValue(this.getModelId().toString(), "TSHH", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.TSHH)));
result.setValue(this.getModelId().toString(), "SPH", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.SPH)));
result.setValue(this.getModelId().toString(), "VAS", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.VAS)));
result.setValue(this.getModelId().toString(), "VRS", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.VRS)));
result.setValue(this.getModelId().toString(), "WHS", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.WHS)));
result.setValue(this.getModelId().toString(), "WD", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.WD)));
result.setValue(this.getModelId().toString(), "WH", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.WH)));
result.setValue(this.getModelId().toString(), "IR", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.IR)));
result.setWarningStatus(this.getWarningStatus(RISK));
// Adding weather data
result.setValue("TM", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.TM)));
result.setValue("UM", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.UM)));
result.setValue("RR", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.RR)));
result.setValue("Q0", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.Q0)));
result.setValue("BT", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.BT)));
result.setValue(CommonNamespaces.NS_WEATHER, "TM", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.TM)));
result.setValue(CommonNamespaces.NS_WEATHER, "UM", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.UM)));
result.setValue(CommonNamespaces.NS_WEATHER, "RR", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.RR)));
result.setValue(CommonNamespaces.NS_WEATHER, "Q0", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.Q0)));
result.setValue(CommonNamespaces.NS_WEATHER, "BT", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.BT)));
results.add(result);
......@@ -530,7 +534,7 @@ public class NaerstadModel extends I18nImpl implements Model{
}
/**
* Calculating the VSR value
* Calculating the VRS value
* @param VAS
* @param RTA
* @param IRTA
......
......@@ -65,7 +65,7 @@ public class NaerstadModelTest extends TestCase {
{
if(res.getResultValidTime().compareTo(cal.getTime()) == 0)
{
assertTrue(res.getAllValues().get("RISK").equals("5.36"));
assertTrue(res.getValue(instance.getModelId().toString(),"RISK").equals("5.36"));
}
System.out.println("Res[" + res.getResultValidTime() + "]:" + res.getAllValues());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment