Commit 40400d6b authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza
Browse files

show extra data on the crop list page

parent 9f0f0402
......@@ -60,6 +60,9 @@ public interface AccessionRepository extends JpaRepository<Accession, Long>, Acc
@Query("select count(a) from Accession a where a.institute.country = ?1 and a.historic = false")
long countByLocation(Country country);
@Query("select count(a) from Accession a where a.crop = ?1 and a.historic = false")
long countByCrop(Crop crop);
@Query(value = "select a.cropName, count(a.id) from Accession a where a.institute = ?1 and a.historic = false group by a.cropName order by count(a) desc", countQuery = "select count(distinct a.cropName) from Accession a where a.institute = ?1")
Page<Object[]> statisticsCropNameInInstitute(FaoInstitute institute, Pageable pageable);
......
......@@ -183,6 +183,8 @@ public interface GenesysService {
long countAllActive();
long countAllHistoric();
long countByCrop(Crop crop);
/**
* For institutes with {@link FaoInstitute#uniqueAcceNumbs}
......
......@@ -248,7 +248,12 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
return accessionRepository.countByHistoric(true);
}
@Override
@Override
public long countByCrop(final Crop crop) {
return accessionRepository.countByCrop(crop);
}
@Override
public long countByInstitute(FaoInstitute institute) {
return accessionRepository.countByInstitute(institute);
}
......
......@@ -18,7 +18,9 @@ package org.genesys2.server.servlet.controller;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.elasticsearch.common.lang3.StringUtils;
......@@ -29,6 +31,7 @@ import org.genesys2.server.service.ContentService;
import org.genesys2.server.service.CropService;
import org.genesys2.server.service.FilterConstants;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.StatisticsService;
import org.genesys2.server.service.TraitService;
import org.genesys2.server.service.impl.FilterHandler;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilter;
......@@ -68,10 +71,22 @@ public class CropController extends BaseController {
@Autowired
private TraitService traitService;
@Autowired
private StatisticsService statisticsService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index(ModelMap model) {
_logger.debug("Viewing all crops");
model.addAttribute("crops", cropService.list(getLocale()));
List<Crop> cropList = cropService.list(getLocale());
Map<Crop, Long> map = new HashMap<>();
for (Crop crop : cropList) {
map.put(crop, genesysService.countByCrop(crop));
}
model.addAttribute("cropsMap", map);
model.addAttribute("numberOfCountries", statisticsService.numberOfCountries());
model.addAttribute("numberOfInstitutes", statisticsService.numberOfInstitutes());
model.addAttribute("numberOfActiveAccessions", statisticsService.numberOfActiveAccessions());
return "/crop/list";
}
......
......@@ -682,6 +682,8 @@ autocomplete.genus=Find Genus...
stats.number-of-countries={0} Countries
stats.number-of-institutes={0} Institutes
stats.number-of-accessions={0} Accessions
stats.number-of-crops={0} Crops
stats.number-of-datasets={0} Datasets
stats.number-of-historic-accessions={0} Historic accessions
navigate.back=Back
......
......@@ -3,25 +3,29 @@
<%@ include file="/WEB-INF/jsp/init.jsp" %>
<html>
<head>
<title><spring:message code="crop.croplist" /></title>
</head>
<head>
<title><spring:message code="crop.croplist" /></title>
</head>
<body>
<h1>
<spring:message code="crop.croplist" />
</h1>
<span><spring:message code="stats.number-of-crops" arguments="${cropsMap.size()}"/></span><br/>
<span><spring:message code="stats.number-of-accessions" arguments="${numberOfActiveAccessions}"/></span><br/>
<span><spring:message code="stats.number-of-institutes" arguments="${numberOfInstitutes}"/></span><br/>
<span><spring:message code="stats.number-of-countries" arguments="${numberOfCountries}"/></span><br/>
<div class="row">
<div id="crop-list-titles" class="container">
<c:forEach items="${crops}" var="crop" varStatus="status">
<div class="col-xs-6 col-sm-3 col-lg-2 crop-wrap">
<a class="fff" href="<c:url value="/c/${crop.shortName}" />"></a>
<img class="img-responsive" src="/html/1/images/<c:out value="${crop.shortName}"/>.png"/>
<p>
<c:out value="${crop.getName(pageContext.response.locale)}" />
</p>
</div>
</c:forEach>
<c:forEach var="entry" items="${cropsMap}">
<div class="col-xs-6 col-sm-3 col-lg-2 crop-wrap">
<a class="fff" href="<c:url value="/c/${entry.key.shortName}" />"></a>
<img class="img-responsive" src="/html/1/images/<c:out value="${entry.key.shortName}"/>.png"/>
<p><c:out value="${entry.key.getName(pageContext.response.locale)}" /></p>
<span><fmt:formatNumber value = "${entry.value}" type = "number"/> <spring:message code="search.section.accession" /></span>
</div>
</c:forEach>
</div>
</div>
......
Markdown is supported
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