Commit 7c325d1a authored by Matija Obreza's avatar Matija Obreza

Country and Institute overviews

parent 889e36af
...@@ -16,8 +16,12 @@ ...@@ -16,8 +16,12 @@
package org.genesys2.server.servlet.controller; package org.genesys2.server.servlet.controller;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.genesys2.server.model.impl.Country; import org.genesys2.server.model.impl.Country;
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;
...@@ -25,6 +29,9 @@ import org.genesys2.server.service.FilterConstants; ...@@ -25,6 +29,9 @@ 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;
import org.genesys2.server.service.InstituteService; import org.genesys2.server.service.InstituteService;
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.spring.ResourceNotFoundException; import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -130,4 +137,19 @@ public class CountryController extends BaseController { ...@@ -130,4 +137,19 @@ public class CountryController extends BaseController {
return "redirect:/explore"; return "redirect:/explore";
} }
@RequestMapping("/{country}/overview")
public String viewData(HttpServletRequest request, @PathVariable(value = "country") String countryStr) throws UnsupportedEncodingException {
_logger.debug("Viewing country " + countryStr);
final Country country = geoService.getCountry(countryStr);
if (country == null) {
throw new ResourceNotFoundException();
}
AppliedFilters appliedFilters=new AppliedFilters();
appliedFilters.add(new AppliedFilter().setFilterName(FilterConstants.ORGCTY_ISO3).addFilterValue(new FilterHandler.LiteralValueFilter(country.getCode3())));
return "forward:/explore/overview?filter=" + URLEncoder.encode(appliedFilters.toString(), "UTF8");
}
} }
...@@ -452,7 +452,7 @@ public class ExplorerController extends BaseController { ...@@ -452,7 +452,7 @@ public class ExplorerController extends BaseController {
// JSP works with JsonObject // JSP works with JsonObject
final Map<String, List<String>> filters = mapper.readValue(appliedFilters.toString(), Map.class); final Map<String, List<String>> filters = mapper.readValue(appliedFilters.toString(), Map.class);
model.addAttribute("filters", filters); model.addAttribute("filters", filters);
model.addAttribute("jsonFilter", appliedFilters.toString());
// Composition overview // Composition overview
overviewInstitutes(model, appliedFilters); overviewInstitutes(model, appliedFilters);
......
...@@ -18,10 +18,13 @@ package org.genesys2.server.servlet.controller; ...@@ -18,10 +18,13 @@ package org.genesys2.server.servlet.controller;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.genesys2.server.model.genesys.Taxonomy2; import org.genesys2.server.model.genesys.Taxonomy2;
...@@ -199,6 +202,21 @@ public class WiewsController extends BaseController { ...@@ -199,6 +202,21 @@ public class WiewsController extends BaseController {
model.addAttribute("page", page); model.addAttribute("page", page);
return "redirect:/explore"; return "redirect:/explore";
} }
@RequestMapping("/{wiewsCode}/overview")
public String viewData(HttpServletRequest request, @PathVariable(value = "wiewsCode") String wiewsCode) throws UnsupportedEncodingException {
_logger.debug("Viewing institute overview " + wiewsCode);
final FaoInstitute faoInstitute = instituteService.getInstitute(wiewsCode);
if (faoInstitute == null) {
throw new ResourceNotFoundException();
}
AppliedFilters appliedFilters=new AppliedFilters();
appliedFilters.add(new AppliedFilter().setFilterName(FilterConstants.INSTCODE).addFilterValue(new FilterHandler.LiteralValueFilter(faoInstitute.getCode())));
return "forward:/explore/overview?filter=" + URLEncoder.encode(appliedFilters.toString(), "UTF8");
}
@RequestMapping("/{wiewsCode}/t/{genus}") @RequestMapping("/{wiewsCode}/t/{genus}")
public String viewDataByGenusSpecies(ModelMap model, @PathVariable(value = "wiewsCode") String wiewsCode, @PathVariable(value = "genus") String genus, public String viewDataByGenusSpecies(ModelMap model, @PathVariable(value = "wiewsCode") String wiewsCode, @PathVariable(value = "genus") String genus,
......
...@@ -165,8 +165,8 @@ faoInstitute.requests.mailto=Email address for material requests: ...@@ -165,8 +165,8 @@ faoInstitute.requests.mailto=Email address for material requests:
faoInstitute.allow.requests=Allow material requests faoInstitute.allow.requests=Allow material requests
faoInstitute.sgsv=Code SGSV faoInstitute.sgsv=Code SGSV
view.accessions=View accessions... view.accessions=Browse accessions
view.datasets=View datasets... view.datasets=View datasets
paged.pageOfPages=Page {0} of {1} paged.pageOfPages=Page {0} of {1}
paged.totalElements={0} entries paged.totalElements={0} entries
...@@ -525,7 +525,7 @@ stats.number-of-countries={0} Countries ...@@ -525,7 +525,7 @@ stats.number-of-countries={0} Countries
stats.number-of-institutes={0} Institutes stats.number-of-institutes={0} Institutes
stats.number-of-accessions={0} Accessions stats.number-of-accessions={0} Accessions
navigate.back=Back navigate.back=\u21E0 Back
content.page.list.title=Article list content.page.list.title=Article list
...@@ -546,5 +546,5 @@ data-overview.sources=Sources of material ...@@ -546,5 +546,5 @@ data-overview.sources=Sources of material
data-overview.management=Collection management data-overview.management=Collection management
data-overview.availability=Availability of material data-overview.availability=Availability of material
data-overview.otherCount=Other data-overview.otherCount=Other
data-overview.missingCount=Not provided data-overview.missingCount=Not specified
data-overview.totalCount=Total data-overview.totalCount=Total
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</form> </form>
</div> </div>
<div class="results"> <div class="results">
<a href="javascript: window.history.go(-1);"><spring:message code="navigate.back" /></a> <a class="btn btn-default" href="javascript: window.history.go(-1);"><spring:message code="navigate.back" /></a>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -12,9 +12,13 @@ ...@@ -12,9 +12,13 @@
</h1> </h1>
<div class="main-col-header clearfix"> <div class="main-col-header clearfix">
<div class="nav-header"> <div class="row">
<div class="results"> <div class="col-xs-9 pull-right text-right">
<a href="javascript: window.history.go(-1);"><spring:message code="navigate.back" /></a> <a class="btn btn-default" href="<c:url value="/explore"><c:param name="filter" value="${jsonFilter}" /></c:url>"><span class="glyphicon glyphicon-eye-open"></span><span style="margin-left: 0.5em;"><spring:message code="view.accessions" /></span></a>
<a class="btn btn-default" href="<c:url value="/explore/map"><c:param name="filter" value="${jsonFilter}" /></c:url>"><span class="glyphicon glyphicon-globe"></span><span style="margin-left: 0.5em;"><spring:message code="maps.view-map" /></span></a>
</div>
<div class="col-xs-3 results">
<a class="btn btn-default" href="javascript: window.history.go(-1);"><spring:message code="navigate.back" /></a>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
<spring:message code="country.stat.countByOrigin" arguments="${countByOrigin}" /> <spring:message code="country.stat.countByOrigin" arguments="${countByOrigin}" />
<c:if test="${countByOrigin gt 0}"> <c:if test="${countByOrigin gt 0}">
<a href="<c:url value="/geo/${country.code3}/data" />"><spring:message code="view.accessions" /></a> <a href="<c:url value="/geo/${country.code3}/data" />"><spring:message code="view.accessions" /></a>
<a href="<c:url value="/geo/${country.code3}/overview" />"><spring:message code="data-overview.short" /></a>
</c:if> </c:if>
</div> </div>
......
...@@ -30,7 +30,9 @@ ...@@ -30,7 +30,9 @@
<spring:message code="faoInstitutes.stat.accessionCount" arguments="${countByInstitute}" /> <spring:message code="faoInstitutes.stat.accessionCount" arguments="${countByInstitute}" />
<c:if test="${countByInstitute gt 0}"> <c:if test="${countByInstitute gt 0}">
<a href="<c:url value="/wiews/${faoInstitute.code}/data" />"><spring:message code="view.accessions" /></a> <a href="<c:url value="/wiews/${faoInstitute.code}/data" />"><spring:message code="view.accessions" /></a>
<a href="<c:url value="/wiews/${faoInstitute.code}/overview" />"><spring:message code="data-overview.short" /></a>
</c:if> </c:if>
<br />
<spring:message code="faoInstitutes.stat.datasetCount" arguments="${datasetCount}" /> <spring:message code="faoInstitutes.stat.datasetCount" arguments="${datasetCount}" />
<c:if test="${datasetCount gt 0}"> <c:if test="${datasetCount gt 0}">
<a href="<c:url value="/wiews/${faoInstitute.code}/datasets" />"><spring:message code="view.datasets" /></a> <a href="<c:url value="/wiews/${faoInstitute.code}/datasets" />"><spring:message code="view.datasets" /></a>
......
...@@ -2010,4 +2010,10 @@ html[dir="rtl"] .text-left { ...@@ -2010,4 +2010,10 @@ html[dir="rtl"] .text-left {
table.terms-table td { table.terms-table td {
padding: 4px 10px; padding: 4px 10px;
} }
\ No newline at end of file
.jumbotron {
padding-top: 24px;
padding-bottom: 24px;
line-height: 1.5;
}
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