Search in sources :

Example 1 with DiseaseTrait

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";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) DiseaseTrait(uk.ac.ebi.spot.goci.model.DiseaseTrait) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with DiseaseTrait

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);
}
Also used : MultipartFile(org.springframework.web.multipart.MultipartFile) ResponseEntity(org.springframework.http.ResponseEntity) DiseaseTrait(uk.ac.ebi.spot.goci.model.DiseaseTrait) FileValidationException(uk.ac.ebi.spot.goci.curation.exception.FileValidationException)

Example 3 with DiseaseTrait

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";
}
Also used : DiseaseTrait(uk.ac.ebi.spot.goci.model.DiseaseTrait) Sort(org.springframework.data.domain.Sort) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with DiseaseTrait

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());
}
Also used : DiseaseTrait(uk.ac.ebi.spot.goci.model.DiseaseTrait) ControllerLinkBuilder(org.springframework.hateoas.mvc.ControllerLinkBuilder)

Example 5 with DiseaseTrait

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());
}
Also used : DiseaseTrait(uk.ac.ebi.spot.goci.model.DiseaseTrait) ControllerLinkBuilder(org.springframework.hateoas.mvc.ControllerLinkBuilder)

Aggregations

DiseaseTrait (uk.ac.ebi.spot.goci.model.DiseaseTrait)22 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 PageRequest (org.springframework.data.domain.PageRequest)4 Pageable (org.springframework.data.domain.Pageable)4 Sort (org.springframework.data.domain.Sort)4 Study (uk.ac.ebi.spot.goci.model.Study)4 ControllerLinkBuilder (org.springframework.hateoas.mvc.ControllerLinkBuilder)2 ResponseEntity (org.springframework.http.ResponseEntity)2 DiseaseTraitDto (uk.ac.ebi.spot.goci.curation.dto.DiseaseTraitDto)2 CsvMapper (com.fasterxml.jackson.dataformat.csv.CsvMapper)1 CsvSchema (com.fasterxml.jackson.dataformat.csv.CsvSchema)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors (java.util.stream.Collectors)1 CosineDistance (org.apache.commons.text.similarity.CosineDistance)1 LevenshteinDistance (org.apache.commons.text.similarity.LevenshteinDistance)1