Commit fb72d8f7 authored by Matija Obreza's avatar Matija Obreza

Provide overview of filtered data

parent 9ca05d84
......@@ -45,6 +45,7 @@ public class AccessionDetails {
private String acqSrc;
private Boolean available;
private Date createdDate;
// FIXME @Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private List<String> duplSite;
private Boolean mlsStatus;
private Boolean art15;
......
......@@ -17,14 +17,12 @@
package org.genesys2.server.service;
import java.util.Collection;
import java.util.List;
import org.genesys2.server.model.elastic.AccessionDetails;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilters;
import org.genesys2.server.service.impl.SearchException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.core.facet.result.Term;
import org.springframework.data.elasticsearch.core.facet.result.TermResult;
public interface ElasticService {
......
......@@ -57,4 +57,10 @@ public interface FilterConstants {
public static final String TAXONOMY_GENUS = "taxonomy.genus";
public static final String ID = "id";
public static final String DUPLSITE = "duplSite";
public static final String DONORCODE = "donorCode";
public static final String INSTITUTE_COUNTRY_ISO3 = "institute.country.iso3";
}
......@@ -441,4 +441,46 @@ public class ExplorerController extends BaseController {
}
}
@RequestMapping(value = "/explore/overview")
public String overview(ModelMap model, @RequestParam(value = "filter", required = false, defaultValue = "{}") String jsonFilter) throws IOException, SearchException {
AppliedFilters appliedFilters = mapper.readValue(jsonFilter, AppliedFilters.class);
// Composition overview
overviewInstitutes(model, appliedFilters);
overviewComposition(model, appliedFilters);
overviewAvailability(model, appliedFilters);
overviewManagement(model, appliedFilters);
overviewSources(model, appliedFilters);
return "/accession/overview";
}
private void overviewInstitutes(ModelMap model, AppliedFilters appliedFilters) throws SearchException {
model.addAttribute("statsInstCode", elasticService.termStatistics(appliedFilters, FilterConstants.INSTCODE, 10));
model.addAttribute("statsInstCountry", elasticService.termStatistics(appliedFilters, FilterConstants.INSTITUTE_COUNTRY_ISO3, 10));
}
private void overviewSources(ModelMap model, AppliedFilters appliedFilters) throws SearchException {
model.addAttribute("statsOrgCty", elasticService.termStatistics(appliedFilters, FilterConstants.ORGCTY_ISO3, 10));
model.addAttribute("statsDonorCode", elasticService.termStatistics(appliedFilters, FilterConstants.DONORCODE, 10));
}
private void overviewAvailability(ModelMap model, AppliedFilters appliedFilters) throws SearchException {
model.addAttribute("statsMLS", elasticService.termStatistics(appliedFilters, FilterConstants.MLSSTATUS, 2));
model.addAttribute("statsAvailable", elasticService.termStatistics(appliedFilters, FilterConstants.AVAILABLE, 2));
}
private void overviewManagement(ModelMap model, AppliedFilters appliedFilters) throws SearchException {
model.addAttribute("statsStorage", elasticService.termStatistics(appliedFilters, FilterConstants.STORAGE, 10));
model.addAttribute("statsDuplSite", elasticService.termStatistics(appliedFilters, FilterConstants.DUPLSITE, 10));
}
private void overviewComposition(ModelMap model, AppliedFilters appliedFilters) throws SearchException {
model.addAttribute("statsGenus", elasticService.termStatistics(appliedFilters, FilterConstants.TAXONOMY_GENUS, 10));
model.addAttribute("statsSpecies", elasticService.termStatistics(appliedFilters, FilterConstants.TAXONOMY_SPECIES, 10));
model.addAttribute("statsCrops", elasticService.termStatistics(appliedFilters, FilterConstants.CROPS, 10));
model.addAttribute("statsSampStat", elasticService.termStatistics(appliedFilters, FilterConstants.SAMPSTAT, 10));
}
}
......@@ -18,7 +18,9 @@ package org.genesys2.server.servlet.controller;
import org.genesys2.server.exception.UserException;
import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.model.impl.User;
import org.genesys2.server.service.CropService;
import org.genesys2.server.service.GeoService;
import org.genesys2.server.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -30,6 +32,8 @@ public class JspHelper {
private UserService userService;
@Autowired
private GeoService geoService;
@Autowired
private CropService cropService;
public String userFullName(Long userId) {
if (userId == null) {
......@@ -53,4 +57,8 @@ public class JspHelper {
public Country getCountry(String iso3) {
return geoService.getCountry(iso3);
}
public Crop getCrop(String shortName) {
return cropService.getCrop(shortName);
}
}
......@@ -336,6 +336,7 @@ filter.alias=Accession name
filter.crops=Crop name
filter.orgCty.iso3=Country of Origin
filter.institute.code=Holding Institute name
filter.institute.country.iso3=Country of holding institute
filter.sampStat=Biological status of accession
filter.institute.code=Holding Institute
filter.geo.latitude=Latitude
......@@ -348,6 +349,8 @@ filter.taxonomy.sciName=Scientific name
filter.sgsv=Safety duplicated in Svalbard
filter.mlsStatus=MLS status of the accession
filter.available=Available for distribution
filter.donorCode=Donor institute
filter.duplSite=Site of safety duplication
filter.download-dwca=Download ZIP
filter.add=Add filter
filter.additional=Additional filters
......@@ -534,3 +537,14 @@ session.expiry-warning=Your current session is about to expire. Do you wish to e
session.expiry-extend=Extend session
download.kml=Download KML
data-overview=Statistical overview
data-overview.short=Overview
data-overview.institutes=Holding institutes
data-overview.composition=Composition of genebank holdings
data-overview.sources=Sources of material
data-overview.management=Collection management
data-overview.availability=Availability of material
data-overview.otherCount=Other
data-overview.missingCount=Not provided
data-overview.totalCount=Total
......@@ -37,6 +37,7 @@
<button class="btn btn-default" type="submit"><spring:message code="filter.download-dwca" /></button>
</form>
</c:if>
<a class="btn btn-default" href="<c:url value="/explore/overview"><c:param name="filter">${jsonFilter}</c:param></c:url>"><span class="glyphicon glyphicon-eye-open"></span><span style="margin-left: 0.5em;"><spring:message code="data-overview.short" /></span></a>
<a class="btn btn-default" href="<c:url value="/explore/map"><c:param name="filter">${jsonFilter}</c:param></c:url>"><span class="glyphicon glyphicon-globe"></span><span style="margin-left: 0.5em;"><spring:message code="maps.view-map" /></span></a>
</div>
</div>
......
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<title><spring:message code="data-overview" /></title>
</head>
<body>
<h1>
<spring:message code="data-overview" />
</h1>
<div class="main-col-header clearfix">
<div class="nav-header">
<div class="results">
<a href="javascript: window.history.go(-1);"><spring:message code="navigate.back" /></a>
</div>
</div>
</div>
<h3><spring:message code="data-overview.institutes" /></h3>
<div class="row row-section">
<div class="col-xs-12 col-sm-6">
<h4 id="stats-instcode"><spring:message code="filter.institute.code" /></h4>
<c:set var="type" value="instCode" />
<c:set var="termResult" value="${statsInstCode}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<div class="col-xs-12 col-sm-6">
<h4 id="stats-instcty"><spring:message code="filter.institute.country.iso3" /></h4>
<c:set var="type" value="country" />
<c:set var="termResult" value="${statsInstCountry}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
</div>
<h3><spring:message code="data-overview.composition" /></h3>
<div class="row row-section">
<div class="col-xs-12 col-sm-6">
<h4 id="stats-crops"><spring:message code="filter.crops" /></h4>
<c:set var="type" value="crop" />
<c:set var="termResult" value="${statsCrops}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<div class="col-xs-12 col-sm-6">
<h4 id="stats-sampstat"><spring:message code="filter.sampStat" /></h4>
<c:set var="type" value="i18n.accession.sampleStatus" />
<c:set var="termResult" value="${statsSampStat}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
</div>
<div class="row row-section">
<div class="col-xs-12 col-sm-6">
<h4 id="stats-genus"><spring:message code="filter.taxonomy.genus" /></h4>
<c:set var="termResult" value="${statsGenus}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
</div>
<div class="col-xs-12 col-sm-6">
<h4 id="stats-species"><spring:message code="filter.taxonomy.species" /></h4>
<c:set var="termResult" value="${statsSpecies}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
</div>
</div>
<h3><spring:message code="data-overview.sources" /></h3>
<div class="row row-section">
<div class="col-xs-12 col-sm-6">
<h4 id="stats-orgcty"><spring:message code="filter.orgCty.iso3" /></h4>
<c:set var="type" value="country" />
<c:set var="termResult" value="${statsOrgCty}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<div class="col-xs-12 col-sm-6">
<h4 id="stats-donorcode"><spring:message code="filter.donorCode" /></h4>
<c:set var="type" value="instCode" />
<c:set var="termResult" value="${statsDonorCode}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
</div>
<h3><spring:message code="data-overview.availability" /></h3>
<div class="row row-section">
<div class="col-xs-12 col-sm-6">
<h4 id="stats-sampstat"><spring:message code="filter.mlsStatus" /></h4>
<c:set var="type" value="bool" />
<c:set var="termResult" value="${statsMLS}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<div class="col-xs-12 col-sm-6">
<h4 id="stats-available"><spring:message code="filter.available" /></h4>
<c:set var="type" value="bool" />
<c:set var="termResult" value="${statsAvailable}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
</div>
<h3><spring:message code="data-overview.management" /></h3>
<div class="row row-section">
<div class="col-xs-12 col-sm-6">
<h4 id="stats-storage"><spring:message code="filter.storage" /></h4>
<c:set var="type" value="i18n.accession.storage" />
<c:set var="termResult" value="${statsStorage}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<div class="col-xs-12 col-sm-6">
<h4 id="stats-duplsite"><spring:message code="filter.duplSite" /></h4>
<c:set var="type" value="instCode" />
<c:set var="termResult" value="${statsDuplSite}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
</div>
<content tag="javascript">
<script type="text/javascript">
</script>
</content>
</body>
</html>
\ No newline at end of file
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<table class="accession">
<c:forEach items="${termResult.terms}" var="term">
<tr><td>
<c:choose>
<c:when test="${type=='country'}">
<a href="<c:url value="/geo/${term.term.toUpperCase()}" />"><c:out value="${jspHelper.getCountry(term.term).getName(pageContext.request.locale)}" /></a>
</c:when>
<c:when test="${type=='crop'}">
<c:out value="${jspHelper.getCrop(term.term).getName(pageContext.request.locale)}" />
</c:when>
<c:when test="${type=='instCode'}">
<a href="<c:url value="/wiews/${term.term.toUpperCase()}" />"><c:out value="${term.term.toUpperCase()}" /></a>
</c:when>
<c:when test="${type=='bool' and term.term=='T'}">
<spring:message code="boolean.true" />
</c:when>
<c:when test="${type=='bool' and term.term=='F'}">
<spring:message code="boolean.false" />
</c:when>
<c:when test="${type ne null && type.startsWith('i18n')}">
<spring:message code="${type.substring(5).concat('.').concat(term.term)}" />
</c:when>
<c:otherwise>${term.term}</c:otherwise>
</c:choose>
</td><td class="text-right"><fmt:formatNumber value="${term.count}" /> <span class="terms-percent"><fmt:formatNumber pattern="#,##0.00%" value="${term.count/(termResult.totalCount+termResult.missingCount)}" /></span></td></tr>
</c:forEach>
<c:if test="${termResult.otherCount gt 0}">
<tr><td><em><spring:message code="data-overview.otherCount" /></em></td><td class="text-right"><fmt:formatNumber value="${termResult.otherCount}" /> <span class="terms-percent"><fmt:formatNumber pattern="#,##0.00%" value="${termResult.otherCount/(termResult.totalCount+termResult.missingCount)}" /></span></td></tr>
</c:if>
<c:if test="${termResult.missingCount gt 0}">
<tr><td><em><spring:message code="data-overview.missingCount" /></em></td><td class="text-right"><fmt:formatNumber value="${termResult.missingCount}" /> <span class="terms-percent"><fmt:formatNumber pattern="#,##0.00%" value="${termResult.missingCount/(termResult.totalCount+termResult.missingCount)}" /></span></td></tr>
</c:if>
<%-- <tr><td><spring:message code="data-overview.totalCount" /></td><td class="text-right">!<fmt:formatNumber value="${termResult.totalCount+termResult.missingCount}" /></td></tr> --%>
</table>
\ No newline at end of file
......@@ -1961,4 +1961,26 @@ html[dir="rtl"] ul.statistics .stats-number {
.chart.chart-pie {
padding: 10px;
}
\ No newline at end of file
}
.terms-percent {
min-width: 60px;
display: inline-block;
}
html[dir="rtl"] .text-right {
text-align: left;
}
html[dir="rtl"] .text-left {
text-align: right;
}
.row {
margin-left: -10px;
margin-right: -10px;
}
.row-section {
margin-bottom: 2em;
}
......@@ -154,8 +154,6 @@
.container {padding-left:0; padding-right:0;}
.row {margin:0;}
#middle-col {border-top:10px solid #e7e5df;}
#nav-main.navbar {border-bottom:none; margin:0;}
......
......@@ -20,7 +20,6 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.log4j.Logger;
......
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