1616
1717package org .labkey .specimen ;
1818
19- import org .apache .commons .collections4 .bag .HashBag ;
19+ import org .apache .commons .collections4 .MultiSet ;
20+ import org .apache .commons .collections4 .multiset .HashMultiSet ;
2021import org .apache .commons .lang3 .mutable .MutableInt ;
2122import org .apache .logging .log4j .Logger ;
2223import org .jetbrains .annotations .NotNull ;
7475import org .labkey .specimen .importer .SpecimenSettingsImporter ;
7576import org .labkey .specimen .model .SpecimenRequestEventType ;
7677import org .labkey .specimen .pipeline .SpecimenPipeline ;
77- import org .labkey .specimen .requirements .SpecimenRequestRequirementProvider ;
7878import org .labkey .specimen .query .SpecimenPivotByDerivativeType ;
7979import org .labkey .specimen .query .SpecimenPivotByPrimaryType ;
8080import org .labkey .specimen .query .SpecimenPivotByRequestingLocation ;
8181import org .labkey .specimen .query .SpecimenQueryView ;
8282import org .labkey .specimen .query .SpecimenUpdateService ;
83+ import org .labkey .specimen .requirements .SpecimenRequestRequirementProvider ;
8384import org .labkey .specimen .security .roles .SpecimenCoordinatorRole ;
8485import org .labkey .specimen .security .roles .SpecimenRequesterRole ;
8586import org .labkey .specimen .settings .RepositorySettings ;
@@ -272,7 +273,7 @@ protected void startupAfterSpringConfig(ModuleContext moduleContext)
272273 {
273274 svc .registerUsageMetrics (NAME , () -> {
274275 // Collect and add specimen repository statistics: simple vs. advanced study count, event/vial/specimen count, count of studies with requests enabled, request count by status
275- HashBag <String > specimenBag = new HashBag <>();
276+ MultiSet <String > specimenMultiSet = new HashMultiSet <>();
276277 MutableInt requestsEnabled = new MutableInt (0 );
277278 MutableInt hasLocations = new MutableInt (0 );
278279
@@ -283,35 +284,35 @@ protected void startupAfterSpringConfig(ModuleContext moduleContext)
283284
284285 if (settings .isSimple ())
285286 {
286- specimenBag .add ("simple" );
287+ specimenMultiSet .add ("simple" );
287288 TableInfo simpleSpecimens = schema .getTable (SpecimenTablesProvider .SIMPLE_SPECIMEN_TABLE_NAME );
288- specimenBag .add ("simpleSpecimens" , (int ) new TableSelector (simpleSpecimens ).getRowCount ());
289+ specimenMultiSet .add ("simpleSpecimens" , (int ) new TableSelector (simpleSpecimens ).getRowCount ());
289290 }
290291 else
291292 {
292- specimenBag .add ("advanced" );
293+ specimenMultiSet .add ("advanced" );
293294 TableInfo events = schema .getTable (SpecimenTablesProvider .SPECIMEN_EVENT_TABLE_NAME );
294295 TableInfo vials = schema .getTable (SpecimenTablesProvider .SPECIMEN_DETAIL_TABLE_NAME );
295296 TableInfo specimens = schema .getTable (SpecimenTablesProvider .SPECIMEN_SUMMARY_TABLE_NAME );
296- specimenBag .add ("events" , (int ) new TableSelector (events ).getRowCount ());
297- specimenBag .add ("vials" , (int ) new TableSelector (vials ).getRowCount ());
298- specimenBag .add ("specimens" , (int ) new TableSelector (specimens ).getRowCount ());
297+ specimenMultiSet .add ("events" , (int ) new TableSelector (events ).getRowCount ());
298+ specimenMultiSet .add ("vials" , (int ) new TableSelector (vials ).getRowCount ());
299+ specimenMultiSet .add ("specimens" , (int ) new TableSelector (specimens ).getRowCount ());
299300 }
300301
301302 if (settings .isEnableRequests ())
302303 requestsEnabled .increment ();
303304
304305 TableInfo locations = schema .getTable (SpecimenQuerySchema .LOCATION_TABLE_NAME );
305306 long locationCount = new TableSelector (locations ).getRowCount ();
306- specimenBag .add ("locations" , (int ) locationCount );
307- specimenBag .add ("locationsInUse" , (int ) new TableSelector (locations , new SimpleFilter (FieldKey .fromParts ("In Use" ), true ), null ).getRowCount ());
307+ specimenMultiSet .add ("locations" , (int ) locationCount );
308+ specimenMultiSet .add ("locationsInUse" , (int ) new TableSelector (locations , new SimpleFilter (FieldKey .fromParts ("In Use" ), true ), null ).getRowCount ());
308309 if (locationCount > 0 )
309310 hasLocations .increment ();
310311
311- LOG .debug (specimenBag .toString ());
312+ LOG .debug (specimenMultiSet .toString ());
312313 });
313314
314- Map <String , Object > specimensMap = specimenBag .uniqueSet ().stream ().collect (Collectors .toMap (s -> s , specimenBag ::getCount ));
315+ Map <String , Object > specimensMap = specimenMultiSet .uniqueSet ().stream ().collect (Collectors .toMap (s -> s , specimenMultiSet ::getCount ));
315316 Map <String , Object > requestsMap = new SqlSelector (SpecimenSchema .get ().getSchema (), new SQLFragment ("SELECT Label, COUNT(*) FROM study.SampleRequest INNER JOIN study.SampleRequestStatus srs ON StatusId = srs.RowId GROUP BY Label" )).getValueMap (String .class );
316317 requestsMap .put ("enabled" , requestsEnabled );
317318 specimensMap .put ("requests" , requestsMap );
0 commit comments