Skip to content
Snippets Groups Projects
Commit 9dea0212 authored by Bhabesh Bhabani Mukhopadhyay's avatar Bhabesh Bhabani Mukhopadhyay
Browse files

Multiple varieties or types included

Multiple varieties or types included in preprocessor level. 
parent 20cd3a44
No related branches found
Tags
No related merge requests found
...@@ -159,11 +159,31 @@ public class PhenologyModelPreprocessor extends ModelRunPreprocessor{ ...@@ -159,11 +159,31 @@ public class PhenologyModelPreprocessor extends ModelRunPreprocessor{
Plant plantDBData = getConfigurationPlantation(FILE_PLANTATION); Plant plantDBData = getConfigurationPlantation(FILE_PLANTATION);
if(!plantDBData.getTypeNames().isEmpty())
{
for(Plantation objTypeNames: plantDBData.getTypeNames())
{
if(objTypeNames.getTypeName().equals((paramPhenologyTypeName)))
{
plant.setSpeciesLatinName(plantDBData.getSpeciesLatinName());
plant.setBaseTemp(objTypeNames.getBaseTemp());
List<Plantation> typeNames = new ArrayList<Plantation>();
typeNames.add(objTypeNames);
plant.setTypeNames(typeNames);
plant.setStartDate(paramSowingDate);
break;
}
}
}
/*
if(plantDBData.getTypeName().equals(paramPhenologyTypeName)) if(plantDBData.getTypeName().equals(paramPhenologyTypeName))
{ {
plant = plantDBData; plant = plantDBData;
plant.setStartDate(paramSowingDate); plant.setStartDate(paramSowingDate);
} }
*/
//plant.setTypeName(paramPhenologyTypeName); //plant.setTypeName(paramPhenologyTypeName);
//plant.setStartDate(paramSowingDate); //plant.setStartDate(paramSowingDate);
...@@ -319,8 +339,42 @@ public class PhenologyModelPreprocessor extends ModelRunPreprocessor{ ...@@ -319,8 +339,42 @@ public class PhenologyModelPreprocessor extends ModelRunPreprocessor{
JsonFactory f = new MappingJsonFactory(); JsonFactory f = new MappingJsonFactory();
JsonParser jp = f.createParser(inputStream); JsonParser jp = f.createParser(inputStream);
JsonNode all = jp.readValueAsTree(); JsonNode all = jp.readValueAsTree();
JsonNode nodePhaseInfo = all.path("phaseInfo");
JsonNode nodeTypeNames = all.path("typeNames");
if(nodeTypeNames.isArray())
{
for(JsonNode nodeTypeName : nodeTypeNames)
{
Plantation plantation = new Plantation();
plantation.setTypeName(nodeTypeName.get("typeName").asText());
if(null != nodeTypeName.get("baseTemp").asText())
{
plantation.setBaseTemp(nodeTypeName.get("baseTemp").asDouble());
}
JsonNode nodeAllPhaseInfo = nodeTypeName.path("phaseInfo");
if(nodeAllPhaseInfo.isArray())
{
List<Plantation.PhaseInfo> listPhaseInfo = new ArrayList<Plantation.PhaseInfo>();
for(JsonNode nodePhaseInfo : nodeAllPhaseInfo)
{
Plantation.PhaseInfo phaseInfo = new Plantation().new PhaseInfo();
phaseInfo.setPhaseName(nodePhaseInfo.get("phaseName").asText());
phaseInfo.setHeatReq(nodePhaseInfo.get("heatReq").asDouble());
listPhaseInfo.add(phaseInfo);
}
if(listPhaseInfo.size() != 0)
{
plantation.setPhaseInfo(listPhaseInfo);
}
}
plantations.add(plantation);
}
}
/*
JsonNode nodePhaseInfo = all.path("phaseInfo");
plant.setSpeciesLatinName(all.get("speciesLatinName").asText()); plant.setSpeciesLatinName(all.get("speciesLatinName").asText());
plant.setTypeName(all.get("typeName").asText()); plant.setTypeName(all.get("typeName").asText());
plant.setBaseTemp(all.get("baseTemp").asDouble()); plant.setBaseTemp(all.get("baseTemp").asDouble());
...@@ -337,8 +391,8 @@ public class PhenologyModelPreprocessor extends ModelRunPreprocessor{ ...@@ -337,8 +391,8 @@ public class PhenologyModelPreprocessor extends ModelRunPreprocessor{
plantations.add(plantation); plantations.add(plantation);
} }
} }
*/
plant.setPlantations(plantations); plant.setTypeNames(plantations);
} catch (IOException ex) { } catch (IOException ex) {
......
...@@ -11,50 +11,38 @@ import java.util.List; ...@@ -11,50 +11,38 @@ import java.util.List;
public class Plant { public class Plant {
private String speciesLatinName; private String speciesLatinName;
private String typeName;
private Double baseTemp; private Double baseTemp;
private Date startDate; private Date startDate;
private List<Plantation> typeNames;
private List<Plantation> plantations;
public String getSpeciesLatinName() { public String getSpeciesLatinName() {
return speciesLatinName; return speciesLatinName;
} }
public void setSpeciesLatinName(String speciesLatinName) { public void setSpeciesLatinName(String speciesLatinName) {
this.speciesLatinName = speciesLatinName; this.speciesLatinName = speciesLatinName;
} }
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public Double getBaseTemp() { public Double getBaseTemp() {
return baseTemp; return baseTemp;
} }
public void setBaseTemp(Double baseTemp) { public void setBaseTemp(Double baseTemp) {
this.baseTemp = baseTemp; this.baseTemp = baseTemp;
} }
public Date getStartDate() { public Date getStartDate() {
return startDate; return startDate;
} }
public void setStartDate(Date startDate) { public void setStartDate(Date startDate) {
this.startDate = startDate; this.startDate = startDate;
} }
public List<Plantation> getTypeNames() {
public List<Plantation> getPlantations() { return typeNames;
return plantations; }
public void setTypeNames(List<Plantation> typeNames) {
this.typeNames = typeNames;
} }
public void setPlantations(List<Plantation> plantations) { @Override
this.plantations = plantations; public String toString() {
return "Plant{" + "speciesLatinName=" + speciesLatinName + ", baseTemp=" + baseTemp + ", startDate=" + startDate + ", typeNames=" + typeNames + '}';
} }
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
package no.nibio.vips.logic.util; package no.nibio.vips.logic.util;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* *
...@@ -11,25 +12,23 @@ import java.util.Date; ...@@ -11,25 +12,23 @@ import java.util.Date;
public class Plantation { public class Plantation {
private String typeName; private String typeName;
private String phaseName; private Double baseTemp;
//private String baseTemp; List<PhaseInfo> phaseInfo;
private Double heatReq;
//private Date startDate;
public Plantation() { public Plantation() {
} }
public Plantation(String typeName, String phaseName, Double heatReq) { public Plantation(String typeName, List<PhaseInfo> phaseInfo) {
this.typeName = typeName; this.typeName = typeName;
this.phaseName = phaseName; this.phaseInfo = phaseInfo;
this.heatReq = heatReq;
} }
public Plantation(String phaseName, Double heatReq) { public Plantation(String typeName,Double baseTemp, List<PhaseInfo> phaseInfo) {
this.phaseName = phaseName; this.typeName = typeName;
this.heatReq = heatReq; this.baseTemp = baseTemp;
this.phaseInfo = phaseInfo;
} }
public String getTypeName() { public String getTypeName() {
return typeName; return typeName;
} }
...@@ -38,25 +37,56 @@ public class Plantation { ...@@ -38,25 +37,56 @@ public class Plantation {
this.typeName = typeName; this.typeName = typeName;
} }
public String getPhaseName() { public Double getBaseTemp() {
return phaseName; return baseTemp;
} }
public void setPhaseName(String phaseName) { public void setBaseTemp(Double baseTemp) {
this.phaseName = phaseName; this.baseTemp = baseTemp;
} }
public Double getHeatReq() { public List<PhaseInfo> getPhaseInfo() {
return heatReq; return phaseInfo;
} }
public void setHeatReq(Double heatReq) { public void setPhaseInfo(List<PhaseInfo> phaseInfo) {
this.heatReq = heatReq; this.phaseInfo = phaseInfo;
} }
@Override @Override
public String toString() { public String toString() {
return "Plantation{" + "typeName=" + typeName + ", phaseName=" + phaseName + ", heatReq=" + heatReq + '}'; return "Plantation{" + "typeName=" + typeName + ", baseTemp=" + baseTemp + ", phaseInfo=" + phaseInfo + '}';
} }
public class PhaseInfo
{
private String phaseName;
private Double heatReq;
public String getPhaseName() {
return phaseName;
}
public void setPhaseName(String phaseName) {
this.phaseName = phaseName;
}
public Double getHeatReq() {
return heatReq;
}
public void setHeatReq(Double heatReq) {
this.heatReq = heatReq;
}
@Override
public String toString() {
return "PhaseInfo{" + "phaseName=" + phaseName + ", heatReq=" + heatReq + '}';
}
}
} }
{ {
"speciesLatinName" : "Zea mays", "speciesLatinName" : "Zea mays",
"typeName" : "TESTVARIETY 2",
"baseTemp" : "10", "baseTemp" : "10",
"phaseInfo": "typeNames" :
[ [
{ {
"phaseName": "VE", "typeName" : "TESTVARIETY 2",
"heatReq" : "66.67" "baseTemp" : "10",
}, "phaseInfo":
{ [
"phaseName": "V2", {
"heatReq" : "111.11" "phaseName": "VE",
}, "heatReq" : "66.67"
{ },
"phaseName": "V3", {
"heatReq" : "194.44" "phaseName": "V2",
}, "heatReq" : "111.11"
{ },
"phaseName": "V4-V6", {
"heatReq" : "263.89" "phaseName": "V3",
}, "heatReq" : "194.44"
{ },
"phaseName": "V7-V9", {
"heatReq" : "338.89" "phaseName": "V4-V6",
}, "heatReq" : "263.89"
{ },
"phaseName": "V10", {
"heatReq" : "411.11" "phaseName": "V7-V9",
}, "heatReq" : "338.89"
{ },
"phaseName": "VT", {
"heatReq" : "630.55" "phaseName": "V10",
}, "heatReq" : "411.11"
{ },
"phaseName": "R2", {
"heatReq" : "922.22" "phaseName": "VT",
}, "heatReq" : "630.55"
{ },
"phaseName": "R5", {
"heatReq" : "1361.11" "phaseName": "R2",
}, "heatReq" : "922.22"
{ },
"phaseName": "R6", {
"heatReq" : "1500" "phaseName": "R5",
} "heatReq" : "1361.11"
},
] {
"phaseName": "R6",
"heatReq" : "1500"
}
]
}
]
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment