use of uk.ac.ebi.spot.goci.model.DiseaseTrait in project goci by EBISPOT.
the class DiseaseTraitController method viewDiseaseTraitToDelete.
// Delete a disease trait
@RequestMapping(value = "/{diseaseTraitId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewDiseaseTraitToDelete(Model model, @PathVariable Long diseaseTraitId) {
DiseaseTrait diseaseTraitToView = diseaseTraitRepository.findOne(diseaseTraitId);
Collection<Study> studiesLinkedToTrait = studyRepository.findByDiseaseTraitId(diseaseTraitId);
model.addAttribute("studies", studiesLinkedToTrait);
model.addAttribute("totalStudies", studiesLinkedToTrait.size());
model.addAttribute("diseaseTrait", diseaseTraitToView);
return "delete_disease_trait";
}
use of uk.ac.ebi.spot.goci.model.DiseaseTrait in project goci by EBISPOT.
the class DiseaseTraitUploadController method updloadDiseaseTraits.
@PostMapping("/uploads")
public Object updloadDiseaseTraits(@Valid FileUploadRequest fileUploadRequest, BindingResult result) {
if (result.hasErrors()) {
throw new FileValidationException(result);
}
MultipartFile multipartFile = fileUploadRequest.getMultipartFile();
List<DiseaseTrait> diseaseTraits = DiseaseTraitDtoAssembler.disassemble(multipartFile);
diseaseTraits = diseaseTraitService.createDiseaseTraits(diseaseTraits);
log.info("{} {} were created", diseaseTraits.size(), EntityType.DISEASE_TRAIT);
return new ResponseEntity<>(DiseaseTraitDtoAssembler.assemble(diseaseTraits), HttpStatus.CREATED);
}
use of uk.ac.ebi.spot.goci.model.DiseaseTrait in project goci by EBISPOT.
the class OldDiseaseTraitController method allDiseaseTraits.
// Return all disease traits
@RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String allDiseaseTraits(Model model) {
Sort sort = sortByTraitAsc();
List<DiseaseTrait> allDiseaseTraits = diseaseTraitRepository.findAll(sort);
model.addAttribute("diseaseTraits", allDiseaseTraits);
model.addAttribute("totaldiseaseTraits", allDiseaseTraits.size());
// Return an empty DiseaseTrait object so user can add a new one
model.addAttribute("diseaseTrait", new DiseaseTrait());
return "disease_traits";
}
use of uk.ac.ebi.spot.goci.model.DiseaseTrait in project goci by EBISPOT.
the class DiseaseTraitController method getDiseaseTraits.
@GetMapping(produces = MediaTypes.HAL_JSON_VALUE)
public Object getDiseaseTraits(PagedResourcesAssembler<DiseaseTrait> assembler, @SortDefault(sort = "trait", direction = Sort.Direction.DESC) @PageableDefault(size = 10, page = 0) Pageable pageable) {
Page<DiseaseTrait> pagedDiseaseTraits = diseaseTraitService.getDiseaseTraits(pageable);
final ControllerLinkBuilder linkBuilder = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(DiseaseTraitController.class).getDiseaseTraits(assembler, pageable));
return assembler.toResource(pagedDiseaseTraits, diseaseTraitDtoAssembler, linkBuilder.withSelfRel());
}
use of uk.ac.ebi.spot.goci.model.DiseaseTrait in project goci by EBISPOT.
the class DiseaseTraitController method searchDiseaseTraitsByParam.
@GetMapping(value = "/search", produces = MediaTypes.HAL_JSON_VALUE)
public Object searchDiseaseTraitsByParam(PagedResourcesAssembler<DiseaseTrait> assembler, @RequestParam String query, Pageable pageable) {
Page<DiseaseTrait> pagedDiseaseTraits = diseaseTraitService.searchByParameter(query, pageable);
final ControllerLinkBuilder linkBuilder = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(DiseaseTraitController.class).getDiseaseTraits(assembler, pageable));
return assembler.toResource(pagedDiseaseTraits, diseaseTraitDtoAssembler, linkBuilder.withSelfRel());
}
Aggregations