2727
2828import java .io .File ;
2929import java .io .IOException ;
30- import java .util .ArrayList ;
3130import java .util .Arrays ;
3231import java .util .HashSet ;
3332import java .util .List ;
33+ import java .util .Map ;
3434import java .util .Set ;
35+ import java .util .function .Function ;
36+ import java .util .stream .Collectors ;
3537
3638/**
3739 * User: bimber
@@ -165,7 +167,7 @@ private void processContainer(Container c, Logger log) throws IOException
165167 filter .addCondition (FieldKey .fromString ("sequenceid" ), null , CompareType .ISBLANK );
166168
167169 TableSelector ts = new TableSelector (tableJsonFiles , filter , null );
168- List < JsonFile > rows = new ArrayList <>( ts .getArrayList (JsonFile .class ));
170+ Map < String , JsonFile > rowMap = ts .getArrayList (JsonFile .class ). stream (). collect ( Collectors . toMap ( JsonFile :: getObjectId , Function . identity () ));
169171
170172 // Also check for genomes from this container, and any additional JsonFiles they may have:
171173 TableInfo tableGenomes = DbSchema .get (JBrowseManager .SEQUENCE_ANALYSIS , DbSchemaType .Module ).getTable ("reference_libraries" );
@@ -184,6 +186,7 @@ private void processContainer(Container c, Logger log) throws IOException
184186 JBrowseSession session = JBrowseSession .getGenericGenomeSession (genomeId );
185187 for (JsonFile json : session .getJsonFiles (u , true ))
186188 {
189+ rowMap .put (json .getObjectId (), json );
187190 expectedDirs .add (json .getBaseDir ());
188191 if (!json .getBaseDir ().exists ())
189192 {
@@ -197,7 +200,7 @@ private void processContainer(Container c, Logger log) throws IOException
197200 if (jbrowseRoot != null && jbrowseRoot .exists ())
198201 {
199202 log .info ("processing container: " + c .getPath ());
200- for (JsonFile json : rows )
203+ for (JsonFile json : rowMap . values () )
201204 {
202205 if (json .getBaseDir () != null )
203206 {
@@ -248,7 +251,7 @@ private void processContainer(Container c, Logger log) throws IOException
248251 }
249252 }
250253
251- for (JsonFile j : rows )
254+ for (JsonFile j : rowMap . values () )
252255 {
253256 if (j .needsProcessing ())
254257 {
0 commit comments