public void validateDocumentToUpdate(Document document) { List<Document> memberList = (List) document.get("members"); if (memberList != null) { // We make sure we don't store duplicates Map<Long, Individual> individualMap = new HashMap<>(); for (Document individual : memberList) { long id = individual.getInteger("uid").longValue(); int version = individual.getInteger("version"); if (id > 0) { Individual tmpIndividual = new Individual() .setVersion(version); tmpIndividual.setUid(id); individualMap.put(id, tmpIndividual); } } document.put("members", individualMap.entrySet().stream() .map(entry -> new Document() .append("uid", entry.getValue().getUid()) .append("version", entry.getValue().getVersion())) .collect(Collectors.toList())); } List<Document> disorderList = (List) document.get("disorders"); if (disorderList != null) { for (Document disorder : disorderList) { fixPhenotypeFields((List) disorder.get("evidences")); } } fixPhenotypeFields((List) document.get("phenotypes")); }
individual.setVersion(1); if (StringUtils.isEmpty(individual.getUuid())) { individual.setUuid(UUIDUtils.generateOpenCGAUUID(UUIDUtils.Entity.INDIVIDUAL));
.setKaryotypicSex(IndividualProperty.KaryotypicSex.XX).setVersion(4).setStatus(new Status("READY")). setLifeStatus(IndividualProperty.LifeStatus.ABORTED).setAffectationStatus(IndividualProperty.AffectationStatus.AFFECTED). setSamples(Arrays.asList(new Sample().setId("1"), new Sample().setId("2"))).setParentalConsanguinity(true);