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

Optional INSTCODE in "add many"

parent e0752d2b
...@@ -201,6 +201,12 @@ public interface GenesysService { ...@@ -201,6 +201,12 @@ public interface GenesysService {
*/ */
Accession getAccession(String instCode, String acceNumb) throws NonUniqueAccessionException; Accession getAccession(String instCode, String acceNumb) throws NonUniqueAccessionException;
/**
* @param acceNumb
* @return list of accessions
*/
List<Accession> listAccessions(String acceNumb);
List<FaoInstitute> findHoldingInstitutes(Set<Long> accessionIds); List<FaoInstitute> findHoldingInstitutes(Set<Long> accessionIds);
Set<Long> listAccessions(FaoInstitute holdingInstitute, Set<Long> accessionIds); Set<Long> listAccessions(FaoInstitute holdingInstitute, Set<Long> accessionIds);
......
...@@ -318,6 +318,18 @@ public class GenesysServiceImpl implements GenesysService, DatasetService { ...@@ -318,6 +318,18 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
} }
} }
/**
* {@inheritDoc}
*/
@Override
public List<Accession> listAccessions(final String acceNumb) {
List<Accession> accessions = new ArrayList<>();
for (final Accession accession : accessionRepository.findByAccessionName(acceNumb)) {
accessions.add(lazyLoadAccession(accession));
}
return accessions;
}
@Override @Override
public Accession getAccession(String instCode, String doi, String acceNumb, String genus) throws NonUniqueAccessionException { public Accession getAccession(String instCode, String doi, String acceNumb, String genus) throws NonUniqueAccessionException {
try { try {
......
...@@ -146,25 +146,23 @@ public class SelectionController extends BaseController { ...@@ -146,25 +146,23 @@ public class SelectionController extends BaseController {
public String add(ModelMap model, RedirectAttributes redirectAttrs, @RequestParam(required = true, value = "instCode") String instCode, public String add(ModelMap model, RedirectAttributes redirectAttrs, @RequestParam(required = true, value = "instCode") String instCode,
@RequestParam(required = true, value = "accessionIds") String accessionIds) { @RequestParam(required = true, value = "accessionIds") String accessionIds) {
if (StringUtils.isBlank(instCode)) { final String[] splits = accessionIds.split("[,;\\t\\n]+");
return "redirect:/sel/"; for (final String s : splits) {
} if (!StringUtils.isBlank(instCode)) {
try {
final String[] splits = accessionIds.split("[,;\\t\\n]+"); final Accession accession = genesysService.getAccession(instCode, s.trim());
for (final String s : splits) { if (accession != null) {
// System.err.println(">> '" + s.trim() + "'"); selectionBean.add(accession.getId());
try { }
final Accession accession = genesysService.getAccession(instCode, s.trim()); } catch (NonUniqueAccessionException e) {
if (accession != null) { // Non-unique
// System.err.println("\t" + accession.getId()); }
selectionBean.add(accession.getId()); } else {
} else { for (final Accession accession : genesysService.listAccessions(s.trim())) {
// System.err.println("\t NF='" + s + "'"); selectionBean.add(accession.getId());
} }
} catch (NonUniqueAccessionException e) { }
// Non-unique }
}
}
return "redirect:/sel/"; return "redirect:/sel/";
} }
......
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