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")); }
individualSolrModel.setVersion(individual.getVersion());
assertEquals(localDate.getDayOfWeek().toString(), individualSolrModel.getCreationDayOfWeek()); assertEquals(individualSolrModel.getVersion(), individual.getVersion()); assertEquals(individualSolrModel.getStatus(), individual.getStatus().getName()); assertEquals(individualSolrModel.getLifeStatus(), individual.getLifeStatus().name());
@Test public void testUpdateIndividuaParents() throws CatalogException { IndividualManager individualManager = catalogManager.getIndividualManager(); individualManager.create(studyFqn, new Individual().setId("child"), QueryOptions.empty(), sessionIdUser); individualManager.create(studyFqn, new Individual().setId("father"), QueryOptions.empty(), sessionIdUser); individualManager.create(studyFqn, new Individual().setId("mother"), QueryOptions.empty(), sessionIdUser); QueryResult<Individual> individualQueryResult = individualManager.update(studyFqn, "child", new ObjectMap() .append(IndividualDBAdaptor.QueryParams.FATHER.key(), new ObjectMap(IndividualDBAdaptor.QueryParams.ID.key(), "father")) .append(IndividualDBAdaptor.QueryParams.MOTHER.key(), new ObjectMap(IndividualDBAdaptor.QueryParams.ID.key(), "mother")), QueryOptions.empty(), sessionIdUser); assertEquals("mother", individualQueryResult.first().getMother().getId()); assertEquals(1, individualQueryResult.first().getMother().getVersion()); assertEquals("father", individualQueryResult.first().getFather().getId()); assertEquals(1, individualQueryResult.first().getFather().getVersion()); }