3737import org .opencb .opencga .catalog .utils .ParamUtils ;
3838import org .opencb .opencga .core .api .ParamConstants ;
3939import org .opencb .opencga .core .common .BatchUtils ;
40+ import org .opencb .opencga .core .common .UriUtils ;
4041import org .opencb .opencga .core .config .storage .CellBaseConfiguration ;
4142import org .opencb .opencga .core .config .storage .SampleIndexConfiguration ;
4243import org .opencb .opencga .core .models .cohort .Cohort ;
@@ -735,8 +736,8 @@ protected boolean synchronizeFiles(StudyMetadata study, List<File> files, String
735736 for (Integer virtualFile : virtualFiles ) {
736737 File file = catalogManager .getFileManager ()
737738 .get (study .getName (), filePathMap .get (virtualFile ), INDEXED_FILES_QUERY_OPTIONS , token ).first ();
738- boolean annotationIndexReady = annotationReadyFilesFromStorage .contains (file . getUri ( ));
739- boolean secondaryIndexReady = secondaryIndexReadyFilesFromStorage .contains (file . getUri ( ));
739+ boolean annotationIndexReady = annotationReadyFilesFromStorage .contains (getFileUri ( file ));
740+ boolean secondaryIndexReady = secondaryIndexReadyFilesFromStorage .contains (getFileUri ( file ));
740741 if (synchronizeIndexedFile (study , file , fileSamplesMap , annotationIndexReady , secondaryIndexReady , token , true )) {
741742 modified = true ;
742743 }
@@ -760,16 +761,16 @@ protected boolean synchronizeFiles(StudyMetadata study, List<File> files, String
760761 .iterator (study .getName (), query , INDEXED_FILES_QUERY_OPTIONS , token )) {
761762 while (iterator .hasNext ()) {
762763 File file = iterator .next ();
763- boolean annotationIndexReady = annotationReadyFilesFromStorage .contains (file . getUri ( ));
764- boolean secondaryIndexReady = secondaryIndexReadyFilesFromStorage .contains (file . getUri ( ));
764+ boolean annotationIndexReady = annotationReadyFilesFromStorage .contains (getFileUri ( file ));
765+ boolean secondaryIndexReady = secondaryIndexReadyFilesFromStorage .contains (getFileUri ( file ));
765766 if (synchronizeIndexedFile (study , file , fileSamplesMap , annotationIndexReady , secondaryIndexReady , token , true )) {
766767 modifiedFiles ++;
767768 modified = true ;
768769 }
769770
770771 // Remove processed file from list of uris.
771772 // Avoid double processing in case of exception
772- batch .remove (file . getUri ( ).toString ());
773+ batch .remove (getFileUri ( file ).toString ());
773774 numFiles ++;
774775 processedFilesInBatch ++;
775776 progressLogger .increment (1 , modifiedFiles + " updated files" );
@@ -818,7 +819,7 @@ protected boolean synchronizeFiles(StudyMetadata study, List<File> files, String
818819 .iterator (study .getName (), indexedFilesQuery , INDEXED_FILES_QUERY_OPTIONS , token )) {
819820 while (iterator .hasNext ()) {
820821 File file = iterator .next ();
821- Integer fileId = fileURIMap .get (file . getUri ( ));
822+ Integer fileId = fileURIMap .get (getFileUri ( file ));
822823 if (fileId == null || !indexedFilesFromStorage .contains (fileId )) {
823824 // Check for annotation index and secondary annotation index
824825 boolean annotationIndexReady ;
@@ -827,8 +828,8 @@ protected boolean synchronizeFiles(StudyMetadata study, List<File> files, String
827828 annotationIndexReady = false ;
828829 secondaryIndexReady = false ;
829830 } else {
830- annotationIndexReady = annotationReadyFilesFromStorage .contains (file . getUri ( ));
831- secondaryIndexReady = secondaryIndexReadyFilesFromStorage .contains (file . getUri ( ));
831+ annotationIndexReady = annotationReadyFilesFromStorage .contains (getFileUri ( file ));
832+ secondaryIndexReady = secondaryIndexReadyFilesFromStorage .contains (getFileUri ( file ));
832833 }
833834 synchronizeIndexedFile (study , file , fileSamplesMap , annotationIndexReady , secondaryIndexReady , token , false );
834835 modified = true ;
@@ -854,7 +855,7 @@ protected boolean synchronizeFiles(StudyMetadata study, List<File> files, String
854855 .iterator (study .getName (), runningIndexFilesQuery , INDEXED_FILES_QUERY_OPTIONS , token )) {
855856 while (iterator .hasNext ()) {
856857 File file = iterator .next ();
857- Integer fileId = fileURIMap .get (file . getUri ( ));
858+ Integer fileId = fileURIMap .get (getFileUri ( file ));
858859 FileMetadata fileMetadata ;
859860 if (fileId == null ) {
860861 fileMetadata = null ;
@@ -893,10 +894,10 @@ protected boolean synchronizeFiles(StudyMetadata study, List<File> files, String
893894 modified = true ;
894895 } else {
895896 // Running job. Might be transforming, or have just started. Do not modify the status!
896- loadingFilesRegardingCatalog .add (file . getUri ( ));
897+ loadingFilesRegardingCatalog .add (getFileUri ( file ));
897898 }
898899 } else {
899- loadingFilesRegardingCatalog .add (file . getUri ( ));
900+ loadingFilesRegardingCatalog .add (getFileUri ( file ));
900901 }
901902 }
902903 }
@@ -941,6 +942,14 @@ protected boolean synchronizeFiles(StudyMetadata study, List<File> files, String
941942 return modified ;
942943 }
943944
945+ private static URI getFileUri (File file ) {
946+ if (file .getType () == File .Type .VIRTUAL ) {
947+ return UriUtils .toUri (file .getPath ());
948+ } else {
949+ return file .getUri ();
950+ }
951+ }
952+
944953 private boolean synchronizeIndexedFile (StudyMetadata study , File file , Map <URI , Set <String >> fileSamplesMap ,
945954 boolean annotationIndexReady , boolean secondaryIndexReady , String token , boolean mainIndexReady )
946955 throws CatalogException {
@@ -996,7 +1005,7 @@ private boolean synchronizeIndexedFile(StudyMetadata study, File file, Map<URI,
9961005 modified = true ;
9971006 }
9981007
999- Set <String > storageSamples = fileSamplesMap .get (file . getUri ( ));
1008+ Set <String > storageSamples = fileSamplesMap .get (getFileUri ( file ));
10001009 Set <String > catalogSamples = new HashSet <>(file .getSampleIds ());
10011010 if (storageSamples == null ) {
10021011 storageSamples = new HashSet <>();
0 commit comments