Commit 28fe3c70 authored by Matija Obreza's avatar Matija Obreza

Use AccessionDetails for list of selected accessions

parent 99b516ba
......@@ -275,4 +275,6 @@ public interface GenesysService {
List<Object[]> getLastUpdatedStatistics(FaoInstitute faoInstitute);
Page<AccessionDetails> listAccessionsDetails(Collection<Long> accessionIds, Pageable page);
}
......@@ -281,6 +281,16 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
return accessionRepository.findById(accessionIds, pageable);
}
@Override
public Page<AccessionDetails> listAccessionsDetails(Collection<Long> accessionIds, Pageable pageable) {
if (! accessionIds.isEmpty()) {
Page<Accession> data = accessionRepository.findById(accessionIds, pageable);
return new PageImpl<AccessionDetails>(getAccessionDetails(data.getContent().stream().map(a -> a.getId()).collect(Collectors.toList())), pageable, data.getTotalElements());
} else {
return new PageImpl<AccessionDetails>(new ArrayList<AccessionDetails>(), pageable, 0);
}
}
@Override
public Accession getAccession(AccessionIdentifier3 aid3) throws NonUniqueAccessionException {
try {
......@@ -407,7 +417,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public AccessionBreeding listAccessionBreeding(AccessionId accession) {
if (accession == null || ! accession.isPersisted()) {
if (accession == null || !accession.isPersisted()) {
return null;
}
return accessionBreedingRepository.findByAccession(accession);
......@@ -415,7 +425,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public AccessionGeo listAccessionGeo(AccessionId accession) {
if (accession == null || ! accession.isPersisted()) {
if (accession == null || !accession.isPersisted()) {
return null;
}
return accessionGeoRepository.findByAccession(accession);
......@@ -439,7 +449,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public AccessionCollect listAccessionCollect(AccessionId accession) {
if (accession == null || ! accession.isPersisted()) {
if (accession == null || !accession.isPersisted()) {
return null;
}
return accessionCollectRepository.findByAccession(accession);
......@@ -447,7 +457,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public AccessionExchange listAccessionExchange(AccessionId accession) {
if (accession == null || ! accession.isPersisted()) {
if (accession == null || !accession.isPersisted()) {
return null;
}
return accessionExchangeRepository.findByAccession(accession);
......@@ -455,7 +465,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public List<AccessionRemark> listAccessionRemarks(AccessionId accession) {
if (accession == null || ! accession.isPersisted()) {
if (accession == null || !accession.isPersisted()) {
return null;
}
return accessionRemarkRepository.findByAccession(accession);
......@@ -637,7 +647,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
}
private AccessionData getAccessionData(AccessionId accessionId) {
if (accessionId == null || ! accessionId.isPersisted())
if (accessionId == null || !accessionId.isPersisted())
return null;
return getAccessionData(accessionId.getId());
}
......
......@@ -82,7 +82,7 @@ public class SelectionController extends BaseController {
@RequestMapping(value = "/")
public String view(ModelMap model, @RequestParam(value = "page", required = false, defaultValue = "1") int page) {
model.addAttribute("pagedData", genesysService.listAccessions(selectionBean.copy(), new PageRequest(page - 1, 50, new Sort("accessionName"))));
model.addAttribute("pagedData", genesysService.listAccessionsDetails(selectionBean.copy(), new PageRequest(page - 1, 50, new Sort("accessionName"))));
model.addAttribute("selection", selectionBean);
// Add userAccessionLists when authenticated
......
......@@ -80,8 +80,8 @@
<td class="idx-col"><p><c:out value="${status.count + pagedData.size * pagedData.number}" /></p></td>
<td class="sel ${selection.containsId(accession.id) ? 'picked' : ''}" x-aid="${accession.id}"></td>
<td><p><local:accession-details-link accession="${accession}" /></p></td>
<td><p><c:out value="${accession.taxonomy.taxonName}" /></p></td>
<td class="notimportant"><p><c:out value="${accession.countryOfOrigin.getName(pageContext.response.locale)}" /></p></td>
<td><p><c:out value="${accession.taxonomy.sciName}" /></p></td>
<td class="notimportant"><p><c:out value="${jspHelper.getCountry(accession.orgCty.iso3).getName(pageContext.response.locale)}" /></p></td>
<td class="notimportant"><p><a href="<c:url value="/wiews/${accession.institute.code}" />"><c:out value="${accession.institute.code}" /></a></p></td>
<%--<td class="notimportant"><a href="<c:url value="/geo/${accession.institute.country.code3}" />"><c:out value="${accession.institute.country.getName(pageContext.response.locale)}" /></a></td>--%>
</tr>
......@@ -100,11 +100,11 @@
</tr>
<tr>
<td><p><spring:message code="accession.taxonomy" /></p></td>
<td><p><c:out value="${accession.taxonomy.taxonName}" /></p></td>
<td><p><c:out value="${accession.taxonomy.sciName}" /></p></td>
</tr>
<tr>
<td class="notimportant"><p><spring:message code="accession.origin" /></p></td>
<td class="notimportant"><p><c:out value="${accession.countryOfOrigin.getName(pageContext.response.locale)}" /></p></td>
<td class="notimportant"><p><c:out value="${jspHelper.getCountry(accession.orgCty.iso3).getName(pageContext.response.locale)}" /></p></td>
</tr>
<tr>
<td class="notimportant"><p><spring:message code="accession.holdingInstitute" /></p></td>
......
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