Commit 8ab3a78a authored by Matija Obreza's avatar Matija Obreza
Browse files

FIXED #8: Crop stats on institute page

parent a57b7db2
...@@ -32,6 +32,7 @@ import org.genesys2.server.model.genesys.Taxonomy2; ...@@ -32,6 +32,7 @@ import org.genesys2.server.model.genesys.Taxonomy2;
import org.genesys2.server.model.impl.FaoInstitute; import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.service.ContentService; import org.genesys2.server.service.ContentService;
import org.genesys2.server.service.DownloadService; import org.genesys2.server.service.DownloadService;
import org.genesys2.server.service.ElasticService;
import org.genesys2.server.service.FilterConstants; import org.genesys2.server.service.FilterConstants;
import org.genesys2.server.service.GenesysService; import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.GeoService; import org.genesys2.server.service.GeoService;
...@@ -42,6 +43,7 @@ import org.genesys2.server.service.TaxonomyService; ...@@ -42,6 +43,7 @@ import org.genesys2.server.service.TaxonomyService;
import org.genesys2.server.service.impl.FilterHandler; import org.genesys2.server.service.impl.FilterHandler;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilter; import org.genesys2.server.service.impl.FilterHandler.AppliedFilter;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilters; import org.genesys2.server.service.impl.FilterHandler.AppliedFilters;
import org.genesys2.server.service.impl.SearchException;
import org.genesys2.spring.ResourceNotFoundException; import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
...@@ -87,6 +89,9 @@ public class WiewsController extends BaseController { ...@@ -87,6 +89,9 @@ public class WiewsController extends BaseController {
@Autowired @Autowired
private StatisticsService statisticsService; private StatisticsService statisticsService;
@Autowired
private ElasticService elasticService;
@RequestMapping("/") @RequestMapping("/")
public String view(ModelMap model, @RequestParam(value = "page", required = false, defaultValue = "1") int page) { public String view(ModelMap model, @RequestParam(value = "page", required = false, defaultValue = "1") int page) {
model.addAttribute("pagedData", instituteService.listPGRInstitutes(new PageRequest(page - 1, 50, new Sort("code")))); model.addAttribute("pagedData", instituteService.listPGRInstitutes(new PageRequest(page - 1, 50, new Sort("code"))));
...@@ -128,6 +133,17 @@ public class WiewsController extends BaseController { ...@@ -128,6 +133,17 @@ public class WiewsController extends BaseController {
long datasetCount = genesysService.countDatasets(faoInstitute); long datasetCount = genesysService.countDatasets(faoInstitute);
model.addAttribute("datasetCount", datasetCount); model.addAttribute("datasetCount", datasetCount);
{
AppliedFilters instituteFilter = new AppliedFilters();
instituteFilter.add(new AppliedFilter().setFilterName(FilterConstants.INSTCODE).addFilterValue(
new FilterHandler.LiteralValueFilter(faoInstitute.getCode())));
try {
model.addAttribute("statisticsCrops", elasticService.termStatisticsAuto(instituteFilter, FilterConstants.CROPS, 5));
} catch (SearchException e) {
_logger.warn(e.getMessage());
}
}
model.addAttribute("statisticsGenus", genesysService.statisticsGenusByInstitute(faoInstitute, new PageRequest(0, 30))); model.addAttribute("statisticsGenus", genesysService.statisticsGenusByInstitute(faoInstitute, new PageRequest(0, 30)));
model.addAttribute("statisticsTaxonomy", genesysService.statisticsSpeciesByInstitute(faoInstitute, new PageRequest(0, 30))); model.addAttribute("statisticsTaxonomy", genesysService.statisticsSpeciesByInstitute(faoInstitute, new PageRequest(0, 30)));
model.addAttribute("statisticsPDCI", statisticsService.statisticsPDCI(faoInstitute)); model.addAttribute("statisticsPDCI", statisticsService.statisticsPDCI(faoInstitute));
......
...@@ -147,23 +147,15 @@ ...@@ -147,23 +147,15 @@
</div> </div>
</c:if> </c:if>
<%-- <h3>
<spring:message code="faoInstitute.statistics" />
</h3> --%>
<div class="row" style="margin-top: 2em;"> <div class="row" style="margin-top: 2em;">
<%-- <c:if test="${statisticsCrop ne null}"> <c:if test="${statisticsCrops ne null}">
<div class="col-sm-4"> <div class="col-xs-12">
<h4><spring:message code="faoInstitute.stat-by-crop" arguments="${statisticsCrop.numberOfElements}" /></h4> <h4>
<ul class="funny-list statistics"> <spring:message code="faoInstitute.stat-by-crop" />
<c:forEach items="${statisticsCrop.content}" var="stat" varStatus="status"> </h4>
<li class="clearfix ${status.count % 2 == 0 ? 'even' : 'odd'}"><span class="stats-number"><fmt:formatNumber value="${stat[1]}" /></span> <a href="<c:url value="/wiews/${faoInstitute.code}/" />"><c:out value="${stat[0].getName(pageContext.response.locale)}" /></a></li> <local:term-result termResult="${statisticsCrops}" type="crop" />
</c:forEach> </div>
</ul> </c:if>
</div>
</c:if> --%>
<div class="col-sm-6"> <div class="col-sm-6">
<h4> <h4>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment