public QueryResult<File> updateAnnotations(String studyStr, String fileStr, String annotationSetId, Map<String, Object> annotations, ParamUtils.CompleteUpdateAction action, QueryOptions options, String token) throws CatalogException { if (annotations == null || annotations.isEmpty()) { return new QueryResult<>(fileStr, -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, fileStr, params, options, token); }
attributes.put("storagePipelineResult", storagePipelineResult); ObjectMap params = new ObjectMap(FileDBAdaptor.QueryParams.ATTRIBUTES.key(), attributes); fileManager.update(study.getFqn(), indexedFile.getPath(), params, new QueryOptions(), sessionId);
fileManager.update(studyFqn, inputFile.getPath(), params, new QueryOptions(), sessionId);
ObjectMap globalStats = new ObjectMap(GLOBAL_STATS, objectWriter.writeValueAsString(stats.first())); ObjectMap alignmentStats = new ObjectMap(FileDBAdaptor.QueryParams.STATS.key(), globalStats); catalogManager.getFileManager().update(studyIdStr, fileInfo.getPath(), alignmentStats, new QueryOptions(), sessionId);
@Test public void testAnnotations() throws CatalogException, JsonProcessingException { List<Variable> variables = new ArrayList<>(); variables.add(new Variable("var_name", "", "", Variable.VariableType.TEXT, "", true, false, Collections.emptyList(), 0, "", "", null, Collections.emptyMap())); variables.add(new Variable("AGE", "", "", Variable.VariableType.INTEGER, "", false, false, Collections.emptyList(), 0, "", "", null, Collections.emptyMap())); variables.add(new Variable("HEIGHT", "", "", Variable.VariableType.DOUBLE, "", false, false, Collections.emptyList(), 0, "", "", null, Collections.emptyMap())); VariableSet vs1 = catalogManager.getStudyManager().createVariableSet(studyFqn, "vs1", "vs1", false, false, "", null, variables, sessionIdUser).first(); ObjectMap annotations = new ObjectMap() .append("var_name", "Joe") .append("AGE", 25) .append("HEIGHT", 180); AnnotationSet annotationSet = new AnnotationSet("annotation1", vs1.getId(), annotations); AnnotationSet annotationSet1 = new AnnotationSet("annotation2", vs1.getId(), annotations); ObjectMapper jsonObjectMapper = getDefaultObjectMapper(); ObjectMap updateAnnotation = new ObjectMap() // Update the annotation values .append(FileDBAdaptor.QueryParams.ANNOTATION_SETS.key(), Arrays.asList( new ObjectMap(jsonObjectMapper.writeValueAsString(annotationSet)), new ObjectMap(jsonObjectMapper.writeValueAsString(annotationSet1)) )); QueryResult<File> update = catalogManager.getFileManager().update(studyFqn, "data/", updateAnnotation, QueryOptions.empty(), sessionIdUser); assertEquals(2, update.first().getAnnotationSets().size()); }
VariantSetStats stats = fileMetadata.getStats(); params = new ObjectMap(FileDBAdaptor.QueryParams.STATS.key(), new ObjectMap(VARIANT_FILE_STATS, stats)); update(studyStr, vcf.getPath(), params, new QueryOptions(), sessionId); } catch (IOException e) { throw new CatalogException("Error reading file \"" + statsFile + "\"", e);
catalogManager.getFileManager().update(studyStr, file.getPath(), params, QueryOptions.empty(), sessionId);
@Test public void testDoNotOverwriteSampleIds() throws CatalogException, FileNotFoundException { File file = catalogManager.getFileManager().upload(study.getFqn(), vcfFileUri, new File().setPath(folder.getPath() + VCF_FILE_NAME), false, false, sessionIdUser).first(); assertEquals(File.FileStatus.READY, file.getStatus().getName()); assertEquals(File.Format.VCF, file.getFormat()); assertEquals(File.Bioformat.VARIANT, file.getBioformat()); assertNotNull(file.getAttributes().get(VARIANT_FILE_METADATA)); assertEquals(4, file.getSamples().size()); //Add a sampleId String sampleId = catalogManager.getSampleManager().create(study.getFqn(), new Sample().setId("Bad_Sample"), null, sessionIdUser) .first().getId(); catalogManager.getFileManager().update(study.getFqn(), file.getPath(), new ObjectMap(FileDBAdaptor.QueryParams.SAMPLES.key(), Collections.singletonList(sampleId)), new QueryOptions(), sessionIdUser); file = catalogManager.getFileManager().get(study.getFqn(), file.getPath(), null, sessionIdUser).first(); assertEquals(5, file.getSamples().size()); assertEquals(sampleId, file.getSamples().get(4).getId()); }
catalogManager.getFileManager().update(study.getFqn(), file.getPath(), parameters, QueryOptions.empty(), sessionId);
catalogManager.getFileManager().update(studyFqn, "data/test/", new ObjectMap(FileDBAdaptor.QueryParams.SAMPLES.key(), Arrays.asList(sample1.getId(), sample2.getId())), QueryOptions.empty(), sessionIdUser);
catalogManager.getFileManager().update(study.getFqn(), file.getPath(), modifyParams, new QueryOptions(), sessionId);
attributes.put("field", "value"); attributes.put("numValue", 5); catalogManager.getFileManager().update(studyFqn, testFolder.getPath(), new ObjectMap("attributes", attributes), new QueryOptions(), sessionIdUser); attributes.put("numValue", "10"); attributes.put("boolean", false); catalogManager.getFileManager().update(studyFqn, fileTest1k.getPath(), new ObjectMap("attributes", attributes), new QueryOptions(), sessionIdUser); attributes.put("numValue", 5); attributes.put("boolean", true); catalogManager.getFileManager().update(studyFqn, fileTest05k.getPath(), new ObjectMap("attributes", attributes), new QueryOptions(), sessionIdUser); attributes.put("numValue", 50); attributes.put("nested", new ObjectMap("num1", 45).append("num2", 33).append("text", "HelloWorld")); catalogManager.getFileManager().update(studyFqn, test01k.getPath(), new ObjectMap("attributes", attributes), new QueryOptions(), sessionIdUser); s_9 = catalogManager.getSampleManager().create(studyFqn, sample, new QueryOptions(), sessionIdUser).first().getId(); catalogManager.getFileManager().update(studyFqn, test01k.getPath(), new ObjectMap(FileDBAdaptor.QueryParams.SAMPLES.key(), Arrays.asList(s_1, s_2, s_3, s_4, s_5)), new QueryOptions(), sessionIdUser);