From 62c7e8833f33535368ac3e49a6b971adb12cc0b4 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Sat, 9 May 2026 11:28:44 -0700 Subject: [PATCH] Auto-refactor lint cleanup SequencedCollections: get(0) -> getFirst(), etc Add missing @NotNull/@Nullable Simplify test assertions Map operation simplification Remove redundant throws clause Switch to parameterized log message C-style array -> Java-style array declaration Delete overridden methods identical to parent Switch statement -> enhanced switch statement Remove redundant imports --- .../MS2ExtensionsController.java | 2 +- .../ms2extensions/PeptideCountUpdater.java | 6 +-- .../atlas/pepdb/PepDBBaseController.java | 3 +- .../atlas/pepdb/PepDBContainerListener.java | 53 ------------------- .../scharp/atlas/pepdb/PepDBController.java | 53 +++++++------------ .../org/scharp/atlas/pepdb/PepDBManager.java | 9 ++-- .../org/scharp/atlas/pepdb/PepDBModule.java | 3 -- .../scharp/atlas/pepdb/PeptideImporter.java | 15 +++--- .../org/scharp/atlas/pepdb/PoolImporter.java | 15 +++--- .../test/tests/pepdb/PepDBModuleTest.java | 2 +- .../studydesign/StudyDesignController.java | 4 +- .../studydesign/model/TreatmentManager.java | 14 ++--- 12 files changed, 52 insertions(+), 127 deletions(-) delete mode 100644 pepdb/src/org/scharp/atlas/pepdb/PepDBContainerListener.java diff --git a/ms2extensions/src/org/labkey/ms2extensions/MS2ExtensionsController.java b/ms2extensions/src/org/labkey/ms2extensions/MS2ExtensionsController.java index b1278a8e..3f72e64f 100644 --- a/ms2extensions/src/org/labkey/ms2extensions/MS2ExtensionsController.java +++ b/ms2extensions/src/org/labkey/ms2extensions/MS2ExtensionsController.java @@ -110,7 +110,7 @@ public ModelAndView getView(Object o, BindException errors) return new HtmlView(DOM.DIV("Success!")); } - warnings.add(0, DOM.DIV("Success, with warnings:")); + warnings.addFirst(DOM.DIV("Success, with warnings:")); return new HtmlView(DOM.DIV(warnings.toArray(new Object[0]))); } return new HtmlView(DOM.LK.FORM( diff --git a/ms2extensions/src/org/labkey/ms2extensions/PeptideCountUpdater.java b/ms2extensions/src/org/labkey/ms2extensions/PeptideCountUpdater.java index 6207590d..ebbc2480 100644 --- a/ms2extensions/src/org/labkey/ms2extensions/PeptideCountUpdater.java +++ b/ms2extensions/src/org/labkey/ms2extensions/PeptideCountUpdater.java @@ -106,14 +106,14 @@ public String update(Container container, User user) } // Only allow one thread to update at a time - LOG.info("Starting to update peptide counts for " + runIds); + LOG.info("Starting to update peptide counts for {}", runIds); try (DbScope.Transaction transaction = MS2ExtensionsModule.getSchema().getScope().ensureTransaction(LOCK)) { // Execute the query, filtering to just the runs that need aggregates calculated SimpleFilter filter = new SimpleFilter(new SimpleFilter.InClause(ms2RunColumn.getFieldKey(), runIds)); Collection> results = new TableSelector(table, Arrays.asList(ms2RunColumn, totalPeptidesColumn, distinctPeptidesColumn), filter, null).getMapCollection(); - LOG.info("Inserting peptide counts for " + runIds); + LOG.info("Inserting peptide counts for {}", runIds); // Iterate through the results and insert them into the table so they're cached and fast to show for (Map result : results) @@ -123,7 +123,7 @@ public String update(Container container, User user) Table.insert(null, MS2ExtensionsModule.getSchema().getTable("Ms2RunAggregates"), toInsert); } transaction.commit(); - LOG.info("Finished updating peptide counts for " + runIds); + LOG.info("Finished updating peptide counts for {}", runIds); } } return null; diff --git a/pepdb/src/org/scharp/atlas/pepdb/PepDBBaseController.java b/pepdb/src/org/scharp/atlas/pepdb/PepDBBaseController.java index 5a604b4a..81c0f5d5 100644 --- a/pepdb/src/org/scharp/atlas/pepdb/PepDBBaseController.java +++ b/pepdb/src/org/scharp/atlas/pepdb/PepDBBaseController.java @@ -26,7 +26,6 @@ import org.scharp.atlas.pepdb.model.ProteinCategory; import org.springframework.validation.Errors; -import java.sql.SQLException; import java.util.List; import java.util.Map; @@ -376,7 +375,7 @@ public void validate(Errors errors) errors.reject(null, "Peptide Group Name is required."); } - public void validateName(Errors errors) throws SQLException + public void validateName(Errors errors) { PeptideGroup bean = getBean(); PeptideGroup pg = PepDBManager.getPeptideGroupByName(bean); diff --git a/pepdb/src/org/scharp/atlas/pepdb/PepDBContainerListener.java b/pepdb/src/org/scharp/atlas/pepdb/PepDBContainerListener.java deleted file mode 100644 index 88027139..00000000 --- a/pepdb/src/org/scharp/atlas/pepdb/PepDBContainerListener.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.scharp.atlas.pepdb; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.NotNull; -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerManager.ContainerListener; -import org.labkey.api.security.User; - -import java.beans.PropertyChangeEvent; -import java.util.Collection; -import java.util.Collections; - -/** - * Created by IntelliJ IDEA. - * User: sravani - * Date: Mar 16, 2009 - * Time: 10:18:45 AM - * To change this template use File | Settings | File Templates. - */ -public class PepDBContainerListener implements ContainerListener -{ - - private static final Logger _log = LogManager.getLogger(PepDBContainerListener.class); - - @Override - public void containerCreated(Container c, User user) - { - } - - @Override - public void containerDeleted(Container c, User user) - { - } - - @Override - public void containerMoved(Container c, Container oldParent, User user) - { - } - - @NotNull - @Override - public Collection canMove(Container c, Container newParent, User user) - { - return Collections.emptyList(); - } - - @Override - public void propertyChange(PropertyChangeEvent evt) - { - } - -} diff --git a/pepdb/src/org/scharp/atlas/pepdb/PepDBController.java b/pepdb/src/org/scharp/atlas/pepdb/PepDBController.java index ace2b6a4..243c840d 100644 --- a/pepdb/src/org/scharp/atlas/pepdb/PepDBController.java +++ b/pepdb/src/org/scharp/atlas/pepdb/PepDBController.java @@ -49,7 +49,6 @@ import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.Controller; -import java.sql.SQLException; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -223,7 +222,7 @@ public ModelAndView getView(DisplayPeptideForm form, BindException errors) throw errors.reject(null, "Peptide Id not found in the database."); return new JspView<>(PAGE_INDEX, form, errors); } - _log.debug("DisplayPeptideForm: " + form); + _log.debug("DisplayPeptideForm: {}", form); VBox box = new VBox(); PeptideQueryForm queryform = new PeptideQueryForm(); queryform.setQueryValue(pepId); @@ -419,7 +418,7 @@ public class DisplayPeptideGroupInformationAction extends SimpleViewAction optimalElitopeListMap; ArrayList peptideIdList; - public HashMap getPeptideGroupMap() throws SQLException + public HashMap getPeptideGroupMap() { if(peptideGroupMap == null) peptideGroupMap = PepDBManager.getPeptideGroupMap(); @@ -44,7 +43,7 @@ public void setPeptideGroupMap(HashMap peptideGroupMap) this.peptideGroupMap = peptideGroupMap; } - public HashMap getProteinCategoryMap() throws SQLException + public HashMap getProteinCategoryMap() { if(proteinCategoryMap == null) proteinCategoryMap = PepDBManager.getProteinCatMap(); @@ -56,7 +55,7 @@ public void setProteinCategoryMap(HashMap proteinCatego this.proteinCategoryMap = proteinCategoryMap; } - public HashMap getProteinCatIDMap() throws SQLException + public HashMap getProteinCatIDMap() { if(proteinCatIDMap == null) proteinCatIDMap = PepDBManager.getProteinCatIDMap(); @@ -68,7 +67,7 @@ public void setProteinCatIDMap(HashMap proteinCatIDMap this.proteinCatIDMap = proteinCatIDMap; } - public HashMap getOptimalElitopeListMap() throws SQLException + public HashMap getOptimalElitopeListMap() { if(optimalElitopeListMap == null) optimalElitopeListMap = PepDBManager.getOptimalEpitopeListMap(); @@ -80,7 +79,7 @@ public void setOptimalElitopeListMap(HashMap optimal this.optimalElitopeListMap = optimalElitopeListMap; } - public ArrayList getPeptideIdList() throws SQLException + public ArrayList getPeptideIdList() { if(peptideIdList == null) { @@ -99,7 +98,7 @@ public void setPeptideIdList(ArrayList peptideIdList) this.peptideIdList = peptideIdList; } - public boolean process(User user, AttachmentFile peptideFile, Errors errors, List resultPeptides) throws SQLException + public boolean process(User user, AttachmentFile peptideFile, Errors errors, List resultPeptides) { try{ String fileName = peptideFile.getFilename(); @@ -269,7 +268,7 @@ && validateInteger(fields[7].trim()) < validateInteger(fields[6].trim())) return true; } - private Peptides createPeptide(String line,String fileName) throws SQLException + private Peptides createPeptide(String line,String fileName) { String [] fields = new String[10]; for(int i =0;i poolTypeMap; private HashMap peptideSequenceMap; private HashMap peptideGroupMap; - public HashMap getPeptidePoolMap() throws SQLException + public HashMap getPeptidePoolMap() { if(peptidePoolMap == null) peptidePoolMap = PepDBManager.getPeptidePoolMap(); @@ -43,7 +42,7 @@ public void setPeptidePoolMap(HashMap peptidePoolMap) this.peptidePoolMap = peptidePoolMap; } - public HashMap getPoolTypeMap() throws SQLException + public HashMap getPoolTypeMap() { if(poolTypeMap == null) poolTypeMap = PepDBManager.getPoolTypeMap(); @@ -55,7 +54,7 @@ public void setPoolTypeMap(HashMap poolTypeMap) this.poolTypeMap = poolTypeMap; } - public HashMap getPeptideSequenceMap() throws SQLException + public HashMap getPeptideSequenceMap() { if(peptideSequenceMap == null) peptideSequenceMap = PepDBManager.getPeptideSequenceMap(); @@ -67,7 +66,7 @@ public void setPeptideSequenceMap(HashMap peptideSequenceMap) this.peptideSequenceMap = peptideSequenceMap; } - public HashMap getPeptideGroupMap() throws SQLException + public HashMap getPeptideGroupMap() { if(peptideGroupMap == null) peptideGroupMap = PepDBManager.getPeptideGroupMap(); @@ -79,7 +78,7 @@ public void setPeptideGroupMap(HashMap peptideGroupMap) this.peptideGroupMap = peptideGroupMap; } - public boolean process(User user, FileForm form, AttachmentFile poolFile,Errors errors) throws SQLException + public boolean process(User user, FileForm form, AttachmentFile poolFile,Errors errors) { String actionType = form.getActionType(); PeptidePool [] peptidePools = PepDBManager.getPeptidePools(); @@ -195,7 +194,7 @@ public boolean process(User user, FileForm form, AttachmentFile poolFile,Errors return true; } - private PeptidePoolAssignment createPoolAssignment(String line) throws SQLException + private PeptidePoolAssignment createPoolAssignment(String line) { String [] fields = new String[3]; for(int i =0;i> newPoolPeptides) throws SQLException + private boolean validatePPLine(String line,Errors errors,int lineNo,HashMap> newPoolPeptides) { String [] fields = new String[3]; for(int i =0;i 0) { - Row convertedRow = new RowMap(selectResp.getRows().get(0)); + Row convertedRow = new RowMap(selectResp.getRows().getFirst()); peptideStartIndex = ((int) convertedRow.getValue("peptide_id")) - 1; } } diff --git a/studydesign/src/org/labkey/studydesign/StudyDesignController.java b/studydesign/src/org/labkey/studydesign/StudyDesignController.java index 12b5224a..b3b15ecd 100644 --- a/studydesign/src/org/labkey/studydesign/StudyDesignController.java +++ b/studydesign/src/org/labkey/studydesign/StudyDesignController.java @@ -324,8 +324,8 @@ public ApiResponse execute(GetStudyTreatmentsForm form, BindException errors) List products = TreatmentManager.getInstance().getStudyProducts(getContainer(), getUser(), null, treatmentProduct.getProductId()); if (products.size() == 1) { - treatmentProductProperties.put("ProductId/Label", products.get(0).getLabel()); - treatmentProductProperties.put("ProductId/Role", products.get(0).getRole()); + treatmentProductProperties.put("ProductId/Label", products.getFirst().getLabel()); + treatmentProductProperties.put("ProductId/Role", products.getFirst().getRole()); } treatmentProductList.add(treatmentProductProperties); diff --git a/studydesign/src/org/labkey/studydesign/model/TreatmentManager.java b/studydesign/src/org/labkey/studydesign/model/TreatmentManager.java index 34637a8c..053d28c3 100644 --- a/studydesign/src/org/labkey/studydesign/model/TreatmentManager.java +++ b/studydesign/src/org/labkey/studydesign/model/TreatmentManager.java @@ -458,7 +458,7 @@ public Integer saveStudyDesignRow(Container container, User user, TableInfo tabl throw errors.getLastRowError(); if (updatedRows.size() == 1) - return asInteger(updatedRows.get(0).get(pkColName)); + return asInteger(updatedRows.getFirst().get(pkColName)); } return null; @@ -717,11 +717,11 @@ public void test() throws Throwable private void verifyCleanUpTreatmentData() throws Exception { // remove cohort and verify delete of TreatmentVisitMap - CohortService.get().deleteCohort(_cohorts.get(0)); + CohortService.get().deleteCohort(_cohorts.getFirst()); verifyTreatmentVisitMapRecords(4); // remove visit and verify delete of TreatmentVisitMap - VisitService.get().deleteVisit(_junitStudy, _user, _visits.get(0)); + VisitService.get().deleteVisit(_junitStudy, _user, _visits.getFirst()); verifyTreatmentVisitMapRecords(2); // we should still have all of our treatments and study products @@ -738,7 +738,7 @@ private void verifyCleanUpTreatmentData() throws Exception verifyTreatmentProductMapRecords(_treatments.get(1).getRowId(), 4); // remove product and verify delete of TreatmentProductMap and ProductAntigen - _manager.deleteStudyProduct(_container, _user, _products.get(0).getRowId()); + _manager.deleteStudyProduct(_container, _user, _products.getFirst().getRowId()); verifyTreatmentProductMapRecords(_treatments.get(1).getRowId(), 3); verifyStudyProductAntigens(_products.get(0).getRowId(), 0); verifyStudyProductAntigens(_products.get(1).getRowId(), 1); @@ -1030,14 +1030,14 @@ public void test() private void verifyCleanUpAssayConfigurations() { - StudyDesignService.get().deleteAssaySpecimenVisits(_container, _visits.get(0).getId()); + StudyDesignService.get().deleteAssaySpecimenVisits(_container, _visits.getFirst().getId()); verifyAssayScheduleRowCount(2); - assertEquals(1, TreatmentManager.getInstance().getAssaySpecimenVisitIds(_container, _assays.get(0)).size()); + assertEquals(1, TreatmentManager.getInstance().getAssaySpecimenVisitIds(_container, _assays.getFirst()).size()); assertEquals(1, TreatmentManager.getInstance().getVisitsForAssaySchedule(_container).size()); StudyDesignService.get().deleteAssaySpecimenVisits(_container, _visits.get(1).getId()); verifyAssayScheduleRowCount(0); - assertEquals(0, TreatmentManager.getInstance().getAssaySpecimenVisitIds(_container, _assays.get(0)).size()); + assertEquals(0, TreatmentManager.getInstance().getAssaySpecimenVisitIds(_container, _assays.getFirst()).size()); assertEquals(0, TreatmentManager.getInstance().getVisitsForAssaySchedule(_container).size()); }