From 70874687533cd50db3b7bfe82885d6cfac9baba2 Mon Sep 17 00:00:00 2001
From: Bhabesh <bhabesh.mukhopadhyay@nibio.no>
Date: Mon, 23 Nov 2020 16:26:19 +0100
Subject: [PATCH] Addition of 'LogIntervalId' and 'DegreeAlgorithmId'

LogIntervalId will determine frequency of weather dataupdate and algorithmId will determine which day degree algorithm required for a particular phenology model
---
 .../PhenologyModelPreprocessor.java           | 18 +++++++++++++++
 .../java/no/nibio/vips/logic/util/Plant.java  | 22 ++++++++++++++++++-
 .../resources/dataset/plantationData.json     |  6 ++++-
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/PhenologyModelPreprocessor.java b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/PhenologyModelPreprocessor.java
index 3666aa30..f8574969 100644
--- a/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/PhenologyModelPreprocessor.java
+++ b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/PhenologyModelPreprocessor.java
@@ -76,12 +76,14 @@ public class PhenologyModelPreprocessor extends ModelRunPreprocessor{
     private final   static  String      NODE_SPECIES            =   "species";
     private final   static  String      NODE_SPECIES_LATIN_NAME =   "speciesLatinName";
     private final   static  String      NODE_BASE_TEMP          =   "baseTemp";
+    private final   static  String      NODE_LOG_INTERVAL_ID    =   "weatherLogIntervalId";
     private final   static  String      NODE_TYPE_NAMES         =   "typeNames";
     private final   static  String      NODE_TYPE_NAME          =   "typeName";
     private final   static  String      NODE_PHASE_INFO         =   "phaseInfo";
     private final   static  String      NODE_PHASE_NAME         =   "phaseName";
     private final   static  String      NODE_HEAT_REQ           =   "heatReq";
     private final   static  String      NODE_WEATHER_PARAMS     =   "weatherParameters";
+    private final   static  String      NODE_DD_ALGORITHM_ID    =   "dayDegreeAlgorithmId";
     
     @Override
     public ModelConfiguration getModelConfiguration(ForecastConfiguration configuration) throws PreprocessorException {
@@ -268,6 +270,14 @@ public class PhenologyModelPreprocessor extends ModelRunPreprocessor{
                         {
                             plant.setBaseTemp(nodeSpecies.get(NODE_BASE_TEMP).asDouble());
                         }
+                        if(null != nodeSpecies.get(NODE_LOG_INTERVAL_ID).asText())
+                        {
+                            plant.setLogIntervalId(nodeSpecies.get(NODE_LOG_INTERVAL_ID).asInt());
+                        }
+                        if(null != nodeSpecies.get(NODE_DD_ALGORITHM_ID).asText())
+                        {
+                            plant.setAlgorithmId(nodeSpecies.get(NODE_DD_ALGORITHM_ID).asInt());
+                        }
                        JsonNode nodeSpeciesWeatherParams   = nodeSpecies.path(NODE_WEATHER_PARAMS);
                        if( null != nodeSpeciesWeatherParams && nodeSpeciesWeatherParams.isArray())
                        {
@@ -289,6 +299,14 @@ public class PhenologyModelPreprocessor extends ModelRunPreprocessor{
                                  if(nodeTypeName.get(NODE_TYPE_NAME).asText().trim().equalsIgnoreCase(strParamTypeName))
                                  {
                                     plant.setTypeName(strParamTypeName);
+                                    if(null != nodeTypeName.get(NODE_LOG_INTERVAL_ID).asText())
+                                    {
+                                        plant.setLogIntervalId(nodeTypeName.get(NODE_LOG_INTERVAL_ID).asInt());
+                                    }
+                                    if(null != nodeTypeName.get(NODE_DD_ALGORITHM_ID).asText())
+                                    {
+                                        plant.setAlgorithmId(nodeTypeName.get(NODE_DD_ALGORITHM_ID).asInt());
+                                    }                                    
                                     if(null != nodeTypeName.get(NODE_BASE_TEMP).asText())
                                     {
                                         plant.setBaseTemp(nodeTypeName.get(NODE_BASE_TEMP).asDouble());
diff --git a/src/main/java/no/nibio/vips/logic/util/Plant.java b/src/main/java/no/nibio/vips/logic/util/Plant.java
index ca3ee42e..8e4344de 100644
--- a/src/main/java/no/nibio/vips/logic/util/Plant.java
+++ b/src/main/java/no/nibio/vips/logic/util/Plant.java
@@ -13,6 +13,8 @@ public class Plant {
     private String              speciesLatinName;
     private String              typeName;
     private Double              baseTemp;
+    private Integer             logIntervalId;
+    private Integer             algorithmId;
     private Date                startDate;
     private String[]            weatherParams;
     
@@ -42,6 +44,22 @@ public class Plant {
         this.baseTemp = baseTemp;
     }
 
+    public Integer getLogIntervalId() {
+        return logIntervalId;
+    }
+
+    public void setLogIntervalId(Integer logIntervalId) {
+        this.logIntervalId = logIntervalId;
+    }
+
+    public Integer getAlgorithmId() {
+        return algorithmId;
+    }
+
+    public void setAlgorithmId(Integer algorithmId) {
+        this.algorithmId = algorithmId;
+    }
+
     public Date getStartDate() {
         return startDate;
     }
@@ -68,9 +86,11 @@ public class Plant {
 
     @Override
     public String toString() {
-        return "Plant{" + "speciesLatinName=" + speciesLatinName + ", typeName=" + typeName + ", baseTemp=" + baseTemp + ", startDate=" + startDate + ", weatherParams=" + weatherParams + ", plantations=" + plantations + '}';
+        return "Plant{" + "speciesLatinName=" + speciesLatinName + ", typeName=" + typeName + ", baseTemp=" + baseTemp + ", logIntervalId=" + logIntervalId + ", algorithmId=" + algorithmId + ", startDate=" + startDate + ", weatherParams=" + weatherParams + ", plantations=" + plantations + '}';
     }
 
 
+
+
         
 }
diff --git a/src/main/resources/dataset/plantationData.json b/src/main/resources/dataset/plantationData.json
index 095fe57d..74845c49 100644
--- a/src/main/resources/dataset/plantationData.json
+++ b/src/main/resources/dataset/plantationData.json
@@ -4,13 +4,17 @@
                 {
                     "speciesLatinName"          : "Zea mays",
                     "baseTemp"                  : "10",
-                    "weatherParameters"         : ["TN","TX","TM"], 
+                    "weatherLogIntervalId"      : "2",
+                    "weatherParameters"         : ["TN","TX","TM"],
+                    "dayDegreeAlgorithmId"      : "1",
                     "typeNames"                 :
                                                 [
                                                     {
                                                         "typeName"          : "TESTVARIETY 2",
                                                         "baseTemp"          : "10",
+                                                        "weatherLogIntervalId"      : "2",
                                                         "weatherParameters" : ["TN","TX","TM"],
+                                                        "dayDegreeAlgorithmId"      :"1",
                                                         "phaseInfo"     :
                                                                         [
                                                                             {
-- 
GitLab