Commit 33283ea3 authored by Matija Obreza's avatar Matija Obreza

Accession details

parent 5a77ee81
......@@ -61,4 +61,6 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
// List<Accession> findByOrigin(String origin);
Page<Accession> findByOrigin(String isoCode3, Pageable pageable);
List<Accession> findByInstituteAndAccessionName(FaoInstitute faoInstitute, String accessionName);
}
package org.crophub.rest.common.service;
import java.util.List;
import org.crophub.rest.common.model.genesys.Accession;
import org.crophub.rest.common.model.impl.Country;
import org.crophub.rest.common.model.impl.FaoInstitute;
......@@ -18,4 +20,8 @@ public interface GenesysService {
Page<Accession> listAccessionsByInstitute(FaoInstitute faoInstitute, Pageable pageable);
Accession getAccession(long accessionId);
List<Accession> listAccessions(FaoInstitute faoInstitute, String accessionName);
}
package org.crophub.rest.common.service.impl;
import java.util.List;
import org.crophub.rest.common.model.genesys.Accession;
import org.crophub.rest.common.model.impl.Country;
import org.crophub.rest.common.model.impl.FaoInstitute;
......@@ -50,4 +52,14 @@ public class GenesysServiceImpl implements GenesysService {
public Page<Accession> listAccessionsByInstitute(FaoInstitute faoInstitute, Pageable pageable) {
return accessionRepository.findByInstitute(faoInstitute, pageable);
}
@Override
public Accession getAccession(long accessionId) {
return accessionRepository.findOne(accessionId);
}
@Override
public List<Accession> listAccessions(FaoInstitute faoInstitute, String accessionName) {
return accessionRepository.findByInstituteAndAccessionName(faoInstitute, accessionName);
}
}
package org.crophub.rest.servlet.controller;
import java.util.List;
import org.crophub.rest.common.model.genesys.Accession;
import org.crophub.rest.common.model.impl.FaoInstitute;
import org.crophub.rest.common.service.GenesysService;
import org.crophub.rest.common.service.InstituteService;
import org.crophub.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/acn")
public class AccessionController extends BaseController {
@Autowired
private InstituteService instituteService;
@Autowired
private GenesysService genesysService;
@RequestMapping("/id/{accessionId}")
public String view(ModelMap model, @PathVariable(value = "accessionId") long accessionId) {
_logger.debug("Viewing ACN " + accessionId);
Accession accession=genesysService.getAccession(accessionId);
if (accession==null) {
throw new ResourceNotFoundException();
}
model.addAttribute("accession", accession);
return "/accession/details";
}
@RequestMapping("/{holdingInstitute}/{accessionName}")
public String viewInstituteAccession(ModelMap model, @PathVariable(value = "holdingInstitute") String holdingInstitute, @PathVariable(value = "accessionName") String accessionName) {
_logger.debug("Viewing ACN " + accessionName);
FaoInstitute faoInstitute = instituteService.getInstitute(holdingInstitute);
if (faoInstitute==null) {
throw new ResourceNotFoundException();
}
List<Accession> accessions=genesysService.listAccessions(faoInstitute, accessionName);
if (accessions.size()==0) {
throw new ResourceNotFoundException();
}
if (accessions.size()==1) {
return "redirect:/acn/id/" + accessions.get(0).getId();
}
model.addAttribute("faoInstitute", faoInstitute);
model.addAttribute("accessions", accessions);
return "/accession/resolve";
}
}
......@@ -108,6 +108,12 @@ accession.holdingInstitute=Holding institute
accession.holdingCountry=Location
accession.taxonomy=Taxonomy
accession.page.profile.title=Accession profile: {0}
accession.page.resolve.title=Multiple accessions found
accession.resolve=Multiple accessions with the name ''{0}'' found in Genesys. Select one from the list.
taxonomy.genus=Genus
taxonomy.species=Species
taxonomy.taxonName=Taxonomy
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<title><spring:message code="accession.page.profile.title" arguments="${accession.accessionName}" argumentSeparator="|" /></title>
</head>
<body>
<h1>
<c:out value="${accession.accessionName}" />
<small><c:out value="${accession.instituteCode}" /></small>
</h1>
<table>
<tbody>
<tr>
<td><spring:message code="accession.holdingInstitute" /></td>
<td><c:out value="${accession.institute.fullName}" /></td>
</tr>
<tr>
<td><spring:message code="accession.holdingCountry" /></td>
<td><c:out value="${accession.institute.country.name}" /></td>
</tr>
<tr>
<td><spring:message code="accession.accessionName" /></td>
<td><c:out value="${accession.accessionName}" /></td>
</tr>
<tr>
<td><spring:message code="accession.origin" /></td>
<td><c:out value="${accession.origin}" /></td>
</tr>
<tr>
<td><spring:message code="taxonomy.genus" /></td>
<td><c:out value="${accession.taxonomy.genus}" /></td>
</tr>
<tr>
<td><spring:message code="taxonomy.species" /></td>
<td><c:out value="${accession.taxonomy.species}" /></td>
</tr>
<tr>
<td><spring:message code="taxonomy.taxonName" /></td>
<td><c:out value="${accession.taxonomy.taxonName}" /></td>
</tr>
<tr>
</tbody>
</table>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<title><spring:message code="accession.page.resolve.title" /></title>
</head>
<body>
<h1><spring:message code="accession.resolve" arguments="${accessionName}" /></h1>
<table>
<thead>
<tr>
<td><spring:message code="accession.accessionName" /></td>
<td><spring:message code="accession.origin" /></td>
<td><spring:message code="accession.taxonomy" /></td>
<td><spring:message code="accession.holdingInstitute" /></td>
<td><spring:message code="accession.holdingCountry" /></td>
</tr>
</thead>
<tbody>
<c:forEach items="${accessions}" var="accession" varStatus="status">
<tr>
<td><a href="<c:url value="/acn/id/${accession.id}" />"><b><c:out value="${accession.accessionName}" /></b></a></td>
<td><c:out value="${country.name}" /></td>
<td><c:out value="${accession.taxonomy.taxonName}" /></td>
<td><a href="<c:url value="/wiews/${accession.institute.code.toLowerCase()}" />"><c:out value="${accession.institute.code}" /></a></td>
<td><a href="<c:url value="/geo/${accession.institute.country.code3.toLowerCase()}" />"><c:out value="${accession.institute.country.name}" /></a></td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
\ No newline at end of file
......@@ -39,7 +39,7 @@
<td><a href="<c:url value="/acn/id/${accession.id}" />"><b><c:out value="${accession.accessionName}" /></b></a></td>
<td><a href="<c:url value="/geo/${accession.origin.toLowerCase()}" />"><c:out value="${accession.origin}" /></a></td>
<td><c:out value="${accession.taxonomy.taxonName}" /></td>
<td><a href="<c:url value="/wiews/${accession.institute.code.toLowerCase()}" />"><c:out value="${accession.institute.code}" /></a></td>
<td><a href="<c:url value="/wiews/${faoInstitute.code.toLowerCase()}" />"><c:out value="${faoInstitute.code}" /></a></td>
<td><a href="<c:url value="/geo/${accession.institute.country.code3.toLowerCase()}" />"><c:out value="${accession.institute.country.name}" /></a></td>
</tr>
</c:forEach>
......
......@@ -15,7 +15,9 @@
<ul>
<c:forEach items="${faoInstitutes.content}" var="faoInstitute" varStatus="status">
<li><a href="<c:url value="/wiews/${faoInstitute.code.toLowerCase()}" />"><b><c:out value="${faoInstitute.code}" /></b> <c:out value="${faoInstitute.fullName}" /></a></li>
<li><a href="<c:url value="/wiews/${faoInstitute.code.toLowerCase()}" />"><b><c:out value="${faoInstitute.code}" /></b> <c:out value="${faoInstitute.fullName}" /></a>
<spring:message code="faoInstitute.accessionCount" arguments="${faoInstitute.accessionCount}" />
</li>
</c:forEach>
</ul>
......
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