From 72adc29f541df0b51d28c92420c2ad8d32cace76 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Sun, 8 Jun 2025 15:00:39 -0700 Subject: [PATCH 1/2] Minor auto-refactor code cleanup on a massive scale --- .../ldk/table/AbstractTableCustomizer.java | 2 +- .../api/ldk/table/ContainerScopedTable.java | 6 +- .../api/ldk/table/CustomPermissionsTable.java | 2 +- .../org/labkey/api/ldk/table/QueryCache.java | 10 +-- .../ldk/table/SimpleButtonConfigFactory.java | 4 +- LDK/src/org/labkey/ldk/LDKController.java | 30 +++---- LDK/src/org/labkey/ldk/LDKServiceImpl.java | 12 +-- .../ldk/notification/NotificationJob.java | 2 +- .../notification/NotificationServiceImpl.java | 7 +- .../notification/SiteSummaryNotification.java | 36 ++++----- .../ldk/query/DefaultTableCustomizer.java | 9 +-- .../org/labkey/ldk/query/LookupSetTable.java | 1 - .../ldk/query/LookupValidationHelper.java | 4 +- .../ldk/query/UniqueConstraintHelper.java | 2 - .../external/labModules/LabModulesTest.java | 18 ++--- .../external/labModules/LabModuleHelper.java | 5 +- .../api/laboratory/AbstractUrlNavItem.java | 4 +- .../api/laboratory/LaboratoryService.java | 2 +- .../api/laboratory/StaticURLNavItem.java | 2 - .../assay/AbstractAssayDataProvider.java | 6 +- .../laboratory/assay/AssayDataProvider.java | 18 ++--- .../api/laboratory/assay/AssayParser.java | 8 +- .../assay/DefaultAssayImportMethod.java | 2 +- .../laboratory/assay/DefaultAssayParser.java | 9 +-- .../laboratory/assay/PivotingAssayParser.java | 13 ++-- .../assay/PivotingImportMethod.java | 4 +- .../query/ContainerIncrementingTable.java | 10 +-- .../ExtraDataSourcesDataProvider.java | 4 +- .../LaboratoryContainerListener.java | 1 - .../laboratory/LaboratoryController.java | 78 +++++++++---------- .../laboratory/LaboratoryDataProvider.java | 2 +- .../labkey/laboratory/LaboratoryManager.java | 8 +- .../laboratory/LaboratoryUpgradeCode.java | 4 +- .../laboratory/SampleTypeDataProvider.java | 4 +- .../labkey/laboratory/assay/AssayHelper.java | 10 +-- .../laboratory/assay/RunUploadContext.java | 4 +- .../notification/LabSummaryNotification.java | 8 +- .../query/AssayRunTemplatesCustomizer.java | 4 +- .../query/FreezerTriggerHelper.java | 8 +- .../query/LaboratoryTableCustomizer.java | 4 +- .../query/LaboratoryWorkbooksTable.java | 12 +-- .../laboratory/query/SamplesCustomizer.java | 2 +- .../security/LaboratoryAdminRole.java | 5 -- .../table/WrappingTableCustomizer.java | 2 +- 44 files changed, 183 insertions(+), 205 deletions(-) diff --git a/LDK/api-src/org/labkey/api/ldk/table/AbstractTableCustomizer.java b/LDK/api-src/org/labkey/api/ldk/table/AbstractTableCustomizer.java index 2ed208f0..56e4b348 100644 --- a/LDK/api-src/org/labkey/api/ldk/table/AbstractTableCustomizer.java +++ b/LDK/api-src/org/labkey/api/ldk/table/AbstractTableCustomizer.java @@ -42,7 +42,7 @@ abstract public class AbstractTableCustomizer implements TableCustomizer * Rely on DefaultSchema's caching of schema creation, and just track the minimum number of DefaultSchemas to * resolve the requested collection of target containers */ - private Map _defaultSchemas = new HashMap<>(); + private final Map _defaultSchemas = new HashMap<>(); public UserSchema getUserSchema(AbstractTableInfo ti, String name) { diff --git a/LDK/api-src/org/labkey/api/ldk/table/ContainerScopedTable.java b/LDK/api-src/org/labkey/api/ldk/table/ContainerScopedTable.java index d1145f73..696c81f0 100644 --- a/LDK/api-src/org/labkey/api/ldk/table/ContainerScopedTable.java +++ b/LDK/api-src/org/labkey/api/ldk/table/ContainerScopedTable.java @@ -242,7 +242,7 @@ public DataIterator getDataIterator(DataIteratorContext context) final String containerColName = getContainerFilterColumn(); final KeyManager keyManager = new KeyManager(); final SimpleTranslator it = new SimpleTranslator(input, context); - final Map inputColMap = new HashMap(); + final Map inputColMap = new HashMap<>(); for (int idx = 1; idx <= input.getColumnCount(); idx++) { ColumnInfo col = input.getColumnInfo(idx); @@ -262,7 +262,7 @@ public DataIterator getDataIterator(DataIteratorContext context) //set the value of the RowId column ColumnInfo pseudoPkCol = getColumn(_pseudoPk); - it.addColumn(pseudoPkCol, new Callable() + it.addColumn(pseudoPkCol, new Callable<>() { @Override public Object call() @@ -270,7 +270,7 @@ public Object call() Container c = null; if (inputColMap.containsKey(containerColName)) { - String containerId = (String)it.getInputColumnValue(inputColMap.get(containerColName)); + String containerId = (String) it.getInputColumnValue(inputColMap.get(containerColName)); if (containerId != null) c = ContainerManager.getForId(containerId); } diff --git a/LDK/api-src/org/labkey/api/ldk/table/CustomPermissionsTable.java b/LDK/api-src/org/labkey/api/ldk/table/CustomPermissionsTable.java index 17b631a8..076ff6a3 100644 --- a/LDK/api-src/org/labkey/api/ldk/table/CustomPermissionsTable.java +++ b/LDK/api-src/org/labkey/api/ldk/table/CustomPermissionsTable.java @@ -34,7 +34,7 @@ */ public class CustomPermissionsTable extends SimpleUserSchema.SimpleTable { - private Map, Class> _permMap = new HashMap<>(); + private final Map, Class> _permMap = new HashMap<>(); public CustomPermissionsTable(SchemaType schema, TableInfo table, ContainerFilter cf) { diff --git a/LDK/api-src/org/labkey/api/ldk/table/QueryCache.java b/LDK/api-src/org/labkey/api/ldk/table/QueryCache.java index 5a251997..35b4798c 100644 --- a/LDK/api-src/org/labkey/api/ldk/table/QueryCache.java +++ b/LDK/api-src/org/labkey/api/ldk/table/QueryCache.java @@ -46,10 +46,10 @@ public class QueryCache { private static final Logger _log = LogManager.getLogger(QueryCache.class); - private Map _cachedAssaySchemas = new HashMap<>(); - private Map _cachedUserSchemas = new HashMap<>(); - private Map _cachedQueries = new HashMap<>(); - private Map _cachedColumns = new HashMap<>(); + private final Map _cachedAssaySchemas = new HashMap<>(); + private final Map _cachedUserSchemas = new HashMap<>(); + private final Map _cachedQueries = new HashMap<>(); + private final Map _cachedColumns = new HashMap<>(); public QueryCache() { @@ -104,7 +104,7 @@ public TableInfo getTableInfo(Container targetContainer, User u, String schemaPa List errors = new ArrayList<>(); TableInfo ti = qd.getTable(errors, true); - if (errors.size() > 0) + if (!errors.isEmpty()) { _log.error("Unable to create tabbed report item for query: " + schemaPath + "." + queryName + " in " + targetContainer.getPath()); for (QueryException e : errors) diff --git a/LDK/api-src/org/labkey/api/ldk/table/SimpleButtonConfigFactory.java b/LDK/api-src/org/labkey/api/ldk/table/SimpleButtonConfigFactory.java index 9f07e0d0..9e6b332a 100644 --- a/LDK/api-src/org/labkey/api/ldk/table/SimpleButtonConfigFactory.java +++ b/LDK/api-src/org/labkey/api/ldk/table/SimpleButtonConfigFactory.java @@ -39,8 +39,8 @@ */ public class SimpleButtonConfigFactory implements ButtonConfigFactory { - private Module _owner; - private String _text; + private final Module _owner; + private final String _text; private DetailsURL _url = null; private String _jsHandler = null; private Integer _insertPosition = null; diff --git a/LDK/src/org/labkey/ldk/LDKController.java b/LDK/src/org/labkey/ldk/LDKController.java index 168ac090..bfa75aec 100644 --- a/LDK/src/org/labkey/ldk/LDKController.java +++ b/LDK/src/org/labkey/ldk/LDKController.java @@ -111,7 +111,7 @@ public LDKController() } @RequiresPermission(ReadPermission.class) - public class GetNotificationsAction extends ReadOnlyApiAction + public static class GetNotificationsAction extends ReadOnlyApiAction { @Override public ApiResponse execute(Object form, BindException errors) @@ -136,7 +136,7 @@ public ApiResponse execute(Object form, BindException errors) } @RequiresPermission(ReadPermission.class) - public class GetFileRootSizesAction extends ReadOnlyApiAction + public static class GetFileRootSizesAction extends ReadOnlyApiAction { @Override public ApiResponse execute(FileRootSizeForm form, BindException errors) throws Exception @@ -212,7 +212,7 @@ public void setIncludeFileCounts(Boolean includeFileCounts) } @RequiresPermission(AdminOperationsPermission.class) - public class GetSiteNotificationDetailsAction extends ReadOnlyApiAction + public static class GetSiteNotificationDetailsAction extends ReadOnlyApiAction { @Override public ApiResponse execute(Object form, BindException errors) throws Exception @@ -242,7 +242,7 @@ public ApiResponse execute(Object form, BindException errors) throws Exception } @RequiresPermission(UpdatePermission.class) - public class UpdateNotificationSubscriptionsAction extends MutatingApiAction + public static class UpdateNotificationSubscriptionsAction extends MutatingApiAction { @Override public ApiResponse execute(UpdateNotificationSubscriptionsForm form, BindException errors) throws Exception @@ -349,7 +349,7 @@ public void setToRemove(Integer[] toRemove) } @RequiresPermission(ReadPermission.class) - public class RunNotificationAction extends SimpleViewAction + public static class RunNotificationAction extends SimpleViewAction { private String _title = null; @@ -403,7 +403,7 @@ public void addNavTrail(NavTree root) } @RequiresPermission(AdminPermission.class) - public class SendNotificationAction extends MutatingApiAction + public static class SendNotificationAction extends MutatingApiAction { @Override public ApiResponse execute(RunNotificationForm form, BindException errors) throws Exception @@ -437,7 +437,7 @@ public ApiResponse execute(RunNotificationForm form, BindException errors) throw } @RequiresPermission(ReadPermission.class) - public class ValidateContainerScopedTablesAction extends SimpleViewAction + public static class ValidateContainerScopedTablesAction extends SimpleViewAction { @Override public ModelAndView getView(Object form, BindException errors) throws Exception @@ -459,7 +459,7 @@ public void addNavTrail(NavTree root) } @RequiresPermission(AdminPermission.class) - public class GetNotificationSubscriptionsAction extends ReadOnlyApiAction + public static class GetNotificationSubscriptionsAction extends ReadOnlyApiAction { @Override public ApiResponse execute(RunNotificationForm form, BindException errors) throws Exception @@ -509,7 +509,7 @@ public ApiResponse execute(RunNotificationForm form, BindException errors) throw } @RequiresPermission(AdminPermission.class) - public class SetNotificationSettingsAction extends MutatingApiAction + public static class SetNotificationSettingsAction extends MutatingApiAction { @Override public ApiResponse execute(NotificationSettingsForm form, BindException errors) @@ -648,7 +648,7 @@ public Predicate allowBindParameter() @RequiresPermission(ReadPermission.class) - public class LogMetricAction extends MutatingApiAction + public static class LogMetricAction extends MutatingApiAction { @Override public ApiResponse execute(LogMetricForm form, BindException errors) throws Exception @@ -822,7 +822,7 @@ public void setKey(String key) } @RequiresPermission(ReadPermission.class) - public class UpdateQueryAction extends SimpleViewAction + public static class UpdateQueryAction extends SimpleViewAction { private QueryForm _form; @@ -1019,7 +1019,7 @@ public void setTargetContainer(String targetContainer) } @RequiresNoPermission - public class RedirectStartAction extends SimpleViewAction + public static class RedirectStartAction extends SimpleViewAction { @Override public ModelAndView getView(Object form, BindException errors) throws Exception @@ -1065,7 +1065,7 @@ public void addNavTrail(NavTree root) public static final String REDIRECT_URL_PROP = "redirectURL"; @RequiresPermission(AdminPermission.class) - public class SetRedirectUrlAction extends MutatingApiAction + public static class SetRedirectUrlAction extends MutatingApiAction { @Override public ApiResponse execute(SetRedirectUrlForm form, BindException errors) throws Exception @@ -1100,7 +1100,7 @@ public void setUrl(String url) } @RequiresPermission(AdminPermission.class) - public class GetRedirectUrlAction extends ReadOnlyApiAction + public static class GetRedirectUrlAction extends ReadOnlyApiAction { @Override public ApiResponse execute(Object form, BindException errors) throws Exception @@ -1111,7 +1111,7 @@ public ApiResponse execute(Object form, BindException errors) throws Exception @RequiresPermission(AdminOperationsPermission.class) @AllowedDuringUpgrade - public class DownloadNaturalizeInstallScriptAction extends ExportAction + public static class DownloadNaturalizeInstallScriptAction extends ExportAction { @Override public void export(Object o, HttpServletResponse response, BindException errors) throws Exception diff --git a/LDK/src/org/labkey/ldk/LDKServiceImpl.java b/LDK/src/org/labkey/ldk/LDKServiceImpl.java index 99a722c7..8f3908a3 100644 --- a/LDK/src/org/labkey/ldk/LDKServiceImpl.java +++ b/LDK/src/org/labkey/ldk/LDKServiceImpl.java @@ -60,7 +60,7 @@ public class LDKServiceImpl extends LDKService private final Set _summaryNotificationSections = new HashSet<>(); private final List> _containerScopedTables = new ArrayList<>(); private Boolean _isNaturalizeInstalled = null; - private final Map>> _queryButtons = new CaseInsensitiveHashMap>>(); + private final Map>> _queryButtons = new CaseInsensitiveHashMap<>(); private static final String BACKGROUND_USER_PROPNAME = "BackgroundAdminUser"; public LDKServiceImpl() @@ -113,7 +113,7 @@ public Map getContainerSizeJson(Container c, User u, boolean inc //append children if (includeAllRootTypes) { - Set paths = new HashSet(); + Set paths = new HashSet<>(); for (FileContentService.ContentType type : FileContentService.ContentType.values()) { File fileRoot = svc.getFileRoot(c, type); @@ -268,7 +268,7 @@ public List validateContainerScopedTables(boolean onlyReportErrors) if (ss.exists()) { messages.add("ERROR: duplicates found in: " + values.get(0) + "." + values.get(1)); - ss.forEach(new Selector.ForEachBlock() + ss.forEach(new Selector.ForEachBlock<>() { @Override public void exec(ResultSet rs) throws SQLException @@ -334,11 +334,11 @@ public void registerQueryButton(ButtonConfigFactory btn, String schema, String q { Map> schemaMap = _queryButtons.get(schema); if (schemaMap == null) - schemaMap = new CaseInsensitiveHashMap>(); + schemaMap = new CaseInsensitiveHashMap<>(); List list = schemaMap.get(query); if (list == null) - list = new ArrayList(); + list = new ArrayList<>(); list.add(btn); @@ -349,7 +349,7 @@ public void registerQueryButton(ButtonConfigFactory btn, String schema, String q @Override public List getQueryButtons(TableInfo ti) { - List buttons = new ArrayList(); + List buttons = new ArrayList<>(); Map> factories = _queryButtons.get(ti.getPublicSchemaName()); if (factories == null) diff --git a/LDK/src/org/labkey/ldk/notification/NotificationJob.java b/LDK/src/org/labkey/ldk/notification/NotificationJob.java index 4ed0b33f..6c9cab80 100644 --- a/LDK/src/org/labkey/ldk/notification/NotificationJob.java +++ b/LDK/src/org/labkey/ldk/notification/NotificationJob.java @@ -42,7 +42,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException _log.info("Trying to run notification: " + _notification.getName()); Set activeContainers = NotificationServiceImpl.get().getActiveContainers(_notification); - if (activeContainers.size() == 0) + if (activeContainers.isEmpty()) { _log.info("there are no active containers, skipping"); } diff --git a/LDK/src/org/labkey/ldk/notification/NotificationServiceImpl.java b/LDK/src/org/labkey/ldk/notification/NotificationServiceImpl.java index 6fede1fd..4c7a95c9 100644 --- a/LDK/src/org/labkey/ldk/notification/NotificationServiceImpl.java +++ b/LDK/src/org/labkey/ldk/notification/NotificationServiceImpl.java @@ -466,7 +466,8 @@ public Set getRecipients(Notification n, Container c) TableSelector ts = new TableSelector(t, Collections.singleton("recipient"), filter, null); if (ts.getRowCount() > 0) { - ts.forEach(new TableSelector.ForEachBlock(){ + ts.forEach(new TableSelector.ForEachBlock<>() + { @Override public void exec(ResultSet rs) throws SQLException { @@ -586,7 +587,7 @@ public void runForContainer(Notification notification, Container c) } List
recipients = NotificationServiceImpl.get().getEmails(notification, c); - if (recipients.size() == 0) + if (recipients.isEmpty()) { _log.info("Notification: " + notification.getName() + " has no recipients, skipping"); return; @@ -605,7 +606,7 @@ public void runForContainer(Notification notification, Container c) mail.setFrom(NotificationServiceImpl.get().getReturnEmail(c)); mail.setSubject(notification.getEmailSubject(c)); - mail.addRecipients(Message.RecipientType.TO, recipients.toArray(new Address[recipients.size()])); + mail.addRecipients(Message.RecipientType.TO, recipients.toArray(new Address[0])); MailHelper.send(mail, u, c); } diff --git a/LDK/src/org/labkey/ldk/notification/SiteSummaryNotification.java b/LDK/src/org/labkey/ldk/notification/SiteSummaryNotification.java index 5c15f0ea..5e85abae 100644 --- a/LDK/src/org/labkey/ldk/notification/SiteSummaryNotification.java +++ b/LDK/src/org/labkey/ldk/notification/SiteSummaryNotification.java @@ -189,7 +189,7 @@ public String getMessageBodyHTML(Container c, User u) _pctFormat.setMaximumFractionDigits(1); Map saved = getSavedValues(c); - Map newValues = new HashMap(); + Map newValues = new HashMap<>(); StringBuilder msg = new StringBuilder(); StringBuilder alerts = new StringBuilder(); @@ -214,7 +214,7 @@ public String getMessageBodyHTML(Container c, User u) } } - if (alerts.length() > 0) + if (!alerts.isEmpty()) { alerts.insert(0, "The following alerts were generated:

"); alerts.append("


"); @@ -261,7 +261,7 @@ private void siteUsage(Container c, User u, final StringBuilder msg, final Strin msg.append("Site Logins In The Past 7 Days:
\n"); msg.append(""); - ss.forEach(new Selector.ForEachBlock() + ss.forEach(new Selector.ForEachBlock<>() { @Override public void exec(ResultSet rs) throws SQLException @@ -296,7 +296,7 @@ private void dataEntryStatus(Container c, User u, final StringBuilder msg) msg.append("Number of Forms Created Yesterday:
\n"); - ss.forEach(new Selector.ForEachBlock() + ss.forEach(new Selector.ForEachBlock<>() { @Override public void exec(ResultSet rs) throws SQLException @@ -314,7 +314,7 @@ private void getStudySizeSummary(Container c, User u, final StringBuilder msg, f String studySize = "studySize"; if (!studies.isEmpty()) { - Map newValueMap = new HashMap(); + Map newValueMap = new HashMap<>(); JSONObject oldValueMap = null; if (saved.containsKey(studySize)) { @@ -343,7 +343,7 @@ private void getStudySizeSummary(Container c, User u, final StringBuilder msg, f msg.append("
Day of WeekDateLoginsDistinct UsersLogins / User
"); - if (newValueMap.size() > 0) + if (!newValueMap.isEmpty()) toSave.put(studySize, new JSONObject(newValueMap).toString()); } } @@ -458,9 +458,9 @@ private void getFileRootSizes(Container c, User u, final StringBuilder msg, fina msg.append("
"); msg.append("
"); - if (newValueMap.size() > 0) + if (!newValueMap.isEmpty()) toSave.put(fileRootSizes, new JSONObject(newValueMap).toString()); - if (newValueMapCounts.size() > 0) + if (!newValueMapCounts.isEmpty()) toSave.put(fileRootCounts, new JSONObject(newValueMapCounts).toString()); } @@ -502,7 +502,7 @@ else if (DbScope.getLabKeyScope().getSqlDialect().isSqlServer()) final Map newValueMap = new HashMap<>(); final JSONObject oldValueMap = saved.containsKey(tableSizes) ? new JSONObject(saved.get(tableSizes)) : null; - ss.forEach(new Selector.ForEachBlock() + ss.forEach(new Selector.ForEachBlock<>() { @Override public void exec(ResultSet object) throws SQLException @@ -519,14 +519,14 @@ public void exec(ResultSet object) throws SQLException previousValue = oldValueMap.getLong(key); } - String pctChange = getPctChange(previousValue, total, 0.05, "The number of rows in the table " + key + " has changed signficiantly since the last run on " + getLastSaveString(c, saved), alerts); + String pctChange = getPctChange(previousValue, total, 0.05, "The number of rows in the table " + key + " has changed signficiantly since the last run on " + getLastSaveString(c, saved), alerts); msg.append("" + (schema == null ? "" : schema) + "" + (table == null ? "" : table) + "" + (total == null ? "" : NumberFormat.getInstance().format(total)) + "" + (previousValue == null ? "" : NumberFormat.getInstance().format(previousValue)) + "" + pctChange + ""); } }); msg.append("
"); - if (newValueMap.size() > 0) + if (!newValueMap.isEmpty()) toSave.put(tableSizes, new JSONObject(newValueMap).toString()); } @@ -543,7 +543,7 @@ private void getDBSize(Container c, User u, final StringBuilder msg, final Strin SqlSelector ss; String dbSizes = "dbSizes"; - final Map newValueMap = new HashMap(); + final Map newValueMap = new HashMap<>(); final JSONObject oldValueMap = saved.containsKey(dbSizes) ? new JSONObject(saved.get(dbSizes)) : null; if (DbScope.getLabKeyScope().getSqlDialect().isSqlServer()) @@ -560,10 +560,10 @@ private void getDBSize(Container c, User u, final StringBuilder msg, final Strin msg.append(""); for (Map row : maps) { - Long size = Long.parseLong(row.get("size").toString()); + long size = Long.parseLong(row.get("size").toString()); String key = row.get("LogicalName").toString(); - newValueMap.put(key, size.toString()); + newValueMap.put(key, Long.toString(size)); Long previousValue = null; if (oldValueMap != null && oldValueMap.has(key)) { @@ -575,7 +575,7 @@ private void getDBSize(Container c, User u, final StringBuilder msg, final Strin } msg.append("
DatabaseLogical NameSize (MB)Previous Size% Change
"); - if (newValueMap.size() > 0) + if (!newValueMap.isEmpty()) toSave.put(dbSizes, new JSONObject(newValueMap).toString()); } } @@ -632,7 +632,7 @@ private void getListSummary(Container c, User u, final StringBuilder msg, final if (ld != null) msg.append("" + ld.getName() + "" + ld.getContainer().getPath() + "" + NumberFormat.getInstance().format(entry.getValue()) + "" + (previousValue == null ? "" : NumberFormat.getInstance().format(previousValue)) + "" + pctChange + ""); - if (newValueMap.size() > 0) + if (!newValueMap.isEmpty()) toSave.put(listSizes, new JSONObject(newValueMap).toString()); } @@ -692,7 +692,7 @@ private void getAssayRunSummary(Container c, User u, final StringBuilder msg, fi msg.append("
Assay Summary:

"); msg.append(""); - Map newValueMap = new HashMap(); + Map newValueMap = new HashMap<>(); JSONObject oldValueMap = saved.containsKey(assayResultSize) ? new JSONObject(saved.get(assayResultSize)) : null; for (String ap : providerMap.keySet()) @@ -716,7 +716,7 @@ private void getAssayRunSummary(Container c, User u, final StringBuilder msg, fi } msg.append("
ProviderProtocolContainer Path# Runs# ResultsPrevious Value% Change

"); - if (newValueMap.size() > 0) + if (!newValueMap.isEmpty()) toSave.put(assayResultSize, new JSONObject(newValueMap).toString()); } } \ No newline at end of file diff --git a/LDK/src/org/labkey/ldk/query/DefaultTableCustomizer.java b/LDK/src/org/labkey/ldk/query/DefaultTableCustomizer.java index db2bc47d..8cb25982 100644 --- a/LDK/src/org/labkey/ldk/query/DefaultTableCustomizer.java +++ b/LDK/src/org/labkey/ldk/query/DefaultTableCustomizer.java @@ -48,7 +48,6 @@ import org.labkey.api.view.template.ClientDependency; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -125,7 +124,7 @@ private void setDetailsUrl(AbstractTableInfo ti) assert queryName != null; List keyFields = ti.getPkColumnNames(); - assert keyFields.size() > 0 : "No key fields found for the table: " + ti.getPublicSchemaName() + "." + ti.getPublicName(); + assert !keyFields.isEmpty() : "No key fields found for the table: " + ti.getPublicSchemaName() + "." + ti.getPublicName(); if (keyFields.size() != 1) { _log.error("Table: " + ti.getUserSchema().getSchemaName() + "." + ti.getPublicName() + " has more than 1 PK: " + StringUtils.join(keyFields, ";") + ", cannot apply custom links - please update the TableCustomizer properties"); @@ -159,14 +158,14 @@ else if (_settings.isSetEditLinkOverrides()) assert queryName != null; List keyFields = ti.getPkColumnNames(); - assert keyFields.size() > 0 : "No key fields found for the table: " + ti.getPublicSchemaName() + "." + ti.getPublicName(); + assert !keyFields.isEmpty() : "No key fields found for the table: " + ti.getPublicSchemaName() + "." + ti.getPublicName(); if (keyFields.size() != 1) { _log.error("Table: " + schemaName + "." + queryName + " has more than 1 PK: " + StringUtils.join(keyFields, ";") + ", cannot apply custom links - please update the TableCustomizer properties"); return; } - if (schemaName != null && queryName != null && keyFields.size() > 0) + if (schemaName != null && queryName != null && !keyFields.isEmpty()) { String keyField = keyFields.get(0); if (!AbstractTableInfo.LINK_DISABLER_ACTION_URL.equals(ti.getImportDataURL(ti.getUserSchema().getContainer()))) @@ -393,7 +392,7 @@ private static boolean configureMoreActionsBtn(TableInfo ti, List _userSchemaMap = new HashMap(); - private final Map> _allowableValueMap = new HashMap>(); + private final Map _userSchemaMap = new HashMap<>(); + private final Map> _allowableValueMap = new HashMap<>(); private LookupValidationHelper(String containerId, int userId, String schemaName, String queryName) { diff --git a/LDK/src/org/labkey/ldk/query/UniqueConstraintHelper.java b/LDK/src/org/labkey/ldk/query/UniqueConstraintHelper.java index 8dbe893e..e1407d15 100644 --- a/LDK/src/org/labkey/ldk/query/UniqueConstraintHelper.java +++ b/LDK/src/org/labkey/ldk/query/UniqueConstraintHelper.java @@ -17,9 +17,7 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** diff --git a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java index 8a64d61b..9dd1ccb6 100644 --- a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java +++ b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java @@ -303,7 +303,7 @@ private void dateParseTest() throws ParseException checkDate("3/5/99", dateFormat3); String clientFormattedString = (String)executeScript("return Ext4.Date.format(LDK.ConvertUtils.parseDate('2024-01-01', 'c'), 'Y-m-d');"); - assertEquals("Incorrect date parsing", clientFormattedString, "2024-01-01"); + assertEquals("Incorrect date parsing", "2024-01-01", clientFormattedString); } private void checkDate(String dateStr, String javaFormatStr) throws ParseException @@ -329,7 +329,7 @@ private void workbookNumberingTest() throws Exception Connection cn = WebTestHelper.getRemoteApiConnection(); //do cleanup in case test is started in the middle - Integer highestWorkbookId = deleteExistingWorkbooks(); + int highestWorkbookId = deleteExistingWorkbooks(); List workbooks = new ArrayList<>(); workbooks.add(_apiContainerHelper.createWorkbook(getProjectName(), "Workbook1", null)); @@ -1466,8 +1466,8 @@ private void samplesTableTest() throws Exception int colIdx = dr.getColumnIndex("comment"); String comment1 = dr.getDataAsText(1, colIdx); String comment2 = dr.getDataAsText(2, colIdx); - Assert.assertEquals(comment1, comment); - Assert.assertEquals(comment2, comment); + Assert.assertEquals(comment, comment1); + Assert.assertEquals(comment, comment2); dr.uncheckAllOnPage(); assertEquals("incorrect number of rows selected", 0, dr.getCheckedCount(this)); @@ -1480,8 +1480,8 @@ private void samplesTableTest() throws Exception dr = new DataRegionTable.DataRegionFinder(getDriver()).withName("query").find(); String comment1b = dr.getDataAsText(1, colIdx); String comment2b = dr.getDataAsText(2, colIdx); - Assert.assertEquals(comment1b, comment + "\nThis should append to the end"); - Assert.assertEquals(comment2b, comment); + Assert.assertEquals(comment + "\nThis should append to the end", comment1b); + Assert.assertEquals(comment, comment2b); refresh(); dr = new DataRegionTable.DataRegionFinder(getDriver()).withName("query").find(); @@ -1502,7 +1502,7 @@ private void samplesTableTest() throws Exception // Debug date parsing String clientFormattedString = (String)executeScript("return Ext4.Date.format(LDK.ConvertUtils.parseDate('2017-01-02'), 'Y-m-d');"); - assertEquals("Incorrect date parsing", clientFormattedString, "2017-01-02"); + assertEquals("Incorrect date parsing", "2017-01-02", clientFormattedString); waitAndClickAndWait(Ext4Helper.Locators.ext4Button("Submit")); @@ -1572,13 +1572,13 @@ private void urlGenerationTest() throws UnsupportedEncodingException //insert dummy data: String[] workbookIds = new String[3]; - Integer i = 0; + int i = 0; int max = 3; while (i < max) { String id = _helper.createWorkbook(getProjectName(), "Workbook" + i, "Description"); workbookIds[i] = id; - insertDummySampleRow(i.toString()); + insertDummySampleRow(Integer.toString(i)); i++; } diff --git a/LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java b/LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java index 92f7ef32..07a798ae 100644 --- a/LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java +++ b/LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java @@ -23,7 +23,6 @@ import org.labkey.test.WebDriverWrapper; import org.labkey.test.util.DataRegionTable; import org.labkey.test.util.Ext4Helper; -import org.labkey.test.util.LogMethod; import org.labkey.test.util.UIAssayHelper; import org.labkey.test.util.ext4cmp.Ext4CmpRef; import org.labkey.test.util.ext4cmp.Ext4ComboRef; @@ -95,7 +94,7 @@ public void clickNavPanelItem(String label, String itemText) { Locator l = getNavPanelItem(label, itemText); _test.waitForElement(l); - Assert.assertEquals("Incorrect number of elements: " + label + "/" + itemText, l.findElements(_test.getDriver()).size(), 1); + Assert.assertEquals("Incorrect number of elements: " + label + "/" + itemText, 1, l.findElements(_test.getDriver()).size()); _test.waitAndClick(l); } @@ -417,7 +416,7 @@ public String getLegalNameFromName(String name) if (name == null) return null; - if (name.length() == 0) + if (name.isEmpty()) return null; StringBuilder buf = new StringBuilder(name.length()); diff --git a/laboratory/api-src/org/labkey/api/laboratory/AbstractUrlNavItem.java b/laboratory/api-src/org/labkey/api/laboratory/AbstractUrlNavItem.java index 8369c171..8d017a14 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/AbstractUrlNavItem.java +++ b/laboratory/api-src/org/labkey/api/laboratory/AbstractUrlNavItem.java @@ -28,8 +28,8 @@ */ abstract public class AbstractUrlNavItem extends AbstractNavItem { - protected String _labelText = null; - protected String _itemText = null; + protected String _labelText; + protected String _itemText; protected DetailsURL _detailsURL = null; protected String _staticURL = null; diff --git a/laboratory/api-src/org/labkey/api/laboratory/LaboratoryService.java b/laboratory/api-src/org/labkey/api/laboratory/LaboratoryService.java index f94f6c3d..b12ca2dc 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/LaboratoryService.java +++ b/laboratory/api-src/org/labkey/api/laboratory/LaboratoryService.java @@ -123,7 +123,7 @@ static public void setInstance(LaboratoryService instance) abstract public @Nullable DemographicsProvider getDemographicsProviderByName(Container c, User u, String name); - public static enum NavItemCategory + public enum NavItemCategory { samples(), misc(), diff --git a/laboratory/api-src/org/labkey/api/laboratory/StaticURLNavItem.java b/laboratory/api-src/org/labkey/api/laboratory/StaticURLNavItem.java index 9598187f..8be60976 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/StaticURLNavItem.java +++ b/laboratory/api-src/org/labkey/api/laboratory/StaticURLNavItem.java @@ -15,8 +15,6 @@ */ package org.labkey.api.laboratory; -import org.labkey.api.query.DetailsURL; - /** * User: bimber * Date: 11/21/12 diff --git a/laboratory/api-src/org/labkey/api/laboratory/assay/AbstractAssayDataProvider.java b/laboratory/api-src/org/labkey/api/laboratory/assay/AbstractAssayDataProvider.java index 93c15cd2..1883fa5d 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/assay/AbstractAssayDataProvider.java +++ b/laboratory/api-src/org/labkey/api/laboratory/assay/AbstractAssayDataProvider.java @@ -173,7 +173,7 @@ public String getDefaultImportMethodName(Container c, User u, int protocolId) if (props.containsKey(getDefaultMethodPropertyKey(protocolId))) return props.get(getDefaultMethodPropertyKey(protocolId)); else - return _importMethods.size() == 0 ? null : _importMethods.iterator().next().getName(); + return _importMethods.isEmpty() ? null : _importMethods.iterator().next().getName(); } private String getDefaultMethodPropertyKey(int protocolId) @@ -263,7 +263,7 @@ public List getReportItems(Container c, User u) { List errors = new ArrayList<>(); TableInfo query = qd.getTable(errors, true); - if (query == null || errors.size() > 0) + if (query == null || !errors.isEmpty()) { _log.error("Unable to create table for query: " + qd.getSchema().getName() + "/" + qd.getName() + ", in container: " + qd.getContainer().getPath()); for (QueryException error : errors) @@ -305,7 +305,7 @@ public List getTabbedReportItems(Container c, User u) { List errors = new ArrayList<>(); TableInfo query = qd.getTable(errors, true); - if (query == null || errors.size() > 0) + if (query == null || !errors.isEmpty()) { _log.error("Unable to create table for query: " + qd.getSchema().getName() + "/" + qd.getName() + ", in container: " + qd.getContainer().getPath()); for (QueryException error : errors) diff --git a/laboratory/api-src/org/labkey/api/laboratory/assay/AssayDataProvider.java b/laboratory/api-src/org/labkey/api/laboratory/assay/AssayDataProvider.java index 9c463abe..2b81f5fb 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/assay/AssayDataProvider.java +++ b/laboratory/api-src/org/labkey/api/laboratory/assay/AssayDataProvider.java @@ -36,28 +36,26 @@ */ public interface AssayDataProvider extends DataProvider { - abstract public String getProviderName(); + String getProviderName(); - abstract public AssayProvider getAssayProvider(); + AssayProvider getAssayProvider(); /** * Returns the set of AssayImportMethods supported by this assay. If none are provided, a default import method * will be used - * @return */ - abstract public Collection getImportMethods(); + Collection getImportMethods(); /** * Return true if this import pathway can be used with assay run templates, which allows runs to be prepared ahead of importing results - * @return */ - public boolean supportsRunTemplates(); + boolean supportsRunTemplates(); - public List getProtocols(Container c); + List getProtocols(Container c); - abstract public AssayImportMethod getImportMethodByName(String methodName); + AssayImportMethod getImportMethodByName(String methodName); - abstract public String getDefaultImportMethodName(Container c, User u, int protocolId); + String getDefaultImportMethodName(Container c, User u, int protocolId); - abstract public boolean isModuleEnabled(Container c); + boolean isModuleEnabled(Container c); } diff --git a/laboratory/api-src/org/labkey/api/laboratory/assay/AssayParser.java b/laboratory/api-src/org/labkey/api/laboratory/assay/AssayParser.java index a2fbebcd..d095168d 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/assay/AssayParser.java +++ b/laboratory/api-src/org/labkey/api/laboratory/assay/AssayParser.java @@ -36,14 +36,14 @@ public interface AssayParser /** * Parses the provided file and json object, returning a list of row maps. */ - public JSONObject getPreview(JSONObject json, File file, String fileName, ViewContext ctx) throws BatchValidationException; + JSONObject getPreview(JSONObject json, File file, String fileName, ViewContext ctx) throws BatchValidationException; /** * Parses the provided file and json object using getPreview(), then saves this to the database */ - public Pair saveBatch(JSONObject json, File file, String fileName, ViewContext ctx) throws BatchValidationException; + Pair saveBatch(JSONObject json, File file, String fileName, ViewContext ctx) throws BatchValidationException; - public ExpProtocol getProtocol(); + ExpProtocol getProtocol(); - public AssayProvider getProvider(); + AssayProvider getProvider(); } diff --git a/laboratory/api-src/org/labkey/api/laboratory/assay/DefaultAssayImportMethod.java b/laboratory/api-src/org/labkey/api/laboratory/assay/DefaultAssayImportMethod.java index b6078a67..2595b9da 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/assay/DefaultAssayImportMethod.java +++ b/laboratory/api-src/org/labkey/api/laboratory/assay/DefaultAssayImportMethod.java @@ -326,7 +326,7 @@ protected Map getWellMap96(final String keyProperty, final Strin TableSelector ts = new TableSelector(ti, new SimpleFilter(FieldKey.fromString("plate"), 1), null); final Map wellMap = new HashMap<>(); - ts.forEach(new Selector.ForEachBlock() + ts.forEach(new Selector.ForEachBlock<>() { @Override public void exec(ResultSet object) throws SQLException diff --git a/laboratory/api-src/org/labkey/api/laboratory/assay/DefaultAssayParser.java b/laboratory/api-src/org/labkey/api/laboratory/assay/DefaultAssayParser.java index 24c5e302..bbcd2ac4 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/assay/DefaultAssayParser.java +++ b/laboratory/api-src/org/labkey/api/laboratory/assay/DefaultAssayParser.java @@ -72,7 +72,6 @@ import java.util.Map; import java.util.Set; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.stream.IntStream; /** @@ -120,7 +119,7 @@ protected Map getPropertyMap(Map 0) + if (description != null && !description.isEmpty()) map.put(description.toLowerCase(), pd); seen.add(pd); } @@ -309,7 +308,6 @@ protected void appendPromotedResultFields(Map row, ImportContext /** * Reads the raw input file and converts it to a regular TSV file before passing to TabLoader * This allows subclasses to transform the input data - * @return */ protected String readRawFile(ImportContext context) throws BatchValidationException { @@ -330,7 +328,7 @@ protected String readRawFile(ImportContext context) throws BatchValidationExcept } if (!StringUtils.isEmpty(StringUtils.join(line))) - out.writeNext(line.toArray(new String[line.size()])); + out.writeNext(line.toArray(new String[0])); } return sw.toString(); @@ -417,7 +415,6 @@ protected List> parseResults(ImportContext context) throws B /** * Override this method to provide custom processing of each result row provided as JSON - * @return */ protected List> processRowsFromJson(List> rows, ImportContext context) { @@ -641,7 +638,7 @@ public List> getFileLines(File file) throws IOException { JSONArray arr = ExcelFactory.convertExcelToJSON(file, true); List> ret = new ArrayList<>(); - if (arr.length() == 0) + if (arr.isEmpty()) return ret; JSONObject sheet = arr.getJSONObject(0); diff --git a/laboratory/api-src/org/labkey/api/laboratory/assay/PivotingAssayParser.java b/laboratory/api-src/org/labkey/api/laboratory/assay/PivotingAssayParser.java index 1e98a190..55c29341 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/assay/PivotingAssayParser.java +++ b/laboratory/api-src/org/labkey/api/laboratory/assay/PivotingAssayParser.java @@ -15,7 +15,6 @@ */ package org.labkey.api.laboratory.assay; -import au.com.bytecode.opencsv.CSVReader; import au.com.bytecode.opencsv.CSVWriter; import org.apache.commons.lang3.StringUtils; import org.labkey.api.collections.CaseInsensitiveHashMap; @@ -25,10 +24,8 @@ import org.labkey.api.security.User; import org.labkey.api.util.Pair; -import java.io.FileReader; import java.io.IOException; import java.io.StringWriter; -import java.io.Reader; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -59,7 +56,7 @@ protected String readRawFile(ImportContext context) throws BatchValidationExcept DomainProperty valueCol = _pivotMethod.getValueColumn(_protocol); DomainProperty pivotCol = _pivotMethod.getPivotColumn(_protocol); Map resultCols = null; - Integer rowIdx = 0; + int rowIdx = 0; for (List line : getFileLines(context.getFile())) { @@ -93,8 +90,8 @@ protected String readRawFile(ImportContext context) throws BatchValidationExcept row.addAll(rowBase); row.add(pair.first); row.add(pair.second); - row.add(rowIdx.toString()); - out.writeNext(row.toArray(new String[row.size()])); + row.add(Integer.toString(rowIdx)); + out.writeNext(row.toArray(new String[0])); } } else @@ -104,7 +101,7 @@ protected String readRawFile(ImportContext context) throws BatchValidationExcept row.add(pivotCol.getLabel()); row.add(valueCol.getLabel()); row.add("_rowIdx"); - out.writeNext(row.toArray(new String[row.size()])); + out.writeNext(row.toArray(new String[0])); } rowIdx++; @@ -126,7 +123,7 @@ protected String readRawFile(ImportContext context) throws BatchValidationExcept private Map inspectHeader(List header, ImportContext context) throws BatchValidationException { Map resultMap = new HashMap<>(); - Map allowable = new CaseInsensitiveHashMap(); + Map allowable = new CaseInsensitiveHashMap<>(); BatchValidationException errors = new BatchValidationException(); for (String val : _pivotMethod.getAllowableValues()) diff --git a/laboratory/api-src/org/labkey/api/laboratory/assay/PivotingImportMethod.java b/laboratory/api-src/org/labkey/api/laboratory/assay/PivotingImportMethod.java index 59b9c61d..0c14202a 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/assay/PivotingImportMethod.java +++ b/laboratory/api-src/org/labkey/api/laboratory/assay/PivotingImportMethod.java @@ -40,8 +40,8 @@ abstract public class PivotingImportMethod extends DefaultAssayImportMethod protected AssayImportMethod _importMethod; protected String _pivotField; protected String _valueField; - protected TableInfo _sourceTable = null; - protected String _sourceColumn = null; + protected TableInfo _sourceTable; + protected String _sourceColumn; public PivotingImportMethod(AssayImportMethod method, String pivotField, String valueField, TableInfo sourceTable, String sourceColumn) { diff --git a/laboratory/api-src/org/labkey/api/laboratory/query/ContainerIncrementingTable.java b/laboratory/api-src/org/labkey/api/laboratory/query/ContainerIncrementingTable.java index 0845cbc6..904c6439 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/query/ContainerIncrementingTable.java +++ b/laboratory/api-src/org/labkey/api/laboratory/query/ContainerIncrementingTable.java @@ -94,7 +94,7 @@ public UpdateSerivce(SimpleUserSchema.SimpleTable ti) @Override protected Map insertRow(User user, Container container, Map row) throws DuplicateKeyException, ValidationException, QueryUpdateServiceException, SQLException { - Integer rowId = null; + Integer rowId; boolean hasSelfAssignedId = false; // This idea here is that the majority of the time the ID will auto-increment within this container (defined as parent + workbooks) // however, there is a backdoor that lets the IDs get set manually. An example of this would be when a row was deleted accidentally or otherwise, and you want @@ -279,7 +279,7 @@ public void close() throws IOException } }; - final Map inputColMap = new HashMap(); + final Map inputColMap = new HashMap<>(); for (int idx = 1; idx <= input.getColumnCount(); idx++) { ColumnInfo col = input.getColumnInfo(idx); @@ -356,8 +356,8 @@ public Object call() throws Exception */ private class IncrementIdGenerator { - private final Map _idMap = new HashMap(); - private final Map> _existingIdsMap = new HashMap>(); + private final Map _idMap = new HashMap<>(); + private final Map> _existingIdsMap = new HashMap<>(); public IncrementIdGenerator() { @@ -409,7 +409,7 @@ public boolean hasRowWithId(Container c, Integer rowId) Set set = _existingIdsMap.get(target); if (set == null) - set = new HashSet(); + set = new HashSet<>(); //if we have already tested this ID, it is assumed to exist if (set.contains(rowId)) diff --git a/laboratory/src/org/labkey/laboratory/ExtraDataSourcesDataProvider.java b/laboratory/src/org/labkey/laboratory/ExtraDataSourcesDataProvider.java index cd4ed0f8..e9c2ac8d 100644 --- a/laboratory/src/org/labkey/laboratory/ExtraDataSourcesDataProvider.java +++ b/laboratory/src/org/labkey/laboratory/ExtraDataSourcesDataProvider.java @@ -208,7 +208,7 @@ public List getSummary(Container c, User u) @Override public List getSubjectIdSummary(Container c, User u, String subjectId) { - List items = new ArrayList(); + List items = new ArrayList<>(); LaboratoryServiceImpl service = LaboratoryServiceImpl.get(); Set sources = service.getAdditionalDataSources(c, u); @@ -239,7 +239,7 @@ public List getTabbedReportItems(Container c, User u) { if (owner instanceof ReportItem sq) { - QueryCache cache = ((ReportItem) owner).getQueryCache(); + QueryCache cache = sq.getQueryCache(); TabbedReportItem reportItem = new QueryTabbedReportItem(cache, this, sq.getSchema(), sq.getQuery(), sq.getLabel(), owner.getReportCategory()); if (sq.getTargetContainer(c) != null) reportItem.setTargetContainer(sq.getTargetContainer(c)); diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryContainerListener.java b/laboratory/src/org/labkey/laboratory/LaboratoryContainerListener.java index 007fbeb9..00fad1e9 100644 --- a/laboratory/src/org/labkey/laboratory/LaboratoryContainerListener.java +++ b/laboratory/src/org/labkey/laboratory/LaboratoryContainerListener.java @@ -13,7 +13,6 @@ import org.labkey.api.module.Module; import org.labkey.api.module.ModuleLoader; import org.labkey.api.module.SimpleModuleContainerListener; -import org.labkey.api.query.BatchValidationException; import org.labkey.api.query.FieldKey; import org.labkey.api.query.UserSchema; import org.labkey.api.security.User; diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryController.java b/laboratory/src/org/labkey/laboratory/LaboratoryController.java index 70aebca8..71c55b96 100644 --- a/laboratory/src/org/labkey/laboratory/LaboratoryController.java +++ b/laboratory/src/org/labkey/laboratory/LaboratoryController.java @@ -117,7 +117,7 @@ public LaboratoryController() } @RequiresPermission(InsertPermission.class) - public class PrepareExptRunAction extends SimpleViewAction + public static class PrepareExptRunAction extends SimpleViewAction { @Override public ModelAndView getView(PlanExptRunForm form, BindException errors) throws Exception @@ -154,7 +154,7 @@ public void addNavTrail(NavTree root) } @RequiresPermission(AdminOperationsPermission.class) - public class EnsureIndexesAction extends ConfirmAction + public static class EnsureIndexesAction extends ConfirmAction { @Override public void validateCommand(Object form, Errors errors) @@ -206,7 +206,7 @@ public void setAssayId(Integer assayId) } @RequiresPermission(AdminPermission.class) - public class EnsureAssayFieldsAction extends ConfirmAction + public static class EnsureAssayFieldsAction extends ConfirmAction { @Override public void validateCommand(EnsureAssayFieldsForm form, Errors errors) @@ -296,7 +296,7 @@ public boolean handlePost(EnsureAssayFieldsForm form, BindException errors) thro @RequiresPermission(AdminPermission.class) - public class SetTableIncrementValueAction extends ConfirmAction + public static class SetTableIncrementValueAction extends ConfirmAction { @Override public void validateCommand(SetTableIncrementForm form, Errors errors) @@ -455,7 +455,7 @@ public void setQuery(String query) } @RequiresPermission(AdminPermission.class) - public class InitWorkbooksAction extends ConfirmAction + public static class InitWorkbooksAction extends ConfirmAction { @Override public void validateCommand(Object form, Errors errors) @@ -494,7 +494,7 @@ public boolean handlePost(Object form, BindException errors) throws Exception } @RequiresPermission(AdminPermission.class) - public class InitContainerIncrementingTableAction extends ConfirmAction + public static class InitContainerIncrementingTableAction extends ConfirmAction { @Override public void validateCommand(SetTableIncrementForm form, Errors errors) @@ -566,7 +566,7 @@ private void processContainer(Container c, String schema, String query) } @RequiresPermission(AdminPermission.class) - public class ResetLaboratoryFoldersAction extends ConfirmAction + public static class ResetLaboratoryFoldersAction extends ConfirmAction { @Override public void validateCommand(Object form, Errors errors) @@ -605,7 +605,7 @@ public boolean handlePost(Object form, BindException errors) throws Exception } @RequiresPermission(InsertPermission.class) - public class ProcessAssayDataAction extends AbstractFileUploadAction + public static class ProcessAssayDataAction extends AbstractFileUploadAction { @Override protected void setContentType(HttpServletResponse response) @@ -698,7 +698,7 @@ public String getResponse(ProcessAssayForm form, Map> @RequiresPermission(AdminPermission.class) - public class PopulateDefaultsAction extends MutatingApiAction + public static class PopulateDefaultsAction extends MutatingApiAction { @Override public ApiResponse execute(PopulateDefaultsForm form, BindException errors) throws Exception @@ -737,7 +737,7 @@ public void setTableNames(String[] tableNames) } @RequiresPermission(UpdatePermission.class) - public class UpdateWorkbookAction extends MutatingApiAction + public static class UpdateWorkbookAction extends MutatingApiAction { @Override public ApiResponse execute(UpdateWorkbookForm form, BindException errors) throws Exception @@ -776,7 +776,7 @@ public ApiResponse execute(UpdateWorkbookForm form, BindException errors) throws } @RequiresPermission(ReadPermission.class) - public class GetDemographicsProvidersAction extends ReadOnlyApiAction + public static class GetDemographicsProvidersAction extends ReadOnlyApiAction { @Override public ApiResponse execute(Object form, BindException errors) throws Exception @@ -803,7 +803,7 @@ public ApiResponse execute(Object form, BindException errors) throws Exception } @RequiresPermission(UpdatePermission.class) - public class UpdateWorkbookTagsAction extends MutatingApiAction + public static class UpdateWorkbookTagsAction extends MutatingApiAction { @Override public ApiResponse execute(UpdateWorkbookForm form, BindException errors) throws Exception @@ -918,7 +918,7 @@ public void setForceTagUpdate(boolean forceTagUpdate) @RequiresPermission(UpdatePermission.class) - public class SaveTemplateAction extends MutatingApiAction + public static class SaveTemplateAction extends MutatingApiAction { @Override public ApiResponse execute(SaveTemplateForm form, BindException errors) throws Exception @@ -1036,7 +1036,7 @@ public void setImportMethod(String importMethod) } @RequiresPermission(ReadPermission.class) - public class CreateTemplateAction extends ExportAction + public static class CreateTemplateAction extends ExportAction { @Override public void validate(ProcessAssayForm form, BindException errors) @@ -1103,7 +1103,7 @@ public void export(ProcessAssayForm form, HttpServletResponse response, BindExce } @RequiresPermission(ReadPermission.class) - public class GetDemographicsSourcesAction extends ReadOnlyApiAction + public static class GetDemographicsSourcesAction extends ReadOnlyApiAction { @Override public ApiResponse execute(DataSourcesForm form, BindException errors) @@ -1150,7 +1150,7 @@ public ApiResponse execute(DataSourcesForm form, BindException errors) if (getUser().hasSiteAdminPermission()) { Map> map = service.getAllDemographicsSources(getUser()); - Map siteSummary = new HashMap(); + Map siteSummary = new HashMap<>(); for (Container c : map.keySet()) { JSONArray arr = siteSummary.get(c.getPath()); @@ -1180,7 +1180,7 @@ public ApiResponse execute(DataSourcesForm form, BindException errors) } @RequiresPermission(ReadPermission.class) - public class GetAdditionalDataSourcesAction extends ReadOnlyApiAction + public static class GetAdditionalDataSourcesAction extends ReadOnlyApiAction { @Override public ApiResponse execute(DataSourcesForm form, BindException errors) @@ -1227,7 +1227,7 @@ public ApiResponse execute(DataSourcesForm form, BindException errors) if (getUser().hasSiteAdminPermission()) { Map> map = service.getAllAdditionalDataSources(getUser()); - Map siteSummary = new HashMap(); + Map siteSummary = new HashMap<>(); for (Container c : map.keySet()) { JSONArray arr = siteSummary.get(c.getPath()); @@ -1299,7 +1299,7 @@ public void setIncludeSiteSummary(boolean includeSiteSummary) } @RequiresPermission(LaboratoryAdminPermission.class) - public class SetDemographicsSourcesAction extends MutatingApiAction + public static class SetDemographicsSourcesAction extends MutatingApiAction { @Override public ApiResponse execute(SetDataSourcesForm form, BindException errors) @@ -1320,7 +1320,7 @@ public ApiResponse execute(SetDataSourcesForm form, BindException errors) return null; } - Set sources = new HashSet(); + Set sources = new HashSet<>(); JSONArray json = new JSONArray(form.getTables()); for (JSONObject obj : JsonUtil.toJSONObjectList(json)) @@ -1383,7 +1383,7 @@ public ApiResponse execute(SetDataSourcesForm form, BindException errors) return null; } - Set sources = new HashSet(); + Set sources = new HashSet<>(); JSONArray json = new JSONArray(form.getTables()); for (JSONObject obj : JsonUtil.toJSONObjectList(json)) @@ -1444,7 +1444,7 @@ public void setTables(String tables) } @RequiresPermission(LaboratoryAdminPermission.class) - public class SetUrlDataSourcesAction extends MutatingApiAction + public static class SetUrlDataSourcesAction extends MutatingApiAction { @Override public ApiResponse execute(SetUrlDataSourcesForm form, BindException errors) @@ -1465,7 +1465,7 @@ public ApiResponse execute(SetUrlDataSourcesForm form, BindException errors) return null; } - Set sources = new HashSet(); + Set sources = new HashSet<>(); JSONArray json = new JSONArray(form.getSources()); for (JSONObject obj : JsonUtil.toJSONObjectList(json)) @@ -1500,7 +1500,7 @@ public void setSources(String sources) } @RequiresPermission(ReadPermission.class) - public class GetAssayImportHeadersAction extends ReadOnlyApiAction + public static class GetAssayImportHeadersAction extends ReadOnlyApiAction { @Override public ApiResponse execute(AssayImportHeadersForm form, BindException errors) @@ -1583,7 +1583,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors) map.put(key, json.get(key) == null ? null : String.valueOf(json.get(key))); } - if (toActivate.size() > 0) + if (!toActivate.isEmpty()) { toActivate.addAll(activeModules); getContainer().setActiveModules(toActivate); @@ -1598,7 +1598,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors) @RequiresPermission(LaboratoryAdminPermission.class) - public class SetItemDefaultViewAction extends MutatingApiAction + public static class SetItemDefaultViewAction extends MutatingApiAction { @Override public ApiResponse execute(JsonDataForm form, BindException errors) @@ -1632,7 +1632,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors) @RequiresPermission(LaboratoryAdminPermission.class) - public class SetDataBrowserSettingsAction extends MutatingApiAction + public static class SetDataBrowserSettingsAction extends MutatingApiAction { @Override public ApiResponse execute(JsonDataForm form, BindException errors) @@ -1653,7 +1653,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors) WritablePropertyMap propMap = PropertyManager.getWritableProperties(getContainer(), TabbedReportItem.OVERRIDES_PROP_KEY, true); List tabbedReports = LaboratoryService.get().getTabbedReportItems(getContainer(), getUser()); - Map reportMap = new HashMap(); + Map reportMap = new HashMap<>(); for (TabbedReportItem item : tabbedReports) { reportMap.put(TabbedReportItem.getOverridesPropertyKey(item), item); @@ -1678,7 +1678,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors) if (reportCategory != null && !ti.getReportCategory().equals(reportCategory)) toSave.put("reportCategory", reportCategory); - if (toSave.keySet().size() > 0) + if (!toSave.keySet().isEmpty()) propMap.put(key, toSave.toString()); else propMap.remove(key); } @@ -1692,7 +1692,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors) @RequiresPermission(LaboratoryAdminPermission.class) - public class SaveAssayDefaultsAction extends MutatingApiAction + public static class SaveAssayDefaultsAction extends MutatingApiAction { @Override public ApiResponse execute(JsonDataForm form, BindException errors) @@ -1725,7 +1725,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors) } @RequiresPermission(ReadPermission.class) - public class GetDataItemsAction extends MutatingApiAction + public static class GetDataItemsAction extends MutatingApiAction { @Override public ApiResponse execute(GetDataItemsForm form, BindException errors) @@ -1825,7 +1825,7 @@ private void ensureModuleActive(NavItem item) Set active = getContainer().getActiveModules(); if (!active.contains(m)) { - Set newActive = new HashSet(); + Set newActive = new HashSet<>(); newActive.addAll(active); newActive.add(m); @@ -1840,7 +1840,7 @@ private void ensureModuleActive(NavItem item) } @RequiresPermission(ReadPermission.class) - public class GetImportMethodsAction extends ReadOnlyApiAction + public static class GetImportMethodsAction extends ReadOnlyApiAction { @Override public ApiResponse execute(ImportMethodsForm form, BindException errors) @@ -1874,7 +1874,7 @@ else if (form.getAssayType() != null) JSONObject json = new JSONObject(); AssayDataProvider adp = LaboratoryService.get().getDataProviderForAssay(provider); List protocolsForProvider = new ArrayList<>(); - if (protocols.size() == 0) + if (protocols.isEmpty()) protocolsForProvider.addAll(adp.getProtocols(getContainer())); else protocolsForProvider.addAll(protocols); @@ -1910,7 +1910,7 @@ else if (form.getAssayType() != null) } @RequiresPermission(ReadPermission.class) - public class GetDataSummaryAction extends ReadOnlyApiAction + public static class GetDataSummaryAction extends ReadOnlyApiAction { @Override public ApiResponse execute(DataSummaryForm form, BindException errors) @@ -1959,7 +1959,7 @@ public ApiResponse execute(DataSummaryForm form, BindException errors) for (String key : items.keySet()) { - List jsonItems = new ArrayList(); + List jsonItems = new ArrayList<>(); for (NavItem item : items.get(key)) { jsonItems.add(item.toJSON(getContainer(), getUser())); @@ -1987,7 +1987,7 @@ public void setDataProviders(String[] dataProviders) } @RequiresPermission(ReadPermission.class) - public class GetSubjectIdSummaryAction extends ReadOnlyApiAction + public static class GetSubjectIdSummaryAction extends ReadOnlyApiAction { @Override public ApiResponse execute(SubjectSummaryForm form, BindException errors) @@ -2249,7 +2249,7 @@ public ActionURL getImportUrl(Container c, User u, String schemaName, String que if (ti == null) return null; List pks = ti.getPkColumnNames(); - if (pks.size() == 0) + if (pks.isEmpty()) return null; ActionURL url = new ActionURL("query", "importData", c); @@ -2330,7 +2330,7 @@ public void setProtocol(Integer protocol) } @RequiresPermission(ReadPermission.class) - public class DataBrowserAction extends SimpleViewAction + public static class DataBrowserAction extends SimpleViewAction { @Override public ModelAndView getView(Object form, BindException errors) throws Exception diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryDataProvider.java b/laboratory/src/org/labkey/laboratory/LaboratoryDataProvider.java index fb324676..c66c1f92 100644 --- a/laboratory/src/org/labkey/laboratory/LaboratoryDataProvider.java +++ b/laboratory/src/org/labkey/laboratory/LaboratoryDataProvider.java @@ -162,7 +162,7 @@ public List getReportItems(Container c, User u) @Override public List getSettingsItems(Container c, User u) { - List items = new ArrayList(); + List items = new ArrayList<>(); String categoryName = "Samples"; String general = "General Settings"; String adminSettings = "Site Administration"; diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryManager.java b/laboratory/src/org/labkey/laboratory/LaboratoryManager.java index 1f9c73dd..374570f6 100644 --- a/laboratory/src/org/labkey/laboratory/LaboratoryManager.java +++ b/laboratory/src/org/labkey/laboratory/LaboratoryManager.java @@ -19,7 +19,6 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.labkey.api.assay.AssayProvider; import org.labkey.api.assay.AssayService; import org.labkey.api.collections.CaseInsensitiveHashMap; @@ -226,7 +225,6 @@ public WorkbookModel getWorkbookModel(Container c, boolean createIfNotPresent) /** * This is designed to iterate a folder and children, resetting the webparts and tabs - * @param c */ public void resetLaboratoryFolderTypes(User u, Container c, boolean includeChildren) { @@ -315,14 +313,14 @@ public void updateWorkbookTags(User u, Container c, Collection tags, boo List toDelete = new ArrayList<>(existingTags); toDelete.removeAll(newTags); - if (toDelete.size() > 0) + if (!toDelete.isEmpty()) { SimpleFilter filter1 = new SimpleFilter(FieldKey.fromString("tag"), toDelete, CompareType.IN); filter1.addCondition(FieldKey.fromString("container"), c.getId()); Table.delete(ti, filter1); } - List toAdd = new ArrayList(newTags); + List toAdd = new ArrayList<>(newTags); toAdd.removeAll(existingTags); Date created = new Date(); @@ -461,7 +459,7 @@ public void initContainerIncrementingTableIds(Container c, User u, String schema QueryUpdateService qus = ct.getUpdateService(); String colName = ct.getIncrementingCol(); - Set toSelect = new HashSet(); + Set toSelect = new HashSet<>(); toSelect.add(colName); for (String ci : ct.getPkColumnNames()) { diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryUpgradeCode.java b/laboratory/src/org/labkey/laboratory/LaboratoryUpgradeCode.java index cd2227a4..271c929a 100644 --- a/laboratory/src/org/labkey/laboratory/LaboratoryUpgradeCode.java +++ b/laboratory/src/org/labkey/laboratory/LaboratoryUpgradeCode.java @@ -57,7 +57,7 @@ public void migrateQuantityField(final ModuleContext moduleContext) filter.addCondition(FieldKey.fromString("quantity"), null, CompareType.ISBLANK); TableSelector ts = new TableSelector(ti, PageFlowUtil.set("rowid", "quantity_string"), filter, null); - ts.forEach(new Selector.ForEachBlock() + ts.forEach(new Selector.ForEachBlock<>() { @Override public void exec(ResultSet rs) throws SQLException @@ -103,7 +103,7 @@ public void updateWorkbookSequences(final ModuleContext moduleContext) final TableInfo ti = LaboratorySchema.getInstance().getTable(LaboratorySchema.TABLE_WORKBOOKS); TableSelector ts = new TableSelector(ti); final Map containerMap = new HashMap<>(); - ts.forEach(new Selector.ForEachBlock() + ts.forEach(new Selector.ForEachBlock<>() { @Override public void exec(ResultSet object) throws SQLException diff --git a/laboratory/src/org/labkey/laboratory/SampleTypeDataProvider.java b/laboratory/src/org/labkey/laboratory/SampleTypeDataProvider.java index 05bef0f8..fc825a0c 100644 --- a/laboratory/src/org/labkey/laboratory/SampleTypeDataProvider.java +++ b/laboratory/src/org/labkey/laboratory/SampleTypeDataProvider.java @@ -77,7 +77,7 @@ public List getDataNavItems(Container c, User u) public List getSampleNavItems(Container c, User u) { //also append all sample types in this container - List navItems = new ArrayList(); + List navItems = new ArrayList<>(); for (ExpSampleType st : SampleTypeService.get().getSampleTypes(c, u, true)) { @@ -130,7 +130,7 @@ public List getSummary(Container c, User u) @Override public List getSubjectIdSummary(Container c, User u, String subjectId) { - List items = new ArrayList(); + List items = new ArrayList<>(); for (ExpSampleType st : SampleTypeService.get().getSampleTypes(c, u, true)) { UserSchema us = QueryService.get().getUserSchema(u, c, "Samples"); diff --git a/laboratory/src/org/labkey/laboratory/assay/AssayHelper.java b/laboratory/src/org/labkey/laboratory/assay/AssayHelper.java index cd5b8f38..e1d8e037 100644 --- a/laboratory/src/org/labkey/laboratory/assay/AssayHelper.java +++ b/laboratory/src/org/labkey/laboratory/assay/AssayHelper.java @@ -126,7 +126,7 @@ public Map saveTemplate(User u, Container c, ExpProtocol protoco validateTemplate(u, c, protocol, templateId, title, importMethod, json); TableInfo ti = LaboratorySchema.getInstance().getSchema().getTable(LaboratorySchema.TABLE_ASSAY_RUN_TEMPLATES); - Map row = new HashMap(); + Map row = new HashMap<>(); row.put("assayId", protocol.getRowId()); row.put("title", title); row.put("importMethod", importMethod); @@ -136,7 +136,7 @@ public Map saveTemplate(User u, Container c, ExpProtocol protoco if (templateId == null) { row = Table.insert(u, ti, row); - templateId = (Integer)row.get("rowid"); + row.get("rowid"); } else { @@ -287,7 +287,7 @@ public static List ensureAssayFields(User user, String providerName) thr public static List ensureAssayFields(User user, String providerName, boolean renameConflictingFields, boolean reportMessagesOnly) throws ChangePropertyDescriptorException { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (!reportMessagesOnly) _log.info("Attempting to synchronize columns for all instances of assay: " + providerName); @@ -299,7 +299,7 @@ public static List ensureAssayFields(User user, String providerName, boo return messages; } - List allProtocols = new ArrayList(); + List allProtocols = new ArrayList<>(); Integer[] protocolIds = new TableSelector(ExperimentService.get().getTinfoProtocol(), Collections.singleton("rowid"), null, null).getArray(Integer.class); for (Integer protocolId : protocolIds) { @@ -448,7 +448,7 @@ public static List ensureAssayFields(User user, String providerName, boo CacheManager.clearAllKnownCaches(); } - if (messages.size() == 0) + if (messages.isEmpty()) { String msg = "No changes are necessary"; messages.add(msg); diff --git a/laboratory/src/org/labkey/laboratory/assay/RunUploadContext.java b/laboratory/src/org/labkey/laboratory/assay/RunUploadContext.java index 0c8e00a2..37839e2d 100644 --- a/laboratory/src/org/labkey/laboratory/assay/RunUploadContext.java +++ b/laboratory/src/org/labkey/laboratory/assay/RunUploadContext.java @@ -82,7 +82,7 @@ public Map getRunProperties() if (_runProperties != null) { AssayProvider provider = AssayService.get().getProvider(getProtocol()); - Map props = new HashMap(); + Map props = new HashMap<>(); for (DomainProperty dp : provider.getRunDomain(getProtocol()).getProperties()) @@ -105,7 +105,7 @@ public Map getBatchProperties() if (_batchProperties != null) { AssayProvider provider = AssayService.get().getProvider(getProtocol()); - Map props = new HashMap(); + Map props = new HashMap<>(); for (DomainProperty dp : provider.getBatchDomain(getProtocol()).getProperties()) { diff --git a/laboratory/src/org/labkey/laboratory/notification/LabSummaryNotification.java b/laboratory/src/org/labkey/laboratory/notification/LabSummaryNotification.java index eaa80ccc..56dd62c4 100644 --- a/laboratory/src/org/labkey/laboratory/notification/LabSummaryNotification.java +++ b/laboratory/src/org/labkey/laboratory/notification/LabSummaryNotification.java @@ -227,7 +227,7 @@ public void getWorkbookSummary(Container c, User u, final StringBuilder msg, Map msg.append("


"); - if (newValueMap.size() > 0) + if (!newValueMap.isEmpty()) toSave.put(rowCount, new JSONObject(newValueMap).toString()); } @@ -273,7 +273,7 @@ public void getDataSummary(Container c, User u, final StringBuilder msg, Map


"); - if (newValueMap.size() > 0) + if (!newValueMap.isEmpty()) toSave.put(rowCount, new JSONObject(newValueMap).toString()); } @@ -343,9 +343,9 @@ public void getFileSummary(Container c, User u, final StringBuilder msg, Map
"); msg.append("
"); - if (newValueMap.size() > 0) + if (!newValueMap.isEmpty()) toSave.put(fileRootSizes, new JSONObject(newValueMap).toString()); - if (newValueMapCounts.size() > 0) + if (!newValueMapCounts.isEmpty()) toSave.put(fileRootCounts, new JSONObject(newValueMapCounts).toString()); } } diff --git a/laboratory/src/org/labkey/laboratory/query/AssayRunTemplatesCustomizer.java b/laboratory/src/org/labkey/laboratory/query/AssayRunTemplatesCustomizer.java index 41aa4b45..f471bb68 100644 --- a/laboratory/src/org/labkey/laboratory/query/AssayRunTemplatesCustomizer.java +++ b/laboratory/src/org/labkey/laboratory/query/AssayRunTemplatesCustomizer.java @@ -44,7 +44,7 @@ public void customize(TableInfo ti) ati.setUpdateURL(DetailsURL.fromString("/laboratory/prepareExptRun.view?assayId=${assayId}&templateId=${rowid}")); ati.setDetailsURL(null); - List newCols = new ArrayList(); + List newCols = new ArrayList<>(); ExprColumn completeCol = new ExprColumn(ti, "enter_results", new SQLFragment("'Enter Results'"), JdbcType.VARCHAR, ti.getColumn("assayId"), ti.getColumn("runid")); completeCol.setName("enter_results"); @@ -65,7 +65,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) newCols.addAll(ati.getColumns()); //reset default visible columns on table - List defaultColumns = new ArrayList(); + List defaultColumns = new ArrayList<>(); defaultColumns.add(completeCol.getFieldKey()); defaultColumns.addAll(ati.getDefaultVisibleColumns()); ati.setDefaultVisibleColumns(defaultColumns); diff --git a/laboratory/src/org/labkey/laboratory/query/FreezerTriggerHelper.java b/laboratory/src/org/labkey/laboratory/query/FreezerTriggerHelper.java index 5c06e54f..5681bcc6 100644 --- a/laboratory/src/org/labkey/laboratory/query/FreezerTriggerHelper.java +++ b/laboratory/src/org/labkey/laboratory/query/FreezerTriggerHelper.java @@ -35,7 +35,7 @@ public class FreezerTriggerHelper private final User _user; private final TableInfo _table; - private final Map> _cachedRows = new HashMap>(); + private final Map> _cachedRows = new HashMap<>(); private FreezerTriggerHelper(String containerId, int userId) { @@ -86,7 +86,7 @@ public boolean isSamplePresent(String location, String freezer, String cane, Str public String getKey(String location, String freezer, String cane, String box, String box_row, String box_column) { - List tokens = new ArrayList(); + List tokens = new ArrayList<>(); if (!StringUtils.isEmpty(location)) tokens.add("location: " + location); @@ -115,8 +115,8 @@ private Map getFreezerRows(String freezer) TableSelector ts = new TableSelector(_table, PageFlowUtil.set("location", "freezer", "cane", "box", "box_row", "box_column", "rowid"), filter, null); - final Map keys = new HashMap(); - ts.forEach(new Selector.ForEachBlock() + final Map keys = new HashMap<>(); + ts.forEach(new Selector.ForEachBlock<>() { @Override public void exec(ResultSet rs) throws SQLException diff --git a/laboratory/src/org/labkey/laboratory/query/LaboratoryTableCustomizer.java b/laboratory/src/org/labkey/laboratory/query/LaboratoryTableCustomizer.java index fbbad913..ed1a8bca 100644 --- a/laboratory/src/org/labkey/laboratory/query/LaboratoryTableCustomizer.java +++ b/laboratory/src/org/labkey/laboratory/query/LaboratoryTableCustomizer.java @@ -117,7 +117,7 @@ public void ensureWorkbookCol(AbstractTableInfo ti) ColumnInfo wrappedContainer = ti.getColumn("workbook"); if (wrappedContainer != null) { - List cols = new ArrayList(); + List cols = new ArrayList<>(); cols.addAll(ti.getDefaultVisibleColumns()); if (!cols.contains(wrappedContainer.getFieldKey())) { @@ -141,7 +141,7 @@ public void customizeURLs(AbstractTableInfo ti) assert queryName != null; List keyFields = ti.getPkColumnNames(); - if (keyFields.size() == 0) + if (keyFields.isEmpty()) { _log.error("Table: " + schemaName + "." + queryName + " has no key fields: " + StringUtils.join(keyFields, ";")); return; diff --git a/laboratory/src/org/labkey/laboratory/query/LaboratoryWorkbooksTable.java b/laboratory/src/org/labkey/laboratory/query/LaboratoryWorkbooksTable.java index f502be7c..c26ee867 100644 --- a/laboratory/src/org/labkey/laboratory/query/LaboratoryWorkbooksTable.java +++ b/laboratory/src/org/labkey/laboratory/query/LaboratoryWorkbooksTable.java @@ -92,7 +92,7 @@ public QueryUpdateService getUpdateService() return new UpdateService(this); } - private class UpdateService extends SimpleQueryUpdateService + private static class UpdateService extends SimpleQueryUpdateService { public UpdateService(SimpleUserSchema.SimpleTable ti) { @@ -111,7 +111,7 @@ protected Map insertRow(User user, Container container, Map inputColMap = new HashMap(); - final Map outputColMap = new HashMap(); + final Map inputColMap = new HashMap<>(); + final Map outputColMap = new HashMap<>(); for (int idx = 1; idx <= input.getColumnCount(); idx++) { @@ -314,9 +314,9 @@ public Object call() throws Exception * The IDs are determined in LaboratoryManager, but this code will increment them within the rows * of a set of incoming records. */ - private class WorkbookIdGenerator + private static class WorkbookIdGenerator { - private final Map _idMap = new HashMap(); + private final Map _idMap = new HashMap<>(); public WorkbookIdGenerator() { diff --git a/laboratory/src/org/labkey/laboratory/query/SamplesCustomizer.java b/laboratory/src/org/labkey/laboratory/query/SamplesCustomizer.java index 46d7b399..673ef63f 100644 --- a/laboratory/src/org/labkey/laboratory/query/SamplesCustomizer.java +++ b/laboratory/src/org/labkey/laboratory/query/SamplesCustomizer.java @@ -54,7 +54,7 @@ private void appendAmountColumn(AbstractTableInfo ti) col.setDescription("This field takes the concentration multiplied by the quantity fields. It is automatically calculated and does not take units or other information into account."); //inject amount column after quantity. - List columns = new ArrayList(); + List columns = new ArrayList<>(); columns.addAll(ti.getColumns()); for (ColumnInfo c : columns) ti.removeColumn(c); diff --git a/laboratory/src/org/labkey/laboratory/security/LaboratoryAdminRole.java b/laboratory/src/org/labkey/laboratory/security/LaboratoryAdminRole.java index 4b18bfa5..082a0ab1 100644 --- a/laboratory/src/org/labkey/laboratory/security/LaboratoryAdminRole.java +++ b/laboratory/src/org/labkey/laboratory/security/LaboratoryAdminRole.java @@ -1,16 +1,11 @@ package org.labkey.laboratory.security; -import org.labkey.api.data.Container; import org.labkey.api.laboratory.security.LaboratoryAdminPermission; -import org.labkey.api.module.ModuleLoader; -import org.labkey.api.security.SecurableResource; -import org.labkey.api.security.SecurityPolicy; import org.labkey.api.security.permissions.DeletePermission; import org.labkey.api.security.permissions.InsertPermission; import org.labkey.api.security.permissions.ReadPermission; import org.labkey.api.security.permissions.UpdatePermission; import org.labkey.api.security.roles.AbstractModuleScopedRole; -import org.labkey.api.security.roles.AbstractRole; import org.labkey.laboratory.LaboratoryModule; /** diff --git a/laboratory/src/org/labkey/laboratory/table/WrappingTableCustomizer.java b/laboratory/src/org/labkey/laboratory/table/WrappingTableCustomizer.java index 1ee50625..cadce41d 100644 --- a/laboratory/src/org/labkey/laboratory/table/WrappingTableCustomizer.java +++ b/laboratory/src/org/labkey/laboratory/table/WrappingTableCustomizer.java @@ -22,7 +22,7 @@ public void customize(TableInfo ti) { LaboratoryService.get().getLaboratoryTableCustomizer().customize(ti); - if (ti.getPkColumnNames().size() > 0) + if (!ti.getPkColumnNames().isEmpty()) LDKService.get().getDefaultTableCustomizer().customize(ti); else LDKService.get().getBuiltInColumnsCustomizer(true).customize(ti); From 730bd13e470684e3dc7ba62dcd7d57e61b6442cc Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Tue, 10 Jun 2025 10:52:37 -0700 Subject: [PATCH 2/2] Remove unnecessary method call --- laboratory/src/org/labkey/laboratory/assay/AssayHelper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/laboratory/src/org/labkey/laboratory/assay/AssayHelper.java b/laboratory/src/org/labkey/laboratory/assay/AssayHelper.java index e1d8e037..ee4a9816 100644 --- a/laboratory/src/org/labkey/laboratory/assay/AssayHelper.java +++ b/laboratory/src/org/labkey/laboratory/assay/AssayHelper.java @@ -136,7 +136,6 @@ public Map saveTemplate(User u, Container c, ExpProtocol protoco if (templateId == null) { row = Table.insert(u, ti, row); - row.get("rowid"); } else {