public QueryResult<Individual> updateAnnotationSet(String studyStr, String individualStr, List<AnnotationSet> annotationSetList, ParamUtils.UpdateAction action, QueryOptions options, String token) throws CatalogException { ObjectMap params = new ObjectMap(AnnotationSetManager.ANNOTATION_SETS, annotationSetList); options = ParamUtils.defaultObject(options, QueryOptions::new); options.put(Constants.ACTIONS, new ObjectMap(AnnotationSetManager.ANNOTATION_SETS, action)); return update(studyStr, individualStr, params, options, token); }
public QueryResult<Individual> updateAnnotations(String studyStr, String individualStr, String annotationSetId, Map<String, Object> annotations, ParamUtils.CompleteUpdateAction action, QueryOptions options, String token) throws CatalogException { if (annotations == null || annotations.isEmpty()) { return new QueryResult<>(individualStr, -1, -1, -1, "Nothing to do: The map of annotations is empty", "", Collections.emptyList()); } ObjectMap params = new ObjectMap(AnnotationSetManager.ANNOTATIONS, new AnnotationSet(annotationSetId, "", annotations)); options = ParamUtils.defaultObject(options, QueryOptions::new); options.put(Constants.ACTIONS, new ObjectMap(AnnotationSetManager.ANNOTATIONS, action)); return update(studyStr, individualStr, params, options, token); }
catalogManager.getIndividualManager().update(studyFqn, individualId, new ObjectMap() .append(IndividualDBAdaptor.QueryParams.ANNOTATION_SETS.key(), Collections.singletonList(new ObjectMap() .append(AnnotationSetManager.ID, "annotation1") thrown.expect(CatalogException.class); thrown.expectMessage("unique"); catalogManager.getIndividualManager().update(studyFqn, individualId, new ObjectMap() .append(IndividualDBAdaptor.QueryParams.ANNOTATION_SETS.key(), Collections.singletonList(new ObjectMap() .append(AnnotationSetManager.ID, "annotation2")
@Test public void testUpdateIndividualInfo() throws CatalogException { IndividualManager individualManager = catalogManager.getIndividualManager(); QueryResult<Individual> individualQueryResult = individualManager.create(studyFqn, new Individual().setId("Test") .setDateOfBirth("19870214"), QueryOptions.empty(), sessionIdUser); assertEquals(1, individualQueryResult.getNumResults()); assertEquals("Test", individualQueryResult.first().getId()); assertEquals("19870214", individualQueryResult.first().getDateOfBirth()); QueryResult<Individual> update = individualManager.update(studyFqn, individualQueryResult.first().getId(), new ObjectMap(IndividualDBAdaptor.QueryParams.DATE_OF_BIRTH.key() , null), QueryOptions.empty(), sessionIdUser); assertEquals("", update.first().getDateOfBirth()); update = individualManager.update(studyFqn, individualQueryResult.first().getId(), new ObjectMap(IndividualDBAdaptor.QueryParams.DATE_OF_BIRTH.key(), "19870214"), QueryOptions.empty(), sessionIdUser); assertEquals("19870214", update.first().getDateOfBirth()); update = individualManager.update(studyFqn, String.valueOf(individualQueryResult.first().getId()), new ObjectMap(IndividualDBAdaptor.QueryParams.ATTRIBUTES.key(), Collections.singletonMap("key", "value")), QueryOptions.empty(), sessionIdUser); assertEquals("value", update.first().getAttributes().get("key")); update = individualManager.update(studyFqn, String.valueOf(individualQueryResult.first().getId()), new ObjectMap(IndividualDBAdaptor.QueryParams.ATTRIBUTES.key(), Collections.singletonMap("key2", "value2")), QueryOptions.empty(), sessionIdUser); assertEquals("value", update.first().getAttributes().get("key")); // Keep "key" assertEquals("value2", update.first().getAttributes().get("key2")); // add new "key2" // Wrong date of birth format thrown.expect(CatalogException.class); thrown.expectMessage("Invalid date of birth format"); individualManager.update(studyFqn, individualQueryResult.first().getId(), new ObjectMap(IndividualDBAdaptor.QueryParams.DATE_OF_BIRTH.key(), "198421"), QueryOptions.empty(), sessionIdUser); }
.first().getId(); catalogManager.getIndividualManager().update(studyFqn, individualId1, new ObjectMap() .append(IndividualDBAdaptor.QueryParams.ANNOTATION_SETS.key(), Collections.singletonList(new ObjectMap() .append(AnnotationSetManager.ID, "annot1") QueryOptions.empty(), sessionIdUser); catalogManager.getIndividualManager().update(studyFqn, individualId2, new ObjectMap() .append(IndividualDBAdaptor.QueryParams.ANNOTATION_SETS.key(), Collections.singletonList(new ObjectMap() .append(AnnotationSetManager.ID, "annot1") QueryOptions.empty(), sessionIdUser); catalogManager.getIndividualManager().update(studyFqn, individualId3, new ObjectMap() .append(IndividualDBAdaptor.QueryParams.ANNOTATION_SETS.key(), Collections.singletonList(new ObjectMap() .append(AnnotationSetManager.ID, "annot1")
@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()); }