throw new CatalogException("Expected folder where place the found files."); Study study = catalogManager.getFileManager().getStudy(directory, sessionId);
protected List<StoragePipelineResult> loadFiles(List<File> files, List<File> expectedLoadedFiles, QueryOptions queryOptions, String outputId) throws Exception { queryOptions.append(VariantFileIndexerStorageOperation.TRANSFORM, false); queryOptions.append(VariantFileIndexerStorageOperation.LOAD, true); queryOptions.append(StorageOperation.CATALOG_PATH, outputId); boolean calculateStats = queryOptions.getBoolean(VariantStorageEngine.Options.CALCULATE_STATS.key()); String studyId = catalogManager.getFileManager().getStudy(files.get(0), sessionId).getId(); List<String> fileIds = files.stream().map(File::getId).collect(Collectors.toList()); String outdir = opencga.createTmpOutdir(studyId, "_LOAD_", sessionId); List<StoragePipelineResult> etlResults = variantManager.index(studyId, fileIds, outdir, queryOptions, sessionId); assertEquals(expectedLoadedFiles.size(), etlResults.size()); checkEtlResults(studyId, etlResults, FileIndex.IndexStatus.READY); Cohort defaultCohort = getDefaultCohort(studyId); for (File file : expectedLoadedFiles) { List<Long> samplesInFile = file.getSamples().stream().map(Sample::getUid).collect(Collectors.toList()); List<Long> samplesInCohort = defaultCohort.getSamples().stream().map(Sample::getUid).collect(Collectors.toList()); assertTrue(samplesInCohort.containsAll(samplesInFile)); } if (calculateStats) { assertEquals(Cohort.CohortStatus.READY, defaultCohort.getStatus().getName()); checkCalculatedStats(studyId, Collections.singletonMap(DEFAULT_COHORT, defaultCohort), catalogManager, dbName, sessionId); } return etlResults; }
Study study = catalogManager.getFileManager().getStudy(folder, sessionId);
private void removeFile(List<File> files, QueryOptions options, String outputId) throws Exception { List<String> fileIds = files.stream().map(File::getId).collect(Collectors.toList()); Study study = catalogManager.getFileManager().getStudy(files.get(0), sessionId); String studyId = study.getFqn(); List<File> removedFiles = variantManager.removeFile(fileIds, studyId, sessionId, new QueryOptions()); assertEquals(files.size(), removedFiles.size()); Cohort all = catalogManager.getCohortManager().get(studyId, new Query(CohortDBAdaptor.QueryParams.ID.key(), StudyEntry.DEFAULT_COHORT), null, sessionId).first(); Set<Long> allSampleIds = all.getSamples().stream().map(Sample::getUid).collect(Collectors.toSet()); assertThat(all.getStatus().getName(), anyOf(is(Cohort.CohortStatus.INVALID), is(Cohort.CohortStatus.NONE))); Set<Long> loadedSamples = catalogManager.getFileManager().get(studyId, new Query(FileDBAdaptor.QueryParams.INDEX_STATUS_NAME.key (), FileIndex.IndexStatus.READY), null, sessionId) .getResult() .stream() .flatMap(f -> f.getSamples().stream()) .map(Sample::getUid) .collect(Collectors.toSet()); assertEquals(loadedSamples, allSampleIds); for (File file : removedFiles) { assertEquals(FileIndex.IndexStatus.TRANSFORMED, file.getIndex().getStatus().getName()); } }
Study study = catalogManager.getFileManager().getStudy(file, sessionId); catalogManager.getFileManager().setStatus(study.getFqn(), file.getPath(), File.FileStatus.TRASHED, null, sessionId);
Study study = catalogManager.getFileManager().getStudy(pedFile, sessionId); long auxTime; long startTime = System.currentTimeMillis();
boolean calculateStats = queryOptions.getBoolean(VariantStorageEngine.Options.CALCULATE_STATS.key()); String studyId = catalogManager.getFileManager().getStudy(files.get(0), sessionId).getId(); queryOptions.append(StorageOperation.CATALOG_PATH, outputId);
@Test public void testDeleteIndexedFile() throws Exception { QueryOptions queryOptions = new QueryOptions(VariantStorageEngine.Options.ANNOTATE.key(), false) .append(VariantStorageEngine.Options.CALCULATE_STATS.key(), false); File inputFile = getFile(0); indexFile(inputFile, queryOptions, outputId); Study study = catalogManager.getFileManager().getStudy(inputFile, sessionId); WriteResult result = catalogManager.getFileManager().delete( study.getFqn(), new Query(FileDBAdaptor.QueryParams.PATH.key(), inputFile.getPath()) , null, sessionId); assertEquals(0, result.getNumModified()); assertTrue(result.getFailed().get(0).getMessage().contains("index status")); }
boolean calculateStats = queryOptions.getBoolean(VariantStorageEngine.Options.CALCULATE_STATS.key()); Study study = catalogManager.getFileManager().getStudy(inputFile, sessionId); String studyId = study.getId();
private void deleteFolderAndCheck(File deletable) throws CatalogException, IOException { List<File> allFilesInFolder; Study study = catalogManager.getFileManager().getStudy(deletable, sessionIdUser); catalogManager.getFileManager().delete(study.getFqn(), new Query(FileDBAdaptor.QueryParams.PATH.key(), deletable.getPath()), null, sessionIdUser); Query query = new Query() .append(FileDBAdaptor.QueryParams.PATH.key(), deletable.getPath()) .append(FileDBAdaptor.QueryParams.STATUS_NAME.key(), File.FileStatus.TRASHED); QueryOptions options = new QueryOptions(QueryOptions.INCLUDE, FileDBAdaptor.QueryParams.PATH.key()); QueryResult<File> fileQueryResult = catalogManager.getFileManager().get(study.getFqn(), query, options, sessionIdUser); assertEquals(1, fileQueryResult.getNumResults()); // allFilesInFolder = catalogManager.getAllFilesInFolder(deletable, null, sessionIdUser).getResult(); query = new Query() .append(FileDBAdaptor.QueryParams.DIRECTORY.key(), fileQueryResult.first().getPath() + ".*") .append(FileDBAdaptor.QueryParams.STATUS_NAME.key(), File.FileStatus.TRASHED); allFilesInFolder = catalogManager.getFileManager().get(study.getFqn(), query, null, sessionIdUser).getResult(); for (File subFile : allFilesInFolder) { assertTrue(subFile.getStatus().getName().equals(File.FileStatus.TRASHED)); } }
throws CatalogException { parameters = getModifiedFileAttributes(file, checksum, fileUri, parameters); Study study = catalogManager.getFileManager().getStudy(file, sessionId);
Study study = catalogManager.getFileManager().getStudy(file, sessionId); if (fileUri == null) { fileUri = catalogManager.getFileManager().getUri(file);