diff --git a/EHR_App/test/src/org/labkey/test/tests/EHR_AppTest.java b/EHR_App/test/src/org/labkey/test/tests/EHR_AppTest.java index 9fbc39ffa..f9d1e9151 100644 --- a/EHR_App/test/src/org/labkey/test/tests/EHR_AppTest.java +++ b/EHR_App/test/src/org/labkey/test/tests/EHR_AppTest.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.labkey.test.components.html.Input.Input; @@ -115,12 +116,6 @@ private void doSetup() throws Exception goToEHRFolder(); } - @Override - public BrowserType bestBrowser() - { - return BrowserType.CHROME; - } - @Override protected String getModuleDirectory() { @@ -591,8 +586,7 @@ private void assertDemographicsNoRowsHaveStatus(ReactAnimalHistoryPage page, Str List statusValues = table.getColumnDataAsText("calculated_status"); for (String status : statusValues) { - assertFalse("Demographics should not contain status '" + excludedStatus + "' but found it", - status.equals(excludedStatus)); + assertNotEquals("Demographics should not contain status '" + excludedStatus + "' but found it", status, excludedStatus); } } } diff --git a/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/model/EHRComplianceDBDomainKind.java b/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/model/EHRComplianceDBDomainKind.java index e99f4860c..034ac2df8 100644 --- a/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/model/EHRComplianceDBDomainKind.java +++ b/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/model/EHRComplianceDBDomainKind.java @@ -1,5 +1,6 @@ package org.labkey.ehr_compliancedb.model; +import org.jetbrains.annotations.NotNull; import org.labkey.api.data.Container; import org.labkey.api.exp.property.Domain; import org.labkey.api.gwt.client.model.GWTPropertyDescriptor; @@ -42,7 +43,7 @@ public String getKindName() } @Override - public Set getReservedPropertyNames(Domain domain, User user) + public @NotNull Set getReservedPropertyNames(Domain domain, User user) { return super.getReservedPropertyNames(domain, user); } diff --git a/EHR_Purchasing/src/org/labkey/ehr_purchasing/EHR_PurchasingContainerListener.java b/EHR_Purchasing/src/org/labkey/ehr_purchasing/EHR_PurchasingContainerListener.java index 335d26c8a..045bd6a8d 100644 --- a/EHR_Purchasing/src/org/labkey/ehr_purchasing/EHR_PurchasingContainerListener.java +++ b/EHR_Purchasing/src/org/labkey/ehr_purchasing/EHR_PurchasingContainerListener.java @@ -16,7 +16,6 @@ package org.labkey.ehr_purchasing; -import org.jetbrains.annotations.NotNull; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager.ContainerListener; import org.labkey.api.data.DbScope; @@ -25,16 +24,8 @@ import org.labkey.api.data.TableInfo; import org.labkey.api.security.User; -import java.beans.PropertyChangeEvent; -import java.util.Collection; -import java.util.Collections; - public class EHR_PurchasingContainerListener implements ContainerListener { - @Override - public void containerCreated(Container c, User user) - { - } @Override public void containerDeleted(Container c, User user) @@ -68,20 +59,4 @@ public void containerDeleted(Container c, User user) transaction.commit(); } } - - @Override - public void propertyChange(PropertyChangeEvent evt) - { - } - - @Override - public void containerMoved(Container c, Container oldParent, User user) - { - } - - @NotNull @Override - public Collection canMove(Container c, Container newParent, User user) - { - return Collections.emptyList(); - } } \ No newline at end of file diff --git a/EHR_SM/src/org/labkey/ehr_sm/EHR_SMContainerListener.java b/EHR_SM/src/org/labkey/ehr_sm/EHR_SMContainerListener.java index 99effbd0b..5bbdf6541 100644 --- a/EHR_SM/src/org/labkey/ehr_sm/EHR_SMContainerListener.java +++ b/EHR_SM/src/org/labkey/ehr_sm/EHR_SMContainerListener.java @@ -16,22 +16,13 @@ package org.labkey.ehr_sm; -import org.jetbrains.annotations.NotNull; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager.ContainerListener; import org.labkey.api.data.PropertyManager; import org.labkey.api.security.User; -import java.util.Collections; -import java.util.Collection; - -import java.beans.PropertyChangeEvent; public class EHR_SMContainerListener implements ContainerListener { - @Override - public void containerCreated(Container c, User user) - { - } @Override public void containerDeleted(Container c, User user) @@ -39,19 +30,4 @@ public void containerDeleted(Container c, User user) PropertyManager.purgeObjectProperties(c); } - @Override - public void propertyChange(PropertyChangeEvent evt) - { - } - - @Override - public void containerMoved(Container c, Container oldParent, User user) - { - } - - @NotNull @Override - public Collection canMove(Container c, Container newParent, User user) - { - return Collections.emptyList(); - } } \ No newline at end of file diff --git a/EHR_SM/src/org/labkey/ehr_sm/EHR_SMCustomizer.java b/EHR_SM/src/org/labkey/ehr_sm/EHR_SMCustomizer.java index 0d7127ef4..ed76a003a 100644 --- a/EHR_SM/src/org/labkey/ehr_sm/EHR_SMCustomizer.java +++ b/EHR_SM/src/org/labkey/ehr_sm/EHR_SMCustomizer.java @@ -50,7 +50,6 @@ public void customize(TableInfo tableInfo) if (tableInfo instanceof AbstractTableInfo && props.containsKey(tableInfo.getName())) { customizeSamples((AbstractTableInfo) tableInfo); - return; } } } @@ -111,7 +110,7 @@ private void customizeSamples(AbstractTableInfo ti) ColumnInfo receivedCol = ti.getColumn(receivedDateCol); if (null == receivedCol) - _log.warn("Sample type " + ti.getName() + " does not have column " + receivedDateCol + " for age at sample calculation."); + _log.warn("Sample type {} does not have column {} for age at sample calculation.", ti.getName(), receivedDateCol); TableInfo demographics = QueryService.get().getUserSchema(ti.getUserSchema().getUser(), ContainerService.get().getForPath(ehrContainerName), "study").getTable("demographics"); diff --git a/EHR_SM/src/org/labkey/ehr_sm/EHR_SMModule.java b/EHR_SM/src/org/labkey/ehr_sm/EHR_SMModule.java index d06cd49f2..5eebb09c2 100644 --- a/EHR_SM/src/org/labkey/ehr_sm/EHR_SMModule.java +++ b/EHR_SM/src/org/labkey/ehr_sm/EHR_SMModule.java @@ -17,7 +17,6 @@ package org.labkey.ehr_sm; import org.jetbrains.annotations.NotNull; -import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.module.CodeOnlyModule; import org.labkey.api.module.ModuleContext; @@ -56,10 +55,4 @@ public void doStartup(ModuleContext moduleContext) ContainerManager.addContainerListener(new EHR_SMContainerListener()); } - @Override - @NotNull - public Collection getSummary(Container c) - { - return Collections.emptyList(); - } } \ No newline at end of file diff --git a/Viral_Load_Assay/src/org/labkey/viral_load_assay/ViralLoadCustomizer.java b/Viral_Load_Assay/src/org/labkey/viral_load_assay/ViralLoadCustomizer.java index c6b4def17..f16dcb334 100644 --- a/Viral_Load_Assay/src/org/labkey/viral_load_assay/ViralLoadCustomizer.java +++ b/Viral_Load_Assay/src/org/labkey/viral_load_assay/ViralLoadCustomizer.java @@ -60,7 +60,7 @@ private void appendVLCol(AbstractTableInfo ti, ColumnInfo subjectCol, ColumnInfo List protocols = AssayService.get().getAssayProtocols(target, ap); if (protocols.size() == 1) { - AssayProtocolSchema schema = ap.createProtocolSchema(ti.getUserSchema().getUser(), target, protocols.get(0), null); + AssayProtocolSchema schema = ap.createProtocolSchema(ti.getUserSchema().getUser(), target, protocols.getFirst(), null); if (schema == null) { return; diff --git a/Viral_Load_Assay/src/org/labkey/viral_load_assay/Viral_Load_AssayModule.java b/Viral_Load_Assay/src/org/labkey/viral_load_assay/Viral_Load_AssayModule.java index 77cf7a5b5..412f7c047 100644 --- a/Viral_Load_Assay/src/org/labkey/viral_load_assay/Viral_Load_AssayModule.java +++ b/Viral_Load_Assay/src/org/labkey/viral_load_assay/Viral_Load_AssayModule.java @@ -52,12 +52,6 @@ public String getName() return 12.28; } - @Override - public boolean hasScripts() - { - return true; - } - @Override @NotNull protected Collection createWebPartFactories() diff --git a/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/ABI7500ImportMethod.java b/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/ABI7500ImportMethod.java index 4ba259521..e7345762a 100644 --- a/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/ABI7500ImportMethod.java +++ b/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/ABI7500ImportMethod.java @@ -385,8 +385,7 @@ protected List> processRowsFromFile(List if (TYPE.Standard.equals(category)) { - if (map.get("sampleVol") == null) - map.put("sampleVol", 1); + map.putIfAbsent("sampleVol", 1); if (!(map.get(QUANTITY_FIELD) instanceof Double)) { @@ -396,13 +395,8 @@ protected List> processRowsFromFile(List } else if (TYPE.NEG_CTL.equals(category)) { - if (map.get("sampleVol") == null) - map.put("sampleVol", 1); + map.putIfAbsent("sampleVol", 1); - if (map.get("cp") != null) - { - map.put("qcflag", "NTC had a value for CT"); - } } for (String field : new String[]{"sampleVol", "volPerRxn", "eluateVol"}) diff --git a/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/AbstractWNPRCImportMethod.java b/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/AbstractWNPRCImportMethod.java index 9b21ac786..b259920bb 100644 --- a/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/AbstractWNPRCImportMethod.java +++ b/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/AbstractWNPRCImportMethod.java @@ -492,9 +492,7 @@ protected List> processRowsFromFile(List if (map.get("well") != null) { map.put("well", ((String) map.get("well")).toUpperCase()); } - if (map.get("sampleType") == null) { - map.put("sampleType", "vRNA"); - } + map.putIfAbsent("sampleType", "vRNA"); if (!mergeTemplateRow(keyProperty, templateRows, map, context)) { continue; diff --git a/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/DefaultVLImportMethod.java b/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/DefaultVLImportMethod.java index eda094736..74cfb9714 100644 --- a/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/DefaultVLImportMethod.java +++ b/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/DefaultVLImportMethod.java @@ -49,12 +49,6 @@ public JSONObject getMetadata(ViewContext ctx, ExpProtocol protocol) return meta; } - @Override - public boolean supportsRunTemplates() - { - return false; - } - protected enum Category { STD(){ @Override diff --git a/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/ViralLoadAssayDataProvider.java b/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/ViralLoadAssayDataProvider.java index 80833af2a..5720bf011 100644 --- a/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/ViralLoadAssayDataProvider.java +++ b/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/ViralLoadAssayDataProvider.java @@ -16,6 +16,7 @@ package org.labkey.viral_load_assay.assay; import org.json.JSONObject; +import org.jetbrains.annotations.NotNull; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.laboratory.NavItem; @@ -119,7 +120,7 @@ public List getSettingsItems(Container c, User u) } @Override - public Set getClientDependencies() + public @NotNull Set getClientDependencies() { LinkedHashSet resources = new LinkedHashSet<>(); resources.add(ClientDependency.fromPath("Viral_Load_Assay/vl_utils.js")); diff --git a/Viral_Load_Assay/test/src/org/labkey/test/tests/external/labModules/ViralLoadAssayTest.java b/Viral_Load_Assay/test/src/org/labkey/test/tests/external/labModules/ViralLoadAssayTest.java index e9042c378..7cd59fc2e 100644 --- a/Viral_Load_Assay/test/src/org/labkey/test/tests/external/labModules/ViralLoadAssayTest.java +++ b/Viral_Load_Assay/test/src/org/labkey/test/tests/external/labModules/ViralLoadAssayTest.java @@ -400,7 +400,7 @@ private void ensureABI7500Records() throws CommandException, IOException else { log("ABI7500 already exists, no action needed"); - Map row = resp.getRows().get(0); + Map row = resp.getRows().getFirst(); DETECTOR_NAME = (String)row.get("detector"); } } @@ -1050,11 +1050,4 @@ protected List getEnabledModules() modules.add("Viral_Load_Assay"); return modules; } - - @Override - public void checkViews() - { - //the module contains an R report tied to a specific assay name, so view check fails when an assay of that name isnt present - //when module-based assays can supply reports this should be corrected - } } diff --git a/ehr/api-src/org/labkey/api/ehr/SharedEHRUpgradeCode.java b/ehr/api-src/org/labkey/api/ehr/SharedEHRUpgradeCode.java index 99632bdf6..294478696 100644 --- a/ehr/api-src/org/labkey/api/ehr/SharedEHRUpgradeCode.java +++ b/ehr/api-src/org/labkey/api/ehr/SharedEHRUpgradeCode.java @@ -180,7 +180,7 @@ else if (methodName.startsWith(IMPORT_DOMAIN_TEMPLATE)) } else { - LOG.error("Domain template '" + domainGroup + "' not found for module '" + moduleName + "'"); + LOG.error("Domain template '{}' not found for module '{}'", domainGroup, moduleName); } } } @@ -204,18 +204,18 @@ public void moduleStartupComplete(ServletContext servletContext) Container container = EHRService.get().getEHRStudyContainer(ContainerManager.getRoot()); if (container == null) { - LOG.warn("No EHR study container. Unable to perform upgrade steps for " + _module.getName()); + LOG.warn("No EHR study container. Unable to perform upgrade steps for {}", _module.getName()); return; } if (!container.getActiveModules().contains(_module)) { - LOG.warn("EHR container does not have module " + _module.getName() + " enabled. Skipping upgrade work."); + LOG.warn("EHR container does not have module {} enabled. Skipping upgrade work.", _module.getName()); } User user = EHRService.get().getEHRUser(ContainerManager.getRoot()); if (user == null || !user.isActive()) { - LOG.warn("No EHR admin user. Unable to perform upgrade steps for " + _module.getName()); + LOG.warn("No EHR admin user. Unable to perform upgrade steps for {}", _module.getName()); return; } @@ -232,7 +232,7 @@ public void moduleStartupComplete(ServletContext servletContext) } else { - LOG.warn("Unable to find container for path " + tsvImport._containerPath + ". Importing into EHR study container."); + LOG.warn("Unable to find container for path {}. Importing into EHR study container.", tsvImport._containerPath); importFile(tsvImport, container, user); } } @@ -260,12 +260,12 @@ public void moduleStartupComplete(ServletContext servletContext) Pair result = DataIntegrationService.get().truncateTargets(container, user, etlInfo.getKey()); if (result.second != null) { - LOG.error("Failed to truncate ETL " + etlInfo.getKey() + ", continuing without queuing a run. Details: " + result.second); + LOG.error("Failed to truncate ETL {}, continuing without queuing a run. Details: {}", etlInfo.getKey(), result.second); continue; } if (!DataIntegrationService.get().resetTransformState(container, user, etlInfo.getKey())) { - LOG.info("No saved state for " + etlInfo.getKey() + " found for reset, starting ETL."); + LOG.info("No saved state for {} found for reset, starting ETL.", etlInfo.getKey()); } } } @@ -279,7 +279,7 @@ public void moduleStartupComplete(ServletContext servletContext) } catch(PipelineJobException | ConfigurationException e) { - LOG.error("Failed to launch ETL " + etlInfo.getKey(), e); + LOG.error("Failed to launch ETL {}", etlInfo.getKey(), e); } } } @@ -311,7 +311,7 @@ private void importFile(TsvImport tsvImport, Container container, User user) thr throw new IllegalArgumentException("No query update service for " + tsvImport._schemaName + "." + tsvImport._queryName); } - LOG.info("Importing " + tsvImport._tsvPath + " to " + tsvImport._schemaName + "." + tsvImport._queryName); + LOG.info("Importing {} to {}.{}", tsvImport._tsvPath, tsvImport._schemaName, tsvImport._queryName); // Delete the current rows updateService.truncateRows(user, container, null, null); diff --git a/ehr/api-src/org/labkey/api/ehr/buttons/MarkCompletedButton.java b/ehr/api-src/org/labkey/api/ehr/buttons/MarkCompletedButton.java index 5b7852dc1..a5d128b5a 100644 --- a/ehr/api-src/org/labkey/api/ehr/buttons/MarkCompletedButton.java +++ b/ehr/api-src/org/labkey/api/ehr/buttons/MarkCompletedButton.java @@ -91,7 +91,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 "EHR.window.MarkCompletedWindow.buttonHandler(dataRegionName, " + PageFlowUtil.jsString(_schemaName) + ", " + PageFlowUtil.jsString(_queryName) + ", " + PageFlowUtil.jsString(xtype) + ", " + PageFlowUtil.jsString(pkColName) + ");"; diff --git a/ehr/api-src/org/labkey/api/ehr/dataentry/AbstractFormSection.java b/ehr/api-src/org/labkey/api/ehr/dataentry/AbstractFormSection.java index ea08bcc5f..b41aea745 100644 --- a/ehr/api-src/org/labkey/api/ehr/dataentry/AbstractFormSection.java +++ b/ehr/api-src/org/labkey/api/ehr/dataentry/AbstractFormSection.java @@ -266,7 +266,7 @@ public Set getTables(DataEntryFormContext ctx) TableInfo ti = ctx.getTable(pair.first, pair.second); if (ti == null) { - _log.error("Unable to create table: " + pair.first + "." + pair.second); + _log.error("Unable to create table: {}.{}", pair.first, pair.second); continue; } diff --git a/ehr/api-src/org/labkey/api/ehr/dataentry/BloodDrawFormSection.java b/ehr/api-src/org/labkey/api/ehr/dataentry/BloodDrawFormSection.java index e0abeb37f..ad439432d 100644 --- a/ehr/api-src/org/labkey/api/ehr/dataentry/BloodDrawFormSection.java +++ b/ehr/api-src/org/labkey/api/ehr/dataentry/BloodDrawFormSection.java @@ -48,7 +48,7 @@ public List getTbarMoreActionButtons() defaultButtons.add("REPEAT_SELECTED"); if (!_isRequest) - defaultButtons.add(0, "ADDBLOODDRAWS"); + defaultButtons.addFirst("ADDBLOODDRAWS"); defaultButtons.add("BULK_ADD_BLOOD"); diff --git a/ehr/api-src/org/labkey/api/ehr/dataentry/DefaultDataEntryFormFactory.java b/ehr/api-src/org/labkey/api/ehr/dataentry/DefaultDataEntryFormFactory.java index 971e9db6c..2f6d488ca 100644 --- a/ehr/api-src/org/labkey/api/ehr/dataentry/DefaultDataEntryFormFactory.java +++ b/ehr/api-src/org/labkey/api/ehr/dataentry/DefaultDataEntryFormFactory.java @@ -54,7 +54,7 @@ public DataEntryForm createForm(DataEntryFormContext ctx) } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { - _log.error("Unable to create form: " + _clazz.getName(), e); + _log.error("Unable to create form: {}", _clazz.getName(), e); return null; } } diff --git a/ehr/api-src/org/labkey/api/ehr/dataentry/DrugAdministrationFormSection.java b/ehr/api-src/org/labkey/api/ehr/dataentry/DrugAdministrationFormSection.java index 7ca271c49..edba97c95 100644 --- a/ehr/api-src/org/labkey/api/ehr/dataentry/DrugAdministrationFormSection.java +++ b/ehr/api-src/org/labkey/api/ehr/dataentry/DrugAdministrationFormSection.java @@ -81,7 +81,7 @@ public DrugAdministrationFormSection(EHRService.FORM_SECTION_LOCATION location, public List getTbarButtons() { List defaultButtons = super.getTbarButtons(); - defaultButtons.add(0, "SEDATIONHELPER"); + defaultButtons.addFirst("SEDATIONHELPER"); int idx = defaultButtons.indexOf("SELECTALL"); if (idx > -1) diff --git a/ehr/api-src/org/labkey/api/ehr/dataentry/EncounterForm.java b/ehr/api-src/org/labkey/api/ehr/dataentry/EncounterForm.java index 088db8639..9abf8f810 100644 --- a/ehr/api-src/org/labkey/api/ehr/dataentry/EncounterForm.java +++ b/ehr/api-src/org/labkey/api/ehr/dataentry/EncounterForm.java @@ -15,13 +15,10 @@ */ package org.labkey.api.ehr.dataentry; -import org.labkey.api.ehr.security.EHRInProgressInsertPermission; import org.labkey.api.module.Module; -import org.labkey.api.security.permissions.Permission; import org.labkey.api.view.template.ClientDependency; import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** @@ -54,9 +51,4 @@ public static EncounterForm create(DataEntryFormContext ctx, Module owner, Strin return new EncounterForm(ctx, owner, name, label, category, sections); } - @Override - protected List> getAvailabilityPermissions() - { - return Collections.singletonList(EHRInProgressInsertPermission.class); - } } diff --git a/ehr/api-src/org/labkey/api/ehr/dataentry/SimpleFormSection.java b/ehr/api-src/org/labkey/api/ehr/dataentry/SimpleFormSection.java index f52ea6754..2aff385ad 100644 --- a/ehr/api-src/org/labkey/api/ehr/dataentry/SimpleFormSection.java +++ b/ehr/api-src/org/labkey/api/ehr/dataentry/SimpleFormSection.java @@ -102,7 +102,7 @@ protected List getFieldKeys(TableInfo ti) List keys = EHRService.get().getDefaultFieldKeys(ti); if (_showLocation) { - keys.add(0, FieldKey.fromString("Id/curLocation/location")); + keys.addFirst(FieldKey.fromString("Id/curLocation/location")); } return keys; @@ -121,7 +121,7 @@ protected List getFormElements(DataEntryFormContext ctx) { if (!cols.containsKey(key)) { - _log.error("Unable to find field: " + key.toString() + " on table " + ti.getPublicSchemaName() + "." + ti.getPublicName()); + _log.error("Unable to find field: {} on table {}.{}", key.toString(), ti.getPublicSchemaName(), ti.getPublicName()); continue; } diff --git a/ehr/api-src/org/labkey/api/ehr/demographics/AbstractDemographicsProvider.java b/ehr/api-src/org/labkey/api/ehr/demographics/AbstractDemographicsProvider.java index 796a7f71c..78123f921 100644 --- a/ehr/api-src/org/labkey/api/ehr/demographics/AbstractDemographicsProvider.java +++ b/ehr/api-src/org/labkey/api/ehr/demographics/AbstractDemographicsProvider.java @@ -75,13 +75,13 @@ public AbstractDemographicsProvider(Module owner, String schemaName, String quer public Map> getProperties(DefaultSchema defaultSchema, Collection ids) { // if in debug, consider enabling debug logging on EHRDemographicsServiceImpl as well - _log.debug("Running DemographicsProvider named: " + this.getName()); + _log.debug("Running DemographicsProvider named: {}", this.getName()); boolean debugEnabled = _log.isDebugEnabled(); String debugTimeFormat = "m 'min' s 'sec' S 'ms'"; if (ids.size() > DemographicsProvider.MAXIMUM_BATCH_SIZE) { - _log.error("unexpected amount of IDs in demographics provider: " + getName() + ". was: " + ids.size(), new Exception()); + _log.error("unexpected amount of IDs in demographics provider: {}. was: {}", getName(), ids.size(), new Exception()); } final Map> ret = new HashMap<>(); @@ -100,7 +100,7 @@ public Map> getProperties(DefaultSchema defaultSchem tiName = ti.getName(); if (tiName == null) tiName = ""; - _log.debug("TableInfo (for table '" + tiName + "') creation time: " + DurationFormatUtils.formatDuration(tableInfoDuration.toMillis(), debugTimeFormat, true)); + _log.debug("TableInfo (for table '{}') creation time: {}", tiName, DurationFormatUtils.formatDuration(tableInfoDuration.toMillis(), debugTimeFormat, true)); } SimpleFilter filter = getFilter(ids); @@ -125,7 +125,7 @@ public void exec(ResultSet object) throws SQLException if (debugEnabled) { Duration rowProcessingDuration = Duration.between(startRowProcessing, LocalDateTime.now()); - _log.debug("Row processing time (for table '" + tiName + "'): " + DurationFormatUtils.formatDuration(rowProcessingDuration.toMillis(), debugTimeFormat, true)); + _log.debug("Row processing time (for table '{}'): {}", tiName, DurationFormatUtils.formatDuration(rowProcessingDuration.toMillis(), debugTimeFormat, true)); } return ret; @@ -252,7 +252,7 @@ protected String getFormattedDuration(Date startDate, Date endDate, boolean leav } catch (IllegalArgumentException iae) { - _log.error("Error formatting duration with startDate '" + startDate + "' and endDate '" + endDate + "'.", iae); + _log.error("Error formatting duration with startDate '{}' and endDate '{}'.", startDate, endDate, iae); return "Error"; } diff --git a/ehr/api-src/org/labkey/api/ehr/demographics/AbstractListDemographicsProvider.java b/ehr/api-src/org/labkey/api/ehr/demographics/AbstractListDemographicsProvider.java index 030256fb8..c401d0edb 100644 --- a/ehr/api-src/org/labkey/api/ehr/demographics/AbstractListDemographicsProvider.java +++ b/ehr/api-src/org/labkey/api/ehr/demographics/AbstractListDemographicsProvider.java @@ -57,7 +57,7 @@ protected void processRow(Results rs, Map cols, Map getColumnNames() } } - HistoryRowImpl rec = records.get(0); + HistoryRowImpl rec = records.getFirst(); HistoryRowImpl newRow = new HistoryRowImpl(this, rec.getCategoryText(), rec.getPrimaryGroup(), rec.getCategoryColor(), rec.getSubjectId(), rec.getDate(), sb.toString(), rec.getQcStateLabel(), rec.getPublicData(), rec.getTaskId(), rec.getTaskRowId(), rec.getFormType(), rec.getObjectId()); newRow.setShowTime(true); newRows.add(newRow); diff --git a/ehr/api-src/org/labkey/api/ehr/history/DefaultLabworkType.java b/ehr/api-src/org/labkey/api/ehr/history/DefaultLabworkType.java index 59a1307a4..7f02563aa 100644 --- a/ehr/api-src/org/labkey/api/ehr/history/DefaultLabworkType.java +++ b/ehr/api-src/org/labkey/api/ehr/history/DefaultLabworkType.java @@ -18,8 +18,8 @@ import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; import org.labkey.api.collections.CaseInsensitiveHashMap; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.CompareType; @@ -118,7 +118,7 @@ public boolean isEnabled(Container c) return c.getActiveModules().contains(_declaringModule); } - public Module getDeclaringModule() + public @NotNull Module getDeclaringModule() { return _declaringModule; } diff --git a/ehr/api-src/org/labkey/api/ehr/history/HistoryRowImpl.java b/ehr/api-src/org/labkey/api/ehr/history/HistoryRowImpl.java index e50e06645..0785e023a 100644 --- a/ehr/api-src/org/labkey/api/ehr/history/HistoryRowImpl.java +++ b/ehr/api-src/org/labkey/api/ehr/history/HistoryRowImpl.java @@ -124,12 +124,12 @@ public String getSortDateString() } catch (ArrayIndexOutOfBoundsException e) { - _log.error("Invalid date: " + _date + " for table: " + _primaryGroup + " and animal " + _subjectId, e); + _log.error("Invalid date: {} for table: {} and animal {}", _date, _primaryGroup, _subjectId, e); return ""; } catch (Exception e) { - _log.error("Error creating sortDateString for animal: " + _subjectId + ", " + _primaryGroup + " with date: " + _date, e); + _log.error("Error creating sortDateString for animal: {}, {} with date: {}", _subjectId, _primaryGroup, _date, e); return ""; } } diff --git a/ehr/api-src/org/labkey/api/ehr/history/SortingLabworkType.java b/ehr/api-src/org/labkey/api/ehr/history/SortingLabworkType.java index 3bcbb8acd..013d915e7 100644 --- a/ehr/api-src/org/labkey/api/ehr/history/SortingLabworkType.java +++ b/ehr/api-src/org/labkey/api/ehr/history/SortingLabworkType.java @@ -133,6 +133,6 @@ protected Integer getSortOrder(ResultSet rs) throws SQLException return 9999; loadTests(false); - return _tests.containsKey(testId) ? _tests.get(testId) : 9999; + return _tests.getOrDefault(testId, 9999); } } diff --git a/ehr/api-src/org/labkey/api/ehr/table/AssignedAtTimeForeignKey.java b/ehr/api-src/org/labkey/api/ehr/table/AssignedAtTimeForeignKey.java index 163a1b6f4..6dc7cc19e 100644 --- a/ehr/api-src/org/labkey/api/ehr/table/AssignedAtTimeForeignKey.java +++ b/ehr/api-src/org/labkey/api/ehr/table/AssignedAtTimeForeignKey.java @@ -68,7 +68,7 @@ public TableInfo getLookupTableInfo() TableInfo ti = qd.getTable(errors, true); if (!errors.isEmpty()) { - _log.error("Error creating lookup table for: " + schemaName + "." + queryName + " in container: " + targetSchema.getContainer().getPath()); + _log.error("Error creating lookup table for: {}.{} in container: {}", schemaName, queryName, targetSchema.getContainer().getPath()); for (QueryException error : errors) { _log.error(error.getMessage(), error); diff --git a/ehr/api-src/org/labkey/api/ehr/table/AssignmentAtTimeForeignKey.java b/ehr/api-src/org/labkey/api/ehr/table/AssignmentAtTimeForeignKey.java index cdf84af10..55725a202 100644 --- a/ehr/api-src/org/labkey/api/ehr/table/AssignmentAtTimeForeignKey.java +++ b/ehr/api-src/org/labkey/api/ehr/table/AssignmentAtTimeForeignKey.java @@ -75,7 +75,7 @@ public TableInfo getLookupTableInfo() TableInfo ti = qd.getTable(errors, true); if (!errors.isEmpty()) { - _log.error("Error creating lookup table for: " + schemaName + "." + queryName + " in container: " + targetSchema.getContainer().getPath()); + _log.error("Error creating lookup table for: {}.{} in container: {}", schemaName, queryName, targetSchema.getContainer().getPath()); for (QueryException error : errors) { _log.error(error.getMessage(), error); diff --git a/ehr/src/org/labkey/ehr/EHRController.java b/ehr/src/org/labkey/ehr/EHRController.java index 7bf750c76..ac4840870 100644 --- a/ehr/src/org/labkey/ehr/EHRController.java +++ b/ehr/src/org/labkey/ehr/EHRController.java @@ -379,7 +379,7 @@ public ModelAndView getView(EHRQueryForm form, BindException errors) String queryName = ti.getName(); if (pks.size() == 1) - keyField = pks.get(0); + keyField = pks.getFirst(); ActionURL url = getViewContext().getActionURL().clone(); @@ -1526,7 +1526,7 @@ public Object execute(PopulateLookupsForm form, BindException errors) throws Exc } else { - _log.warn("File listed in manifest file but data file not found: " + cols[0] + ". Using manifest file: " + _lookupsManifestModule.getName()); + _log.warn("File listed in manifest file but data file not found: {}. Using manifest file: {}", cols[0], _lookupsManifestModule.getName()); } } @@ -1681,7 +1681,7 @@ else if (!form.isDelete()) { _additionalReportsResource = _additionalReportsModule.getModuleResource(_additionalReportsPath); if (_additionalReportsResource == null || !_additionalReportsResource.exists()) - _log.info("No additional reports found in " + mp.getEffectiveValue(getContainer()) + " module."); + _log.info("No additional reports found in {} module.", mp.getEffectiveValue(getContainer())); } } } diff --git a/ehr/src/org/labkey/ehr/EHRManager.java b/ehr/src/org/labkey/ehr/EHRManager.java index 63b92bb2c..933c7b2f0 100644 --- a/ehr/src/org/labkey/ehr/EHRManager.java +++ b/ehr/src/org/labkey/ehr/EHRManager.java @@ -251,7 +251,7 @@ public User getEHRUser(Container c, boolean logOnError) if (emailAddress == null) { if (logOnError) - _log.warn("Attempted to access EHR email module property from container: " + (c == null ? null : c.getPath()) + ", but it was null. Some code may not work as expected.", new Exception()); + _log.warn("Attempted to access EHR email module property from container: {}, but it was null. Some code may not work as expected.", c == null ? null : c.getPath(), new Exception()); return null; } @@ -549,7 +549,7 @@ public List ensureDatasetPropertyDescriptors(Container c, User u, boolea { if (dp == null) { - _log.error("domain has a null domain property: " + domain.getName()); + _log.error("domain has a null domain property: {}", domain.getName()); continue; } @@ -947,7 +947,7 @@ else if (d.getName().equalsIgnoreCase(DatasetNames.BLOOD)) } else { - _log.warn("unable to find index: " + tableName + "." + idxName); + _log.warn("unable to find index: {}.{}", tableName, idxName); String indexName = getIndexName(realTable.getSqlDialect(), tableName, toDisable.columnNames); if (doesIndexExist(realTable.getSchema(), tableName, indexName)) { @@ -959,7 +959,7 @@ else if (d.getName().equalsIgnoreCase(DatasetNames.BLOOD)) } else { - _log.warn("unable to find index: " + tableName + "." + indexName); + _log.warn("unable to find index: {}.{}", tableName, indexName); } } } @@ -977,7 +977,7 @@ else if (d.getName().equalsIgnoreCase(DatasetNames.BLOOD)) Dataset ds = study.getDatasetByLabel(label); if (ds != null) { - _log.info("increasing size of " + ColumnNames.REMARK + " column for dataset: " + label); + _log.info("increasing size of " + ColumnNames.REMARK + " column for dataset: {}", label); SQLFragment sql = new SQLFragment("ALTER TABLE studydataset." + ds.getDomain().getStorageTableName() + " ALTER COLUMN " + ColumnNames.REMARK + " NVARCHAR(max)"); SqlExecutor se = new SqlExecutor(DbScope.getLabKeyScope()); @@ -1014,14 +1014,14 @@ private void resolveProperty(Container c, Container sharedContainer, List 0) { for (PropertyDescriptor p : pdArray) { - _log.error("found match in container: " + p.getContainer().getPath() + " [" + p.getPropertyURI() + "]"); + _log.error("found match in container: {} [{}]", p.getContainer().getPath(), p.getPropertyURI()); } } else @@ -1454,9 +1454,9 @@ private void updatePropertyURI(Domain d, PropertyDescriptor pd) throws SQLExcept { //only 1 ID, but not using correct propertyURI String updateSql = "UPDATE exp.propertydomain SET propertyid = ? where domainId = ? AND propertyid = ?"; - long updated = executor.execute(updateSql, propertyId, d.getTypeId(), oldIds.get(0)); + long updated = executor.execute(updateSql, propertyId, d.getTypeId(), oldIds.getFirst()); - PropertyDescriptor toDelete = OntologyManager.getPropertyDescriptor(oldIds.get(0)); + PropertyDescriptor toDelete = OntologyManager.getPropertyDescriptor(oldIds.getFirst()); if (toDelete != null) { PropertyService.get().deleteValidatorsAndFormats(toDelete.getContainer(), toDelete.getPropertyId()); diff --git a/ehr/src/org/labkey/ehr/EHRServiceImpl.java b/ehr/src/org/labkey/ehr/EHRServiceImpl.java index 6f5e1708f..31d009fa8 100644 --- a/ehr/src/org/labkey/ehr/EHRServiceImpl.java +++ b/ehr/src/org/labkey/ehr/EHRServiceImpl.java @@ -90,7 +90,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.InvocationTargetException; -import java.nio.file.Files; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; @@ -307,7 +306,7 @@ private TableCustomizer instantiateCustomizer(Class c } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { - _log.error("Unable to create instance of class '" + customizerClass.getName() + "'", e); + _log.error("Unable to create instance of class '{}'", customizerClass.getName(), e); } return null; @@ -524,7 +523,7 @@ public Pair getActionOverride(String actionName, Container c) if (ModuleHtmlView.exists(pair.first, pair.second)) return pair; else - _log.error("Unable to find registered EHR action: " + pair.first.getName() + " / " + pair.second); + _log.error("Unable to find registered EHR action: {} / {}", pair.first.getName(), pair.second); } } @@ -740,7 +739,7 @@ public boolean hasPermission (String schemaName, String queryName, Container c, SecurableResource sr = EHRSecurityManager.get().getSecurableResource(c, u, schemaName, queryName); if (sr == null) { - _log.warn("Unable to find SecurableResource for table: " + schemaName + "." + queryName); + _log.warn("Unable to find SecurableResource for table: {}.{}", schemaName, queryName); return false; } @@ -840,7 +839,7 @@ public void customizeDateColumn(AbstractTableInfo ti, String colName) private void addDatePartCol(AbstractTableInfo ti, ColumnInfo dateCol, String label, String description, Integer datePart) { - String colName = dateCol.getName() + label.replaceAll(" ", ""); + String colName = dateCol.getName() + label.replace(" ", ""); if (ti.getColumn(colName, false) == null) { String colSql = dateCol.getValueSql(ExprColumn.STR_TABLE_ALIAS).getSQL(); diff --git a/ehr/src/org/labkey/ehr/dataentry/RecordDeleteRunner.java b/ehr/src/org/labkey/ehr/dataentry/RecordDeleteRunner.java index b094197d7..2221fa595 100644 --- a/ehr/src/org/labkey/ehr/dataentry/RecordDeleteRunner.java +++ b/ehr/src/org/labkey/ehr/dataentry/RecordDeleteRunner.java @@ -104,7 +104,7 @@ public void run(Container c) if (!isEnabled(c)) return; - _log.info("Starting EHR Record Delete Runner for folder: " + c.getPath()); + _log.info("Starting EHR Record Delete Runner for folder: {}", c.getPath()); User u = EHRService.get().getEHRUser(c); if (u == null) @@ -149,7 +149,7 @@ private void deleteRecordsFromTable(TableInfo ti, String pkField) keys.add(row); } - _log.info("deleting " + keys.size() + " records from table: " + ti.getName() + " in container: " + ti.getUserSchema().getContainer().getPath()); + _log.info("deleting {} records from table: {} in container: {}", keys.size(), ti.getName(), ti.getUserSchema().getContainer().getPath()); ti.getUpdateService().deleteRows(ti.getUserSchema().getUser(), ti.getUserSchema().getContainer(), keys, null, new HashMap<>()); } } diff --git a/ehr/src/org/labkey/ehr/demographics/AnimalRecordImpl.java b/ehr/src/org/labkey/ehr/demographics/AnimalRecordImpl.java index 9e9e3fb84..45843e4b3 100644 --- a/ehr/src/org/labkey/ehr/demographics/AnimalRecordImpl.java +++ b/ehr/src/org/labkey/ehr/demographics/AnimalRecordImpl.java @@ -230,7 +230,7 @@ public String getCurrentRoom() { List> housing = getActiveHousing(); if (housing != null && !housing.isEmpty()) - return (String)housing.get(0).get("room"); + return (String)housing.getFirst().get("room"); return null; } @@ -240,7 +240,7 @@ public String getCurrentCage() { List> housing = getActiveHousing(); if (housing != null && !housing.isEmpty()) - return (String)housing.get(0).get("cage"); + return (String)housing.getFirst().get("cage"); return null; } @@ -300,7 +300,7 @@ public Date getMostRecentArrival() { List> rows = (List)_props.get("source"); if (!rows.isEmpty()) - return (Date)rows.get(0).get("mostRecentArrival"); + return (Date)rows.getFirst().get("mostRecentArrival"); } return null; @@ -313,7 +313,7 @@ public String getMostRecentArrivalSource() { List> rows = (List)_props.get("source"); if (!rows.isEmpty()) - return (String)rows.get(0).get("source/meaning"); + return (String)rows.getFirst().get("source/meaning"); } return null; diff --git a/ehr/src/org/labkey/ehr/demographics/EHRDemographicsServiceImpl.java b/ehr/src/org/labkey/ehr/demographics/EHRDemographicsServiceImpl.java index 61c3c8920..7888a610a 100644 --- a/ehr/src/org/labkey/ehr/demographics/EHRDemographicsServiceImpl.java +++ b/ehr/src/org/labkey/ehr/demographics/EHRDemographicsServiceImpl.java @@ -113,7 +113,7 @@ public AnimalRecord getAnimal(Container c, String id) { List ret = getAnimals(c, Collections.singletonList(id)); - return !ret.isEmpty() ? ret.get(0) : null; + return !ret.isEmpty() ? ret.getFirst() : null; } /** @@ -166,11 +166,11 @@ private synchronized void cacheRecord(AnimalRecordImpl record, boolean validateO { if (existing.getProps().isEmpty() && !record.getProps().isEmpty()) { - _log.error("mismatch for cached record for animal: " + record.getId() + ". cached record has properties, but new record does not"); + _log.error("mismatch for cached record for animal: {}. cached record has properties, but new record does not", record.getId()); } else if (!existing.getProps().isEmpty() && record.getProps().isEmpty()) { - _log.error("mismatch for cached record for animal: " + record.getId() + ". cached record has no properties, but new record does"); + _log.error("mismatch for cached record for animal: {}. cached record has no properties, but new record does", record.getId()); } else if (existing.getProps().isEmpty() && record.getProps().isEmpty()) { @@ -192,7 +192,7 @@ else if (existing.getProps().isEmpty() && record.getProps().isEmpty()) MapDifference diff = Maps.difference(props1, props2); if (!diff.areEqual()) { - _log.error("mismatch for cached record for animal: " + record.getId()); + _log.error("mismatch for cached record for animal: {}", record.getId()); Map> diffEntries = diff.entriesDiffering(); if (diffEntries.isEmpty()) { @@ -201,7 +201,7 @@ else if (existing.getProps().isEmpty() && record.getProps().isEmpty()) for (String prop : diffEntries.keySet()) { - _log.error("property: " + prop); + _log.error("property: {}", prop); _log.error("original: "); _log.error(diffEntries.get(prop).leftValue()); _log.error("new value: "); @@ -327,7 +327,7 @@ private void doUpdateRecords(Container c, User u, List> cha if (!needsUpdate.isEmpty()) { - _log.info("updating demographics providers: [" + StringUtils.join(providerNames, ";") + "] for " + ids.size() + " ids. " + (ids.size() > 10 ? "" : "[" + StringUtils.join(ids, ",") + "]")); + _log.info("updating demographics providers: [{}] for {} ids. {}", StringUtils.join(providerNames, ";"), ids.size(), ids.size() > 10 ? "" : "[" + StringUtils.join(ids, ",") + "]"); } @@ -423,25 +423,25 @@ private void updateForProvider(DefaultSchema defaultSchema, DemographicsProvider if (!uncachedIds.isEmpty() && !async) { - _log.warn("Animal record not found in cache for: " + uncachedIds + ". Not a problem if these are newly inserted animals. Discovered during update of provider: " + p.getName()); + _log.warn("Animal record not found in cache for: {}. Not a problem if these are newly inserted animals. Discovered during update of provider: {}", uncachedIds, p.getName()); } idsToUpdate.removeAll(uniqueIds); if (!idsToUpdate.isEmpty()) { - _log.info("reporting change for " + idsToUpdate.size() + " additional ids after change in provider: " + p.getName() + (idsToUpdate.size() < 100 ? ". " + StringUtils.join(idsToUpdate, ";") : "")); + _log.info("reporting change for {} additional ids after change in provider: {}{}", idsToUpdate.size(), p.getName(), idsToUpdate.size() < 100 ? ". " + StringUtils.join(idsToUpdate, ";") : ""); updateForProvider(defaultSchema, p, idsToUpdate, false, async); } } timer.stop(); - _log.info("updated demographics provider: " + p.getName() + " for " + ids.size() + " ids. " + (ids.size() > 100 ? "" : "[" + StringUtils.join(ids, ",") + "]") + " took " + timer.getDuration()); + _log.info("updated demographics provider: {} for {} ids. {} took {}", p.getName(), ids.size(), ids.size() > 100 ? "" : "[" + StringUtils.join(ids, ",") + "]", timer.getDuration()); } // Create and cache IDs in the background private void asyncCache(final Container c, final List ids) { - _log.info("Perform async cache for " + ids.size() + " animals"); + _log.info("Perform async cache for {} animals", ids.size()); // Copy the list as it may be backed by a JavaScript array (via a trigger script) that ends up holding // onto a lot of additional scope and memory @@ -485,7 +485,7 @@ private List createRecords(Container c, Collection ids, bo ids_string.append(id); ids_string.append(","); } - _log.debug("DEMOGRAPHICS_DEBUG: Demographics records being created for animal(s): " + ids_string); + _log.debug("DEMOGRAPHICS_DEBUG: Demographics records being created for animal(s): {}", ids_string); } User u = EHRService.get().getEHRUser(c); @@ -503,7 +503,7 @@ private List createRecords(Container c, Collection ids, bo while (start < allIds.size()) { List sublist = allIds.subList(start, Math.min(allIds.size(), start + DemographicsProvider.MAXIMUM_BATCH_SIZE)); - _log.debug("Creating demographics records for " + sublist.size() + " animals (" + start + " of " + allIds.size() + " already complete)"); + _log.debug("Creating demographics records for {} animals ({} of {} already complete)", sublist.size(), start, allIds.size()); start = start + DemographicsProvider.MAXIMUM_BATCH_SIZE; DefaultSchema defaultSchema = DefaultSchema.get(u, c); @@ -546,7 +546,7 @@ private List createRecords(Container c, Collection ids, bo double duration = ((new Date()).getTime() - startTime.getTime()) / 1000.0; if (duration > (2.0 * allIds.size())) { - _log.warn("recached " + allIds.size() + " records in " + duration + " seconds"); + _log.warn("recached {} records in {} seconds", allIds.size(), duration); } return records; } @@ -573,7 +573,7 @@ public void cacheAnimals(Container c, User u, boolean validateOnCreate, boolean if (!ids.isEmpty()) { - _log.info("Forcing recache of " + ids.size() + " animals"); + _log.info("Forcing recache of {} animals", ids.size()); createRecords(c, ids, validateOnCreate); _log.info("Cache load complete"); } @@ -629,7 +629,7 @@ private int cacheLivingAnimalsForAllContainers(boolean validateOnCreate) QueryService.get().setEnvironment(QueryService.Environment.USER, u); QueryService.get().setEnvironment(QueryService.Environment.CONTAINER, s.getContainer()); - _log.info("Recaching EHR demographics for all living animals in " + s.getContainer().getPath()); + _log.info("Recaching EHR demographics for all living animals in {}", s.getContainer().getPath()); EHRDemographicsServiceImpl.get().cacheAnimals(s.getContainer(), u, validateOnCreate, true); totalCached++; diff --git a/ehr/src/org/labkey/ehr/history/ClinicalHistoryManager.java b/ehr/src/org/labkey/ehr/history/ClinicalHistoryManager.java index 9455ffd51..67fb0f520 100644 --- a/ehr/src/org/labkey/ehr/history/ClinicalHistoryManager.java +++ b/ehr/src/org/labkey/ehr/history/ClinicalHistoryManager.java @@ -23,8 +23,6 @@ import org.labkey.api.util.logging.LogHelper; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.HashSet; import java.util.LinkedHashMap; @@ -104,14 +102,7 @@ public List getHistory(Container c, User u, String subjectId, String public void sortRowsByDate(List rows) { - Collections.sort(rows, new Comparator<>() - { - @Override - public int compare(HistoryRow o1, HistoryRow o2) - { - return (-1 * (o1.getSortDateString().compareTo(o2.getSortDateString()))); - } - }); + rows.sort((o1, o2) -> (-1 * (o1.getSortDateString().compareTo(o2.getSortDateString())))); } protected List getDataSources(Container c, User u) @@ -122,7 +113,7 @@ protected List getDataSources(Container c, User u) if (source.isAvailable(c, u)) { if (sources.containsKey(source.getName())) - _log.warn("There is an existing source with the name: " + source.getName()); + _log.warn("There is an existing source with the name: {}", source.getName()); sources.put(source.getName(), source); } diff --git a/ehr/src/org/labkey/ehr/history/DefaultEncountersDataSource.java b/ehr/src/org/labkey/ehr/history/DefaultEncountersDataSource.java index afb28706a..b430cb29e 100644 --- a/ehr/src/org/labkey/ehr/history/DefaultEncountersDataSource.java +++ b/ehr/src/org/labkey/ehr/history/DefaultEncountersDataSource.java @@ -70,7 +70,7 @@ public DefaultEncountersDataSource(Module module) long duration = ((new Date()).getTime() - start.getTime()) / 1000; if (duration > 3) - _log.error("Loaded snomed tags in: " + duration + " seconds"); + _log.error("Loaded snomed tags in: {} seconds", duration); return super.getRows(c, u, filter, redacted); } @@ -167,12 +167,12 @@ protected Map>> getSnomedTags(Containe if (fc instanceof CompareType.CompareClause cc) { Object val = (cc.getParamVals() != null && cc.getParamVals().length > 0) ? cc.getParamVals()[0] : null; - FieldKey fk = FieldKey.fromParts(FieldKey.fromString("recordid"), cc.getFieldKeys().get(0)); + FieldKey fk = FieldKey.fromParts(FieldKey.fromString("recordid"), cc.getFieldKeys().getFirst()); newFilter.addCondition(fk, val, cc.getCompareType()); } else { - _log.error("Unknown filter clause type: " + fc.getClass().getName()); + _log.error("Unknown filter clause type: {}", fc.getClass().getName()); } } diff --git a/ehr/src/org/labkey/ehr/history/DefaultLabworkDataSource.java b/ehr/src/org/labkey/ehr/history/DefaultLabworkDataSource.java index 6e8ae1f12..862638964 100644 --- a/ehr/src/org/labkey/ehr/history/DefaultLabworkDataSource.java +++ b/ehr/src/org/labkey/ehr/history/DefaultLabworkDataSource.java @@ -124,13 +124,13 @@ protected Set getColumnNames() long duration = ((new Date()).getTime() - start.getTime()) / 1000; if (duration > 6) - _log.error("Loaded lab results for: " + subjectId + " in " + duration + " seconds"); + _log.error("Loaded lab results for: {} in {} seconds", subjectId, duration); start = new Date(); _flags = getFlags(c, u, subjectId, minDate, maxDate); duration = ((new Date()).getTime() - start.getTime()) / 1000; if (duration > 4) - _log.error("Loaded clinpath flags for: " + subjectId + " in " + duration + " seconds"); + _log.error("Loaded clinpath flags for: {} in {} seconds", subjectId, duration); return super.getRows(c, u, subjectId, minDate, maxDate, redacted); } diff --git a/ehr/src/org/labkey/ehr/model/EHRDomainKind.java b/ehr/src/org/labkey/ehr/model/EHRDomainKind.java index 1433e1301..dc6ccbdea 100644 --- a/ehr/src/org/labkey/ehr/model/EHRDomainKind.java +++ b/ehr/src/org/labkey/ehr/model/EHRDomainKind.java @@ -16,6 +16,7 @@ package org.labkey.ehr.model; +import org.jetbrains.annotations.NotNull; import org.labkey.api.data.Container; import org.labkey.api.exp.property.Domain; import org.labkey.api.gwt.client.model.GWTPropertyDescriptor; @@ -63,7 +64,7 @@ public String getKindName() } @Override - public Set getReservedPropertyNames(Domain domain, User user) + public @NotNull Set getReservedPropertyNames(Domain domain, User user) { return super.getReservedPropertyNames(domain, user); } diff --git a/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsImportTask.java b/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsImportTask.java index d89820729..67ee80a28 100644 --- a/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsImportTask.java +++ b/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsImportTask.java @@ -185,7 +185,7 @@ private static void processKinship(Container c, User u, FileLike pipelineDir, Lo DbSchema ehrSchema = EHRSchema.getInstance().getSchema(); TableInfo kinshipTable = ehrSchema.getTable("kinship"); - log.info("Inspecting file length: " + output.getPath()); + log.info("Inspecting file length: {}", output.getPath()); try { @@ -217,7 +217,7 @@ private static void processKinship(Container c, User u, FileLike pipelineDir, Lo } else { - maxVal = ret.get(0) == null ? 0 : ret.get(0).intValue(); + maxVal = ret.getFirst() == null ? 0 : ret.getFirst().intValue(); } SqlExecutor ex = new SqlExecutor(kinshipTable.getSchema()); @@ -306,7 +306,7 @@ else if (kinshipTable.getSqlDialect().isPostgreSQL()) if (lineNum % 250000 == 0) { - log.info("imported " + String.format("%,d", lineNum) + " rows"); + log.info("imported {} rows", String.format("%,d", lineNum)); if (job != null) { job.updateStatusForTask(); @@ -320,7 +320,7 @@ else if (kinshipTable.getSqlDialect().isPostgreSQL()) stmt.executeBatch(); transaction.commit(); - log.info("Inserted " + String.format("%,d", lineNum) + " rows into ehr.kinship"); + log.info("Inserted {} rows into ehr.kinship", String.format("%,d", lineNum)); } } catch (RuntimeSQLException | SQLException | IOException e) @@ -442,11 +442,11 @@ private void handleMissingCoefficient(User user, Container container, String id, PipelineJob job = getJob(); if (!species.equals(results.getString("species"))) { - job.getLogger().info("Relation across species, kinship coefficent not calculated. Id: " + id + ", Id2: " + id2 + ", Relation: " + relation); + job.getLogger().info("Relation across species, kinship coefficent not calculated. Id: {}, Id2: {}, Relation: {}", id, id2, relation); } else { - job.getLogger().info("Kinship validation failed. Missing coefficient for Id: " + id + ", Id2: " + id2 + ". Relation: " + relation); + job.getLogger().info("Kinship validation failed. Missing coefficient for Id: {}, Id2: {}. Relation: {}", id, id2, relation); } } } @@ -481,9 +481,7 @@ private void validateSetOfRelations(TableInfo kinshipTable, Map lastRun) - { - return true; - } - - return false; + return lastModified == null || lastModified.getTime() > lastRun; } } diff --git a/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsRTask.java b/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsRTask.java index 03d06a251..e2af29f78 100644 --- a/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsRTask.java +++ b/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsRTask.java @@ -135,7 +135,7 @@ public RecordedAction runScript(String scriptName, String outputFileName, String args.add("-f"); args.add(tsvFile.toNioPathForRead().toFile().getPath()); - getJob().getLogger().info("Using working directory of: " + support.getAnalysisDirectory().getPath()); + getJob().getLogger().info("Using working directory of: {}", support.getAnalysisDirectory().getPath()); ProcessBuilder pb = new ProcessBuilder(args); job.runSubProcess(pb, support.getAnalysisDirectory()); @@ -164,7 +164,7 @@ private String inferRPath() if (RScriptEngineFactory.isRScriptEngine(def.getExtensions())) { path = new File(def.getExePath()).getParent(); - getJob().getLogger().info("Using RSciptEngine path: " + path); + getJob().getLogger().info("Using RSciptEngine path: {}", path); return path; } } @@ -174,7 +174,7 @@ private String inferRPath() String packagePath = PipelineJobService.get().getConfigProperties().getSoftwarePackagePath("R"); if (StringUtils.trimToNull(packagePath) != null) { - getJob().getLogger().info("Using path from pipeline config: " + packagePath); + getJob().getLogger().info("Using path from pipeline config: {}", packagePath); return packagePath; } @@ -182,7 +182,7 @@ private String inferRPath() Map env = System.getenv(); if (env.containsKey("RHOME")) { - getJob().getLogger().info("Using path from RHOME: " + env.get("RHOME")); + getJob().getLogger().info("Using path from RHOME: {}", env.get("RHOME")); return env.get("RHOME"); } diff --git a/ehr/src/org/labkey/ehr/query/EHRLookupsUserSchema.java b/ehr/src/org/labkey/ehr/query/EHRLookupsUserSchema.java index 415ec8c1f..ec6e8bfa2 100644 --- a/ehr/src/org/labkey/ehr/query/EHRLookupsUserSchema.java +++ b/ehr/src/org/labkey/ehr/query/EHRLookupsUserSchema.java @@ -239,7 +239,7 @@ private String getPkColName(TableInfo ti) { List pkCols = ti.getPkColumnNames(); if (pkCols.size() == 1) - return pkCols.get(0); + return pkCols.getFirst(); } return null; diff --git a/ehr/src/org/labkey/ehr/table/DefaultEHRCustomizer.java b/ehr/src/org/labkey/ehr/table/DefaultEHRCustomizer.java index c3bcfe483..3a9711fc9 100644 --- a/ehr/src/org/labkey/ehr/table/DefaultEHRCustomizer.java +++ b/ehr/src/org/labkey/ehr/table/DefaultEHRCustomizer.java @@ -115,7 +115,7 @@ public void customize(TableInfo table) Container c = us.getContainer(); if (!c.getActiveModules().contains(ModuleLoader.getInstance().getModule(EHRModule.class))) { - _log.error("Attempting to use DefaultEHRCustomizer on table (" + us.getName() + "." + table.getName() + ") even though the module is not enabled: " + c.getPath()); + _log.error("Attempting to use DefaultEHRCustomizer on table ({}.{}) even though the module is not enabled: {}", us.getName(), table.getName(), c.getPath()); return; } } @@ -755,13 +755,13 @@ private TableInfo getRealTableForDataset(AbstractTableInfo ti, String label) if (ds == null) { // NOTE: this seems to happen during study import on TeamCity. It does not seem to happen during normal operation - _log.info("A dataset was requested that does not exist: " + label + " in container: " + ehrContainer.getPath()); + _log.info("A dataset was requested that does not exist: {} in container: {}", label, ehrContainer.getPath()); StringBuilder sb = new StringBuilder(); for (Dataset d : s.getDatasets()) { sb.append(d.getName() + ", "); } - _log.info("datasets present: " + sb); + _log.info("datasets present: {}", sb); return null; } @@ -1138,7 +1138,7 @@ private void customizeAnimalTable(AbstractTableInfo ds) if (ds.getColumn("age") != null) { - _log.warn("Table already has an age column. Customize might have been called twice? " + ds.getName()); + _log.warn("Table already has an age column. Customize might have been called twice? {}", ds.getName()); return; } @@ -1591,10 +1591,10 @@ public TableInfo getLookupTableInfo() TableInfo ti = qd.getTable(errors, true); if (!errors.isEmpty() || ti == null) { - _log.warn("Error creating housing at time lookup table for: " + schemaName + "." + queryName + " in container: " + targetSchema.getContainer().getPath()); + _log.warn("Error creating housing at time lookup table for: {}.{} in container: {}", schemaName, queryName, targetSchema.getContainer().getPath()); for (QueryException e : errors) { - _log.error("Lookup table QueryException: " + e.getMessage(), e); + _log.error("Lookup table QueryException: {}", e.getMessage(), e); } } if (ti == null) @@ -1606,7 +1606,7 @@ public TableInfo getLookupTableInfo() if (ti instanceof AbstractTableInfo) roomAtTime.setFk(new QueryForeignKey(getUserSchema((AbstractTableInfo) ti, "ehr_lookups"), null, "rooms", "room", "room")); else - _log.error("Table is not AbstractTableInfo: " + ti.getPublicName()); + _log.error("Table is not AbstractTableInfo: {}", ti.getPublicName()); ((BaseColumnInfo)ti.getColumn(pkCol.getName())).setHidden(true); ((BaseColumnInfo)ti.getColumn(pkCol.getName())).setKeyField(true); @@ -1640,7 +1640,7 @@ private void customizeRooms(AbstractTableInfo ti) private ColumnInfo getPkCol(TableInfo ti) { List pks = ti.getPkColumns(); - return (pks.size() != 1) ? null : pks.get(0); + return (pks.size() != 1) ? null : pks.getFirst(); } private boolean hasAnimalLookup(AbstractTableInfo ti) @@ -1713,7 +1713,7 @@ public TableInfo getLookupTableInfo() TableInfo ti = qd.getTable(errors, true); if (!errors.isEmpty()) { - _log.warn("Error creating survivorship lookup table for: " + schemaName + "." + queryName + " in container: " + targetSchema.getContainer().getPath()); + _log.warn("Error creating survivorship lookup table for: {}.{} in container: {}", schemaName, queryName, targetSchema.getContainer().getPath()); for (QueryException e : errors) { _log.warn(e.getMessage(), e); @@ -1722,7 +1722,7 @@ public TableInfo getLookupTableInfo() if (ti == null) { - _log.warn("Error creating survivorship lookup table for: " + schemaName + "." + queryName + " in container: " + targetSchema.getContainer().getPath() + ", see server log for more details. Table was null"); + _log.warn("Error creating survivorship lookup table for: {}.{} in container: {}, see server log for more details. Table was null", schemaName, queryName, targetSchema.getContainer().getPath()); } else { @@ -1844,7 +1844,7 @@ public TableInfo getLookupTableInfo() TableInfo ti = qd.getTable(errors, true); if (!errors.isEmpty()) { - _log.warn("Error creating age at time lookup table for: " + schemaName + "." + queryName + " in container: " + targetSchema.getContainer().getPath()); + _log.warn("Error creating age at time lookup table for: {}.{} in container: {}", schemaName, queryName, targetSchema.getContainer().getPath()); for (QueryException e : errors) { _log.warn(e.getMessage(), e); diff --git a/ehr/src/org/labkey/ehr/utils/TriggerScriptFactory.java b/ehr/src/org/labkey/ehr/utils/TriggerScriptFactory.java index 73895e96b..9ce6a5f63 100644 --- a/ehr/src/org/labkey/ehr/utils/TriggerScriptFactory.java +++ b/ehr/src/org/labkey/ehr/utils/TriggerScriptFactory.java @@ -36,7 +36,7 @@ public class TriggerScriptFactory extends ScriptTriggerFactory { @Override @NotNull - protected Collection createTriggerScript(Container c, TableInfo table) throws ScriptException + protected Collection createTriggerScript(@NotNull Container c, TableInfo table) throws ScriptException { // Check if other triggers exist Collection ret = super.createTriggerScript(c, table); diff --git a/ehr/src/org/labkey/ehr/utils/TriggerScriptHelper.java b/ehr/src/org/labkey/ehr/utils/TriggerScriptHelper.java index 7ccdcc5c8..d62e8c5dd 100644 --- a/ehr/src/org/labkey/ehr/utils/TriggerScriptHelper.java +++ b/ehr/src/org/labkey/ehr/utils/TriggerScriptHelper.java @@ -239,7 +239,7 @@ public void updateProblemsFromCase(String newId, String oldId, String caseId) TableInfo ti = dataset.getTableInfo(user); SQLFragment sql = new SQLFragment("UPDATE studydataset." + dataset.getDomain().getStorageTableName() + " SET participantid = ? WHERE caseid = ? and participantid = ?", newId, caseId, oldId); int modified = new SqlExecutor(ti.getSchema()).execute(sql); - _log.info("updated Id on " + modified + " problems due to Id change on case: " + caseId); + _log.info("updated Id on {} problems due to Id change on case: {}", modified, caseId); } public void deleteProblemsFromCase(String caseId) @@ -258,7 +258,7 @@ public void deleteProblemsFromCase(String caseId) TableInfo ti = dataset.getTableInfo(user); SQLFragment sql = new SQLFragment("DELETE FROM studydataset." + dataset.getDomain().getStorageTableName() + " WHERE caseid = ?", caseId); int modified = new SqlExecutor(ti.getSchema()).execute(sql); - _log.info("deleted " + modified + " master problems due to case deletion: " + caseId); + _log.info("deleted {} master problems due to case deletion: {}", modified, caseId); } public void closeActiveProblemsForCase(String id, Date enddate, String caseId) @@ -337,10 +337,7 @@ public EHRQCState getQCStateForLabel(String label) { Map qcStates = EHRSecurityManager.get().getQCStateInfo(getContainer()); - if (qcStates.containsKey(label)) - return qcStates.get(label); - else - return null; + return qcStates.getOrDefault(label, null); } public static void cascadeDelete(int userId, String containerId, String schemaName, String queryName, String keyField, Object keyValue) @@ -661,7 +658,7 @@ public void createHousingRecord(String id, Date date, @Nullable Date enddate, St { if (deathDate.before(date)) { - _log.error("attempting to create a housing record that starts after the death date: " + _dateTimeFormat.format(date), new Exception()); + _log.error("attempting to create a housing record that starts after the death date: {}", _dateTimeFormat.format(date), new Exception()); return; } else if (enddate == null || enddate.after(deathDate)) @@ -769,7 +766,7 @@ public void createDemographicsRecord(String id, Map props, TableSelector ts = new TableSelector(ti, new SimpleFilter(FieldKey.fromString("Id"), id), null); if (ts.exists()) { - _log.info("Id already exists, no need to create demographics record: " + id); + _log.info("Id already exists, no need to create demographics record: {}", id); return; } @@ -858,11 +855,11 @@ public void updateDemographicsRecord(List> updatedRows) thro newRows.add(row); keyRows.add(keyRow); ids.add(id); - _log.debug("Attempting to update demographics for " + id + ": " + row); + _log.debug("Attempting to update demographics for {}: {}", id, row); } else { - _log.error("Unable to find demographics record for id: " + id); + _log.error("Unable to find demographics record for id: {}", id); } } @@ -1030,7 +1027,7 @@ public boolean isDefaultProject(Object projectId) catch (ConversionException e) { //ignore. could consider trying to resolve this against displayValue - _log.warn("unable to convert project to integer: [" + projectId + "]", new Exception()); + _log.warn("unable to convert project to integer: [{}]", projectId, new Exception()); } return false; @@ -1197,7 +1194,7 @@ else if (doWarnForBloodNearOverages()) errorMsgBuilder.append("Blood volume of ") .append(rowQuantity) .append(" (") - .append(overages.descendingSet().iterator().next()) + .append(overages.descendingSet().getFirst()) .append(" over ") .append(interval) .append(" days) exceeds the allowable volume of ") @@ -1212,7 +1209,7 @@ else if (doWarnForBloodNearOverages()) errorMsgBuilder.append("Limit notice! Blood volume of ") .append(rowQuantity) .append(" (") - .append(closeToThreshold.descendingSet().iterator().next()) + .append(closeToThreshold.descendingSet().getFirst()) .append(" over ") .append(interval) .append(" days) is within ") @@ -1468,7 +1465,7 @@ public void processCompletedRequests(final List requestIds) public void sendRequestStateEmail(final String label, final List requestIds) { JobRunner.getDefault().execute(() -> { - _log.info("processing " + label.toLowerCase() + " request email for " + requestIds.size() + " records"); + _log.info("processing {} request email for {} records", label.toLowerCase(), requestIds.size()); final TableInfo requestTable = getTableInfo("ehr", "requests"); SimpleFilter filter = new SimpleFilter(FieldKey.fromString("requestid"), requestIds, CompareType.IN); @@ -1508,7 +1505,7 @@ public void updateParentRequestQcState(String requestId, Integer qcStateId) { if (requestId != null && qcStateId != null) { - _log.info("Updating request status for " + requestId); + _log.info("Updating request status for {}", requestId); Map toUpdate = new CaseInsensitiveHashMap<>(); toUpdate.put("qcstate", qcStateId); toUpdate.put("requestid", requestId); @@ -1566,7 +1563,7 @@ private SQLFragment getRequestStudyDataSQL(Container c, User u, String requestId public void processModifiedRequests(final List requestIds) { - _log.info("processing request status for " + requestIds.size() + " records"); + _log.info("processing request status for {} records", requestIds.size()); for (String requestId : requestIds) { SQLFragment sql = getRequestStudyDataSQL(getContainer(), getUser(), requestId); @@ -1716,7 +1713,7 @@ private Date findMostRecentDate(String id, Date lastVal, Map> } catch (ConversionException e) { - _log.warn("Improper date: " + obj, e); + _log.warn("Improper date: {}", obj, e); } } } @@ -1747,7 +1744,7 @@ public void updateStatusField(List ids, Map> liveBirt { if (!idsInDemographics.contains(id)) { - _log.info("ID not in demographics table, cannot update status: " + id); + _log.info("ID not in demographics table, cannot update status: {}", id); continue; } @@ -2263,7 +2260,7 @@ public void createRequestsForBloodAdditionalServices(String id, Date date, Integ //test permission first if (!EHRService.get().hasPermission("study", "clinpathRuns", getContainer(), getUser(), InsertPermission.class, EHRService.QCSTATES.RequestPending.getQCState(getContainer()))) { - _log.warn("User does not have permission to insert requests into Clinpath Runs follow blood draw: " + getUser().getEmail()); + _log.warn("User does not have permission to insert requests into Clinpath Runs follow blood draw: {}", getUser().getEmail()); return; } @@ -2295,13 +2292,13 @@ public void createRequestsForBloodAdditionalServices(String id, Date date, Integ if (row.get("formtype") == null) { - _log.error("Unable to determine formtype for automatic lab request for service: " + row.get("service")); + _log.error("Unable to determine formtype for automatic lab request for service: {}", row.get("service")); continue; } if (rowMap.get("labwork_service") == null) { - _log.error("Unable to determine formtype for automatic lab request for service: " + row.get("service")); + _log.error("Unable to determine formtype for automatic lab request for service: {}", row.get("service")); continue; } @@ -2425,7 +2422,7 @@ public void deleteSnomedTags(String objectid) { new SqlExecutor(ti.getSchema()).execute(new SQLFragment("DELETE FROM ehr.snomed_tags WHERE objectid = ?", pk)); } - _log.info("deleted " + pks.size() + " snomed tags for record: " + objectid); + _log.info("deleted {} snomed tags for record: {}", pks.size(), objectid); } } @@ -2448,13 +2445,13 @@ public void updateSNOMEDTags(String id, String objectid, String codes, boolean i String[] codeList = StringUtils.split(codes, ";"); int sort = 1; - _log.info("adding " + codeList.length + " SNOMED tags for: " + objectid); + _log.info("adding {} SNOMED tags for: {}", codeList.length, objectid); for (String code : codeList) { String[] tokens = code.split("<>"); if (tokens.length != 2) { - _log.error("Improper SNOMED code string: " + codes); + _log.error("Improper SNOMED code string: {}", codes); continue; } @@ -2560,7 +2557,7 @@ public int compare(Map o1, Map o2) Date date = _dateTimeFormat.parse(row.get("date").toString()); if (!dateOnly && date.getHours() == 0 && date.getMinutes() == 0) { - _log.warn("Attempting to terminate " + dataset + " records with a rounded date. This might indicate upstream code is rounding the date: " + _dateTimeFormat.format(date)); + _log.warn("Attempting to terminate {} records with a rounded date. This might indicate upstream code is rounding the date: {}", dataset, _dateTimeFormat.format(date)); } SimpleFilter filter = new SimpleFilter(FieldKey.fromString("Id"), row.get("Id")); @@ -2599,7 +2596,7 @@ public int compare(Map o1, Map o2) if (!toUpdate.isEmpty()) { - _log.info("closing " + dataset + " records: " + toUpdate.size()); + _log.info("closing {} records: {}", dataset, toUpdate.size()); Map context = getExtraContext(); context.put("skipAnnounceChangedParticipants", true); context.put("skipClosingRecords", true); @@ -2653,7 +2650,7 @@ public void ensureSingleFlagCategoryActive(String id, String flag, String object TableInfo flagCategoriesTable = getTableInfo("ehr_lookups", "flag_categories"); TableSelector ts2 = new TableSelector(flagCategoriesTable, Collections.singleton("enforceUnique"), new SimpleFilter(FieldKey.fromString("category"), category), null); List ret = ts2.getArrayList(Boolean.class); - boolean enforceUnique = ret != null && ret.size() == 1 ? ret.get(0) : false; + boolean enforceUnique = ret != null && ret.size() == 1 ? ret.getFirst() : false; if (enforceUnique) { @@ -2668,19 +2665,14 @@ public void ensureSingleFlagCategoryActive(String id, String flag, String object QueryUpdateService qus = flagsTable.getUpdateService(); TableSelector ts = new TableSelector(flagsTable, PageFlowUtil.set("lsid", "Id", "enddate"), filter, null); - ts.forEach(new Selector.ForEachBlock<>() - { - @Override - public void exec(ResultSet rs) throws SQLException - { - Map row = new CaseInsensitiveHashMap<>(); - row.put("enddate", enddate); - rows.add(row); + ts.forEach(rs -> { + Map row = new CaseInsensitiveHashMap<>(); + row.put("enddate", enddate); + rows.add(row); - Map keys = new CaseInsensitiveHashMap<>(); - keys.put("lsid", rs.getString("lsid")); - oldKeys.add(keys); - } + Map keys = new CaseInsensitiveHashMap<>(); + keys.put("lsid", rs.getString("lsid")); + oldKeys.add(keys); }); try @@ -2714,7 +2706,7 @@ public Integer getNextFlagCode() { SqlSelector ss = new SqlSelector(EHRSchema.getInstance().getSchema(), "SELECT COALESCE(max(code), 0) as expr FROM ehr_lookups.flag_values"); List ret = ss.getArrayList(Integer.class); - _nextFlagCode = ret.isEmpty() ? 0 : ret.get(0); + _nextFlagCode = ret.isEmpty() ? 0 : ret.getFirst(); } _nextFlagCode++; diff --git a/ehr/test/src/org/labkey/test/tests/ehr/AbstractEHRTest.java b/ehr/test/src/org/labkey/test/tests/ehr/AbstractEHRTest.java index 53c98276e..a927d4c1b 100644 --- a/ehr/test/src/org/labkey/test/tests/ehr/AbstractEHRTest.java +++ b/ehr/test/src/org/labkey/test/tests/ehr/AbstractEHRTest.java @@ -440,7 +440,7 @@ protected void populate(@LoggedParam String tableLabel) List completeEl = completeDiv.findElements(getDriver()); clickButton("Populate " + tableLabel, 0); if (!completeEl.isEmpty()) - longWait().until(ExpectedConditions.stalenessOf(completeEl.get(0))); + longWait().until(ExpectedConditions.stalenessOf(completeEl.getFirst())); waitForElement(completeDiv, POPULATE_TIMEOUT_MS); Assert.assertFalse("Error populating " + tableLabel, elementContains(Locator.id("msgbox"), "ERROR")); resumeJsErrorChecker(); @@ -454,7 +454,7 @@ protected void deleteDataFrom(@LoggedParam String tableLabel) List completeEl = completeDiv.findElements(getDriver()); clickButton(("All".equals(tableLabel) ? "Delete " : "Delete Data From ") + tableLabel, 0); if (!completeEl.isEmpty()) - longWait().until(ExpectedConditions.stalenessOf(completeEl.get(0))); + longWait().until(ExpectedConditions.stalenessOf(completeEl.getFirst())); waitForElement(completeDiv, POPULATE_TIMEOUT_MS); Assert.assertFalse("Error deleting " + tableLabel, elementContains(Locator.id("msgbox"), "ERROR")); resumeJsErrorChecker(); diff --git a/ehr/test/src/org/labkey/test/tests/ehr/ComplianceTrainingTest.java b/ehr/test/src/org/labkey/test/tests/ehr/ComplianceTrainingTest.java index af7f0abad..0e64c0031 100644 --- a/ehr/test/src/org/labkey/test/tests/ehr/ComplianceTrainingTest.java +++ b/ehr/test/src/org/labkey/test/tests/ehr/ComplianceTrainingTest.java @@ -46,6 +46,8 @@ import java.util.Map; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; @BaseWebDriverTest.ClassTimeout(minutes = 5) public abstract class ComplianceTrainingTest extends BaseWebDriverTest implements AdvancedSqlTest @@ -158,7 +160,7 @@ public void testTriggerScripts() throws Exception SelectRowsResponse resp = src.execute(_apiHelper.getConnection(), getProjectName()); assertEquals(1, resp.getRowCount().intValue()); - assertEquals(requirementType2, resp.getRows().get(0).get("type")); + assertEquals(requirementType2, resp.getRows().getFirst().get("type")); log("checking triggers for employees table"); @@ -219,10 +221,10 @@ public void testTriggerScripts() throws Exception resp = src.execute(_apiHelper.getConnection(), getProjectName()); assertEquals(1, resp.getRowCount().intValue()); - assertEquals(employeeLocation3, resp.getRows().get(0).get("location")); - assertEquals(employeeCategory2, resp.getRows().get(0).get("category")); - assertEquals(employeeTitle2, resp.getRows().get(0).get("title")); - assertEquals(employeeType2, resp.getRows().get(0).get("type")); + assertEquals(employeeLocation3, resp.getRows().getFirst().get("location")); + assertEquals(employeeCategory2, resp.getRows().getFirst().get("category")); + assertEquals(employeeTitle2, resp.getRows().getFirst().get("title")); + assertEquals(employeeType2, resp.getRows().getFirst().get("type")); _apiHelper.updateRow("ehr_compliancedb", "employees", Maps.of("employeeid", employee1, "location", "garbage value"), true); @@ -300,16 +302,16 @@ public void testTriggerScripts() throws Exception cmd = _apiHelper.prepareUpdateCommand("ehr_compliancedb", "employees", "employeeid", new String[]{"employeeid"}, new Object[][]{{employee2}}, new Object[][]{{employee1}}); _apiHelper.doSaveRows(PasswordUtil.getUsername(), cmd, new JSONObject()); - assertEquals(false, _apiHelper.doesRowExist("ehr_compliancedb", "requirementsperemployee", Maps.of("employeeid", employee1), "employeeid")); - assertEquals(false, _apiHelper.doesRowExist("ehr_compliancedb", "employeerequirementexemptions", Maps.of("employeeid", employee1), "employeeid")); + assertFalse(_apiHelper.doesRowExist("ehr_compliancedb", "requirementsperemployee", Maps.of("employeeid", employee1), "employeeid")); + assertFalse(_apiHelper.doesRowExist("ehr_compliancedb", "employeerequirementexemptions", Maps.of("employeeid", employee1), "employeeid")); - assertEquals(true, _apiHelper.doesRowExist("ehr_compliancedb", "requirementsperemployee", Maps.of("employeeid", employee2), "employeeid")); - assertEquals(true, _apiHelper.doesRowExist("ehr_compliancedb", "employeerequirementexemptions", Maps.of("employeeid", employee2), "employeeid")); + assertTrue(_apiHelper.doesRowExist("ehr_compliancedb", "requirementsperemployee", Maps.of("employeeid", employee2), "employeeid")); + assertTrue(_apiHelper.doesRowExist("ehr_compliancedb", "employeerequirementexemptions", Maps.of("employeeid", employee2), "employeeid")); cmd = _apiHelper.prepareUpdateCommand("ehr_compliancedb", "requirements", "requirementname", new String[]{"requirementname"}, new Object[][]{{requirementName2}}, new Object[][]{{requirementName1}}); _apiHelper.doSaveRows(PasswordUtil.getUsername(), cmd, new JSONObject()); - assertEquals(false, _apiHelper.doesRowExist("ehr_compliancedb", "requirementspercategory", Maps.of("requirementname", requirementName1), "requirementname")); - assertEquals(true, _apiHelper.doesRowExist("ehr_compliancedb", "requirementspercategory", Maps.of("requirementname", requirementName2), "requirementname")); + assertFalse(_apiHelper.doesRowExist("ehr_compliancedb", "requirementspercategory", Maps.of("requirementname", requirementName1), "requirementname")); + assertTrue(_apiHelper.doesRowExist("ehr_compliancedb", "requirementspercategory", Maps.of("requirementname", requirementName2), "requirementname")); } @Test diff --git a/ehr/test/src/org/labkey/test/tests/ehr/EHRBillingHelper.java b/ehr/test/src/org/labkey/test/tests/ehr/EHRBillingHelper.java index 822d0c3d4..66a7fa750 100644 --- a/ehr/test/src/org/labkey/test/tests/ehr/EHRBillingHelper.java +++ b/ehr/test/src/org/labkey/test/tests/ehr/EHRBillingHelper.java @@ -120,7 +120,7 @@ public void verifyBillingInvoicedItemsUsingAPI(String InvoicedId, List canMove(Container c, Container newParent, User user) - { - return Collections.emptyList(); - } } \ No newline at end of file diff --git a/ehr_billing/src/org/labkey/ehr_billing/EHR_BillingController.java b/ehr_billing/src/org/labkey/ehr_billing/EHR_BillingController.java index 031991db3..7864e7ad3 100644 --- a/ehr_billing/src/org/labkey/ehr_billing/EHR_BillingController.java +++ b/ehr_billing/src/org/labkey/ehr_billing/EHR_BillingController.java @@ -199,7 +199,7 @@ public ModelAndView getView(QueryForm form, BindException errors) String keyField = null; if (pks.size() == 1) - keyField = pks.get(0); + keyField = pks.getFirst(); ColumnInfo objectid = ti.getColumn("objectid"); diff --git a/ehr_billing/src/org/labkey/ehr_billing/notification/BillingNotification.java b/ehr_billing/src/org/labkey/ehr_billing/notification/BillingNotification.java index fdde62318..e24ed7963 100644 --- a/ehr_billing/src/org/labkey/ehr_billing/notification/BillingNotification.java +++ b/ehr_billing/src/org/labkey/ehr_billing/notification/BillingNotification.java @@ -380,7 +380,7 @@ public void exec(ResultSet object) throws SQLException values = new HashMap<>(); - Integer count = values.containsKey(fd.getFieldName()) ? values.get(fd.getFieldName()) : 0; + Integer count = values.getOrDefault(fd.getFieldName(), 0); count++; values.put(fd.getFieldName(), count); diff --git a/ehr_billing/src/org/labkey/ehr_billing/pipeline/BillingPipelineJob.java b/ehr_billing/src/org/labkey/ehr_billing/pipeline/BillingPipelineJob.java index d2927ea9a..7d0780f75 100644 --- a/ehr_billing/src/org/labkey/ehr_billing/pipeline/BillingPipelineJob.java +++ b/ehr_billing/src/org/labkey/ehr_billing/pipeline/BillingPipelineJob.java @@ -32,7 +32,6 @@ import org.labkey.api.view.ViewBackgroundInfo; import org.labkey.vfs.FileLike; -import java.io.File; import java.io.IOException; import java.util.Calendar; import java.util.Date; diff --git a/ehr_billing/src/org/labkey/ehr_billing/pipeline/BillingTask.java b/ehr_billing/src/org/labkey/ehr_billing/pipeline/BillingTask.java index 4e44bf8d5..f6e292312 100644 --- a/ehr_billing/src/org/labkey/ehr_billing/pipeline/BillingTask.java +++ b/ehr_billing/src/org/labkey/ehr_billing/pipeline/BillingTask.java @@ -140,8 +140,8 @@ public RecordedActionSet run() throws PipelineJobException throw new PipelineJobException("Billing Container not found."); getJob().getLogger().info("Beginning process to save billing run data"); - getJob().getLogger().info("Start date: " + getSupport().getStartDate().toString()); - getJob().getLogger().info("End date: " + getSupport().getEndDate().toString()); + getJob().getLogger().info("Start date: {}", getSupport().getStartDate().toString()); + getJob().getLogger().info("End date: {}", getSupport().getEndDate().toString()); User user = getJob().getUser(); Container container = getJob().getContainer(); @@ -291,7 +291,7 @@ private String getOrCreateInvoiceRecord(Map row, Date endDate) t TableSelector ts = new TableSelector(invoice, filter, null); if (!ts.exists()) { - getJob().getLogger().info("Creating invoice record for invoice number " + invoiceNumber); + getJob().getLogger().info("Creating invoice record for invoice number {}", invoiceNumber); Map toCreate = new CaseInsensitiveHashMap<>(); toCreate.put("invoiceNumber", invoiceNumber); toCreate.put("accountNumber", row.get("debitedAccount")); @@ -363,7 +363,7 @@ private void writeToInvoicedItems(BillingPipelineJobProcess process, Collection< { if (toInsert.get(field) == null) { - getJob().getLogger().warn("Missing value for field: " + field + " for transactionNumber: " + toInsert.get("transactionNumber")); + getJob().getLogger().warn("Missing value for field: {} for transactionNumber: {}", field, toInsert.get("transactionNumber")); } } @@ -391,7 +391,7 @@ private void updateProcessedMiscChargesRecords(BillingPipelineJobProcess process { TableInfo ti = process.getMiscChargesTableInfo() != null ? process.getMiscChargesTableInfo() : EHR_BillingSchema.getInstance().getMiscCharges(); String invoiceId = getOrCreateInvoiceRunRecord(); - getJob().getLogger().info("Updating " + rows.size() + " records in " + ti.getName() + " table"); + getJob().getLogger().info("Updating {} records in {} table", rows.size(), ti.getName()); int updates = 0; for (Map row : rows) @@ -404,14 +404,14 @@ private void updateProcessedMiscChargesRecords(BillingPipelineJobProcess process Table.update(getJob().getUser(), ti, toUpdate, objectId); } - getJob().getLogger().info("Finished updating " + updates + " records in " + ti.getName() + " table."); + getJob().getLogger().info("Finished updating {} records in {} table.", updates, ti.getName()); } catch (RuntimeSQLException e) { throw new PipelineJobException(e); } - getJob().getLogger().info("Finished updating records for Invoice Run Id " + _invoiceId); + getJob().getLogger().info("Finished updating records for Invoice Run Id {}", _invoiceId); } private Collection> getRowList(BillingPipelineJobProcess process, Container container) @@ -442,7 +442,7 @@ private Collection> getRowList(BillingPipelineJobProcess pro if (!colKeys.containsKey(col)) { - getJob().getLogger().warn("Unable to find column with key: " + col + " for table: " + ti.getPublicName()); + getJob().getLogger().warn("Unable to find column with key: {} for table: {}", col, ti.getPublicName()); } } @@ -453,7 +453,7 @@ private Collection> getRowList(BillingPipelineJobProcess pro private void runProcessing(BillingPipelineJobProcess process, Container billingRunContainer) throws PipelineJobException { - getJob().getLogger().info("Caching " + process.getLabel()); + getJob().getLogger().info("Caching {}", process.getLabel()); if (process.isProcedureCharges()) { @@ -472,7 +472,7 @@ private void runProcessing(BillingPipelineJobProcess process, Container billingR String procedureQuery = (String) row.get("queryName"); int chargeId = (Integer) row.get("chargeId"); - getJob().getLogger().info("Processing '" + row.get("description") + "'"); + getJob().getLogger().info("Processing '{}'", row.get("description")); // for each procedure query, get query results UserSchema schema = QueryService.get().getUserSchema(getJob().getUser(), billingRunContainer, procedureSchema); @@ -528,11 +528,11 @@ private void runProcessing(BillingPipelineJobProcess process, Container billingR else if (process.getQueryName() != null && !process.getQueryToInvoiceItemColMap().isEmpty()) { Collection> rows = getRowList(process, billingRunContainer); - getJob().getLogger().info(rows.size() + " rows found"); + getJob().getLogger().info("{} rows found", rows.size()); writeToInvoicedItems(process, rows, getSupport()); } - getJob().getLogger().info("Finished Caching " + process.getLabel()); + getJob().getLogger().info("Finished Caching {}", process.getLabel()); } private ChargeInfo getChargeInfo(int chargeId, ArrayList chargeInfoArrayList, Object date) @@ -675,7 +675,7 @@ private void updateInvoiceTable(Container billingRunContainer) Iterator> iterator = invoiceTotalCost.iterator(); Map existingInvoiceAmounts = getExistingInvoiceAmounts(); - getJob().getLogger().info(invoiceTotalCost.getSize() + " rows to be updated"); + getJob().getLogger().info("{} rows to be updated", invoiceTotalCost.getSize()); while (iterator.hasNext()) {