diff --git a/src/main/java/no/bioforsk/vips/model/applescabmodel/AppleScabModel.java b/src/main/java/no/bioforsk/vips/model/applescabmodel/AppleScabModel.java index ada81b49a8ffa4c22523abf48861e11e3691a997..0a65fe6fb4a8aab05c8343a823b3a138b2c9100c 100644 --- a/src/main/java/no/bioforsk/vips/model/applescabmodel/AppleScabModel.java +++ b/src/main/java/no/bioforsk/vips/model/applescabmodel/AppleScabModel.java @@ -35,6 +35,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.InvalidAggregationTypeException; import no.bioforsk.vips.util.WeatherElements; import no.bioforsk.vips.util.WeatherObservationListException; @@ -118,19 +119,19 @@ public class AppleScabModel extends I18nImpl implements Model{ { Result result = new ResultImpl(); result.setResultValidTime(timeStamp); - result.setValue(AppleScabCalculations.ASCOSPORE_MATURITY, this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ASCOSPORE_MATURITY) != null ? String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ASCOSPORE_MATURITY)) : ""); - result.setValue(AppleScabCalculations.ACCUMULATED_MILLS, String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ACCUMULATED_MILLS))); - result.setValue(AppleScabCalculations.TM, String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.TM))); - result.setValue(AppleScabCalculations.BT, String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.BT))); - result.setValue(AppleScabCalculations.RR, String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.RR))); + result.setValue(this.getModelId().toString(), AppleScabCalculations.ASCOSPORE_MATURITY, this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ASCOSPORE_MATURITY) != null ? String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ASCOSPORE_MATURITY)) : ""); + result.setValue(this.getModelId().toString(), AppleScabCalculations.ACCUMULATED_MILLS, String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ACCUMULATED_MILLS))); + result.setValue(CommonNamespaces.NS_WEATHER, AppleScabCalculations.TM, String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.TM))); + result.setValue(CommonNamespaces.NS_WEATHER, AppleScabCalculations.BT, String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.BT))); + result.setValue(CommonNamespaces.NS_WEATHER, AppleScabCalculations.RR, String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.RR))); Double accumulatedTemperature = this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ACCUMULATED_TEMPERATURE); - result.setValue(AppleScabCalculations.ACCUMULATED_TEMPERATURE, accumulatedTemperature != null ? String.valueOf(accumulatedTemperature) : ""); + result.setValue(CommonNamespaces.NS_WEATHER, AppleScabCalculations.ACCUMULATED_TEMPERATURE, accumulatedTemperature != null ? String.valueOf(accumulatedTemperature) : ""); Double aggregatedLeafWetness = this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.AGGREGATED_LEAF_WETNESS); - result.setValue(AppleScabCalculations.AGGREGATED_LEAF_WETNESS, aggregatedLeafWetness != null ? String.valueOf(aggregatedLeafWetness) : ""); + result.setValue(CommonNamespaces.NS_WEATHER, AppleScabCalculations.AGGREGATED_LEAF_WETNESS, aggregatedLeafWetness != null ? String.valueOf(aggregatedLeafWetness) : ""); Double aggregatedTemperature = this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.AGGREGATED_TEMPERATURE); - result.setValue(AppleScabCalculations.AGGREGATED_TEMPERATURE, aggregatedTemperature != null ? String.valueOf(aggregatedTemperature) : ""); + result.setValue(CommonNamespaces.NS_WEATHER, AppleScabCalculations.AGGREGATED_TEMPERATURE, aggregatedTemperature != null ? String.valueOf(aggregatedTemperature) : ""); Double aggregatedPrecipitation = this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.AGGREGATED_PRECIPITATION); - result.setValue(AppleScabCalculations.AGGREGATED_PRECIPITATION, aggregatedPrecipitation != null ? String.valueOf(aggregatedPrecipitation) : ""); + result.setValue(CommonNamespaces.NS_WEATHER, AppleScabCalculations.AGGREGATED_PRECIPITATION, aggregatedPrecipitation != null ? String.valueOf(aggregatedPrecipitation) : ""); // Deciding warning status result.setWarningStatus(this.getWarningStatus(timeStamp)); diff --git a/src/test/java/no/bioforsk/vips/model/applescabmodel/AppleScabModelTest.java b/src/test/java/no/bioforsk/vips/model/applescabmodel/AppleScabModelTest.java index 5b2aab90070c8fac2da0547c80ae9e9358343e34..d3614855df0e83030a398974bfa5fc64fa3cfe6b 100644 --- a/src/test/java/no/bioforsk/vips/model/applescabmodel/AppleScabModelTest.java +++ b/src/test/java/no/bioforsk/vips/model/applescabmodel/AppleScabModelTest.java @@ -24,6 +24,7 @@ import no.bioforsk.vips.entity.Result; import no.bioforsk.vips.entity.WeatherObservation; import no.bioforsk.vips.model.ConfigValidationException; import no.bioforsk.vips.model.ModelExcecutionException; +import no.bioforsk.vips.util.CommonNamespaces; import no.bioforsk.vips.util.WeatherObservationListException; import org.codehaus.jackson.JsonFactory; import org.codehaus.jackson.JsonNode; @@ -85,14 +86,14 @@ public class AppleScabModelTest extends TestCase { ); for(Result result:results) { - if(!result.getValue(AppleScabCalculations.ACCUMULATED_TEMPERATURE).equals("")) + if(!result.getValue(instance.getModelId().toString(), AppleScabCalculations.ACCUMULATED_TEMPERATURE).equals("")) { System.out.println( format.format(result.getResultValidTime()) + - "\t" + result.getValue(AppleScabCalculations.ACCUMULATED_TEMPERATURE) + - "\t" + result.getValue(AppleScabCalculations.AGGREGATED_LEAF_WETNESS) + - "\t" + result.getValue(AppleScabCalculations.AGGREGATED_TEMPERATURE) + - "\t" + result.getValue(AppleScabCalculations.AGGREGATED_PRECIPITATION) + "\t" + result.getValue(CommonNamespaces.NS_WEATHER, AppleScabCalculations.ACCUMULATED_TEMPERATURE) + + "\t" + result.getValue(CommonNamespaces.NS_WEATHER, AppleScabCalculations.AGGREGATED_LEAF_WETNESS) + + "\t" + result.getValue(CommonNamespaces.NS_WEATHER, AppleScabCalculations.AGGREGATED_TEMPERATURE) + + "\t" + result.getValue(CommonNamespaces.NS_WEATHER, AppleScabCalculations.AGGREGATED_PRECIPITATION) ); } } @@ -110,11 +111,11 @@ public class AppleScabModelTest extends TestCase { { System.out.println( format.format(result.getResultValidTime()) + - "\t" + result.getValue("AccumulatedMills") + - "\t" + result.getValue("AscosporeMaturity") + - "\t" + result.getValue("TM") + - "\t" + result.getValue("BT") + - "\t" + result.getValue("RR") + "\t" + result.getValue(instance.getModelId().toString(), "AccumulatedMills") + + "\t" + result.getValue(instance.getModelId().toString(), "AscosporeMaturity") + + "\t" + result.getValue(CommonNamespaces.NS_WEATHER, "TM") + + "\t" + result.getValue(CommonNamespaces.NS_WEATHER, "BT") + + "\t" + result.getValue(CommonNamespaces.NS_WEATHER, "RR") ); }