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

Allowing for more than one organization's stations to be shown on the front page map

parent 7503a295
Branches
Tags
2 merge requests!17Develop,!12Ny server 2019
......@@ -659,7 +659,7 @@ public class ForecastBean {
return resource;
}
public Kml getForecastsAggregateKml(Integer organizationId, List<Integer> cropOrganismIds, Date theDate, String serverName)
public Kml getForecastsAggregateKml(List<Integer> organizationIds, List<Integer> cropOrganismIds, Date theDate, String serverName)
{
//String iconPath = Globals.PROTOCOL + "://" + serverName + "/public/images/";
String iconPath = "//" + serverName + "/public/images/";
......@@ -696,7 +696,20 @@ public class ForecastBean {
// Run through forecast configurations
//Date benchmark = new Date();
List<PointOfInterest> poisWithAggregate = getPointOfInterestForecastsAggregate(organizationId, cropOrganismIds, theDate);
List<PointOfInterest> poisWithAggregate = new ArrayList<>();
if(organizationIds.size() == 1 && organizationIds.get(0).equals(-1))
{
em.createNamedQuery("Organization.findAll",Organization.class).getResultStream().forEach(
org-> poisWithAggregate.addAll(getPointOfInterestForecastsAggregate(org.getOrganizationId(), cropOrganismIds, theDate))
);
}
else
{
organizationIds.stream().forEach(
orgId-> poisWithAggregate.addAll(getPointOfInterestForecastsAggregate(orgId, cropOrganismIds, theDate))
);
}
//System.out.println(this.getClass().getName() + " DEBUG: getPointOfInterestForecastsAggregate took " + (new Date().getTime() - benchmark.getTime()) + " ms to complete.");
GISEntityUtil gisUtil = new GISEntityUtil();
......
......@@ -429,6 +429,8 @@ public class LogicService {
@PathParam("organizationId") Integer organizationId,
@QueryParam("cropCategoryId") List<Integer> cropCategoryIds)
{
List<Integer> organizationIds = new ArrayList<>();
organizationIds.add(organizationId);
if(cropCategoryIds == null || cropCategoryIds.isEmpty())
{
return Response.noContent().build();
......@@ -436,7 +438,33 @@ public class LogicService {
else
{
List<Integer> cropOrganismIds = SessionControllerGetter.getOrganismBean().getCropCategoryOrganismIds(cropCategoryIds);
Kml retVal = SessionControllerGetter.getForecastBean().getForecastsAggregateKml(organizationId, cropOrganismIds, SystemTime.getSystemTime(), ServletUtil.getServerName(httpServletRequest));
Kml retVal = SessionControllerGetter.getForecastBean().getForecastsAggregateKml(organizationIds, cropOrganismIds, SystemTime.getSystemTime(), ServletUtil.getServerName(httpServletRequest));
return Response.ok().entity(retVal).build();
}
}
/**
*
* @param organizationId
* @param cropCategoryIds
* @return
*/
@GET
@Path("forecastresults/aggregate/orgspan")
@GZIP
@Produces("application/vnd.google-earth.kml+xml;charset=utf-8")
@Facet("restricted")
public Response getForecastResultsAggregate(
@QueryParam("organizationId") List<Integer> organizationIds,
@QueryParam("cropCategoryId") List<Integer> cropCategoryIds)
{
if(cropCategoryIds == null || cropCategoryIds.isEmpty())
{
return Response.noContent().build();
}
else
{
List<Integer> cropOrganismIds = SessionControllerGetter.getOrganismBean().getCropCategoryOrganismIds(cropCategoryIds);
Kml retVal = SessionControllerGetter.getForecastBean().getForecastsAggregateKml(organizationIds, cropOrganismIds, SystemTime.getSystemTime(), ServletUtil.getServerName(httpServletRequest));
return Response.ok().entity(retVal).build();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment