From 9ad73249dbfa99b14074d32f9fa1c7179d878ae2 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Tue, 15 Sep 2026 12:12:15 -0700 Subject: [PATCH] Make `PrecursorKey` serializable for ehCache compatibility --- .../spectrum/LibrarySpectrumMatchGetter.java | 49 ++----------------- 1 file changed, 4 insertions(+), 45 deletions(-) diff --git a/src/org/labkey/targetedms/view/spectrum/LibrarySpectrumMatchGetter.java b/src/org/labkey/targetedms/view/spectrum/LibrarySpectrumMatchGetter.java index 94ea34f17..b81cfe75f 100644 --- a/src/org/labkey/targetedms/view/spectrum/LibrarySpectrumMatchGetter.java +++ b/src/org/labkey/targetedms/view/spectrum/LibrarySpectrumMatchGetter.java @@ -45,6 +45,7 @@ import org.labkey.targetedms.query.PrecursorManager; import java.io.IOException; +import java.io.Serializable; import java.nio.file.Files; import java.nio.file.Path; import java.sql.SQLException; @@ -128,7 +129,7 @@ private static boolean isLargeSpectrumLibrary(Path libPath) { throw new IllegalStateException("Expected Container argument in PeptideIdRts cache."); } - TargetedMSRun run = TargetedMSManager.getRunForGeneralMolecule(precursor.getGeneralMoleculeId()); + TargetedMSRun run = TargetedMSManager.getRunForGeneralMolecule(precursor.generalMoleculeId()); // Get the spectrum libraries for this run Map libraryFilePathsMap = LibraryManager.getLibraryFilePaths(run.getId()); @@ -140,7 +141,7 @@ private static boolean isLargeSpectrumLibrary(Path libPath) if(reader != null) { List rtInfos = reader.getRetentionTimes((Container) argument, - libPath, precursor.getModifiedSequence()); + libPath, precursor.modifiedSequence()); if (!rtInfos.isEmpty()) { @@ -359,49 +360,7 @@ public static List getUnsupportedLibraries(TargetedMSRun run) return unsupportedLibs; } - private static class PrecursorKey - { - private final String _modifiedSequence; - private final long _generalMoleculeId; - - - private PrecursorKey(String modifiedSequence, long generalMoleculeId) - { - _modifiedSequence = modifiedSequence; - _generalMoleculeId = generalMoleculeId; - } - - public String getModifiedSequence() - { - return _modifiedSequence; - } - - public long getGeneralMoleculeId() - { - return _generalMoleculeId; - } - - @Override - public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - PrecursorKey that = (PrecursorKey) o; - - if (_generalMoleculeId != that._generalMoleculeId) return false; - return _modifiedSequence.equals(that._modifiedSequence); - - } - - @Override - public int hashCode() - { - int result = _modifiedSequence.hashCode(); - result = (int) (31 * result + _generalMoleculeId); - return result; - } - } + private record PrecursorKey(String modifiedSequence, long generalMoleculeId) implements Serializable { } public static class PeptideIdRtInfo {