From 85d155bf4277fa340a5590bf56067f75b9ca431a Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Sat, 9 May 2026 11:28:42 -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 --- .../nirc_ehr/NIRCOrchardFileGenerator.java | 2 +- .../buttons/MarkTreatmentCompletedButton.java | 2 +- .../CagematesDemographicsProvider.java | 8 ++-- .../notification/NIRCDeathNotification.java | 6 --- .../NIRCPregnancyOutcomeNotification.java | 6 --- .../nirc_ehr/query/NIRC_EHRTriggerHelper.java | 46 +++++++++---------- .../table/NIRC_EHRSharedDatasetTrigger.java | 4 +- .../table/NIRC_EHRTriggerScriptFactory.java | 2 +- 8 files changed, 31 insertions(+), 45 deletions(-) diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/NIRCOrchardFileGenerator.java b/nirc_ehr/src/org/labkey/nirc_ehr/NIRCOrchardFileGenerator.java index 6d7ba620..cce21677 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/NIRCOrchardFileGenerator.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/NIRCOrchardFileGenerator.java @@ -86,7 +86,7 @@ public void run() if (orchardFileLocation == null) { // Don't run if we don't have a location to write the file - _log.warn("Orchard file location is null, cannot generate Orchard file for taskid: " + taskid); + _log.warn("Orchard file location is null, cannot generate Orchard file for taskid: {}", taskid); return; } diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/buttons/MarkTreatmentCompletedButton.java b/nirc_ehr/src/org/labkey/nirc_ehr/buttons/MarkTreatmentCompletedButton.java index 42c9c081..3e6ab9e9 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/buttons/MarkTreatmentCompletedButton.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/buttons/MarkTreatmentCompletedButton.java @@ -33,7 +33,7 @@ protected String getJsHandler(TableInfo ti) String pkColName = null; if (ti.getPkColumnNames() != null && ti.getPkColumnNames().size() == 1) { - pkColName = ti.getPkColumnNames().get(0); + pkColName = ti.getPkColumnNames().getFirst(); } return "NIRC_EHR.window.MarkTreatmentCompletedWindow.buttonHandler(dataRegionName, " + PageFlowUtil.jsString(_schemaName) + ", " + PageFlowUtil.jsString(_queryName) + ", " + PageFlowUtil.jsString(xtype) + ", " + PageFlowUtil.jsString(pkColName) + ");"; diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/demographics/CagematesDemographicsProvider.java b/nirc_ehr/src/org/labkey/nirc_ehr/demographics/CagematesDemographicsProvider.java index 9c3fab8a..c0479886 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/demographics/CagematesDemographicsProvider.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/demographics/CagematesDemographicsProvider.java @@ -45,8 +45,8 @@ public Set getIdsToUpdate(Container c, String id, Map or List> newList = newProps == null ? null : (List)newProps.get(_propName); Set ret = new TreeSet<>(); - List oldAnimals = oldList == null || oldList.isEmpty() ? Collections.emptyList() : toList(oldList.get(0).get("animals")); - List newAnimals = newList == null || newList.isEmpty() ? Collections.emptyList() : toList(newList.get(0).get("animals")); + List oldAnimals = oldList == null || oldList.isEmpty() ? Collections.emptyList() : toList(oldList.getFirst().get("animals")); + List newAnimals = newList == null || newList.isEmpty() ? Collections.emptyList() : toList(newList.getFirst().get("animals")); ret.addAll(newAnimals); ret.addAll(oldAnimals); @@ -54,7 +54,7 @@ public Set getIdsToUpdate(Container c, String id, Map or if (!ret.isEmpty()) { - _log.info(id + ": Triggered additional housing updates for " + ret.size() + " ids: " + StringUtils.join(ret, ";")); + _log.info("{}: Triggered additional housing updates for {} ids: {}", id, ret.size(), StringUtils.join(ret, ";")); } return ret; @@ -75,7 +75,7 @@ else if (input instanceof String) } else { - _log.error("Unknown type: " + input.getClass().getName() + ", " + input); + _log.error("Unknown type: {}, {}", input.getClass().getName(), input); return Collections.emptyList(); } } diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCDeathNotification.java b/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCDeathNotification.java index 6603d94c..7e4961c7 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCDeathNotification.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCDeathNotification.java @@ -46,12 +46,6 @@ public String getEmailSubject(Container c) return "Death Alert " + getDateTimeFormat(c).format(new Date()); } - @Override - public String getCronString() - { - return null; - } - @Override public String getScheduleDescription() { diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCPregnancyOutcomeNotification.java b/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCPregnancyOutcomeNotification.java index 1913b489..3486d12f 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCPregnancyOutcomeNotification.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCPregnancyOutcomeNotification.java @@ -46,12 +46,6 @@ public String getEmailSubject(Container c) return "Pregnancy Outcome Alert " + getDateTimeFormat(c).format(new Date()); } - @Override - public String getCronString() - { - return null; - } - @Override public String getScheduleDescription() { diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/query/NIRC_EHRTriggerHelper.java b/nirc_ehr/src/org/labkey/nirc_ehr/query/NIRC_EHRTriggerHelper.java index 74bd1adf..e3070eca 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/query/NIRC_EHRTriggerHelper.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/query/NIRC_EHRTriggerHelper.java @@ -146,7 +146,7 @@ else if (enddate == null || enddate.after(deathDate)) TableSelector ts = new TableSelector(ti, PageFlowUtil.set("date"), nextFilter, new Sort("date")); List dates = ts.getArrayList(Date.class); if (!dates.isEmpty()) - enddate = dates.get(0); + enddate = dates.getFirst(); } String qcstate = ConvertHelper.convert(row.get("qcstate"), String.class); @@ -383,8 +383,8 @@ public void clinicalMoveNotification(final String animalId, final String date) return; } - String remark = (String) EHRDemographicsService.get().getAnimal(container, animalId).getActiveHousing().get(0).get("remark"); - String performedBy = (String) EHRDemographicsService.get().getAnimal(container, animalId).getActiveHousing().get(0).get("performedBy"); + String remark = (String) EHRDemographicsService.get().getAnimal(container, animalId).getActiveHousing().getFirst().get("remark"); + String performedBy = (String) EHRDemographicsService.get().getAnimal(container, animalId).getActiveHousing().getFirst().get("performedBy"); //construct html for email notification final StringBuilder html = new StringBuilder(); @@ -396,7 +396,7 @@ public void clinicalMoveNotification(final String animalId, final String date) appendAnimalDetails(html, animalId, container); // send Clinical Move Notification - _log.debug("NIRC Clinical Move notification job sending email for animal " + animalId + " in container " + container.getPath()); + _log.debug("NIRC Clinical Move notification job sending email for animal {} in container {}", animalId, container.getPath()); TriggerScriptNotification.sendMessage(subject, html.toString(), recipients, container, user); }), DbScope.CommitTaskOption.POSTCOMMIT); @@ -404,7 +404,7 @@ public void clinicalMoveNotification(final String animalId, final String date) } } - public void sendDeathNotification(final String animalId) throws Exception + public void sendDeathNotification(final String animalId) { //check whether Death Notification is enabled if (!NotificationService.get().isActive(new NIRCDeathNotification(), _container) || !NotificationService.get().isServiceEnabled()) @@ -450,28 +450,28 @@ public void sendDeathNotification(final String animalId) throws Exception //construct html for email notification final StringBuilder html = new StringBuilder(); - if (deathDate.getValue() == null) + if (deathDate.get() == null) { - _log.error("NIRC death notification job found no death date for animal " + animalId + " in container " + _container.getPath()); + _log.error("NIRC death notification job found no death date for animal {} in container {}", animalId, _container.getPath()); html.append("Death date not found. Please contact system administrator.").append("
"); return; } - html.append("Animal '").append(PageFlowUtil.filter(animalId)).append("' has been declared dead on '").append(_dateFormat.format(deathDate.getValue())).append("'.
"); - html.append("Performed By: ").append(PageFlowUtil.filter(performedBy.getValue())).append("
"); - html.append("Disposition: ").append(PageFlowUtil.filter(disposition.getValue())).append("

"); + html.append("Animal '").append(PageFlowUtil.filter(animalId)).append("' has been declared dead on '").append(_dateFormat.format(deathDate.get())).append("'.
"); + html.append("Performed By: ").append(PageFlowUtil.filter(performedBy.get())).append("
"); + html.append("Disposition: ").append(PageFlowUtil.filter(disposition.get())).append("

"); //append animal details appendAnimalDetails(html, animalId, container); //append link to Necropsy form String url = AppProps.getInstance().getBaseServerUrl() + AppProps.getInstance().getContextPath() + "/ehr" + - container.getPath() + "/dataEntryForm.view?formType=Necropsy&taskid=" + taskId.getValue(); + container.getPath() + "/dataEntryForm.view?formType=Necropsy&taskid=" + taskId.get(); html.append(""); html.append("Click here to record Necropsy
"); // send Death Notification - _log.debug("NIRC Death notification job sending email for animal " + animalId + " in container " + container.getPath()); + _log.debug("NIRC Death notification job sending email for animal {} in container {}", animalId, container.getPath()); TriggerScriptNotification.sendMessage(subject, html.toString(), recipients, container, user); }), DbScope.CommitTaskOption.POSTCOMMIT); @@ -479,7 +479,7 @@ public void sendDeathNotification(final String animalId) throws Exception } } - public void generateOrchardFile(final String taskid) throws Exception + public void generateOrchardFile(final String taskid) { NIRCOrchardFileGenerator orchardFileGenerator = NIRC_EHRManager.getOrchardFileGenerator(); orchardFileGenerator.generateOrchardFile(_container, _user, taskid); @@ -500,7 +500,7 @@ private void appendAnimalDetails(StringBuilder html, String id, final Container List> activeHousing = EHRDemographicsService.get().getAnimal(container, id).getActiveHousing(); if (null != activeHousing && !activeHousing.isEmpty()) { - cage = (String) activeHousing.get(0).get("cage/cage"); + cage = (String) activeHousing.getFirst().get("cage/cage"); } else { @@ -524,10 +524,8 @@ private String getProject(String id) SimpleFilter filter = new SimpleFilter(FieldKey.fromString("Id"), id); TableSelector ts = new TableSelector(ti, PageFlowUtil.set("project"), filter, null); final Mutable project = new MutableObject<>(); - ts.forEach(rs -> { - project.setValue(rs.getString("project")); - }); - return project.getValue(); + ts.forEach(rs -> project.setValue(rs.getString("project"))); + return project.get(); } private String getProtocol(String id) @@ -557,7 +555,7 @@ private String getProtocol(String id) protocol.setValue(title + (inves == null ? "" : " - " + inves)); } }); - return protocol.getValue(); + return protocol.get(); } public String createAssignmentRecord(String dataset, String id, Map row) throws SQLException, BatchValidationException, QueryUpdateServiceException, InvalidKeyException, DuplicateKeyException @@ -682,7 +680,7 @@ public boolean canCloseCase(String category) return false; } - public void closeDailyClinicalObs(String caseid, String enddate) throws SQLException + public void closeDailyClinicalObs(String caseid, String enddate) { TableInfo ti = getTableInfo("study", "observation_order"); SimpleFilter filter = new SimpleFilter(FieldKey.fromString("caseid"), caseid); @@ -708,7 +706,7 @@ public void closeDailyClinicalObs(String caseid, String enddate) throws SQLExcep } } - public void ensureDailyClinicalObservationOrders(String id, String caseid, final Date date, String performedby, String qcstate, String taskid, List> ordersInTransaction) throws SQLException + public void ensureDailyClinicalObservationOrders(String id, String caseid, final Date date, String performedby, String qcstate, String taskid, List> ordersInTransaction) { TableInfo ti = getTableInfo("study", "observation_order"); SimpleFilter filter = new SimpleFilter(FieldKey.fromParts("category","value"), "Activity"); @@ -898,7 +896,7 @@ public boolean isProcedureOrderEntered(String orderid) TableInfo ti = getTableInfo("study", "prc_order"); SimpleFilter filter = new SimpleFilter(FieldKey.fromString("objectid"), orderid); TableSelector ts = new TableSelector(ti, PageFlowUtil.set("qcstate"), filter, null); - Integer qcstate = ts.getArrayList(Integer.class).get(0); + Integer qcstate = ts.getArrayList(Integer.class).getFirst(); if (EHRService.get().getQCStates(_container).get("Completed").getRowId() == qcstate) return true; @@ -967,7 +965,7 @@ public void updateProcedureOrdersToCompleted(List ids) try { ti.getUpdateService().updateRows(_user, _container, rows, null, null, getExtraContext()); - _log.info("Successfully updated " + rows.size() + " prc_order rows to 'Completed' status"); + _log.info("Successfully updated {} prc_order rows to 'Completed' status", rows.size()); } catch (Exception e) { @@ -1023,7 +1021,7 @@ public void sendPregnancyOutcomeNotification(final String animalId, Map ne } @Override - public void beforeInsert(TableInfo table, Container c, User user, @Nullable QueryUpdateService.InsertOption insertOption, @Nullable Map newRow, ValidationException errors, Map extraContext) throws ValidationException + public void beforeInsert(TableInfo table, Container c, User user, @Nullable QueryUpdateService.InsertOption insertOption, @Nullable Map newRow, ValidationException errors, Map extraContext) { transformAnimalIdToUpperCase(newRow); verifyPerformedBy(table, newRow, errors); @@ -44,7 +44,7 @@ public void beforeInsert(TableInfo table, Container c, User user, @Nullable Quer @Override public void beforeUpdate(TableInfo table, Container c, User user, @Nullable QueryUpdateService.InsertOption insertOption, @Nullable Map newRow, @Nullable Map oldRow, - ValidationException errors, Map extraContext) throws ValidationException + ValidationException errors, Map extraContext) { verifyPerformedBy(table, newRow, errors); } diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/table/NIRC_EHRTriggerScriptFactory.java b/nirc_ehr/src/org/labkey/nirc_ehr/table/NIRC_EHRTriggerScriptFactory.java index c8430640..841df98f 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/table/NIRC_EHRTriggerScriptFactory.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/table/NIRC_EHRTriggerScriptFactory.java @@ -14,7 +14,7 @@ public class NIRC_EHRTriggerScriptFactory extends ScriptTriggerFactory { @Override @NotNull - protected Collection createTriggerScript(Container c, TableInfo table) throws ScriptException + protected Collection createTriggerScript(@NotNull Container c, TableInfo table) throws ScriptException { return Collections.singleton(new NIRC_EHRSharedDatasetTrigger()); }