use of uk.ac.ebi.spot.goci.model.DiseaseTrait in project goci by EBISPOT.
the class SolrIndexer method mapTraits.
Integer mapTraits() {
Sort sort = new Sort(new Sort.Order("trait"));
Pageable pager = new PageRequest(0, pageSize, sort);
Page<DiseaseTrait> diseaseTraitPage = diseaseTraitRepository.findAll(pager);
traitMapper.map(diseaseTraitPage.getContent());
while (diseaseTraitPage.hasNext()) {
if (maxPages != -1 && diseaseTraitPage.getNumber() >= maxPages - 1) {
break;
}
pager = pager.next();
diseaseTraitPage = diseaseTraitRepository.findAll(pager);
traitMapper.map(diseaseTraitPage.getContent());
if (sysOutLogging) {
System.out.print(".");
}
}
return (int) diseaseTraitPage.getTotalElements();
}
use of uk.ac.ebi.spot.goci.model.DiseaseTrait in project goci by EBISPOT.
the class StudyDataService method updateStudyDiseaseTraitByAccessionId.
public Study updateStudyDiseaseTraitByAccessionId(String trait, String accessionId) {
Study study = this.getStudyByAccessionId(accessionId).orElseThrow(() -> new ResourceNotFoundException("Study", accessionId));
DiseaseTrait diseaseTrait = Optional.ofNullable(diseaseTraitRepository.findByTraitIgnoreCase(trait)).orElseThrow(() -> new ResourceNotFoundException("Disease Trait", trait));
study.setDiseaseTrait(diseaseTrait);
studyRepository.save(study);
log.info("Study with accession Id: {} found and updated", accessionId);
return study;
}
use of uk.ac.ebi.spot.goci.model.DiseaseTrait in project goci by EBISPOT.
the class ViewController method masterdetailPage.
@GetMapping("/disease-traits")
public String masterdetailPage(Model model) {
List<Map<String, Object>> dataList = new ArrayList<>();
List<DiseaseTraitProjection> projections = diseaseTraitRepository.findAllOrOrderByStudiesLargest(new PageRequest(0, 30));
projections.forEach(x -> {
Map<String, Object> result = new HashMap<>();
result.put("trait", x.getTrait());
result.put("studies", x.getStudiesCount());
dataList.add(result);
});
List<Long> ids = new ArrayList<>();
AtomicInteger count = new AtomicInteger(1);
projections.forEach(projection -> {
if (count.get() <= 4) {
ids.add(projection.getId());
count.getAndIncrement();
}
});
List<DiseaseTrait> diseaseTraits = diseaseTraitRepository.findAllByIdIsIn(ids);
List<Object> parents = new ArrayList<>();
diseaseTraits.forEach(diseaseTrait -> {
String trait = diseaseTrait.getTrait();
List<Map<String, Object>> children = new ArrayList<>();
diseaseTrait.getStudies().forEach(study -> {
Map<String, Object> child = new HashMap<>();
child.put("name", study.getPublicationId().getPubmedId());
child.put(VALUE, 40);
children.add(child);
});
Map<String, Object> parent = new LinkedHashMap<>();
parent.put("name", trait + " (" + children.size() + ")");
parent.put(VALUE, 102);
parent.put("children", children);
parents.add(parent);
});
List<Object> parents2 = new ArrayList<>();
Map<String, Object> parenta = new LinkedHashMap<>();
parenta.put("name", "core");
parenta.put(VALUE, "10");
parenta.put("children", parents);
parents2.add(parenta);
model.addAttribute("dataList", dataList);
model.addAttribute("mapData", parents2);
return "disease-traits";
}
use of uk.ac.ebi.spot.goci.model.DiseaseTrait in project goci by EBISPOT.
the class DiseaseTraitDtoAssembler method disassemble.
public static DiseaseTrait disassemble(DiseaseTraitDto diseaseTraitDTO) {
DiseaseTrait diseaseTrait = new DiseaseTrait();
diseaseTrait.setTrait(diseaseTraitDTO.getTrait());
return diseaseTrait;
}
use of uk.ac.ebi.spot.goci.model.DiseaseTrait 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