Commit b188e6bd authored by Matija Obreza's avatar Matija Obreza
Browse files

Return JSON of accession details on request (content-negotiated response)

parent 611a9a90
......@@ -23,6 +23,7 @@ import java.util.UUID;
import org.genesys2.server.filerepository.model.ImageGallery;
import org.genesys2.server.filerepository.service.ImageGalleryService;
import org.genesys2.server.model.dataset.DS;
import org.genesys2.server.model.elastic.AccessionDetails;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.PDCI;
......@@ -41,11 +42,13 @@ import org.genesys2.server.service.impl.NonUniqueAccessionException;
import org.genesys2.server.service.impl.PDCICalculator;
import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/acn")
......@@ -73,15 +76,23 @@ public class AccessionController extends BaseController {
@Autowired
private StatisticsService statisticsService;
@Autowired
private InstituteFilesService instituteFilesService;
@Autowired
private ImageGalleryService imageGalleryService;
@RequestMapping("/id/{accessionId}")
@RequestMapping(value = "/id/{accessionId}", produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody AccessionDetails viewJson(ModelMap model, @PathVariable(value = "accessionId") long accessionId) {
AccessionDetails ad = genesysService.getAccessionDetails(accessionId);
if (ad == null) {
throw new ResourceNotFoundException();
}
return ad;
}
@RequestMapping(value = "/id/{accessionId}")
public String view(ModelMap model, @PathVariable(value = "accessionId") long accessionId) {
_logger.debug("Viewing ACN " + accessionId);
final Accession accession = genesysService.getAccession(accessionId);
......
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