Commit 02eb36bf authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza

DOI as accession URL

parent 25b4d35a
......@@ -146,4 +146,6 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
@Query("select year(a.lastModifiedDate), month(a.lastModifiedDate), day(a.lastModifiedDate), count(a) from Accession a where a.institute = ?1 group by year(a.lastModifiedDate), month(a.lastModifiedDate), day(a.lastModifiedDate) order by year(a.lastModifiedDate) desc, month(a.lastModifiedDate) desc, day(a.lastModifiedDate) desc")
public List<Object[]> lastUpdatedStatistics(FaoInstitute faoInstitute);
public Accession findByDoi(String doi);
}
......@@ -77,6 +77,8 @@ public interface GenesysService {
Accession getAccession(long accessionId);
Accession getAccessionByDOI(String doi);
List<Accession> listAccessions(FaoInstitute faoInstitute, String accessionName);
AllAccnames listAccessionNames(AccessionId accession);
......
......@@ -336,6 +336,11 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
return accession;
}
@Override
public Accession getAccessionByDOI(final String doi) {
return accessionRepository.findByDoi(doi);
}
@Override
public AccessionDetails getAccessionDetails(long accessionId) {
AccessionData accession = getAccessionData(accessionId);
......
package org.genesys2.server.servlet.controller;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.service.GenesysService;
import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* @author Maxym Borodenko
*/
@Controller
public class DoiController extends BaseController {
@Autowired
private GenesysService genesysService;
@RequestMapping("/{firstPartDOI:10\\.[0-9]+}/{secondPartDOI:.+}")
public String view(@PathVariable String firstPartDOI, @PathVariable String secondPartDOI) {
final String doi = firstPartDOI + "/" + secondPartDOI;
_logger.info("Lookup accession by DOI");
Accession accession = genesysService.getAccessionByDOI(doi);
if (accession == null) {
throw new ResourceNotFoundException();
} else {
return "forward:/acn/id/" + accession.getId().toString();
}
}
}
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