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;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.service.ContentService;
import org.genesys2.server.service.DownloadService;
import org.genesys2.server.service.ElasticService;
import org.genesys2.server.service.FilterConstants;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.GeoService;
......@@ -42,6 +43,7 @@ import org.genesys2.server.service.TaxonomyService;
import org.genesys2.server.service.impl.FilterHandler;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilter;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilters;
import org.genesys2.server.service.impl.SearchException;
import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
......@@ -87,6 +89,9 @@ public class WiewsController extends BaseController {
@Autowired
private StatisticsService statisticsService;
@Autowired
private ElasticService elasticService;
@RequestMapping("/")
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"))));
......@@ -128,6 +133,17 @@ public class WiewsController extends BaseController {
long datasetCount = genesysService.countDatasets(faoInstitute);
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("statisticsTaxonomy", genesysService.statisticsSpeciesByInstitute(faoInstitute, new PageRequest(0, 30)));
model.addAttribute("statisticsPDCI", statisticsService.statisticsPDCI(faoInstitute));
......
......@@ -147,23 +147,15 @@
</div>
</c:if>
<%-- <h3>
<spring:message code="faoInstitute.statistics" />
</h3> --%>
<div class="row" style="margin-top: 2em;">
<%-- <c:if test="${statisticsCrop ne null}">
<div class="col-sm-4">
<h4><spring:message code="faoInstitute.stat-by-crop" arguments="${statisticsCrop.numberOfElements}" /></h4>
<ul class="funny-list statistics">
<c:forEach items="${statisticsCrop.content}" var="stat" varStatus="status">
<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>
</c:forEach>
</ul>
<c:if test="${statisticsCrops ne null}">
<div class="col-xs-12">
<h4>
<spring:message code="faoInstitute.stat-by-crop" />
</h4>
<local:term-result termResult="${statisticsCrops}" type="crop" />
</div>
</c:if> --%>
</c:if>
<div class="col-sm-6">
<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