@@ -1063,7 +1063,7 @@ private boolean synchronizeSample(StudyMetadata study, SampleMetadata sampleMeta
10631063 catalogManager .getSampleManager ()
10641064 .updateSampleInternalVariantIndex (study .getName (), sample ,
10651065 new SampleInternalVariantIndex (
1066- new IndexStatus (sampleMetadata .getIndexStatus (). name ()),
1066+ toIndexStatus (sampleMetadata .getIndexStatus ()),
10671067 sampleMetadata .getFiles ().size (),
10681068 sampleMetadata .isMultiFileSample ()), token );
10691069 modified = true ;
@@ -1073,7 +1073,7 @@ private boolean synchronizeSample(StudyMetadata study, SampleMetadata sampleMeta
10731073 catalogManager .getSampleManager ()
10741074 .updateSampleInternalVariantAnnotationIndex (study .getName (), sample ,
10751075 new SampleInternalVariantAnnotationIndex (
1076- new IndexStatus (sampleMetadata .getAnnotationStatus (). name ())), token );
1076+ toIndexStatus (sampleMetadata .getAnnotationStatus ())), token );
10771077 modified = true ;
10781078 }
10791079
@@ -1083,7 +1083,7 @@ private boolean synchronizeSample(StudyMetadata study, SampleMetadata sampleMeta
10831083 catalogManager .getSampleManager ()
10841084 .updateSampleInternalVariantSecondaryAnnotationIndex (study .getName (), sample ,
10851085 new SampleInternalVariantSecondaryAnnotationIndex (
1086- new IndexStatus (sampleMetadata .getSecondaryAnnotationIndexStatus (). name ())), token );
1086+ toIndexStatus (sampleMetadata .getSecondaryAnnotationIndexStatus ())), token );
10871087 modified = true ;
10881088 }
10891089
@@ -1136,14 +1136,15 @@ private boolean synchronizeSample(StudyMetadata study, SampleMetadata sampleMeta
11361136 catalogVariantSecondarySampleIndexModified = true ;
11371137 }
11381138
1139- String sampleIndexFamilyStatus = sampleMetadata .getFamilyIndexStatus (sampleIndexVersion ).name ();
1140- String catalogSecondarySampleIndexFamilyStatus = secureGet (sample , s -> s .getInternal ().getVariant ().getSecondarySampleIndex ().getFamilyStatus ().getId (), null );
1141- if (!sampleIndexFamilyStatus .equals (catalogSecondarySampleIndexFamilyStatus )) {
1139+ IndexStatus sampleIndexFamilyStatus = toIndexStatus (sampleMetadata .getFamilyIndexStatus (sampleIndexVersion ));
1140+ String catalogSecondarySampleIndexFamilyStatus = secureGet (sample , s -> s .getInternal ().getVariant ()
1141+ .getSecondarySampleIndex ().getFamilyStatus ().getId (), null );
1142+ if (!sampleIndexFamilyStatus .getId ().equals (catalogSecondarySampleIndexFamilyStatus )) {
11421143 String message = "Family Index is "
1143- + (sampleIndexFamilyStatus .equals (IndexStatus .READY ) ? "ready" : "not ready" )
1144+ + (sampleIndexFamilyStatus .getId (). equals (IndexStatus .READY ) ? "ready" : "not ready" )
11441145 + " with version=" + sampleIndexVersion ;
11451146 catalogVariantSecondarySampleIndex .setFamilyStatus (
1146- new IndexStatus (sampleIndexFamilyStatus , message ));
1147+ new IndexStatus (sampleIndexFamilyStatus . getId () , message ));
11471148 catalogVariantSecondarySampleIndexModified = true ;
11481149 }
11491150
@@ -1214,6 +1215,41 @@ private boolean synchronizeSample(StudyMetadata study, SampleMetadata sampleMeta
12141215 return modified ;
12151216 }
12161217
1218+ private static IndexStatus toIndexStatus (TaskMetadata .Status indexStatus ) {
1219+ return toIndexStatus (indexStatus , "" );
1220+ }
1221+
1222+ private static IndexStatus toIndexStatus (TaskMetadata .Status storageStatus , String message ) {
1223+ String statusName ;
1224+ switch (storageStatus ) {
1225+ case NONE :
1226+ case ERROR :
1227+ case ABORTED :
1228+ statusName = IndexStatus .NONE ;
1229+ break ;
1230+ case RUNNING :
1231+ statusName = IndexStatus .INDEXING ;
1232+ break ;
1233+ case DONE :
1234+ case READY :
1235+ statusName = IndexStatus .READY ;
1236+ break ;
1237+ case INVALID :
1238+ statusName = IndexStatus .INVALID ;
1239+ break ;
1240+ default :
1241+ throw new IllegalStateException ("Unexpected value: " + storageStatus );
1242+ }
1243+ if (message .isEmpty ()) {
1244+ if (statusName .equals (storageStatus .name ())) {
1245+ message = "Index is " + statusName .toLowerCase ();
1246+ } else {
1247+ message = "Index is " + statusName .toLowerCase () + " (storage status: " + storageStatus .name ().toLowerCase () + ")" ;
1248+ }
1249+ }
1250+ return new IndexStatus (statusName , message );
1251+ }
1252+
12171253 public void synchronizeRemovedStudyFromStorage (String study , String token ) throws CatalogException {
12181254 catalogManager .getCohortManager ().update (study , StudyEntry .DEFAULT_COHORT ,
12191255 new CohortUpdateParams ().setSamples (Collections .emptyList ()),
0 commit comments