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

New functionality for interactive models

parent b7ffad34
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (c) 2015 NIBIO <http://www.nibio.no/>.
*
* This file is part of VIPSCommon.
* VIPSCommon is free software: you can redistribute it and/or modify
* it under the terms of the NIBIO Open Source License as published by
* NIBIO, either version 1 of the License, or (at your option) any
* later version.
*
* VIPSCommon is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* NIBIO Open Source License for more details.
*
* You should have received a copy of the NIBIO Open Source License
* along with VIPSCommon. If not, see <http://www.nibio.no/licenses/>.
*
*/
package no.bioforsk.vips.pestmanagement;
import java.util.Date;
/**
* @copyright 2015 <a href="http://www.bioforsk.no/">Bioforsk</a>
* @author Tor-Einar Skog <tor-einar.skog@bioforsk.no>
*/
public interface Spraying {
public Date getSprayingDate();
public String getPesticideName();
public Double getSprayingEffectFactor();
}
/*
* Copyright (c) 2015 NIBIO <http://www.nibio.no/>.
*
* This file is part of VIPSCommon.
* VIPSCommon is free software: you can redistribute it and/or modify
* it under the terms of the NIBIO Open Source License as published by
* NIBIO, either version 1 of the License, or (at your option) any
* later version.
*
* VIPSCommon is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* NIBIO Open Source License for more details.
*
* You should have received a copy of the NIBIO Open Source License
* along with VIPSCommon. If not, see <http://www.nibio.no/licenses/>.
*
*/
package no.bioforsk.vips.pestmanagement;
import java.util.Date;
/**
* @copyright 2015 <a href="http://www.nibio.no/">NIBIO</a>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/
public class SprayingImpl implements Spraying{
private Date sprayingDate;
private String pesticideName;
private Double sprayingEffectFactor;
/**
* @return the sprayingDate
*/
@Override
public Date getSprayingDate() {
return sprayingDate;
}
/**
* @param sprayingDate the sprayingDate to set
*/
public void setSprayingDate(Date sprayingDate) {
this.sprayingDate = sprayingDate;
}
/**
* @return the pesticideName
*/
@Override
public String getPesticideName() {
return pesticideName;
}
/**
* @param pesticideName the pesticideName to set
*/
public void setPesticideName(String pesticideName) {
this.pesticideName = pesticideName;
}
/**
* @return the sprayingEffectFactor
*/
@Override
public Double getSprayingEffectFactor() {
return sprayingEffectFactor;
}
/**
* @param sprayingEffectFactor the sprayingEffectFactor to set
*/
public void setSprayingEffectFactor(Double sprayingEffectFactor) {
this.sprayingEffectFactor = sprayingEffectFactor;
}
}
/*
* Copyright (c) 2015 NIBIO <http://www.nibio.no/>.
*
* This file is part of VIPSCommon.
* VIPSCommon is free software: you can redistribute it and/or modify
* it under the terms of the NIBIO Open Source License as published by
* NIBIO, either version 1 of the License, or (at your option) any
* later version.
*
* VIPSCommon is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* NIBIO Open Source License for more details.
*
* You should have received a copy of the NIBIO Open Source License
* along with VIPSCommon. If not, see <http://www.nibio.no/licenses/>.
*
*/
package no.bioforsk.vips.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
/**
* @copyright 2015 <a href="http://www.nibio.no/">NIBIO</a>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/
public class ParseRESTParamUtil {
/**
*
* @param dateStr
* @param timeZone
* @return Date or null if not parseable (input format is "yyyy-MM-dd")
*/
public Date parseISODate(String dateStr, TimeZone timeZone)
{
if(dateStr == null || dateStr.isEmpty())
{
return null;
}
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
format.setTimeZone(timeZone);
try
{
return format.parse(dateStr);
}
catch(ParseException ex)
{
return null;
}
}
/**
*
* @param dateStr
* @param timeZone
* @return Date or null if not parseable (accepted format is "yyyy-MM-dd HH:mm:ss")
*/
public Date parseISODateTime(String dateStr, TimeZone timeZone)
{
if(dateStr == null || dateStr.isEmpty())
{
return null;
}
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
format.setTimeZone(timeZone);
try
{
return format.parse(dateStr);
}
catch(ParseException ex)
{
return null;
}
}
public Double parseDouble(String doubleStr)
{
if(doubleStr == null || doubleStr.isEmpty())
{
return null;
}
try
{
return Double.parseDouble(doubleStr);
}
catch(NumberFormatException ex)
{
return null;
}
}
public Integer parseInteger(String intStr)
{
if(intStr == null || intStr.isEmpty())
{
return null;
}
try
{
return Integer.parseInt(intStr);
}
catch(NumberFormatException ex)
{
return null;
}
}
public Boolean parseCheckbox(String checkboxStr)
{
return checkboxStr != null;
}
}
......@@ -29,7 +29,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TimeZone;
import no.bioforsk.vips.entity.WeatherObservation;
......@@ -1326,4 +1325,6 @@ public class WeatherUtil {
}
return retVal;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment