4545import org .labkey .api .data .ContainerFilter ;
4646import org .labkey .api .data .ContainerManager ;
4747import org .labkey .api .data .ConversionExceptionWithMessage ;
48+ import org .labkey .api .data .DatabaseCache ;
4849import org .labkey .api .data .DbSchema ;
4950import org .labkey .api .data .DbScope ;
5051import org .labkey .api .data .DbSequence ;
@@ -202,10 +203,11 @@ public static SampleTypeServiceImpl get()
202203
203204 private static final Logger LOG = LogHelper .getLogger (SampleTypeServiceImpl .class , "Info about sample type operations" );
204205
205- // SampleType -> Container cache
206+ /** SampleType LSID -> Container cache */
206207 private final Cache <String , String > sampleTypeCache = CacheManager .getStringKeyCache (CacheManager .UNLIMITED , CacheManager .DAY , "SampleType to container" );
207208
208- private final Cache <String , SortedSet <MaterialSource >> materialSourceCache = CacheManager .getBlockingStringKeyCache (CacheManager .UNLIMITED , CacheManager .DAY , "Material sources" , (container , argument ) ->
209+ /** ContainerId -> MaterialSources */
210+ private final Cache <String , SortedSet <MaterialSource >> materialSourceCache = DatabaseCache .get (ExperimentServiceImpl .get ().getSchema ().getScope (), CacheManager .UNLIMITED , CacheManager .DAY , "Material sources" , (container , argument ) ->
209211 {
210212 Container c = ContainerManager .getForId (container );
211213 if (c == null )
@@ -215,7 +217,6 @@ public static SampleTypeServiceImpl get()
215217 return Collections .unmodifiableSortedSet (new TreeSet <>(new TableSelector (getTinfoMaterialSource (), filter , null ).getCollection (MaterialSource .class )));
216218 });
217219
218-
219220 Cache <String , SortedSet <MaterialSource >> getMaterialSourceCache ()
220221 {
221222 return materialSourceCache ;
@@ -954,9 +955,7 @@ public ExpSampleTypeImpl createSampleType(Container c, User u, String name, Stri
954955 else
955956 ExperimentService .get ().ensureDataTypeContainerExclusionsNonAdmin (ExperimentService .DataTypeForExclusion .DashboardSampleType , st .getRowId (), c , u );
956957 transaction .addCommitTask (() -> clearMaterialSourceCache (c ), DbScope .CommitTaskOption .IMMEDIATE , POSTCOMMIT , POSTROLLBACK );
957- transaction .addCommitTask (() -> {
958- indexSampleType (SampleTypeService .get ().getSampleType (domain .getTypeURI ()), SearchService .get ().defaultTask ().getQueue (c , SearchService .PRIORITY .modified ));
959- }, POSTCOMMIT );
958+ transaction .addCommitTask (() -> indexSampleType (SampleTypeService .get ().getSampleType (domain .getTypeURI ()), SearchService .get ().defaultTask ().getQueue (c , SearchService .PRIORITY .modified )), POSTCOMMIT );
960959
961960 return st ;
962961 }
@@ -1012,8 +1011,7 @@ public long next(Date date)
10121011 public DbSequence getDbSequence (Date date )
10131012 {
10141013 Pair <String ,Integer > seqName = getSequenceName (date );
1015- final DbSequence seq = DbSequenceManager .getPreallocatingSequence (ContainerManager .getRoot (), seqName .first , seqName .second , 100 );
1016- return seq ;
1014+ return DbSequenceManager .getPreallocatingSequence (ContainerManager .getRoot (), seqName .first , seqName .second , 100 );
10171015 }
10181016 }
10191017
@@ -1083,7 +1081,7 @@ public ValidationException updateSampleType(GWTDomain<? extends GWTPropertyDescr
10831081 validateSampleTypeName (container , user , newName , oldSampleTypeName .equalsIgnoreCase (newName ));
10841082 hasNameChange = true ;
10851083 st .setName (newName );
1086- changeDetails .append ("The name of the sample type '" + oldSampleTypeName + "' was changed to '" + newName + "'." );
1084+ changeDetails .append ("The name of the sample type '" ). append ( oldSampleTypeName ). append ( "' was changed to '" ). append ( newName ). append ( "'." );
10871085 }
10881086
10891087 String newDescription = StringUtils .trimToNull (update .getDescription ());
@@ -1595,7 +1593,7 @@ private AliquotAvailableAmountUnit computeAliquotTotalAmounts(List<AliquotAmount
15951593 return null ;
15961594
15971595 Unit totalUnit = null ;
1598- String totalUnitsStr = null ;
1596+ String totalUnitsStr ;
15991597 if (!StringUtils .isEmpty (sampleTypeUnitsStr ))
16001598 totalUnitsStr = sampleTypeUnitsStr ;
16011599 else if (!StringUtils .isEmpty (sampleItemUnitsStr ))
@@ -1915,9 +1913,7 @@ public Map<String, Integer> moveSamples(Collection<? extends ExpMaterial> sample
19151913 if (inventoryService != null )
19161914 {
19171915 Map <String , Integer > inventoryCounts = inventoryService .moveSamples (sampleIds , targetContainer , user );
1918- inventoryCounts .forEach ((key , count ) -> {
1919- updateCounts .compute (key , (k , c ) -> c == null ? count : c + count );
1920- });
1916+ inventoryCounts .forEach ((key , count ) -> updateCounts .compute (key , (k , c ) -> c == null ? count : c + count ));
19211917 }
19221918
19231919 // create summary audit entries for the source and target containers
@@ -2264,7 +2260,6 @@ private void deleteSampleCounterSequence(Container container, boolean isRootOnly
22642260 Container seqContainer = container .getProject ();
22652261 DbSequenceManager .delete (seqContainer , seqName );
22662262 DbSequenceManager .invalidatePreallocatingSequence (container , seqName , 0 );
2267- return ;
22682263 }
22692264
22702265 @ Override
0 commit comments