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

View datasets by instCode

parent 34283223
......@@ -69,6 +69,7 @@ public interface GenesysService {
List<Metadata> listMetadata(Accession accession);
Page<Metadata> listMetadata(Pageable pageable);
Page<Metadata> listDatasets(FaoInstitute faoInstitute, Pageable pageable);
Metadata getMetadata(long metadataId);
......@@ -128,4 +129,5 @@ public interface GenesysService {
void refreshMetadataMethods();
}
......@@ -271,6 +271,11 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
return metadataRepository.findAll(pageable);
}
@Override
public Page<Metadata> listDatasets(FaoInstitute faoInstitute, Pageable pageable) {
return metadataRepository.findByInstituteCode(faoInstitute.getCode(), pageable);
}
@Override
public Metadata getMetadata(long metadataId) {
return metadataRepository.findOne(metadataId);
......@@ -708,7 +713,7 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
zos.finish();
}
@Override
@Transactional
@PreAuthorize("hasRole('ADMINISTRATOR')")
......
......@@ -85,7 +85,7 @@ public class WiewsController extends BaseController {
@RequestMapping("/{wiewsCode}")
public String view(ModelMap model, @PathVariable(value = "wiewsCode") String wiewsCode) {
_logger.debug("Viewing country " + wiewsCode);
_logger.debug("Viewing institute " + wiewsCode);
FaoInstitute faoInstitute = instituteService.getInstitute(wiewsCode);
if (faoInstitute == null) {
throw new ResourceNotFoundException();
......@@ -105,6 +105,19 @@ public class WiewsController extends BaseController {
return "/wiews/details";
}
@RequestMapping("/{wiewsCode}/datasets")
public String viewDatasets(ModelMap model, @PathVariable(value = "wiewsCode") String wiewsCode, @RequestParam(value = "page", defaultValue = "1") int page) {
_logger.debug("Viewing datasets for instCode=" + wiewsCode);
FaoInstitute faoInstitute = instituteService.getInstitute(wiewsCode);
if (faoInstitute == null) {
throw new ResourceNotFoundException();
}
model.addAttribute("faoInstitute", faoInstitute);
model.addAttribute("pagedData", genesysService.listDatasets(faoInstitute, new PageRequest(page - 1, 30)));
return "/metadata/index";
}
@PreAuthorize("hasRole('ADMINISTRATOR')")
@RequestMapping("/{wiewsCode}/edit")
public String edit(ModelMap model, @PathVariable(value = "wiewsCode") String wiewsCode) {
......
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