use of uk.ac.ebi.spot.goci.curation.dto.DiseaseTraitDto in project goci by EBISPOT.
the class DiseaseTraitDtoAssembler method toResource.
public Resource<DiseaseTraitDto> toResource(DiseaseTrait diseaseTrait) {
DiseaseTraitDto diseaseTraitDTO = DiseaseTraitDto.builder().id(diseaseTrait.getId()).trait(diseaseTrait.getTrait()).studies(diseaseTrait.getStudies().size()).build();
final ControllerLinkBuilder controllerLinkBuilder = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(DiseaseTraitController.class).getOneDiseaseTrait(diseaseTrait.getId()));
Resource<DiseaseTraitDto> resource = new Resource<>(diseaseTraitDTO);
resource.add(controllerLinkBuilder.withSelfRel());
return resource;
}
use of uk.ac.ebi.spot.goci.curation.dto.DiseaseTraitDto in project goci by EBISPOT.
the class DiseaseTraitDtoAssembler method assemble.
public static List<DiseaseTraitDto> assemble(List<DiseaseTrait> diseaseTraits) {
List<DiseaseTraitDto> diseaseTraitDTOS = new ArrayList<>();
diseaseTraits.forEach(diseaseTrait -> {
DiseaseTraitDto diseaseTraitDTO = DiseaseTraitDto.builder().id(diseaseTrait.getId()).trait(diseaseTrait.getTrait()).build();
diseaseTraitDTOS.add(diseaseTraitDTO);
});
return diseaseTraitDTOS;
}
use of uk.ac.ebi.spot.goci.curation.dto.DiseaseTraitDto in project goci by EBISPOT.
the class DiseaseTraitDtoAssembler method disassemble.
public static List<DiseaseTrait> disassemble(MultipartFile multipartFile) {
CsvMapper mapper = new CsvMapper();
CsvSchema schema = FileHandler.getSchemaFromMultiPartFile(multipartFile);
List<DiseaseTraitDto> diseaseTraitDtos;
try {
InputStream inputStream = multipartFile.getInputStream();
MappingIterator<DiseaseTraitDto> iterator = mapper.readerFor(DiseaseTraitDto.class).with(schema).readValues(inputStream);
diseaseTraitDtos = iterator.readAll();
} catch (IOException ex) {
throw new FileUploadException("Could not read the file");
}
List<DiseaseTrait> diseaseTraits = new ArrayList<>();
diseaseTraitDtos.forEach(diseaseTraitDTO -> {
DiseaseTrait diseaseTrait = new DiseaseTrait();
diseaseTrait.setTrait(diseaseTraitDTO.getTrait());
diseaseTraits.add(diseaseTrait);
});
return diseaseTraits;
}
Aggregations