@@ -5072,6 +5072,7 @@ public ApiResponse execute(ArchiveReadsetsForm form, BindException errors) throw
50725072
50735073 Set <File > toDelete = new HashSet <>();
50745074 List <Map <String , Object >> toUpdate = new ArrayList <>();
5075+ Set <Long > encounteredReaddata = new HashSet <>();
50755076 for (ReadData rd : rs .getReadData ())
50765077 {
50775078 if (rd .getSra_accession () == null )
@@ -5080,7 +5081,14 @@ public ApiResponse execute(ArchiveReadsetsForm form, BindException errors) throw
50805081 return null ;
50815082 }
50825083
5084+ // A given ReadData can be referenced by multiple readsets
5085+ if (encounteredReaddata .contains (rd .getRowid ()))
5086+ {
5087+ continue ;
5088+ }
5089+
50835090 toUpdate .add (new CaseInsensitiveHashMap <>(Map .of ("rowid" , rd .getRowid (), "archived" , true , "container" , rd .getContainer ())));
5091+ encounteredReaddata .add (rd .getRowid ());
50845092
50855093 // File 1:
50865094 ExpData d1 = ExperimentService .get ().getExpData (rd .getFileId1 ());
@@ -5134,7 +5142,6 @@ public ApiResponse execute(ArchiveReadsetsForm form, BindException errors) throw
51345142 {
51355143 List <Map <String , Object >> keys = new ArrayList <>();
51365144 toUpdate .forEach (row -> {
5137-
51385145 keys .add (new CaseInsensitiveHashMap <>(Map .of ("rowid" , row .get ("rowid" ))));
51395146 });
51405147
@@ -5144,7 +5151,7 @@ public ApiResponse execute(ArchiveReadsetsForm form, BindException errors) throw
51445151 }
51455152 catch (Exception e )
51465153 {
5147- _log .error (e );
5154+ _log .error ("Error archiving readsets" , e );
51485155 errors .reject (ERROR_MSG , "Error archiving readset: " + readsetId + ", " + e .getMessage ());
51495156 return null ;
51505157 }
0 commit comments