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

Some error handling

parent 0088ad77
No related branches found
No related tags found
No related merge requests found
......@@ -106,6 +106,10 @@ public class ForecastBean {
public List<ForecastResult> getForecastResults(Long forecastConfigurationId, Integer latestDays)
{
ForecastResult mostRecentForecastResult = this.getMostRecentForecastResult(forecastConfigurationId);
if(mostRecentForecastResult == null)
{
return null;
}
Calendar cal = Calendar.getInstance();
cal.setTime(mostRecentForecastResult.getResultValidTime());
cal.add(Calendar.DATE, -latestDays);
......@@ -120,7 +124,14 @@ public class ForecastBean {
q.setParameter("forecastConfigurationId", forecastConfigurationId);
q.setParameter("timeStart", timeStart);
q.setParameter("timeEnd", timeEnd);
return q.getResultList();
try
{
return q.getResultList();
}
catch(NoResultException ex)
{
return null;
}
}
public ForecastResult getMostRecentForecastResult(Long forecastConfigurationId)
......@@ -135,7 +146,14 @@ public class ForecastBean {
+ ");", ForecastResult.class);
q.setParameter("forecastConfigurationId", forecastConfigurationId);
return (ForecastResult) q.getSingleResult();
try
{
return (ForecastResult) q.getSingleResult();
}
catch(NoResultException ex)
{
return null;
}
}
/**
......
......@@ -81,6 +81,10 @@ public class LogicService {
public Response getForecastResults(@PathParam("forecastConfigurationId") Long forecastConfigurationId)
{
List<ForecastResult> results = SessionControllerGetter.getForecastBean().getForecastResults(forecastConfigurationId);
if(results == null)
{
results = new ArrayList<>();
}
return Response.ok().entity(results).build();
}
......@@ -93,6 +97,10 @@ public class LogicService {
)
{
List<ForecastResult> results = SessionControllerGetter.getForecastBean().getForecastResults(forecastConfigurationId, latestDays);
if(results == null)
{
results = new ArrayList<>();
}
return Response.ok().entity(results).build();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment