public List<Document> annotationToDB(VariableSet variableSet, AnnotationSet annotationSet) { return annotationToDB(variableSet, annotationSet.getId(), annotationSet.getAnnotations()); }
if (annotationSetIds.contains(annotationSet.getId())) { throw new CatalogDBException("Found more than one annotationSet with same id " + annotationSet.getId()); annotationSetIds.add(annotationSet.getId()); .append(AnnotationSetParams.ANNOTATION_SET_NAME.key(), annotationSet.getId()) .append(PRIVATE_UID, entryId); if (isVersioned) { throw CatalogDBException.alreadyExists("AnnotationSet", "id", annotationSet.getId());
while (iterator.hasNext()) { AnnotationSet annotationSet = iterator.next(); String annotationSetName = annotationSet.getId(); ParamUtils.checkAlias(annotationSetName, "annotationSetName");
if (!existingAnnotationSets.contains(annotationSet.getId())) { throw new CatalogDBException("Could not delete: AnnotationSet " + annotationSet.getId() + " not found"); removeAnnotationSet(entryId, annotationSet.getId(), isVersioned); String variableSetId = annotationSetIdVariableSetUidMap.get(annotationSet.getId()); variableSetAnnotationsets.get(variableSetId).remove(annotationSet.getId()); removeAnnotationSet(entryId, annotationSet.getId(), isVersioned);
.append(AnnotationSetParams.ANNOTATION_SET_NAME.key(), annotationSet.getId()) .append("_id", id)); if (count.first() > 0) { throw CatalogDBException.alreadyExists("AnnotationSet", "name", annotationSet.getId()); List<Document> documentList = annotationConverter.annotationToDB(variableSet, annotationSet.getId(), annotationSet.getAnnotations()); Filters.eq(AnnotationSetParams.ANNOTATION_SET_NAME.key(), new Document("$ne", annotationSet.getId())) ); Bson update = new Document() throw CatalogDBException.alreadyExists("AnnotationSet", "name", annotationSet.getId());
annotationSetMap.put(annotationSet.getId(), annotationSet); if (annotationSetMap.containsKey(annotationSet.getId())) { throw new CatalogException("Cannot add AnnotationSet " + annotationSet.getId() + ". An AnnotationSet with " + "the same id was already found."); } else if (variableSetMap.containsKey(annotationSet.getVariableSetId())) { if (StringUtils.isEmpty(annotationSet.getId())) { throw new CatalogException("Cannot remove annotationSet. Mandatory annotationSet id field is empty"); ParamUtils.checkParameter(annotationSet.getId(), "annotationSet id"); annotationSet.getId()); if (annotationSetQueryResult.getNumResults() == 0) { throw new CatalogException("AnnotationSet " + annotationSet.getId() + " not found. Annotations could not be updated.");
@Test public void testUpdateAnnotationFail() throws CatalogException { Sample sample = catalogManager.getSampleManager().get(studyFqn, s_1, null, sessionIdUser).first(); AnnotationSet annotationSet = sample.getAnnotationSets().get(0); thrown.expect(CatalogException.class); //Can not delete required fields thrown.expectMessage("required variable"); catalogManager.getSampleManager().removeAnnotations(studyFqn, s_1, annotationSet.getId(), Collections.singletonList("NAME"), QueryOptions.empty(), sessionIdUser); }
@Test public void testDeleteAnnotation() throws CatalogException { // We add one of the non mandatory annotations // First update catalogManager.getSampleManager().updateAnnotations(studyFqn, s_1, "annot1", new ObjectMap("EXTRA", "extra"), ParamUtils.CompleteUpdateAction.ADD, QueryOptions.empty(), sessionIdUser); Sample sample = catalogManager.getSampleManager().get(studyFqn, s_1, null, sessionIdUser).first(); AnnotationSet annotationSet = sample.getAnnotationSets().get(0); assertEquals("extra", annotationSet.getAnnotations().get("EXTRA")); // Now we remove that non mandatory annotation catalogManager.getSampleManager().removeAnnotations(studyFqn, s_1, annotationSet.getId(), Collections.singletonList("EXTRA"), QueryOptions.empty(), sessionIdUser); sample = catalogManager.getSampleManager().get(studyFqn, s_1, null, sessionIdUser).first(); annotationSet = sample.getAnnotationSets().get(0); assertTrue(!annotationSet.getAnnotations().containsKey("EXTRA")); // Now we attempt to remove one mandatory annotation thrown.expect(CatalogException.class); //Can not delete required fields thrown.expectMessage("required variable"); catalogManager.getSampleManager().removeAnnotations(studyFqn, s_1, annotationSet.getId(), Collections.singletonList("AGE"), QueryOptions.empty(), sessionIdUser); }
catalogManager.getIndividualManager().updateAnnotations(studyFqn, ind.getId(), annotationSet.getId(), annotationSet.getAnnotations(), ParamUtils.CompleteUpdateAction.SET, new QueryOptions(Constants.INCREMENT_VERSION, true), sessionIdUser); catalogManager.getSampleManager().updateAnnotations(studyFqn, s_1, annotationSet.getId(), annotationSet.getAnnotations(), ParamUtils.CompleteUpdateAction.SET, new QueryOptions(Constants.INCREMENT_VERSION, true), sessionIdUser); catalogManager.getIndividualManager().updateAnnotations(studyFqn, ind.getId(), annotationSet.getId(), annotationSet.getAnnotations(), ParamUtils.CompleteUpdateAction.SET, new QueryOptions(Constants.INCREMENT_VERSION, true), sessionIdUser); annotationSet.getAnnotations().remove("EXTRA"); catalogManager.getIndividualManager().updateAnnotations(studyFqn, ind.getId(), annotationSet.getId(), annotationSet.getAnnotations(), ParamUtils.CompleteUpdateAction.SET, new QueryOptions(Constants.INCREMENT_VERSION, true), sessionIdUser); catalogManager.getSampleManager().updateAnnotations(studyFqn, s_1, annotationSet.getId(), annotationSet.getAnnotations(), ParamUtils.CompleteUpdateAction.SET, new QueryOptions(Constants.INCREMENT_VERSION, true), sessionIdUser); catalogManager.getIndividualManager().updateAnnotations(studyFqn, ind.getId(), annotationSet.getId(), annotationSet.getAnnotations(), ParamUtils.CompleteUpdateAction.SET, new QueryOptions(Constants.INCREMENT_VERSION, true), sessionIdUser); catalogManager.getSampleManager().updateAnnotations(studyFqn, s_1, annotationSet.getId(), annotationSet.getAnnotations(), ParamUtils.CompleteUpdateAction.SET, new QueryOptions(Constants.INCREMENT_VERSION, true), sessionIdUser); catalogManager.getIndividualManager().updateAnnotations(studyFqn, ind.getId(), annotationSet.getId(), annotationUpdate, ParamUtils.CompleteUpdateAction.ADD, new QueryOptions(Constants.INCREMENT_VERSION, true), sessionIdUser); catalogManager.getSampleManager().updateAnnotations(studyFqn, s_1, annotationSet.getId(), annotationUpdate, ParamUtils.CompleteUpdateAction.ADD, new QueryOptions(Constants.INCREMENT_VERSION, true), sessionIdUser);
.append(String.valueOf(vs.getUid()), vs.getId()), new QueryOptions()); assertEquals(1, annotationSets.size()); assertEquals("annotName", annotationSets.get(0).getId()); assertEquals(vs.getId(), annotationSets.get(0).getVariableSetId());