From bdfb7d1749c75d48ce1cdeaab63ac6d6633d62ce Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Mon, 29 Dec 2025 16:27:16 -0800 Subject: [PATCH 1/4] Address some miscellaneous warnings --- api/src/org/labkey/api/admin/AdminBean.java | 2 -- .../labkey/api/exp/api/ExperimentService.java | 3 +++ api/src/org/labkey/api/util/IntegerUtils.java | 6 ++--- .../view/DataViewSnapshotSelectionForm.java | 1 - .../org/labkey/query/QueryServiceImpl.java | 22 +++++++++---------- .../query/reports/AttachmentReport.java | 2 +- .../search/view/SearchWebPartFactory.java | 17 ++++---------- .../labkey/study/query/DatasetQueryView.java | 8 +++---- 8 files changed, 24 insertions(+), 37 deletions(-) diff --git a/api/src/org/labkey/api/admin/AdminBean.java b/api/src/org/labkey/api/admin/AdminBean.java index 26921853d15..62631713f3c 100644 --- a/api/src/org/labkey/api/admin/AdminBean.java +++ b/api/src/org/labkey/api/admin/AdminBean.java @@ -80,9 +80,7 @@ public static class RecentUser public static final String servletContainer = ModuleLoader.getServletContext().getServerInfo(); public static final String servletConfiguration = "Embedded"; public static final String sessionTimeout = Formats.commaf0.format(ModuleLoader.getServletContext().getSessionTimeout()); - @SuppressWarnings("unused") // Available substitution property, not used directly in code public static final String buildTime = ModuleLoader.getInstance().getCoreModule().getBuildTime(); - @SuppressWarnings("unused") // Available substitution property, not used directly in code public static final String serverStartupTime = DateUtil.formatDateTime(ContainerManager.getRoot()); public static final List modules; diff --git a/api/src/org/labkey/api/exp/api/ExperimentService.java b/api/src/org/labkey/api/exp/api/ExperimentService.java index 2a3ecc53443..f89a451d717 100644 --- a/api/src/org/labkey/api/exp/api/ExperimentService.java +++ b/api/src/org/labkey/api/exp/api/ExperimentService.java @@ -1297,10 +1297,13 @@ public XarImportOptions setStrictValidateExistingSampleType(boolean strictValida } } + @Deprecated // Use IntegerUtils.asLong() instead static Long asLong(Object o) { return null==o ? null : o.getClass() == Long.class ? (Long)o : ((Number)o).longValue(); } + + @Deprecated // Use IntegerUtils.asLong() instead static Integer asInteger(Object o) { if (null == o) diff --git a/api/src/org/labkey/api/util/IntegerUtils.java b/api/src/org/labkey/api/util/IntegerUtils.java index f6bc610dbe3..7e241f8f916 100644 --- a/api/src/org/labkey/api/util/IntegerUtils.java +++ b/api/src/org/labkey/api/util/IntegerUtils.java @@ -5,11 +5,11 @@ /** * This Class to help with dealing with Object that may represent an integer number (char,short,int,long). It - * is meant to fill in the small gap between Java (e.g casts and instanceof) and ConvertUtils. Hopefully, this + * is meant to fill in the small gap between Java (e.g. casts and instanceof) and ConvertUtils. Hopefully, this * class makes it just a little easier to deal with Integer valued Numbers. *
- * Unfortunately, Number does not help with detecting integer/non-integer types, so this class only handles Object - * instances that have corresponding to the primitive types. {@code boolean}, {@code byte}, {@code char}, + * Unfortunately, Number does not help with detecting integer/noninteger types, so this class only handles Object + * instances that have corresponding to the primitive types. {@code boolean}, {@code byte}, {@code char}, * {@code short}, {@code int}, {@code long}, {@code float}, and {@code double}) *
* Because "Integer" is kind of ambiguous, I will use "Integral" to mean any integer type. For now, I am not including diff --git a/api/src/org/labkey/api/view/DataViewSnapshotSelectionForm.java b/api/src/org/labkey/api/view/DataViewSnapshotSelectionForm.java index 80ef5e8aa5e..fd40efa3bbc 100644 --- a/api/src/org/labkey/api/view/DataViewSnapshotSelectionForm.java +++ b/api/src/org/labkey/api/view/DataViewSnapshotSelectionForm.java @@ -3,7 +3,6 @@ import org.labkey.api.collections.LongHashSet; import org.labkey.api.data.DataRegionSelection; -import java.util.HashSet; import java.util.Set; public class DataViewSnapshotSelectionForm extends DataViewSelectionForm diff --git a/query/src/org/labkey/query/QueryServiceImpl.java b/query/src/org/labkey/query/QueryServiceImpl.java index 0883a1ec48d..45749c18d19 100644 --- a/query/src/org/labkey/query/QueryServiceImpl.java +++ b/query/src/org/labkey/query/QueryServiceImpl.java @@ -385,18 +385,16 @@ private static SQLFragment getColumnInSql(@NotNull FieldKey fieldKey, Object val SQLFragment fromSql = t.getFromSQL("_"); - SQLFragment sqlFragment = new SQLFragment() - .append("(").appendIdentifier(col.getAlias()) - .append(")") - .append(negate ? " NOT" : "") - .append(" IN (") - .append(" SELECT ") - .append(t.getColumns().get(0).getValueSql("_")) - .append(" FROM ") - .append(fromSql) - .append(")"); - - return sqlFragment; + return new SQLFragment() + .append("(").appendIdentifier(col.getAlias()) + .append(")") + .append(negate ? " NOT" : "") + .append(" IN (") + .append(" SELECT ") + .append(t.getColumns().get(0).getValueSql("_")) + .append(" FROM ") + .append(fromSql) + .append(")"); } /** diff --git a/query/src/org/labkey/query/reports/AttachmentReport.java b/query/src/org/labkey/query/reports/AttachmentReport.java index 29213865e0b..bdef0864736 100644 --- a/query/src/org/labkey/query/reports/AttachmentReport.java +++ b/query/src/org/labkey/query/reports/AttachmentReport.java @@ -80,7 +80,7 @@ public String getType() @Override public boolean canEdit(User user, Container container, List errors) { - // disallow a non site admin user from editing a server AttachmentReport + // disallow a non-site-admin user from editing a server AttachmentReport if (StringUtils.isNotEmpty(getFilePath()) && !container.hasPermission(user, AdminOperationsPermission.class)) { errors.add(new SimpleValidationError("You must be an administrator in order to edit this report.")); diff --git a/search/src/org/labkey/search/view/SearchWebPartFactory.java b/search/src/org/labkey/search/view/SearchWebPartFactory.java index dbb2572df00..278700f43a6 100644 --- a/search/src/org/labkey/search/view/SearchWebPartFactory.java +++ b/search/src/org/labkey/search/view/SearchWebPartFactory.java @@ -18,20 +18,13 @@ import org.jetbrains.annotations.NotNull; import org.labkey.api.data.BooleanFormat; import org.labkey.api.view.AlwaysAvailableWebPartFactory; -import org.labkey.api.view.HttpView; import org.labkey.api.view.JspView; -import org.labkey.api.view.Portal; +import org.labkey.api.view.Portal.WebPart; import org.labkey.api.view.ViewContext; import org.labkey.api.view.WebPartFactory; -import org.labkey.api.view.WebPartView; import java.text.ParseException; -/** - * User: adam - * Date: Jan 19, 2010 - * Time: 2:03:13 PM - */ public class SearchWebPartFactory extends AlwaysAvailableWebPartFactory { public SearchWebPartFactory() @@ -41,7 +34,7 @@ public SearchWebPartFactory() } @Override - public WebPartView getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart) + public SearchWebPart getWebPartView(@NotNull ViewContext portalCtx, @NotNull WebPart webPart) { boolean includeSubfolders = includeSubfolders(webPart); @@ -57,13 +50,13 @@ public WebPartView getWebPartView(@NotNull ViewContext portalCtx, @NotNull Po @Override - public HttpView getEditView(Portal.WebPart webPart, ViewContext context) + public JspView getEditView(WebPart webPart, ViewContext context) { return new JspView<>("/org/labkey/search/view/customizeSearchWebPart.jsp", webPart); } - public static boolean includeSubfolders(Portal.WebPart part) + public static boolean includeSubfolders(WebPart part) { String value = part.getPropertyMap().get("includeSubfolders"); @@ -77,5 +70,3 @@ public static boolean includeSubfolders(Portal.WebPart part) } } } - - diff --git a/study/src/org/labkey/study/query/DatasetQueryView.java b/study/src/org/labkey/study/query/DatasetQueryView.java index d51a088d11a..556a1a16d90 100644 --- a/study/src/org/labkey/study/query/DatasetQueryView.java +++ b/study/src/org/labkey/study/query/DatasetQueryView.java @@ -594,13 +594,11 @@ private MenuButton createQCStateButton() } boolean addSeparator = false; + if (getContainer().hasPermission(getUser(), QCAnalystPermission.class)) { - if (!addSeparator) - { - addSeparator = true; - button.addSeparator(); - } + addSeparator = true; + button.addSeparator(); ActionURL updateAction = new ActionURL(StudyController.UpdateQCStateAction.class, getContainer()); updateAction.addReturnUrl(getViewContext().getActionURL()); button.addMenuItem("Update state of selected rows", "if (verifySelected(" + DataRegion.getJavaScriptObjectReference(getDataRegionName()) + ".form, \"" + From 542a4fca2c16d6c4c63a212098608b16ea1faede Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Mon, 29 Dec 2025 17:05:29 -0800 Subject: [PATCH 2/4] Correct comment --- api/src/org/labkey/api/exp/api/ExperimentService.java | 2 +- api/src/org/labkey/api/util/IntegerUtils.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/org/labkey/api/exp/api/ExperimentService.java b/api/src/org/labkey/api/exp/api/ExperimentService.java index f89a451d717..9569c853007 100644 --- a/api/src/org/labkey/api/exp/api/ExperimentService.java +++ b/api/src/org/labkey/api/exp/api/ExperimentService.java @@ -1303,7 +1303,7 @@ static Long asLong(Object o) return null==o ? null : o.getClass() == Long.class ? (Long)o : ((Number)o).longValue(); } - @Deprecated // Use IntegerUtils.asLong() instead + @Deprecated // Use IntegerUtils.asInteger() instead static Integer asInteger(Object o) { if (null == o) diff --git a/api/src/org/labkey/api/util/IntegerUtils.java b/api/src/org/labkey/api/util/IntegerUtils.java index 7e241f8f916..42218b17a33 100644 --- a/api/src/org/labkey/api/util/IntegerUtils.java +++ b/api/src/org/labkey/api/util/IntegerUtils.java @@ -27,7 +27,7 @@ public static boolean isIntegral(Object o) return c == Byte.class || c == Short.class || c==Integer.class || c==Long.class; } - /** returns Numeric object as a Long. This method will throw if not Object is not Integral. */ + /** returns Numeric object as a Long. This method will throw if Object is not Integral. */ public static Long asLong(Object o) { if (!isIntegral(o)) @@ -35,7 +35,7 @@ public static Long asLong(Object o) return o.getClass() == Long.class ? (Long)o : Long.valueOf(((Number)o).longValue()); } - /** returns Numeric object as an Integer. This method will throw if not Object is not Integral or is out of range. */ + /** returns Numeric object as an Integer. This method will throw if Object is not Integral or is out of range. */ public static Integer asInteger(Object o) throws ClassCastException { if (null == o) From 9d005d1dff25e9de331f7c999a2d7938a0a026bb Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Mon, 29 Dec 2025 18:38:30 -0800 Subject: [PATCH 3/4] Delegate to IntegerUtils methods --- .../org/labkey/api/exp/api/ExperimentService.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/api/src/org/labkey/api/exp/api/ExperimentService.java b/api/src/org/labkey/api/exp/api/ExperimentService.java index 9569c853007..dc3783608b9 100644 --- a/api/src/org/labkey/api/exp/api/ExperimentService.java +++ b/api/src/org/labkey/api/exp/api/ExperimentService.java @@ -79,6 +79,7 @@ import org.labkey.api.reader.TabLoader; import org.labkey.api.security.User; import org.labkey.api.services.ServiceRegistry; +import org.labkey.api.util.IntegerUtils; import org.labkey.api.util.Pair; import org.labkey.api.util.StringUtilsLabKey; import org.labkey.api.view.HttpView; @@ -1300,19 +1301,12 @@ public XarImportOptions setStrictValidateExistingSampleType(boolean strictValida @Deprecated // Use IntegerUtils.asLong() instead static Long asLong(Object o) { - return null==o ? null : o.getClass() == Long.class ? (Long)o : ((Number)o).longValue(); + return IntegerUtils.asLong(o); } @Deprecated // Use IntegerUtils.asInteger() instead static Integer asInteger(Object o) { - if (null == o) - return null; - if (o.getClass() == Integer.class) - return (Integer)o; - long l = ((Number)o).longValue(); - if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) - throw new IllegalArgumentException("Invalid int value: " + l); - return (int)l; + return IntegerUtils.asInteger(o); } } From 05ae6578db956c6f81a279a0318e1c380b31a19d Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Mon, 29 Dec 2025 18:41:29 -0800 Subject: [PATCH 4/4] @Override --- api/src/org/labkey/api/exp/api/ExperimentService.java | 6 ++---- .../org/labkey/experiment/api/ExperimentServiceImpl.java | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/src/org/labkey/api/exp/api/ExperimentService.java b/api/src/org/labkey/api/exp/api/ExperimentService.java index dc3783608b9..ac7725a2922 100644 --- a/api/src/org/labkey/api/exp/api/ExperimentService.java +++ b/api/src/org/labkey/api/exp/api/ExperimentService.java @@ -720,10 +720,8 @@ static void validateParentAlias(Map aliasMap, Set reserv ExpData getExpDataByURL(Path p, @Nullable Container c); /** - * Get all ExpData for the dataFileUrl. - * - * Having more than one ExpData for the same file path doesn't happen often but is allowed. - * Some examples: + * Get all ExpData for the dataFileUrl. Having more than one ExpData for the same file path doesn't happen often but + * is allowed. Some examples: * - The file or pipeline root may be shared by more than one container and an exp.data may be created in each container when importing assay data. * - In the MS2 analysis pipeline, there are tools that rewrite an input file to add more data. We model them as separate exp.data. */ diff --git a/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java b/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java index 24cca6884d6..367d743da66 100644 --- a/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java +++ b/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java @@ -3610,6 +3610,7 @@ private void _verifyAllEdges(Container c, @Nullable Integer limit) } } + @Override public void clearAncestors(ExpRunItem runItem) { boolean isSample = runItem instanceof ExpMaterial; @@ -3619,16 +3620,19 @@ public void clearAncestors(ExpRunItem runItem) clearDataAncestors(List.of(runItem.getRowId())); } + @Override public void repopulateAncestors() { ClosureQueryHelper.truncateAndRecreate(); } + @Override public void clearDataAncestors(Collection dataRowIds) { ClosureQueryHelper.clearAncestorsForDataObjects(dataRowIds); } + @Override public void clearMaterialAncestors(Collection materialRowIds) { ClosureQueryHelper.clearAncestorsForMaterials(materialRowIds);