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
No related tags found
2 merge requests!17Develop,!12Ny server 2019
This commit is part of merge request !12. Comments created here will be created in the context of that merge request.
...@@ -659,7 +659,7 @@ public class ForecastBean { ...@@ -659,7 +659,7 @@ public class ForecastBean {
return resource; 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 = Globals.PROTOCOL + "://" + serverName + "/public/images/";
String iconPath = "//" + serverName + "/public/images/"; String iconPath = "//" + serverName + "/public/images/";
...@@ -696,7 +696,20 @@ public class ForecastBean { ...@@ -696,7 +696,20 @@ public class ForecastBean {
// Run through forecast configurations // Run through forecast configurations
//Date benchmark = new Date(); //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."); //System.out.println(this.getClass().getName() + " DEBUG: getPointOfInterestForecastsAggregate took " + (new Date().getTime() - benchmark.getTime()) + " ms to complete.");
GISEntityUtil gisUtil = new GISEntityUtil(); GISEntityUtil gisUtil = new GISEntityUtil();
......
...@@ -429,6 +429,8 @@ public class LogicService { ...@@ -429,6 +429,8 @@ public class LogicService {
@PathParam("organizationId") Integer organizationId, @PathParam("organizationId") Integer organizationId,
@QueryParam("cropCategoryId") List<Integer> cropCategoryIds) @QueryParam("cropCategoryId") List<Integer> cropCategoryIds)
{ {
List<Integer> organizationIds = new ArrayList<>();
organizationIds.add(organizationId);
if(cropCategoryIds == null || cropCategoryIds.isEmpty()) if(cropCategoryIds == null || cropCategoryIds.isEmpty())
{ {
return Response.noContent().build(); return Response.noContent().build();
...@@ -436,7 +438,33 @@ public class LogicService { ...@@ -436,7 +438,33 @@ public class LogicService {
else else
{ {
List<Integer> cropOrganismIds = SessionControllerGetter.getOrganismBean().getCropCategoryOrganismIds(cropCategoryIds); 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(); 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