diff --git a/announcements/src/org/labkey/announcements/AnnouncementUserListener.java b/announcements/src/org/labkey/announcements/AnnouncementUserListener.java index d1591656203..bc085b3bf77 100644 --- a/announcements/src/org/labkey/announcements/AnnouncementUserListener.java +++ b/announcements/src/org/labkey/announcements/AnnouncementUserListener.java @@ -19,8 +19,6 @@ import org.labkey.api.security.User; import org.labkey.api.security.UserManager.UserListener; -import java.beans.PropertyChangeEvent; - /** * User: adam * Date: Nov 5, 2008 diff --git a/announcements/src/org/labkey/announcements/NotificationSettingsImporterFactory.java b/announcements/src/org/labkey/announcements/NotificationSettingsImporterFactory.java index 5d1747106f5..e3992d80d17 100644 --- a/announcements/src/org/labkey/announcements/NotificationSettingsImporterFactory.java +++ b/announcements/src/org/labkey/announcements/NotificationSettingsImporterFactory.java @@ -15,7 +15,6 @@ */ package org.labkey.announcements; -import org.jetbrains.annotations.NotNull; import org.labkey.announcements.model.AnnouncementManager; import org.labkey.api.admin.AbstractFolderImportFactory; import org.labkey.api.admin.FolderArchiveDataTypes; @@ -26,13 +25,9 @@ import org.labkey.api.message.settings.MessageConfigService; import org.labkey.api.notification.EmailService; import org.labkey.api.pipeline.PipelineJob; -import org.labkey.api.pipeline.PipelineJobWarning; import org.labkey.api.writer.VirtualFile; import org.labkey.folder.xml.NotificationsType; -import java.util.Collection; -import java.util.Collections; - /** * User: cnathe * Date: 10/31/12 diff --git a/announcements/src/org/labkey/announcements/ToursController.java b/announcements/src/org/labkey/announcements/ToursController.java index 43201b83bb6..7fa4054f84c 100644 --- a/announcements/src/org/labkey/announcements/ToursController.java +++ b/announcements/src/org/labkey/announcements/ToursController.java @@ -53,7 +53,7 @@ public ToursController() // Anyone with read permission can attempt to view the list. ToursTable will do further permission checking. @RequiresPermission(ReadPermission.class) @SuppressWarnings("UnusedDeclaration") - public class BeginAction extends SimpleViewAction + public static class BeginAction extends SimpleViewAction { @Override public ModelAndView getView(QueryForm queryForm, BindException errors) @@ -86,7 +86,7 @@ public static ActionURL getEditTourURL(Container c) @ActionNames("edit, editTour") @RequiresPermission(ReadPermission.class) //will check below - public class EditTourAction extends SimpleViewAction + public static class EditTourAction extends SimpleViewAction { @Override public ModelAndView getView(EditTourForm editTourForm, BindException errors) @@ -118,7 +118,7 @@ public void addNavTrail(NavTree root) @ActionNames("tours, saveTour") @RequiresPermission(ReadPermission.class) //will check below - public class SaveTourAction extends MutatingApiAction + public static class SaveTourAction extends MutatingApiAction { @Override public void validateForm(SimpleApiJsonForm form, Errors errors) @@ -173,7 +173,7 @@ public Object execute(SimpleApiJsonForm form, BindException errors) } @RequiresPermission(ReadPermission.class) - public class GetTourAction extends MutatingApiAction + public static class GetTourAction extends MutatingApiAction { @Override diff --git a/announcements/src/org/labkey/announcements/api/AnnouncementImpl.java b/announcements/src/org/labkey/announcements/api/AnnouncementImpl.java index 6c1162b9f9d..7470e40a3de 100644 --- a/announcements/src/org/labkey/announcements/api/AnnouncementImpl.java +++ b/announcements/src/org/labkey/announcements/api/AnnouncementImpl.java @@ -20,7 +20,6 @@ import org.labkey.api.announcements.api.Announcement; import org.labkey.api.attachments.Attachment; import org.labkey.api.data.Container; -import org.labkey.api.security.User; import org.labkey.api.wiki.WikiRendererType; import java.util.Collection; diff --git a/announcements/src/org/labkey/announcements/api/AnnouncementServiceImpl.java b/announcements/src/org/labkey/announcements/api/AnnouncementServiceImpl.java index f874cbc6de3..2872015d602 100644 --- a/announcements/src/org/labkey/announcements/api/AnnouncementServiceImpl.java +++ b/announcements/src/org/labkey/announcements/api/AnnouncementServiceImpl.java @@ -96,7 +96,7 @@ public Announcement insertAnnouncement(Container c, User u, String title, String } } - if (validMemberListIds.size() > 0) + if (!validMemberListIds.isEmpty()) { // insert.setMemberListIds(validMemberListIds); // This gets set in AnnouncementManager.validateModelWithSideEffects by parsing the memberListInput insert.setMemberListInput(StringUtils.join(validMemberListIds, "\n")); // Pretend this is coming as comma-separated input from a form diff --git a/announcements/src/org/labkey/announcements/customizeAnnouncementWebPart.jsp b/announcements/src/org/labkey/announcements/customizeAnnouncementWebPart.jsp index a8980947023..ab2849506d4 100644 --- a/announcements/src/org/labkey/announcements/customizeAnnouncementWebPart.jsp +++ b/announcements/src/org/labkey/announcements/customizeAnnouncementWebPart.jsp @@ -15,17 +15,17 @@ * limitations under the License. */ %> -<%@ page import="org.apache.commons.lang3.StringUtils" %> <%@ page import="org.labkey.api.view.HttpView" %> <%@ page import="org.labkey.api.view.Portal" %> <%@ page import="org.labkey.api.view.ViewContext" %> +<%@ page import="java.util.Objects" %> <%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %> <%@ page extends="org.labkey.api.jsp.JspBase" %> <% Portal.WebPart webPart = (Portal.WebPart)HttpView.currentModel(); ViewContext context = getViewContext(); - String selected = StringUtils.defaultString(webPart.getPropertyMap().get("style"), "full"); + String selected = Objects.toString(webPart.getPropertyMap().get("style"), "full"); %> diff --git a/announcements/src/org/labkey/announcements/model/AnnouncementDigestProvider.java b/announcements/src/org/labkey/announcements/model/AnnouncementDigestProvider.java index f053f347c86..96a1fc80557 100644 --- a/announcements/src/org/labkey/announcements/model/AnnouncementDigestProvider.java +++ b/announcements/src/org/labkey/announcements/model/AnnouncementDigestProvider.java @@ -174,7 +174,7 @@ private static String loadBody() } catch (IOException e) { - throw new UnexpectedException(e); + throw UnexpectedException.wrap(e); } } @@ -194,20 +194,19 @@ protected void addCustomReplacements(Replacements replacements) private void initReason() { - StringBuilder sb = new StringBuilder(); - sb.append("You have received this email because you are signed up for a daily digest of new posts to "); - sb.append(PageFlowUtil.filter(dailyDigestBean.boardPath)); - sb.append(" at "); - sb.append(PageFlowUtil.filter(dailyDigestBean.siteUrl)); - sb.append(". If you no longer wish to receive these notifications, please change your email preferences."); - - reasonForEmail = sb.toString(); + String sb = "You have received this email because you are signed up for a daily digest of new posts to " + + PageFlowUtil.filter(dailyDigestBean.boardPath) + + " at " + + PageFlowUtil.filter(dailyDigestBean.siteUrl) + + ". If you no longer wish to receive these notifications, please change your email preferences."; + + reasonForEmail = sb; } private void initPosts() diff --git a/announcements/src/org/labkey/announcements/model/AnnouncementManager.java b/announcements/src/org/labkey/announcements/model/AnnouncementManager.java index c9c210c6b13..21cf656d564 100644 --- a/announcements/src/org/labkey/announcements/model/AnnouncementManager.java +++ b/announcements/src/org/labkey/announcements/model/AnnouncementManager.java @@ -408,13 +408,12 @@ private static void notifyModerators(Container c, User user, AnnouncementModel a msg.setFrom(LookAndFeelProperties.getInstance(c).getSystemEmailAddress()); msg.setSubject("New " + name.toLowerCase() + " in " + c.getPath() + " (" + c.getTitle() + ") requires moderator review"); - StringBuilder content = new StringBuilder(); - content.append("Please visit the Moderator Review page at ").append(new ActionURL(ModeratorReviewAction.class, c).getURIString()); - content.append("\n\nSubject: ").append(ann.getTitle()); - content.append("\nUser: ").append(user.getDisplayName(user)).append(" (").append(user.getEmail()).append(")"); - content.append("\n").append(name).append(": ").append(AnnouncementsController.getThreadURL(c, ann.getEntityId(), ann.getRowId()).getURIString()); + String content = "Please visit the Moderator Review page at " + new ActionURL(ModeratorReviewAction.class, c).getURIString() + + "\n\nSubject: " + ann.getTitle() + + "\nUser: " + user.getDisplayName(user) + " (" + user.getEmail() + ")" + + "\n" + name + ": " + AnnouncementsController.getThreadURL(c, ann.getEntityId(), ann.getRowId()).getURIString(); - msg.setTextContent(content.toString()); + msg.setTextContent(content); emailer.addMessage(toList, msg); emailer.start(); } @@ -1248,7 +1247,7 @@ private static String loadBody() } catch (IOException e) { - throw new UnexpectedException(e); + throw UnexpectedException.wrap(e); } } diff --git a/announcements/src/org/labkey/announcements/model/DiscussionServiceImpl.java b/announcements/src/org/labkey/announcements/model/DiscussionServiceImpl.java index 5cc9e0308e7..ca3127caaab 100644 --- a/announcements/src/org/labkey/announcements/model/DiscussionServiceImpl.java +++ b/announcements/src/org/labkey/announcements/model/DiscussionServiceImpl.java @@ -60,7 +60,7 @@ public class DiscussionServiceImpl implements DiscussionService { @Override - public WebPartView startDiscussion(Container c, User user, String identifier, ActionURL pageURL, URLHelper cancelURL, String title, String summary, boolean allowMultipleDiscussions) + public WebPartView startDiscussion(Container c, User user, String identifier, ActionURL pageURL, URLHelper cancelURL, String title, String summary, boolean allowMultipleDiscussions) { if (!allowMultipleDiscussions) { @@ -110,7 +110,7 @@ public static ActionURL fromSaved(String saved) } - public WebPartView getDiscussion(Container c, URLHelper currentURL, AnnouncementModel ann, User user) + public WebPartView getDiscussion(Container c, URLHelper currentURL, AnnouncementModel ann, User user) { // NOTE: don't pass in AnnouncementModel, it came from getBareAnnouncements() return new AnnouncementsController.ThreadView(c, currentURL, user, null, ann.getEntityId()); @@ -147,7 +147,7 @@ public DiscussionService.DiscussionView getDiscussionArea(Container c, User user { discussionId = Integer.parseInt(id); } - else if (displayFirstDiscussionByDefault && params.isEmpty() && discussions.size() > 0) + else if (displayFirstDiscussionByDefault && params.isEmpty() && !discussions.isEmpty()) { discussionId = discussions.get(0).getRowId(); } @@ -168,7 +168,7 @@ else if (displayFirstDiscussionByDefault && params.isEmpty() && discussions.size // clean up discussion parameters (in case caller didn't) pageURL.deleteScopeParameters("discussion"); - WebPartView start = startDiscussion(c, user, objectId, pageURL, adjustedCurrentURL, newDiscussionTitle, "", allowMultipleDiscussions); + WebPartView start = startDiscussion(c, user, objectId, pageURL, adjustedCurrentURL, newDiscussionTitle, "", allowMultipleDiscussions); String title; if (start instanceof AnnouncementsController.ThreadView) @@ -188,8 +188,8 @@ else if (displayFirstDiscussionByDefault && params.isEmpty() && discussions.size { AnnouncementModel selected = null; - WebPartView discussionView = null; - HttpView respondView = null; + WebPartView discussionView = null; + HttpView respondView = null; if (discussionId != 0) { @@ -246,7 +246,7 @@ public void deleteDiscussions(Container c, User user, String... identifiers) @Override public void deleteDiscussions(Container container, User user, Collection identifiers) { - Collection discussions = AnnouncementManager.getDiscussions(container, identifiers.toArray(new String[identifiers.size()])); + Collection discussions = AnnouncementManager.getDiscussions(container, identifiers.toArray(new String[0])); for (AnnouncementModel ann : discussions) { AnnouncementManager.deleteAnnouncement(container, ann.getRowId()); @@ -328,17 +328,17 @@ public static class AnchorView extends HtmlView } - public static class ThreadWrapper extends WebPartView + public static class ThreadWrapper extends WebPartView { String _id; String _class = "labkey-hidden"; VBox _vbox; - ThreadWrapper(URLHelper currentURL, String caption, HttpView... views) + ThreadWrapper(URLHelper currentURL, String caption, HttpView... views) { super(FrameType.NONE); _vbox = new VBox(); - for (HttpView v : views) + for (HttpView v : views) { if (v != null) { @@ -354,7 +354,7 @@ public static class ThreadWrapper extends WebPartView _id = "discussionBox" + UniqueID.getRequestScopedUID(HttpView.currentRequest()); - for (HttpView view : views) + for (HttpView view : views) { if (view != null) addClientDependencies(view.getClientDependencies()); @@ -399,7 +399,7 @@ public void doEndTag(PrintWriter out) } - public static class PickerView extends JspView + public static class PickerView extends JspView { final public String discussionAreaId; final public URLHelper pageURL; diff --git a/announcements/src/org/labkey/announcements/model/EmailPrefsSelector.java b/announcements/src/org/labkey/announcements/model/EmailPrefsSelector.java index bc9062c4e01..c668a16ccd9 100644 --- a/announcements/src/org/labkey/announcements/model/EmailPrefsSelector.java +++ b/announcements/src/org/labkey/announcements/model/EmailPrefsSelector.java @@ -105,7 +105,7 @@ public boolean shouldSend(@Nullable AnnouncementModel ann, User user) // log information to mothership (to help track this down) and return false (to avoid subsequent NPE). if (null == up) { - ExceptionUtil.logExceptionToMothership(HttpView.currentRequest(), new IllegalStateException("UserPreference is null for user: " + user.getEmail() + ", ann: " + (null != ann ? ann.getRowId() : null) + ", c: " + _c.toString() + "\n" + pp.toString())); + ExceptionUtil.logExceptionToMothership(HttpView.currentRequest(), new IllegalStateException("UserPreference is null for user: " + user.getEmail() + ", ann: " + (null != ann ? ann.getRowId() : null) + ", c: " + _c.toString() + "\n" + pp)); return false; } @@ -213,7 +213,7 @@ UserPreference getApplicablePreference(@Nullable AnnouncementModel ann) @Override public String toString() { - return "PreferencePicker: " + _c.getId() + " " + _preferenceMap.toString(); + return "PreferencePicker: " + _c.getId() + " " + _preferenceMap; } } } diff --git a/announcements/src/org/labkey/announcements/model/TourModel.java b/announcements/src/org/labkey/announcements/model/TourModel.java index 4e7d310b4eb..78174ac3a84 100644 --- a/announcements/src/org/labkey/announcements/model/TourModel.java +++ b/announcements/src/org/labkey/announcements/model/TourModel.java @@ -111,7 +111,7 @@ public JSONObject abbrevDef() public JSONObject toJSON() { JSONObject out = new JSONObject(); - if (!getJson().equals("")) + if (!getJson().isEmpty()) { out = new JSONObject(getJson()); } diff --git a/announcements/src/org/labkey/announcements/query/ForumSubscriptionTable.java b/announcements/src/org/labkey/announcements/query/ForumSubscriptionTable.java index 1389c2f9112..7fbe6ea5088 100644 --- a/announcements/src/org/labkey/announcements/query/ForumSubscriptionTable.java +++ b/announcements/src/org/labkey/announcements/query/ForumSubscriptionTable.java @@ -116,9 +116,9 @@ public QueryUpdateService getUpdateService() private static class SubscriptionTarget { - @NotNull private User _user; - @NotNull private Container _container; - @NotNull private String _srcIdentifier; + @NotNull private final User _user; + @NotNull private final Container _container; + @NotNull private final String _srcIdentifier; private SubscriptionTarget(@NotNull User user, @NotNull Container container, @NotNull String srcIdentifier) { @@ -203,7 +203,7 @@ private SubscriptionTarget getTargets(Map row, User user, Contai targetContainer = ContainerManager.getForId(folderId.toString()); if (targetContainer == null) { - throw new InvalidKeyException("No such Folder: " + folderId.toString()); + throw new InvalidKeyException("No such Folder: " + folderId); } } diff --git a/announcements/src/org/labkey/announcements/update.jsp b/announcements/src/org/labkey/announcements/update.jsp index 25654d119e5..484c959e0b5 100644 --- a/announcements/src/org/labkey/announcements/update.jsp +++ b/announcements/src/org/labkey/announcements/update.jsp @@ -144,8 +144,8 @@ if (settings.hasExpires()) for (Attachment att : ann.getAttachments()) { x++; - id = makeId("remove_"); - %> + makeId("remove_"); + %> logo <%= h(att.getName()) %> <%= link("remove").onClick("LABKEY.discuss.removeAttachment(" + q(ann.getEntityId()) + "," + q(att.getName()) + "," + q("attach-"+x) + ");") %> <% diff --git a/api/gwtsrc/org/labkey/api/gwt/client/AuditBehaviorType.java b/api/gwtsrc/org/labkey/api/gwt/client/AuditBehaviorType.java index b028989f2d6..6fcdec69095 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/AuditBehaviorType.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/AuditBehaviorType.java @@ -25,7 +25,7 @@ public enum AuditBehaviorType DETAILED("Detailed"), SUMMARY("Summary"); - private String _label; + private final String _label; AuditBehaviorType(String label) { diff --git a/api/gwtsrc/org/labkey/api/gwt/client/DefaultScaleType.java b/api/gwtsrc/org/labkey/api/gwt/client/DefaultScaleType.java index 20b9f1d0674..187ef2755ab 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/DefaultScaleType.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/DefaultScaleType.java @@ -24,7 +24,7 @@ public enum DefaultScaleType LINEAR("Linear"), LOG("Log"); - private String _label; + private final String _label; DefaultScaleType(String label) { diff --git a/api/gwtsrc/org/labkey/api/gwt/client/assay/model/GWTProtocol.java b/api/gwtsrc/org/labkey/api/gwt/client/assay/model/GWTProtocol.java index 2fed56970d3..e4f3e003117 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/assay/model/GWTProtocol.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/assay/model/GWTProtocol.java @@ -46,16 +46,16 @@ public class GWTProtocol implements IsSerializable private List> _domains; private List _availablePlateTemplates; - private Map _availableMetadataInputFormats = new HashMap(); + private Map _availableMetadataInputFormats = new HashMap<>(); private String _metadataInputFormatHelp; private String _selectedPlateTemplate; private String _selectedMetadataInputFormat; /** Scripts defined in the module itself, associated with the assay provider */ - private List _moduleTransformScripts = new ArrayList(); + private List _moduleTransformScripts = new ArrayList<>(); /** Scripts defined in the assay definition */ - private List> _protocolTransformScripts = new ArrayList<>(); + private final List> _protocolTransformScripts = new ArrayList<>(); private List _availableDetectionMethods; private String _selectedDetectionMethod; diff --git a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTDomain.java b/api/gwtsrc/org/labkey/api/gwt/client/model/GWTDomain.java index d802cdfc2c6..eecd41589ee 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTDomain.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/model/GWTDomain.java @@ -221,7 +221,7 @@ public boolean allowsPhi(FieldType field) */ public void setMandatoryFieldNames(Set mandatoryFieldNames) { - this.mandatoryPropertyDescriptorNames = new HashSet(); + this.mandatoryPropertyDescriptorNames = new HashSet<>(); for (String mandatoryPropertyDescriptor : mandatoryFieldNames) { this.mandatoryPropertyDescriptorNames.add(mandatoryPropertyDescriptor.toLowerCase()); @@ -248,7 +248,7 @@ public Set getReservedFieldNames() */ public void setReservedFieldNames(Set reservedFieldNames) { - this.reservedFieldNames = new HashSet(); + this.reservedFieldNames = new HashSet<>(); for (String s : reservedFieldNames) { this.reservedFieldNames.add(s.toLowerCase()); @@ -270,7 +270,7 @@ public void setReservedFieldNamePrefixes(Set prefixes) */ public void setExcludeFromExportFieldNames(Set excludeFromExportFieldNames) { - this.excludeFromExportFieldNames = new HashSet(); + this.excludeFromExportFieldNames = new HashSet<>(); for (String excludeFromExportFieldName : excludeFromExportFieldNames) { this.excludeFromExportFieldNames.add(excludeFromExportFieldName.toLowerCase()); @@ -298,7 +298,7 @@ public Set getPhiNotAllowedFieldNames() public void setPhiNotAllowedFieldNames(Set phiNotAllowedFieldNames) { - this.phiNotAllowedFieldNames = new HashSet(); + this.phiNotAllowedFieldNames = new HashSet<>(); for (String fieldName : phiNotAllowedFieldNames) { this.phiNotAllowedFieldNames.add(fieldName.toLowerCase()); diff --git a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTIndex.java b/api/gwtsrc/org/labkey/api/gwt/client/model/GWTIndex.java index 3edc2783fae..75e8030492d 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTIndex.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/model/GWTIndex.java @@ -45,7 +45,7 @@ public GWTIndex(List columnNames, boolean unique) public GWTIndex(GWTIndex other) { - setColumnNames(new ArrayList(other.getColumnNames())); + setColumnNames(new ArrayList<>(other.getColumnNames())); setUnique(other.isUnique()); } diff --git a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTPropertyValidator.java b/api/gwtsrc/org/labkey/api/gwt/client/model/GWTPropertyValidator.java index 8db2fb0b563..2a4715f39b4 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTPropertyValidator.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/model/GWTPropertyValidator.java @@ -171,11 +171,9 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null) return false; - if (!(o instanceof GWTPropertyValidator)) + if (!(o instanceof GWTPropertyValidator that)) return false; - GWTPropertyValidator that = (GWTPropertyValidator) o; - if (getRowId() != that.getRowId()) return false; if (!StringUtils.equals(getName(), that.getName())) return false; if (!PropertyUtil.nullSafeEquals(getType(), that.getType())) return false; diff --git a/api/gwtsrc/org/labkey/api/gwt/client/pipeline/GWTPipelineConfig.java b/api/gwtsrc/org/labkey/api/gwt/client/pipeline/GWTPipelineConfig.java deleted file mode 100644 index d828080d143..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/pipeline/GWTPipelineConfig.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.pipeline; - -import java.io.Serializable; -import java.util.List; - -/** - * User: jeckels - * Date: Jan 20, 2012 - */ -public class GWTPipelineConfig implements Serializable -{ - private List _tasks; - - public GWTPipelineConfig() - { - } - - public GWTPipelineConfig(List tasks) - { - _tasks = tasks; - } - - public List getTasks() - { - return _tasks; - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/pipeline/GWTPipelineTask.java b/api/gwtsrc/org/labkey/api/gwt/client/pipeline/GWTPipelineTask.java deleted file mode 100644 index b6179805c0f..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/pipeline/GWTPipelineTask.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.pipeline; - -import java.io.Serializable; - -/** - * User: jeckels - * Date: Jan 20, 2012 - */ -public class GWTPipelineTask implements Serializable -{ - private String _taskId; - private String _name; - private String _groupName; - - public GWTPipelineTask() - { - } - - public GWTPipelineTask(String taskId, String name, String groupName) - { - _taskId = taskId; - _name = name; - _groupName = groupName; - } - - public String getTaskId() - { - return _taskId; - } - - public String getName() - { - return _name; - } - - public String getGroupName() - { - return _groupName; - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/pipeline/PipelineGWTService.java b/api/gwtsrc/org/labkey/api/gwt/client/pipeline/PipelineGWTService.java deleted file mode 100644 index bb7eea97214..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/pipeline/PipelineGWTService.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.pipeline; - -import com.google.gwt.user.client.rpc.RemoteService; - -/** - * User: jeckels - * Date: Jan 20, 2012 - */ -public interface PipelineGWTService extends RemoteService -{ - public GWTPipelineConfig getLocationOptions(String pipelineId); -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/pipeline/PipelineGWTServiceAsync.java b/api/gwtsrc/org/labkey/api/gwt/client/pipeline/PipelineGWTServiceAsync.java deleted file mode 100644 index ae522c23c71..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/pipeline/PipelineGWTServiceAsync.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.pipeline; - -import com.google.gwt.user.client.rpc.AsyncCallback; - -public interface PipelineGWTServiceAsync -{ - void getLocationOptions(String pipelineId, AsyncCallback async); -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/BoundCheckBox.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/BoundCheckBox.java deleted file mode 100644 index d6e9d4275e1..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/BoundCheckBox.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.ui.CheckBox; -import org.labkey.api.gwt.client.util.BooleanProperty; - -/** - * User: matthewb - * Date: Mar 29, 2010 - * Time: 11:36:09 AM - */ -public class BoundCheckBox extends CheckBox -{ - public BoundCheckBox(String id, BooleanProperty property, DirtyCallback dirtyCallback) - { - this(id, null, property, dirtyCallback); - } - - public BoundCheckBox(String id, String name, final BooleanProperty property, final DirtyCallback dirtyCallback) - { - super("", true); - DOM.setElementAttribute(getElement(), "id", id); - if (name != null) - { - setName(name); - } - - setValue(property.booleanValue()); - - addClickHandler(new ClickHandler() - { - @Override - public void onClick(ClickEvent event) - { - property.set(Boolean.TRUE == getValue()); - if (dirtyCallback != null) - { - dirtyCallback.setDirty(true); - } - } - }); - } -} \ No newline at end of file diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/BoundTextBox.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/BoundTextBox.java index c3f5f42dbd6..54c523a0d3d 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/BoundTextBox.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/ui/BoundTextBox.java @@ -156,7 +156,7 @@ public final String validate() protected String validateValue(String text) { text = text.trim(); - if (_required && (text == null || text.length() == 0)) + if (_required && (text == null || text.isEmpty())) return "\"" + _caption + "\" is required."; return null; } diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/DirtyCallback.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/DirtyCallback.java index c169e9e131e..01d1d89c53e 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/DirtyCallback.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/ui/DirtyCallback.java @@ -22,5 +22,5 @@ */ public interface DirtyCallback { - public void setDirty(boolean dirty); + void setDirty(boolean dirty); } \ No newline at end of file diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/FileUploadWithListeners.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/FileUploadWithListeners.java deleted file mode 100644 index 7db94e31b24..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/FileUploadWithListeners.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.dom.client.Element; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.ui.ChangeListener; -import com.google.gwt.user.client.ui.ChangeListenerCollection; -import com.google.gwt.user.client.ui.ClickListener; -import com.google.gwt.user.client.ui.ClickListenerCollection; -import com.google.gwt.user.client.ui.FileUpload; -import com.google.gwt.user.client.ui.SourcesChangeEvents; -import com.google.gwt.user.client.ui.SourcesClickEvents; - -/** - * User: jgarms - * Date: Oct 30, 2008 - */ -public class FileUploadWithListeners extends FileUpload implements SourcesClickEvents, SourcesChangeEvents -{ - @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) - private ClickListenerCollection clickListeners; - - @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) - private ChangeListenerCollection changeListeners; - - public FileUploadWithListeners() - { - super(); - sinkEvents(Event.ONCLICK | Event.ONCHANGE); - } - - protected FileUploadWithListeners(Element element) - { - super(element); - } - - @Override - public void addClickListener(ClickListener listener) - { - if (clickListeners == null) - { - clickListeners = new ClickListenerCollection(); - sinkEvents(Event.ONCLICK); - } - clickListeners.add(listener); - } - - @Override - public void removeClickListener(ClickListener listener) - { - if (clickListeners != null) - { - clickListeners.remove(listener); - } - } - - @Override - public void addChangeListener(ChangeListener listener) - { - if (changeListeners == null) - { - changeListeners = new ChangeListenerCollection(); - sinkEvents(Event.ONCHANGE); - } - changeListeners.add(listener); - } - - @Override - public void removeChangeListener(ChangeListener listener) - { - if (changeListeners != null) - changeListeners.remove(listener); - } - - @Override - public void onBrowserEvent(Event event) - { - if (DOM.eventGetType(event) == Event.ONCLICK) - { - if (clickListeners != null) - clickListeners.fireClick(this); - } - else if (DOM.eventGetType(event) == Event.ONCHANGE) - { - if (changeListeners != null) - changeListeners.fireChange(this); - } - } - -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/FontButton.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/FontButton.java deleted file mode 100644 index 04eedc66bfe..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/FontButton.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.user.client.ui.HTML; - -/** - * Created by klum on 9/8/2015. - */ -public class FontButton extends HTML -{ - public FontButton(String fontClass) - { - super(""); - - setStyleName("gwt-FontImage gwt-PushButton"); - } - - public void setEnabled(boolean enabled) - { - if (enabled) - removeStyleName("gwt-PushButton-up-disabled"); - else - addStyleName("gwt-PushButton-up-disabled"); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/HelpPopup.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/HelpPopup.java index de862f0139f..d23c009c174 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/HelpPopup.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/ui/HelpPopup.java @@ -16,10 +16,6 @@ package org.labkey.api.gwt.client.ui; -import com.google.gwt.event.dom.client.MouseOutEvent; -import com.google.gwt.event.dom.client.MouseOutHandler; -import com.google.gwt.event.dom.client.MouseOverEvent; -import com.google.gwt.event.dom.client.MouseOverHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.InlineLabel; @@ -31,8 +27,8 @@ */ public class HelpPopup extends InlineLabel { - private Element _element; - private String _title; + private final Element _element; + private final String _title; private String _body; public HelpPopup(String title, String body) diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/ImageButton.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/ImageButton.java index 1b4d2b5dca2..1b160535f3b 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/ImageButton.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/ui/ImageButton.java @@ -32,8 +32,8 @@ public class ImageButton extends ButtonBase implements ClickListener { - private ClickListenerCollection _clickListeners = new ClickListenerCollection(); - private List _clickHandlers = new ArrayList(); + private final ClickListenerCollection _clickListeners = new ClickListenerCollection(); + private final List _clickHandlers = new ArrayList<>(); private String _text; public ImageButton(String text, ClickListener listener) diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/LinkButton.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/LinkButton.java deleted file mode 100644 index d3c228c497d..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/LinkButton.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.user.client.ui.ClickListener; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.Widget; - -/** - * User: brittp - * Date: Feb 9, 2007 - * Time: 5:33:32 PM - */ -public class LinkButton extends Composite -{ - public LinkButton(String html, final String link) - { - this(html, link, false); - } - - public LinkButton(String html, final String link, boolean isBracketStyle) - { - Widget w; - if (isBracketStyle) - w = new HTML("[" + html + "]"); - else - w = new ImageButton(html, new ClickListener() - { - @Override - public void onClick(Widget sender) - { - WindowUtil.setLocation(link); - } - }); - - initWidget(w); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/PropertyType.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/PropertyType.java index 2db81917db0..180beb643c2 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/PropertyType.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/ui/PropertyType.java @@ -124,7 +124,7 @@ public static PropertyType fromName(String type) } - private static Map synonyms = new HashMap(); + private static final Map synonyms = new HashMap<>(); private static void _put(PropertyType t) { synonyms.put(t.toString().toLowerCase(), t); diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/Saveable.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/Saveable.java index bef6a6ce8f1..690d1c42c28 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/Saveable.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/ui/Saveable.java @@ -32,7 +32,7 @@ public interface Saveable */ String getCurrentURL(); - public interface SaveListener + interface SaveListener { void saveSuccessful(ObjectType result, String designerUrl); } diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/StringListBox.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/StringListBox.java deleted file mode 100644 index 2e8ad8537bf..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/StringListBox.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.user.client.ui.ChangeListener; -import com.google.gwt.user.client.ui.ChangeListenerCollection; -import com.google.gwt.user.client.ui.HasText; -import com.google.gwt.user.client.ui.ListBox; -import com.google.gwt.user.client.ui.Widget; -import org.labkey.api.gwt.client.util.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * User: Mark Igra - * Date: Mar 5, 2007 - * Time: 4:54:30 PM - */ -public class StringListBox extends ListBox implements HasText, ChangeListener -{ - List/**/ values; - boolean allowExtension; - private String addItemText = ""; - private ChangeListenerCollection externalListeners = new ChangeListenerCollection(); - private int lastSelected; - - public StringListBox(String[] values, String selected, boolean allowExtension) - { - List/**/ list = new ArrayList/**/(); - for (int i = 0; i < values.length; i++) - list.add(values[i]); - - init(list, selected, allowExtension, false); - } - - public StringListBox(List/**/ values, String selected, boolean allowExtension, boolean addSelectedWithoutMatch) - { - init(values, selected, allowExtension, addSelectedWithoutMatch); - } - - private void init(List/**/ values, String selected, boolean allowExtension, boolean addSelectedWithoutMatch) - { - this.values = values; - this.allowExtension = allowExtension; - boolean match = false; - addItem(""); - selected = StringUtils.trimToNull(selected); - if (null == selected) - setSelectedIndex(0); - - for (int i = 0; i < values.size(); i++) - { - String str = (String) values.get(i); - addItem(str); - if (str.equals(selected)) - { - setSelectedIndex(i + 1); - match = true; - } - } - if (!match) - { - if (null != selected && !allowExtension && !addSelectedWithoutMatch) - throw new IllegalArgumentException("Item " + selected + " not found in list."); - if (null != selected) - { - addItem(selected); - setSelectedIndex(values.size() + 1); - } - } - if (allowExtension) - { - addItem(addItemText); - } - lastSelected = getSelectedIndex(); - super.addChangeListener(this); - } - - - @Override - public String getText() - { - int itemSelected = getSelectedIndex(); - if (itemSelected < 0) - return null; - - return getItemText(itemSelected).length() == 0 ? null : getItemText(itemSelected); - } - - @Override - public void setText(String text) - { - for (int i = 0; i < getItemCount(); i++) - if (getItemText(i).equals(text)) - { - setSelectedIndex(i); - lastSelected = i; - return; - } - - if (allowExtension) - { - insertItem(text, getItemCount() - 1); - setSelectedIndex(getItemCount() - 2); - lastSelected = getItemCount() - 2; - } - else - throw new IllegalArgumentException("Could not find text " + text); - } - - public String getAddItemText() - { - return addItemText; - } - - public void setAddItemText(String addItemText) - { - this.addItemText = addItemText; - } - - - @Override - public void addChangeListener(ChangeListener listener) - { - externalListeners.add(listener); - } - - @Override - public void removeChangeListener(ChangeListener listener) - { - externalListeners.remove(listener); - } - - @Override - public void onChange(Widget sender) - { - int selectedIndex = getSelectedIndex(); - if (allowExtension && selectedIndex == getItemCount() - 1) - { - String val = WindowUtil.prompt("Enter new value.", ""); - if (null != val) - { - insertItem(val, getItemCount() - 1); - setSelectedIndex(getItemCount() - 2); - lastSelected = getItemCount() -2; - externalListeners.fireChange(this); - } - else //Set back to the old selection on cancel - setSelectedIndex(lastSelected); - } - else - { - lastSelected = getSelectedIndex(); - externalListeners.fireChange(this); - } - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/TextBoxDialogBox.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/TextBoxDialogBox.java index 7a09613b043..b87bf216d06 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/TextBoxDialogBox.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/ui/TextBoxDialogBox.java @@ -33,7 +33,7 @@ */ public abstract class TextBoxDialogBox extends DialogBox { - private TextBox _textBox; + private final TextBox _textBox; public TextBoxDialogBox(String title, String label) { diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/DomainImportGrid.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/DomainImportGrid.java deleted file mode 100644 index 674ebce8ac6..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/DomainImportGrid.java +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui.domain; - -import com.google.gwt.event.dom.client.ChangeEvent; -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.user.client.ui.FlexTable; -import com.google.gwt.user.client.ui.Grid; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.InlineHTML; -import com.google.gwt.user.client.ui.ListBox; -import com.google.gwt.user.client.ui.VerticalPanel; -import org.labkey.api.gwt.client.model.GWTDomain; -import org.labkey.api.gwt.client.model.GWTPropertyDescriptor; -import org.labkey.api.gwt.client.ui.BoundCheckBox; -import org.labkey.api.gwt.client.ui.PropertyType; -import org.labkey.api.gwt.client.util.BooleanProperty; -import org.labkey.api.gwt.client.util.StringUtils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * User: jgarms - * Date: Nov 5, 2008 - */ -public class DomainImportGrid, FieldType extends GWTPropertyDescriptor> extends VerticalPanel -{ - List _columns = new ArrayList(); - Map _importColumnMap = new HashMap(); - Map _includeWidgetMap = new HashMap(); - DomainType _domain; - - private Grid _grid; - private ColumnMapper _mapper; - private List _inferredColumns; - private Map _columnMap = new HashMap(); - private static final String NO_MAPPING_COLUMN = "No mapping"; - - public DomainImportGrid(DomainType domain) - { - _domain = domain; - - _grid = new Grid(1, 0); - _grid.setStyleName("labkey-data-region-legacy labkey-show-borders"); - - add(_grid); - } - - public void removeColumnMapper() - { - if (_mapper != null) - { - remove(_mapper); - _mapper = null; - } - } - - public void addColumnMapper(List columnsToMap, List columnsToMapInfo) - { - _mapper = new ColumnMapper(_inferredColumns, columnsToMap, columnsToMapInfo); - - // initialized auto mapped columns in the grid - for (String mappedColumn : _mapper.getMappedColumnNames()) - selectMappedColumn(mappedColumn, true); - - add(_mapper); - } - - public ColumnMapper getColumnMapper() - { - return _mapper; - } - - private void selectMappedColumn(String columnName, boolean mapped) - { - if (_includeWidgetMap.containsKey(columnName)) - { - BoundCheckBox check = _includeWidgetMap.get(columnName); - - if (mapped) - check.setValue(true); - check.setEnabled(!mapped); - } - } - - public void setColumns(List columns) - { - _inferredColumns = columns; - _grid.resizeColumns(columns.size()); - int numDataRows = columns.get(0).getData().size(); - _grid.resizeRows(numDataRows + 2); // Need a row for the name and a row for the type - - for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) - { - InferencedColumn column = columns.get(columnIndex); - final GWTPropertyDescriptor prop = column.getPropertyDescriptor(); - - String columnMapKey = ((Integer)columnIndex).toString(); - _columnMap.put(columnMapKey, (FieldType)prop); - - // name panel with checkbox to enable/disable import - HorizontalPanel namePanel = new HorizontalPanel(); - final BooleanProperty include = new BooleanProperty(true); - BoundCheckBox includeInImport = new BoundCheckBox("id_import_" + columnMapKey, include, dirty -> _importColumnMap.put(prop, include)); - _includeWidgetMap.put(prop.getName(), includeInImport); - - namePanel.add(includeInImport); - namePanel.add(new InlineHTML(" " + prop.getName() + " ")); - _grid.getRowFormatter().setStyleName(0, "labkey-column-header"); - _grid.setWidget(0, columnIndex, namePanel); - - // save in the import map - _importColumnMap.put(prop, include); - _columns.add((FieldType)prop); - - // type info - _grid.getRowFormatter().setStyleName(1, "labkey-row"); - _grid.setWidget(1, columnIndex, new InlineHTML(PropertyType.fromName(prop.getRangeURI()).getDisplay())); - - List data = column.getData(); - for (int row=0; row 3 && row == numDataRows - 2) - cellData = "" + cellData + ""; - else if (numDataRows > 3 && row == numDataRows - 1) - cellData = "" + cellData + ""; - - _grid.getRowFormatter().setStyleName(row+2, "labkey-row"); - _grid.setHTML(row+2, columnIndex, cellData); - } - } - } - - public List getColumns(boolean includeIgnored) - { - // don't include columns that are unselected for import - List columns = new ArrayList(); - - for (FieldType prop : _columns) - { - if (includeIgnored || isImportEnabled(prop)) - columns.add(prop); - } - return columns; - } - - public boolean isImportEnabled(GWTPropertyDescriptor prop) - { - if (null != _importColumnMap.get(prop)) - return _importColumnMap.get(prop).booleanValue(); - return false; - } - - private class ColumnMapperChangeHandler implements ChangeHandler - { - private String _lastValue; - private ListBox _cmp; - - public ColumnMapperChangeHandler(ListBox component) - { - _cmp = component; - } - - @Override - public void onChange(ChangeEvent event) - { - String value = _cmp.getSelectedValue(); - if (value != null && !NO_MAPPING_COLUMN.equals(value)) - selectMappedColumn(value, true); - - // reset the previous value - if (_lastValue != null) - selectMappedColumn(_lastValue, false); - - _lastValue = value; - } - } - - public class ColumnMapper extends VerticalPanel - { - List _columnSelectors = new ArrayList<>(); - private List _columnsToMap; - - public ColumnMapper(List inferredColumns, List columnsToMap, - List columnsToMapInfo) - { - _columnsToMap = columnsToMap; - - VerticalPanel panel = new VerticalPanel(); - panel.add(new HTML("
")); - panel.add(new HTML("Column Mapping:")); - panel.add(new InlineHTML("The list below are columns that already exist in the Domain and can be mapped with the " + - "inferred columns from the uploaded file.
Establish a mapping by selecting a column from the dropdown list to match " + - "the existing Domain column.
When the data is imported, the data from the inferred column will be added to the " + - "mapped Domain column.

")); - - int row = 0; - FlexTable table = new FlexTable(); - table.setStyleName("labkey-data-region-legacy"); - - table.getRowFormatter().setStyleName(row, "labkey-row"); - table.setWidget(row, 0, new InlineHTML("Domain Column")); - table.setWidget(row++, 1, new InlineHTML("Column from File")); - - Map extraInfoMap = new HashMap(); - for (GWTPropertyDescriptor prop : columnsToMapInfo) - extraInfoMap.put(prop.getName(), prop); - - for (String destinationColumn : columnsToMap) - { - ListBox selector = new ListBox(); - Set aliases = new HashSet(); - - GWTPropertyDescriptor prop = extraInfoMap.get(destinationColumn); - if (prop != null) - aliases = convertAliasToSet(prop.getImportAliases()); - - selector.setWidth("250px"); - - selector.addChangeHandler(new ColumnMapperChangeHandler(selector)); - - selector.setName(destinationColumn); - selector.addItem(NO_MAPPING_COLUMN); - // add an entry in the mapping dropdown for each inferred field - Map fieldMap = new HashMap<>(); - int idx = 1; - for (InferencedColumn column : inferredColumns) - { - String name = column.getPropertyDescriptor().getName(); - selector.addItem(name); - fieldMap.put(name, idx++); - } - - // initialize the selection with the best match - GWTPropertyDescriptor matchedCol = findClosestColumn(destinationColumn, prop, aliases, inferredColumns); - if (matchedCol != null && fieldMap.containsKey(matchedCol.getName())) - { - selector.setSelectedIndex(fieldMap.get(matchedCol.getName())); - } - _columnSelectors.add(selector); - - table.getRowFormatter().setStyleName(row, "labkey-row"); - table.setWidget(row, 0, new InlineHTML(selector.getName())); - table.setWidget(row++, 1, selector); - } - - panel.add(table); - add(panel); - } - - public GWTPropertyDescriptor findClosestColumn(String colName, GWTPropertyDescriptor colMetaData, Set aliases, List columns) - { - // if we have extended metadata for the target column, try to match using property descriptor type information, - // or column aliases (if present) - if (colMetaData != null) - { - for (InferencedColumn column : columns) - { - if (areColumnTypesEquivalent(colMetaData, column.getPropertyDescriptor())) - return column.getPropertyDescriptor(); - - // if the column has import aliases, try to use those as an additional match criteria - for (String alias : aliases) - { - if (areColumnNamesEquivalent(alias, column.getPropertyDescriptor().getName())) - return column.getPropertyDescriptor(); - } - } - } - - // else if no match found, try the simple column name matching - for (InferencedColumn column : columns) - { - if (areColumnNamesEquivalent(colName, column.getPropertyDescriptor().getName())) - return column.getPropertyDescriptor(); - } - return null; - } - - public Set getMappedColumnNames() - { - Set columnNames = new HashSet(); - for (ListBox listBox : _columnSelectors) - { - String value = listBox.getSelectedValue(); - if (value != null) - columnNames.add(value); - } - return columnNames; - } - - /** - * Map of column in the file -> column in the database - */ - public Map getColumnMap() - { - Map result = new HashMap(); - - for (int i = 0; i < _columnsToMap.size(); i++) - { - String dataColumn = _columnsToMap.get(i); - ListBox selector = _columnSelectors.get(i); - String fileColumn = selector.getSelectedValue(); - if (fileColumn != null) - result.put(fileColumn, dataColumn); - } - - return result; - } - - /** - * Try to find a reasonable match in column names, like "Visit Date" and "Date", - * or "ParticipantID" and "participant id". - */ - private boolean areColumnTypesEquivalent(GWTPropertyDescriptor col1, GWTPropertyDescriptor col2) - { - String name1 = col1.getName().replaceAll(" ", ""); - String name2 = col2.getName().replaceAll(" ", ""); - - // if the names are an exact match (less whitespace) - if (name1.equalsIgnoreCase(name2)) - return true; - - // if the columns are the same type and one of the names represents a subset - if (col1.getRangeURI().equalsIgnoreCase(col2.getRangeURI())) - { - if ((name1.indexOf(name2) >= 0) || (name2.indexOf(name1) >= 0)) - return true; - } - return false; - } - - /** - * Try to find a reasonable match in column names, like "Visit Date" and "Date", - * or "ParticipantID" and "participant id". - */ - private boolean areColumnNamesEquivalent(String col1, String col2) - { - col1 = col1.toLowerCase(); - col2 = col2.toLowerCase(); - col1 = col1.replaceAll(" ",""); - col2 = col2.replaceAll(" ",""); - if (col1.equals(col2)) - return true; - if (col1.indexOf(col2) >= 0) - return true; - if (col2.indexOf(col1) >= 0) - return true; - return false; - } - - private Set convertAliasToSet(String s) - { - Set result = new LinkedHashSet(); - String arrayString = convertAliasStringToArray(s); - - if (!StringUtils.isEmpty(arrayString)) - { - String[] aliases = arrayString.split(","); - for (String alias : aliases) - { - if (!StringUtils.isEmpty(alias)) - { - if (alias.startsWith("\"") && alias.endsWith("\"")) - { - // Strip off the leading and trailing quotes - alias = alias.substring(1, alias.length() - 1); - } - result.add(alias); - } - } - } - return result; - } - - /** - * Breaks apart an import alias string into its individual aliases. - */ - public native String convertAliasStringToArray(String s) /*-{ - - var pattern = '[^,; \\t\\n\\f\"]+|\"[^\"]*\"'; - var r = new RegExp(pattern, 'g'); - var result = []; - var alias; - - while ((alias = r.exec(s)) != null) - { - result.push(alias); - } - return result.join(','); - }-*/; - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/GWTImportException.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/GWTImportException.java deleted file mode 100644 index 302f90c3af7..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/GWTImportException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui.domain; - -import com.google.gwt.user.client.rpc.SerializableException; - -/** - * User: jgarms - * Date: Nov 4, 2008 - */ -public class GWTImportException extends SerializableException -{ - public GWTImportException() - { - super(); - } - - public GWTImportException(String message) - { - super(message); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/ImportStatus.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/ImportStatus.java deleted file mode 100644 index e32e80cf885..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/ImportStatus.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui.domain; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.List; - -/* -* User: adam -* Date: Dec 24, 2009 -* Time: 7:26:51 AM -*/ -public class ImportStatus implements IsSerializable -{ - private List _messages; - private boolean _isComplete; - private String _jobId; - private int _totalRows; - private int _currentRow; - - public List getMessages() - { - return _messages; - } - - public void setMessages(List messages) - { - _messages = messages; - } - - public boolean isComplete() - { - return _isComplete; - } - - public void setComplete(boolean complete) - { - _isComplete = complete; - } - - public String getJobId() - { - return _jobId; - } - - public void setJobId(String jobId) - { - _jobId = jobId; - } - - public int getTotalRows() - { - return _totalRows; - } - - public void setTotalRows(int totalRows) - { - _totalRows = totalRows; - } - - public int getCurrentRow() - { - return _currentRow; - } - - public void setCurrentRow(int currentRow) - { - _currentRow = currentRow; - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/InferencedColumn.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/InferencedColumn.java deleted file mode 100644 index 8174b7b3991..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/InferencedColumn.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui.domain; - -import com.google.gwt.user.client.rpc.IsSerializable; -import org.labkey.api.gwt.client.model.GWTPropertyDescriptor; - -import java.util.List; - -/** - * Represents an inferenced column of data from a file -- excel or tsv. - * - * Contains a guess at a property descriptor, as well as the first - * few rows of data from the file. - * - * User: jgarms - * Date: Nov 4, 2008 - */ -public class InferencedColumn implements IsSerializable -{ - private GWTPropertyDescriptor propertyDescriptor; - private List data; - - public InferencedColumn() {} - - public InferencedColumn(GWTPropertyDescriptor propertyDescriptor, List data) - { - this.propertyDescriptor = propertyDescriptor; - this.data = data; - } - - public GWTPropertyDescriptor getPropertyDescriptor() - { - return propertyDescriptor; - } - - public List getData() - { - return data; - } - - public void setData(List data) - { - this.data = data; - } - - public void setPropertyDescriptor(GWTPropertyDescriptor propertyDescriptor) - { - this.propertyDescriptor = propertyDescriptor; - } - - public String toString() - { - StringBuilder sb = new StringBuilder(); - sb.append(propertyDescriptor.getName()).append(" (").append(propertyDescriptor.getRangeURI()).append(')'); - sb.append(": {"); - boolean needComma = false; - for (String s : data) - { - if (needComma) - sb.append(", "); - else - needComma = true; - sb.append(s); - } - sb.append('}'); - return sb.toString(); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ProgressBar.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ProgressBar.java deleted file mode 100644 index edb56bc4465..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ProgressBar.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Copyright 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.labkey.api.gwt.client.ui.incubator; - -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.ui.Widget; - -/** - * A widget that displays progress on an arbitrary scale. - * - *

CSS Style Rules

- *
    - *
  • .gwt-ProgressBar-shell { primary style }
  • - *
  • .gwt-ProgressBar-shell .gwt-ProgressBar-bar { the actual progress bar } - *
  • - *
  • .gwt-ProgressBar-shell .gwt-ProgressBar-text { text on the bar }
  • - *
  • .gwt-ProgressBar-shell .gwt-ProgressBar-text-firstHalf { applied to text - * when progress is less than 50 percent }
  • - *
  • .gwt-ProgressBar-shell .gwt-ProgressBar-text-secondHalf { applied to - * text when progress is greater than 50 percent }
  • - *
- */ -public class ProgressBar extends Widget implements ResizableWidget -{ - /** - * A formatter used to format the text displayed in the progress bar widget. - */ - public abstract static class TextFormatter { - /** - * Generate the text to display in the ProgressBar based on the current - * value. - * - * Override this method to change the text displayed within the ProgressBar. - * - * @param bar the progress bar - * @param curProgress the current progress - * @return the text to display in the progress bar - */ - protected abstract String getText(ProgressBar bar, double curProgress); - } - - /** - * The bar element that displays the progress. - */ - private Element barElement; - - /** - * The current progress. - */ - private double curProgress; - - /** - * The maximum progress. - */ - private double maxProgress; - - /** - * The minimum progress. - */ - private double minProgress; - - /** - * A boolean that determines if the text is visible. - */ - private boolean textVisible = true; - - /** - * The element that displays text on the page. - */ - private Element textElement; - - /** - * The current text formatter. - */ - private TextFormatter textFormatter; - - /** - * Create a progress bar with default range of 0 to 100. - */ - public ProgressBar() { - this(0.0, 100.0, 0.0); - } - - /** - * Create a progress bar with an initial progress and a default range of 0 to - * 100. - * - * @param curProgress the current progress - */ - public ProgressBar(double curProgress) { - this(0.0, 100.0, curProgress); - } - - /** - * Create a progress bar within the given range. - * - * @param minProgress the minimum progress - * @param maxProgress the maximum progress - */ - public ProgressBar(double minProgress, double maxProgress) { - this(minProgress, maxProgress, 0.0); - } - - /** - * Create a progress bar within the given range starting at the specified - * progress amount. - * - * @param minProgress the minimum progress - * @param maxProgress the maximum progress - * @param curProgress the current progress - */ - public ProgressBar(double minProgress, double maxProgress, double curProgress) { - this(minProgress, maxProgress, curProgress, null); - } - - /** - * Create a progress bar within the given range starting at the specified - * progress amount. - * - * @param minProgress the minimum progress - * @param maxProgress the maximum progress - * @param curProgress the current progress - * @param textFormatter the text formatter - */ - public ProgressBar(double minProgress, double maxProgress, - double curProgress, TextFormatter textFormatter) { - this.minProgress = minProgress; - this.maxProgress = maxProgress; - this.curProgress = curProgress; - setTextFormatter(textFormatter); - - // Create the outer shell - setElement(DOM.createDiv()); - DOM.setStyleAttribute(getElement(), "position", "relative"); - setStyleName("gwt-ProgressBar-shell"); - - // Create the bar element - barElement = DOM.createDiv(); - DOM.appendChild(getElement(), barElement); - DOM.setStyleAttribute(barElement, "height", "100%"); - DOM.setElementProperty(barElement, "className", "gwt-ProgressBar-bar"); - - // Create the text element - textElement = DOM.createDiv(); - DOM.appendChild(getElement(), textElement); - DOM.setStyleAttribute(textElement, "position", "absolute"); - DOM.setStyleAttribute(textElement, "top", "0px"); - DOM.setElementProperty(textElement, "className", - "gwt-ProgressBar-text-firstHalf"); - - // Set the current progress - setProgress(curProgress); - } - - /** - * Get the maximum progress. - * - * @return the maximum progress - */ - public double getMaxProgress() { - return maxProgress; - } - - /** - * Get the minimum progress. - * - * @return the minimum progress - */ - public double getMinProgress() { - return minProgress; - } - - /** - * Get the current percent complete, relative to the minimum and maximum - * values. The percent will always be between 0.0 - 1.0. - * - * @return the current percent complete - */ - public double getPercent() { - // If we have no range - if (maxProgress <= minProgress) { - return 0.0; - } - - // Calculate the relative progress - double percent = (curProgress - minProgress) / (maxProgress - minProgress); - return Math.max(0.0, Math.min(1.0, percent)); - } - - /** - * Get the current progress. - * - * @return the current progress - */ - public double getProgress() { - return curProgress; - } - - /** - * Get the text formatter. - * - * @return the text formatter - */ - public TextFormatter getTextFormatter() { - return textFormatter; - } - - /** - * Check whether the text is visible or not. - * - * @return true if the text is visible - */ - public boolean isTextVisible() { - return textVisible; - } - - /** - * This method is called when the dimensions of the parent element change. - * Subclasses should override this method as needed. - * - * Move the text to the center of the progress bar. - * - * @param width the new client width of the element - * @param height the new client height of the element - */ - @Override - public void onResize(int width, int height) { - if (textVisible) { - int textWidth = DOM.getElementPropertyInt(textElement, "offsetWidth"); - int left = (width / 2) - (textWidth / 2); - DOM.setStyleAttribute(textElement, "left", left + "px"); - } - } - - /** - * Redraw the progress bar when something changes the layout. - */ - public void redraw() { - if (isAttached()) { - int width = DOM.getElementPropertyInt(getElement(), "clientWidth"); - int height = DOM.getElementPropertyInt(getElement(), "clientHeight"); - onResize(width, height); - } - } - - /** - * Set the maximum progress. If the minimum progress is more than the current - * progress, the current progress is adjusted to be within the new range. - * - * @param maxProgress the maximum progress - */ - public void setMaxProgress(double maxProgress) { - this.maxProgress = maxProgress; - curProgress = Math.min(curProgress, maxProgress); - resetProgress(); - } - - /** - * Set the minimum progress. If the minimum progress is more than the current - * progress, the current progress is adjusted to be within the new range. - * - * @param minProgress the minimum progress - */ - public void setMinProgress(double minProgress) { - this.minProgress = minProgress; - curProgress = Math.max(curProgress, minProgress); - resetProgress(); - } - - /** - * Set the current progress. - * - * @param curProgress the current progress - */ - public void setProgress(double curProgress) { - this.curProgress = Math.max(minProgress, Math.min(maxProgress, curProgress)); - - // Calculate percent complete - int percent = (int) (100 * getPercent()); - DOM.setStyleAttribute(barElement, "width", percent + "%"); - DOM.setElementProperty(textElement, "innerHTML", generateText(curProgress)); - - // Set the style depending on the size of the bar - if (percent < 50) { - DOM.setElementProperty(textElement, "className", - "gwt-ProgressBar-text gwt-ProgressBar-text-firstHalf"); - } else { - DOM.setElementProperty(textElement, "className", - "gwt-ProgressBar-text gwt-ProgressBar-text-secondHalf"); - } - - // Realign the text - redraw(); - } - - /** - * Set the text formatter. - * - * @param textFormatter the text formatter - */ - public void setTextFormatter(TextFormatter textFormatter) { - this.textFormatter = textFormatter; - } - - /** - * Sets whether the text is visible over the bar. - * - * @param isVisible True to show text, false to hide it - */ - public void setTextVisible(boolean isVisible) { - this.textVisible = isVisible; - if (this.textVisible) { - DOM.setStyleAttribute(textElement, "display", ""); - redraw(); - } else { - DOM.setStyleAttribute(textElement, "display", "none"); - } - } - - /** - * Generate the text to display within the progress bar. Override this - * function to change the default progress percent to a more informative - * message, such as the number of kilobytes downloaded. - * - * @param curProgress the current progress - * @return the text to display in the progress bar - */ - protected String generateText(double curProgress) { - if (textFormatter != null) { - return textFormatter.getText(this, curProgress); - } else { - return (int) (100 * getPercent()) + "%"; - } - } - - /** - * Get the bar element. - * - * @return the bar element - */ - protected Element getBarElement() { - return barElement; - } - - /** - * Get the text element. - * - * @return the text element - */ - protected Element getTextElement() { - return textElement; - } - - /** - * This method is called immediately after a widget becomes attached to the - * browser's document. - */ - @Override - protected void onLoad() { - // Reset the position attribute of the parent element - DOM.setStyleAttribute(getElement(), "position", "relative"); - ResizableWidgetCollection.get().add(this); - redraw(); - } - - @Override - protected void onUnload() { - ResizableWidgetCollection.get().remove(this); - } - - /** - * Reset the progress text based on the current min and max progress range. - */ - protected void resetProgress() { - setProgress(getProgress()); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ResizableWidgetCollection.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ResizableWidgetCollection.java index 7491734892d..22d036c221a 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ResizableWidgetCollection.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ResizableWidgetCollection.java @@ -47,12 +47,12 @@ private static class ResizableWidgetInfo { /** * The current clientHeight. */ - private int curHeight = 0; + private int curHeight; /** * The current clientWidth. */ - private int curWidth = 0; + private int curWidth; /** * Constructor. @@ -109,7 +109,7 @@ public static ResizableWidgetCollection get() { * The timer used to periodically compare the dimensions of elements to their * old dimensions. */ - private Timer resizeCheckTimer = new Timer() { + private final Timer resizeCheckTimer = new Timer() { @Override public void run() { // Ignore changes that result from window resize events @@ -134,7 +134,7 @@ public void run() { /** * A hash map of the resizable widgets this collection is checking. */ - private Map widgets = new HashMap(); + private final Map widgets = new HashMap<>(); /** * The current window height. diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/DateProperty.java b/api/gwtsrc/org/labkey/api/gwt/client/util/DateProperty.java deleted file mode 100644 index 68e40ea7a7a..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/DateProperty.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.util; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.Date; - -/** - * User: Matthew - * Date: Apr 25, 2007 - * Time: 4:44:09 PM - */ -public class DateProperty implements IPropertyWrapper, IsSerializable -{ - Date d; - - public DateProperty() - { - d = null; - } - - public DateProperty(Date d) - { - this.d = d; - } - - @Override - public Object get() - { - return d; - } - - @Override - public void set(Object o) - { - d = (Date)o; - } - - public Date getDate() - { - return d; - } - - public String toString() - { - return String.valueOf(d); - } - - @Override - public int hashCode() - { - return null==d ? 0 : d.hashCode(); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/DoubleProperty.java b/api/gwtsrc/org/labkey/api/gwt/client/util/DoubleProperty.java deleted file mode 100644 index d3a278a7167..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/DoubleProperty.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.util; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * User: Matthew - * Date: Apr 25, 2007 - * Time: 4:43:06 PM - */ -public class DoubleProperty implements IPropertyWrapper, IsSerializable -{ - Double d; - - public DoubleProperty() - { - d = null; - } - - public DoubleProperty(double d) - { - setDbl(d); - } - - public DoubleProperty(Double d) - { - set(d); - } - - @Override - public Object get() - { - return d; - } - - @Override - public void set(Object o) - { - d = (Double)o; - } - - public Double getDouble() - { - return d; - } - - public void setDbl(double d) - { - //this.d = Double.valueOf(d); - this.d = Double.valueOf(d); - } - - public double getDbl() - { - return d.doubleValue(); - } - - public String toString() - { - return String.valueOf(d); - } - - @Override - public int hashCode() - { - return null==d ? 0 : d.hashCode(); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/ErrorDialogAsyncCallback.java b/api/gwtsrc/org/labkey/api/gwt/client/util/ErrorDialogAsyncCallback.java index f760be8bac7..a5ba4f7b7d8 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/ErrorDialogAsyncCallback.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/util/ErrorDialogAsyncCallback.java @@ -23,6 +23,7 @@ * User: jeckels * Date: May 28, 2010 */ +@SuppressWarnings("PatternVariableCanBeUsed") public abstract class ErrorDialogAsyncCallback implements AsyncCallback { private final String _description; @@ -99,7 +100,7 @@ public final void onFailure(Throwable caught) } if (message == null) { - message = caught.getMessage() == null || caught.getMessage().trim().equals("") ? caught.toString() : caught.getMessage(); + message = caught.getMessage() == null || caught.getMessage().trim().isEmpty() ? caught.toString() : caught.getMessage(); } if (_description != null) { diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/IPropertyWrapper.java b/api/gwtsrc/org/labkey/api/gwt/client/util/IPropertyWrapper.java index 987c6b86bf2..7e75458d846 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/IPropertyWrapper.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/util/IPropertyWrapper.java @@ -23,7 +23,7 @@ */ public interface IPropertyWrapper { - public Object get(); - public void set(Object o); - public int hashCode(); + Object get(); + void set(Object o); + int hashCode(); } diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/PropertyUtil.java b/api/gwtsrc/org/labkey/api/gwt/client/util/PropertyUtil.java index ced465b608c..186080c2fd4 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/PropertyUtil.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/util/PropertyUtil.java @@ -109,14 +109,14 @@ public static String getRelativeURL(String action) public static String getRelativeURL(String action, String pageFlow) { String[] pathParts = PropertyUtil.getContainerPath().split("/"); - String encodedPath = "/"; + StringBuilder encodedPath = new StringBuilder("/"); for (String pathPart : pathParts) { - if (pathPart.length() > 0) + if (!pathPart.isEmpty()) { //issue 14006: changed encodeComponent to encodePathSegment, b/c the former will convert spaces to '+' String part = URL.encodePathSegment(pathPart); - encodedPath += part + "/"; + encodedPath.append(part).append("/"); } } if (!action.contains(".")) diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/StringUtils.java b/api/gwtsrc/org/labkey/api/gwt/client/util/StringUtils.java index d94ba4a2f00..1af3b035e6e 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/StringUtils.java +++ b/api/gwtsrc/org/labkey/api/gwt/client/util/StringUtils.java @@ -32,7 +32,7 @@ public class StringUtils { public static boolean isEmpty(String str) { - return null == str || str.length()==0; + return null == str || str.isEmpty(); } public static String trimToNull(String str) @@ -41,7 +41,7 @@ public static String trimToNull(String str) return str; str = str.trim(); - return str.length() == 0 ? null : str; + return str.isEmpty() ? null : str; } public static String trimToEmpty(String str) @@ -73,7 +73,7 @@ public static String join(List l, String join) static public String filter(String s, boolean encodeSpace) { - if (null == s || 0 == s.length()) + if (null == s || s.isEmpty()) return ""; int len = s.length(); diff --git a/api/src/jakarta/servlet/jsp/JspWriter.java b/api/src/jakarta/servlet/jsp/JspWriter.java index 211d374aa6c..857ec34db3c 100644 --- a/api/src/jakarta/servlet/jsp/JspWriter.java +++ b/api/src/jakarta/servlet/jsp/JspWriter.java @@ -16,8 +16,6 @@ */ package jakarta.servlet.jsp; -import org.labkey.api.util.SafeToRender; - import java.io.IOException; /* diff --git a/api/src/org/labkey/api/action/AbstractFileUploadAction.java b/api/src/org/labkey/api/action/AbstractFileUploadAction.java index 6d9a106a3a1..b9706c32a8c 100644 --- a/api/src/org/labkey/api/action/AbstractFileUploadAction.java +++ b/api/src/org/labkey/api/action/AbstractFileUploadAction.java @@ -179,9 +179,8 @@ private void export(FORM form, HttpServletResponse response) throws Exception // Parameter name (String) -> File on disk/original file name Pair Map> savedFiles = new HashMap<>(); - if (basicRequest instanceof MultipartHttpServletRequest) + if (basicRequest instanceof MultipartHttpServletRequest request) { - MultipartHttpServletRequest request = (MultipartHttpServletRequest) basicRequest; Iterator nameIterator = request.getFileNames(); while (nameIterator.hasNext()) @@ -273,7 +272,7 @@ protected File handleFile(String filename, InputStream input, Writer writer) thr public static class UploadException extends IOException { - private int _statusCode; + private final int _statusCode; public UploadException(String message, int statusCode) { diff --git a/api/src/org/labkey/api/action/ApiQueryResponse.java b/api/src/org/labkey/api/action/ApiQueryResponse.java index 27dff01502b..b8d927756c2 100644 --- a/api/src/org/labkey/api/action/ApiQueryResponse.java +++ b/api/src/org/labkey/api/action/ApiQueryResponse.java @@ -74,7 +74,7 @@ public class ApiQueryResponse implements ApiResponse private long _numRespRows = 0; //number of response rows private RenderContext _ctx = null; private boolean _schemaEditable = false; - private boolean _metaDataOnly = false; + private boolean _metaDataOnly; private DataRegion _dataRegion; private TableInfo _tinfo = null; private List _displayColumns = null; diff --git a/api/src/org/labkey/api/action/ApiResponseWriter.java b/api/src/org/labkey/api/action/ApiResponseWriter.java index ffd81bc6aab..3d202d3b298 100644 --- a/api/src/org/labkey/api/action/ApiResponseWriter.java +++ b/api/src/org/labkey/api/action/ApiResponseWriter.java @@ -531,9 +531,8 @@ public static Pair convertToJSON(Errors errors, int startingE msg = msg.substring(0, idx); } - if (error instanceof SimpleValidationError.FieldWarning) + if (error instanceof SimpleValidationError.FieldWarning fieldWarning) { - SimpleValidationError.FieldWarning fieldWarning = (SimpleValidationError.FieldWarning) error; severity = fieldWarning.getSeverity(); key = fieldWarning.getField(); propertyId = fieldWarning.getObjectName(); diff --git a/api/src/org/labkey/api/action/BaseViewAction.java b/api/src/org/labkey/api/action/BaseViewAction.java index 1d9ccdae89b..d31dda91433 100644 --- a/api/src/org/labkey/api/action/BaseViewAction.java +++ b/api/src/org/labkey/api/action/BaseViewAction.java @@ -194,7 +194,7 @@ static public class ViewActionParameterPropertyValues extends ServletRequestPara { public ViewActionParameterPropertyValues(ServletRequest request) { - this(request, (String)null, (String)null); + this(request, null, null); } public ViewActionParameterPropertyValues(ServletRequest request, @Nullable String prefix, @Nullable String prefixSeparator) @@ -289,12 +289,14 @@ public void setPageConfig(PageConfig page) } + @Override public Container getContainer() { return getViewContext().getContainer(); } + @Override public User getUser() { return getViewContext().getUser(); @@ -507,7 +509,7 @@ else if (propClass.isPrimitive()) else if (propClass.isArray()) { if (value instanceof Collection) - value = ((Collection) value).toArray(new String[((Collection) value).size()]); + value = ((Collection) value).toArray(new String[0]); else if (!value.getClass().isArray()) value = new String[] {String.valueOf(value)}; converted = ConvertUtils.convert((String[])value, propClass); diff --git a/api/src/org/labkey/api/action/ExportException.java b/api/src/org/labkey/api/action/ExportException.java index 39d60475bfd..4650cb814f0 100644 --- a/api/src/org/labkey/api/action/ExportException.java +++ b/api/src/org/labkey/api/action/ExportException.java @@ -26,7 +26,7 @@ */ public class ExportException extends Exception { - private ModelAndView _errorView; + private final ModelAndView _errorView; public ExportException(ModelAndView errorView) { diff --git a/api/src/org/labkey/api/action/ExtendedApiQueryResponse.java b/api/src/org/labkey/api/action/ExtendedApiQueryResponse.java index 977f9768884..4a272221a18 100644 --- a/api/src/org/labkey/api/action/ExtendedApiQueryResponse.java +++ b/api/src/org/labkey/api/action/ExtendedApiQueryResponse.java @@ -172,9 +172,8 @@ private static ColMap getColMap(RenderContext ctx, DisplayColumn dc, boolean inc ColMap colMap = makeColMap(value, displayValue, formattedValue, url, includeFormattedValue, urlTarget); //missing values - if (dc instanceof MVDisplayColumn) + if (dc instanceof MVDisplayColumn mvColumn) { - MVDisplayColumn mvColumn = (MVDisplayColumn) dc; colMap.put(ColMapEntry.mvValue, mvColumn.getMvIndicator(ctx)); colMap.put(ColMapEntry.mvRawValue, mvColumn.getRawValue(ctx)); } diff --git a/api/src/org/labkey/api/action/StatusReportingRunnableAction.java b/api/src/org/labkey/api/action/StatusReportingRunnableAction.java index f38ee1a914f..fb5efac5cb2 100644 --- a/api/src/org/labkey/api/action/StatusReportingRunnableAction.java +++ b/api/src/org/labkey/api/action/StatusReportingRunnableAction.java @@ -68,7 +68,7 @@ public ModelAndView getView(StatusReportingRunnableForm form, BindException erro { getPageConfig().setTemplate(PageConfig.Template.Dialog); - return new JspView("/org/labkey/api/action/statusReport.jsp"); + return new JspView<>("/org/labkey/api/action/statusReport.jsp"); } @Override diff --git a/api/src/org/labkey/api/admin/DiagnosticsLink.java b/api/src/org/labkey/api/admin/DiagnosticsLink.java deleted file mode 100644 index 1d30c828718..00000000000 --- a/api/src/org/labkey/api/admin/DiagnosticsLink.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2018 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.admin; - -import org.labkey.api.security.permissions.AdminPermission; -import org.labkey.api.security.permissions.Permission; -import org.labkey.api.view.ActionURL; - -public class DiagnosticsLink -{ - private ActionURL _linkUrl; - private Class _permission; - - public DiagnosticsLink(ActionURL linkUrl) - { - this(linkUrl, AdminPermission.class); //default to Admin permission if not specified - } - - public DiagnosticsLink(ActionURL linkUrl, Class permission) - { - _linkUrl = linkUrl; - _permission = permission; - } - - public ActionURL getLinkUrl() - { - return _linkUrl; - } - - public Class getPermission() - { - return _permission; - } -} diff --git a/api/src/org/labkey/api/admin/FolderExportContext.java b/api/src/org/labkey/api/admin/FolderExportContext.java index 0287090c1db..41c8bf5b870 100644 --- a/api/src/org/labkey/api/admin/FolderExportContext.java +++ b/api/src/org/labkey/api/admin/FolderExportContext.java @@ -18,14 +18,12 @@ import org.labkey.api.data.Container; import org.labkey.api.data.PHI; import org.labkey.api.exp.xar.LSIDRelativizer; -import org.labkey.api.files.FileContentService; import org.labkey.api.security.User; import org.labkey.api.study.Study; import org.labkey.api.study.StudyService; import org.labkey.api.util.Pair; import org.labkey.folder.xml.FolderDocument; -import java.io.File; import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; @@ -53,7 +51,7 @@ public class FolderExportContext extends AbstractFolderContext private Set _listIds; private List> _lists; private Set _queryKeys; - private String _fileRootPath; + private final String _fileRootPath; private final LSIDRelativizer.RelativizedLSIDs _relativizedLSIDs = new LSIDRelativizer.RelativizedLSIDs(LSIDRelativizer.FOLDER_RELATIVE); diff --git a/api/src/org/labkey/api/admin/FolderWriter.java b/api/src/org/labkey/api/admin/FolderWriter.java index dd8573ac1fd..ac7ca67253e 100644 --- a/api/src/org/labkey/api/admin/FolderWriter.java +++ b/api/src/org/labkey/api/admin/FolderWriter.java @@ -36,6 +36,7 @@ public interface FolderWriter extends Writer } boolean show(Container c); + @Override boolean selectedByDefault(ExportType type, boolean forTemplate); void initialize(FolderExportContext context); } diff --git a/api/src/org/labkey/api/admin/SubfolderWriter.java b/api/src/org/labkey/api/admin/SubfolderWriter.java index 6c7777b0eaf..35eed53c3cc 100644 --- a/api/src/org/labkey/api/admin/SubfolderWriter.java +++ b/api/src/org/labkey/api/admin/SubfolderWriter.java @@ -49,7 +49,7 @@ public void write(Container container, FolderExportContext ctx, VirtualFile vf) List childrenToExport = new ArrayList<>(); getChildrenToExport(ctx, allChildren, childrenToExport); - if (childrenToExport.size() > 0) + if (!childrenToExport.isEmpty()) { // Set up the pointer in the folder.xml file and the new dir ctx.getXml().addNewSubfolders().setDir(DIRECTORY_NAME); diff --git a/api/src/org/labkey/api/announcements/DiscussionService.java b/api/src/org/labkey/api/announcements/DiscussionService.java index 55dafb668c8..7b6046e15c4 100644 --- a/api/src/org/labkey/api/announcements/DiscussionService.java +++ b/api/src/org/labkey/api/announcements/DiscussionService.java @@ -70,13 +70,6 @@ static DiscussionService get() } /** - * @param c - * @param user - * @param identifier - * @param pageURL persistent URL to link back to original page, additional parameter discussionId will automatically be added - * @param title - * @param summary - * @param allowMultipleDiscussions * @return WebPartView with a form to start a new discussion, will post directly to Announcements controller */ WebPartView startDiscussion(Container c, User user, String identifier, ActionURL pageURL, URLHelper cancelURL, String title, String summary, boolean allowMultipleDiscussions); diff --git a/api/src/org/labkey/api/announcements/api/Announcement.java b/api/src/org/labkey/api/announcements/api/Announcement.java index e82d2636e54..c8c16a2b830 100644 --- a/api/src/org/labkey/api/announcements/api/Announcement.java +++ b/api/src/org/labkey/api/announcements/api/Announcement.java @@ -18,7 +18,6 @@ import org.jetbrains.annotations.NotNull; import org.labkey.api.attachments.Attachment; import org.labkey.api.data.Container; -import org.labkey.api.security.User; import org.labkey.api.wiki.WikiRendererType; import java.util.Collection; diff --git a/api/src/org/labkey/api/announcements/api/AnnouncementService.java b/api/src/org/labkey/api/announcements/api/AnnouncementService.java index 2770ed9cba1..47f889749d7 100644 --- a/api/src/org/labkey/api/announcements/api/AnnouncementService.java +++ b/api/src/org/labkey/api/announcements/api/AnnouncementService.java @@ -19,7 +19,6 @@ import org.labkey.api.data.Container; import org.labkey.api.security.User; import org.labkey.api.services.ServiceRegistry; -import org.labkey.api.util.GUID; import java.util.List; diff --git a/api/src/org/labkey/api/announcements/api/DiscussionSrcTypeProvider.java b/api/src/org/labkey/api/announcements/api/DiscussionSrcTypeProvider.java index 799a9d48ad4..968902b5e8e 100644 --- a/api/src/org/labkey/api/announcements/api/DiscussionSrcTypeProvider.java +++ b/api/src/org/labkey/api/announcements/api/DiscussionSrcTypeProvider.java @@ -26,7 +26,7 @@ default ActionURL getThreadURL(Container container, User user, int announcementR default String getEmailSubject(Container container, User user, int announcementRowId, String discussionSrcIdentifier, String body, String title, String parentBody) { return null; - }; + } default Set getRecipients(Container container, User user, String discussionSrcIdentifier) { diff --git a/api/src/org/labkey/api/assay/AbstractAssayProvider.java b/api/src/org/labkey/api/assay/AbstractAssayProvider.java index 713045df26f..423c76b42c7 100644 --- a/api/src/org/labkey/api/assay/AbstractAssayProvider.java +++ b/api/src/org/labkey/api/assay/AbstractAssayProvider.java @@ -582,7 +582,7 @@ protected Pair> createBatchDomain(Container if (includeStandardProperties) { List resolverTypes = getParticipantVisitResolverTypes(); - if (resolverTypes != null && resolverTypes.size() > 0) + if (resolverTypes != null && !resolverTypes.isEmpty()) { DomainProperty resolverProperty = addProperty(domain, PARTICIPANT_VISIT_RESOLVER_PROPERTY_NAME, PARTICIPANT_VISIT_RESOLVER_PROPERTY_CAPTION, PropertyType.STRING); resolverProperty.setHidden(true); @@ -720,7 +720,7 @@ private void addReusableData(Map reusableFiles, ExpData inputData) // Not all datas are associated with a file if (inputData.getFile() != null) { - reusableFiles.put(AssayDataCollector.PRIMARY_FILE + (reusableFiles.size() == 0 ? "" : Integer.toString(reusableFiles.size())), inputData.getFile()); + reusableFiles.put(AssayDataCollector.PRIMARY_FILE + (reusableFiles.isEmpty() ? "" : Integer.toString(reusableFiles.size())), inputData.getFile()); } } @@ -1128,13 +1128,7 @@ public ModelAndView createResultDetailsView(ViewContext context, ExpProtocol pro // remove the DetailsColumn from the column list List columns = queryView.getDisplayColumns(); - ListIterator iter = columns.listIterator(); - while (iter.hasNext()) - { - DisplayColumn column = iter.next(); - if (column instanceof DetailsColumn) - iter.remove(); - } + columns.removeIf(column -> column instanceof DetailsColumn); region.setDisplayColumns(columns); ExpRun run = data.getRun(); diff --git a/api/src/org/labkey/api/assay/AssayDataCollectorDisplayColumn.java b/api/src/org/labkey/api/assay/AssayDataCollectorDisplayColumn.java index ad392987e91..7c3a119f5a2 100644 --- a/api/src/org/labkey/api/assay/AssayDataCollectorDisplayColumn.java +++ b/api/src/org/labkey/api/assay/AssayDataCollectorDisplayColumn.java @@ -33,7 +33,7 @@ public class AssayDataCollectorDisplayColumn extends SimpleDisplayColumn { private final AssayRunUploadForm _form; - private ColumnInfo _col; + private final ColumnInfo _col; public AssayDataCollectorDisplayColumn(TableInfo table, AssayRunUploadForm form) { diff --git a/api/src/org/labkey/api/assay/AssayFileWriter.java b/api/src/org/labkey/api/assay/AssayFileWriter.java index dccdc4325d9..247ee42cfc3 100644 --- a/api/src/org/labkey/api/assay/AssayFileWriter.java +++ b/api/src/org/labkey/api/assay/AssayFileWriter.java @@ -32,7 +32,6 @@ import org.labkey.api.util.DateUtil; import org.labkey.api.util.FileUtil; import org.labkey.api.util.NetworkDrive; -import org.labkey.api.util.UnexpectedException; import org.labkey.api.view.ViewContext; import org.labkey.vfs.FileLike; diff --git a/api/src/org/labkey/api/assay/AssayProtocolSchema.java b/api/src/org/labkey/api/assay/AssayProtocolSchema.java index 3fcfdc58192..4b5412b3334 100644 --- a/api/src/org/labkey/api/assay/AssayProtocolSchema.java +++ b/api/src/org/labkey/api/assay/AssayProtocolSchema.java @@ -788,11 +788,10 @@ public List getModuleCustomViews(Container container, QueryDefinitio */ private static void fixupPropertyURL(ColumnInfo fk, MutableColumnInfo col) { - if (null == fk || !(col.getURL() instanceof StringExpressionFactory.FieldKeyStringExpression)) + if (null == fk || !(col.getURL() instanceof StringExpressionFactory.FieldKeyStringExpression fkse)) return; TableInfo table = fk.getParentTable(); - StringExpressionFactory.FieldKeyStringExpression fkse = (StringExpressionFactory.FieldKeyStringExpression)col.getURL(); // quick check Set keys = fkse.getFieldKeys(); Map map = new HashMap<>(); diff --git a/api/src/org/labkey/api/assay/AssayProvider.java b/api/src/org/labkey/api/assay/AssayProvider.java index 400702bd4b8..8b4968cdc63 100644 --- a/api/src/org/labkey/api/assay/AssayProvider.java +++ b/api/src/org/labkey/api/assay/AssayProvider.java @@ -159,7 +159,7 @@ default String getLabel() /** @return a view to plug into the import UI that describes the expected data files. * Reasonable things to include might be things like the file type (Excel/TSV/XML), layout (column headers/XSD), etc */ - HttpView getDataDescriptionView(AssayRunUploadForm form); + HttpView getDataDescriptionView(AssayRunUploadForm form); @Nullable Pair findTargetStudyProperty(ExpProtocol protocol); @@ -376,10 +376,11 @@ interface XarCallbacks { default void beforeXarExportRun(ExpRun run, ExperimentRunType xrun) { - }; + } + default void beforeXarImportRun(ExperimentRunType xrun) { - }; + } } default XarCallbacks getXarCallbacks(User user, Container container) diff --git a/api/src/org/labkey/api/assay/AssayProviderSchema.java b/api/src/org/labkey/api/assay/AssayProviderSchema.java index 64279fbf78d..b819ed281c5 100644 --- a/api/src/org/labkey/api/assay/AssayProviderSchema.java +++ b/api/src/org/labkey/api/assay/AssayProviderSchema.java @@ -59,7 +59,7 @@ public class AssayProviderSchema extends AssaySchema private Map _protocolsByName; /** Cache the "child" schemas so that we don't have to recreate them over and over within this schema's lifecycle */ - private Map _protocolSchemas = new HashMap<>(); + private final Map _protocolSchemas = new HashMap<>(); public AssayProviderSchema(User user, Container container, @NotNull AssayProvider provider, @Nullable Container targetStudy) { @@ -182,10 +182,10 @@ private AssayProtocolSchema getProtocolSchema(ExpProtocol protocol) public static class TestCase extends Assert { - private Mockery _context; - private ExpProtocol _protocol1; - private AssayProvider _provider1; - private AssayProviderSchema _schemaImpl; + private final Mockery _context; + private final ExpProtocol _protocol1; + private final AssayProvider _provider1; + private final AssayProviderSchema _schemaImpl; public TestCase() { diff --git a/api/src/org/labkey/api/assay/AssayResultsFileWriter.java b/api/src/org/labkey/api/assay/AssayResultsFileWriter.java index 41c5eeac87a..1c6b1bd7023 100644 --- a/api/src/org/labkey/api/assay/AssayResultsFileWriter.java +++ b/api/src/org/labkey/api/assay/AssayResultsFileWriter.java @@ -158,9 +158,9 @@ public Map savePostedFiles(ContextType context) throws Experim public static class TestCase extends Assert { - private Mockery _context; - private ExpRun _run; - private ExpProtocol _protocol; + private final Mockery _context; + private final ExpRun _run; + private final ExpProtocol _protocol; public TestCase() { diff --git a/api/src/org/labkey/api/assay/AssayRunUploadContextImpl.java b/api/src/org/labkey/api/assay/AssayRunUploadContextImpl.java index 972c0b7c230..29ec65e980d 100644 --- a/api/src/org/labkey/api/assay/AssayRunUploadContextImpl.java +++ b/api/src/org/labkey/api/assay/AssayRunUploadContextImpl.java @@ -301,7 +301,6 @@ public ActionURL getActionURL() * The file will be added as an output ExpData to the imported assay run. * * @return A singleton map with key {@link AssayDataCollector#PRIMARY_FILE} and value of the uploaded file. - * @throws ExperimentException */ @Override @NotNull diff --git a/api/src/org/labkey/api/assay/DefaultAssayRunCreator.java b/api/src/org/labkey/api/assay/DefaultAssayRunCreator.java index ea9741fdb32..82c29ade74b 100644 --- a/api/src/org/labkey/api/assay/DefaultAssayRunCreator.java +++ b/api/src/org/labkey/api/assay/DefaultAssayRunCreator.java @@ -1021,11 +1021,11 @@ public static Pair createdRelatedOutputData(AssayRunUploadConte if (roleName == null) { roleName = relatedFile.getName().substring(baseName.length()); - while (roleName.length() > 0 && (roleName.startsWith(".") || roleName.startsWith("-") || roleName.startsWith("_") || roleName.startsWith(" "))) + while (!roleName.isEmpty() && (roleName.startsWith(".") || roleName.startsWith("-") || roleName.startsWith("_") || roleName.startsWith(" "))) { roleName = roleName.substring(1); } - if ("".equals(roleName)) + if (roleName.isEmpty()) { roleName = null; } diff --git a/api/src/org/labkey/api/assay/FileUploadDataCollector.java b/api/src/org/labkey/api/assay/FileUploadDataCollector.java index 1052f34619c..8b6238d617f 100644 --- a/api/src/org/labkey/api/assay/FileUploadDataCollector.java +++ b/api/src/org/labkey/api/assay/FileUploadDataCollector.java @@ -37,10 +37,10 @@ */ public class FileUploadDataCollector> extends AbstractTempDirDataCollector { - private int _maxFileInputs = 1; + private int _maxFileInputs; private final Map _reusableFiles; // Name of the form for the file. - private String _fileInputName; + private final String _fileInputName; public FileUploadDataCollector() { diff --git a/api/src/org/labkey/api/assay/ReplacedRunFilter.java b/api/src/org/labkey/api/assay/ReplacedRunFilter.java index a88421bf352..ea4840f8802 100644 --- a/api/src/org/labkey/api/assay/ReplacedRunFilter.java +++ b/api/src/org/labkey/api/assay/ReplacedRunFilter.java @@ -47,7 +47,7 @@ */ public class ReplacedRunFilter { - private static ReplacedRunFilter DEFAULT_FILTER = new ReplacedRunFilter(Type.CURRENT_ONLY); + private static final ReplacedRunFilter DEFAULT_FILTER = new ReplacedRunFilter(Type.CURRENT_ONLY); public enum Type { @@ -76,7 +76,7 @@ public void addCondition(SimpleFilter filter, FieldKey fieldKey) } }; - private String _title; + private final String _title; Type(String title) { @@ -116,7 +116,7 @@ public void addToURL(ActionURL url, String dataRegionName, FieldKey fieldKey) } } - private Type _type; + private final Type _type; public ReplacedRunFilter(Type type) { diff --git a/api/src/org/labkey/api/assay/actions/AssayResultDetailsAction.java b/api/src/org/labkey/api/assay/actions/AssayResultDetailsAction.java index 1287f039798..7cd5bc1444f 100644 --- a/api/src/org/labkey/api/assay/actions/AssayResultDetailsAction.java +++ b/api/src/org/labkey/api/assay/actions/AssayResultDetailsAction.java @@ -53,10 +53,9 @@ public ModelAndView getView(DataDetailsForm form, BindException errors) _dataRowId = form.getDataRowId(); AssayProvider provider = form.getProvider(); - if (!(provider instanceof AbstractAssayProvider)) + if (!(provider instanceof AbstractAssayProvider aap)) throw new RuntimeException("Assay must be derived from AbstractAssayProvider to use the AssayResultDetailsAction"); - AbstractAssayProvider aap = (AbstractAssayProvider) provider; _data = aap.getDataForDataRow(_dataRowId, _protocol); if (_data == null) { diff --git a/api/src/org/labkey/api/assay/actions/AssayRunUploadForm.java b/api/src/org/labkey/api/assay/actions/AssayRunUploadForm.java index 7f227d8181d..b1930453c2d 100644 --- a/api/src/org/labkey/api/assay/actions/AssayRunUploadForm.java +++ b/api/src/org/labkey/api/assay/actions/AssayRunUploadForm.java @@ -155,7 +155,7 @@ protected Map getPropertyMapFromRequest(List values) public void saveDefaultBatchValues() throws ExperimentException { - Map objectMap = new HashMap(getBatchProperties()); + Map objectMap = new HashMap<>(getBatchProperties()); stripFileProperties(objectMap); DefaultValueService.get().setDefaultValues(getContainer(), objectMap, getUser()); } public void saveDefaultRunValues() throws ExperimentException { - Map objectMap = new HashMap(getRunProperties()); + Map objectMap = new HashMap<>(getRunProperties()); stripFileProperties(objectMap); DefaultValueService.get().setDefaultValues(getContainer(), objectMap, getUser()); } @@ -611,7 +611,7 @@ public void saveDefaultValues(Map values, String scope) if (values.isEmpty()) return; - Map objectMap = new HashMap(values); + Map objectMap = new HashMap<>(values); DefaultValueService.get().setDefaultValues(getContainer(), objectMap, getUser(), scope); } diff --git a/api/src/org/labkey/api/assay/actions/assayHeader.jsp b/api/src/org/labkey/api/assay/actions/assayHeader.jsp index 70311039e84..0653a34b81b 100644 --- a/api/src/org/labkey/api/assay/actions/assayHeader.jsp +++ b/api/src/org/labkey/api/assay/actions/assayHeader.jsp @@ -34,7 +34,7 @@ <% JspView me = HttpView.currentView(); AssayHeaderView bean = me.getModelBean(); - if (bean.isIncludeDescription() && bean.getProtocol().getProtocolDescription() != null && !"".equals(bean.getProtocol().getProtocolDescription().trim())) { %> + if (bean.isIncludeDescription() && bean.getProtocol().getProtocolDescription() != null && !bean.getProtocol().getProtocolDescription().trim().isEmpty()) { %>

<%= h(bean.getProtocol().getProtocolDescription()) %>

<% } diff --git a/api/src/org/labkey/api/assay/plate/PlateDataStateManager.java b/api/src/org/labkey/api/assay/plate/PlateDataStateManager.java index cc8ae4b1f56..d923d1ff97b 100644 --- a/api/src/org/labkey/api/assay/plate/PlateDataStateManager.java +++ b/api/src/org/labkey/api/assay/plate/PlateDataStateManager.java @@ -17,7 +17,7 @@ public class PlateDataStateManager implements DataStateHandler { public static final String HANDLER_NAME = "PlateDataStateHandler"; - private static PlateDataStateManager _instance = new PlateDataStateManager(); + private static final PlateDataStateManager _instance = new PlateDataStateManager(); /** * Maps to DataStates for plate related operations. Initially, there is only a single data state diff --git a/api/src/org/labkey/api/assay/query/BatchListQueryView.java b/api/src/org/labkey/api/assay/query/BatchListQueryView.java index 6a3ec6929bc..57539515ce1 100644 --- a/api/src/org/labkey/api/assay/query/BatchListQueryView.java +++ b/api/src/org/labkey/api/assay/query/BatchListQueryView.java @@ -36,7 +36,7 @@ */ public class BatchListQueryView extends QueryView { - private ExpProtocol _protocol; + private final ExpProtocol _protocol; public BatchListQueryView(ExpProtocol protocol, AssaySchema schema, QuerySettings settings) { diff --git a/api/src/org/labkey/api/audit/AbstractAuditHandler.java b/api/src/org/labkey/api/audit/AbstractAuditHandler.java index f21ff0ca9a0..d34c1bc0a16 100644 --- a/api/src/org/labkey/api/audit/AbstractAuditHandler.java +++ b/api/src/org/labkey/api/audit/AbstractAuditHandler.java @@ -156,7 +156,7 @@ public void addAuditEvent(User user, Container c, TableInfo table, @Nullable Aud batch.clear(); } } - if (batch.size() > 0) + if (!batch.isEmpty()) { auditLog.addEvents(user, batch, useTransactionAuditCache); batch.clear(); diff --git a/api/src/org/labkey/api/audit/AuditTypeEvent.java b/api/src/org/labkey/api/audit/AuditTypeEvent.java index 78fa0e21f2d..68f5b313908 100644 --- a/api/src/org/labkey/api/audit/AuditTypeEvent.java +++ b/api/src/org/labkey/api/audit/AuditTypeEvent.java @@ -15,17 +15,13 @@ */ package org.labkey.api.audit; -import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerManager; import org.labkey.api.security.Group; import org.labkey.api.security.User; import org.labkey.api.security.UserManager; import org.labkey.api.util.ExceptionUtil; -import org.labkey.api.util.logging.LogHelper; -import org.slf4j.LoggerFactory; import java.util.Date; import java.util.LinkedHashMap; diff --git a/api/src/org/labkey/api/audit/DefaultAuditProvider.java b/api/src/org/labkey/api/audit/DefaultAuditProvider.java index d2f216990f6..d3bebacde18 100644 --- a/api/src/org/labkey/api/audit/DefaultAuditProvider.java +++ b/api/src/org/labkey/api/audit/DefaultAuditProvider.java @@ -22,11 +22,9 @@ import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.SimpleFilter; import org.labkey.api.data.Sort; -import org.labkey.api.data.TableInfo; import org.labkey.api.query.UserSchema; import org.labkey.api.security.User; import org.labkey.api.view.ActionURL; -import org.labkey.api.view.ViewContext; import java.util.Collections; import java.util.List; diff --git a/api/src/org/labkey/api/audit/TransactionAuditProvider.java b/api/src/org/labkey/api/audit/TransactionAuditProvider.java index a8be5907012..164867fa90e 100644 --- a/api/src/org/labkey/api/audit/TransactionAuditProvider.java +++ b/api/src/org/labkey/api/audit/TransactionAuditProvider.java @@ -1,6 +1,5 @@ package org.labkey.api.audit; -import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.Nullable; import org.labkey.api.audit.query.AbstractAuditDomainKind; import org.labkey.api.audit.query.DefaultAuditTypeTable; diff --git a/api/src/org/labkey/api/audit/provider/ModulePropertiesAuditProvider.java b/api/src/org/labkey/api/audit/provider/ModulePropertiesAuditProvider.java index 8b2c264ca8a..676d7b20d52 100644 --- a/api/src/org/labkey/api/audit/provider/ModulePropertiesAuditProvider.java +++ b/api/src/org/labkey/api/audit/provider/ModulePropertiesAuditProvider.java @@ -3,16 +3,11 @@ import org.labkey.api.audit.AbstractAuditTypeProvider; import org.labkey.api.audit.AuditTypeEvent; import org.labkey.api.audit.AuditTypeProvider; -import org.labkey.api.audit.DetailedAuditTypeEvent; import org.labkey.api.audit.query.AbstractAuditDomainKind; -import org.labkey.api.audit.query.DefaultAuditTypeTable; import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerFilter; -import org.labkey.api.data.TableInfo; import org.labkey.api.exp.PropertyDescriptor; import org.labkey.api.exp.PropertyType; import org.labkey.api.query.FieldKey; -import org.labkey.api.query.UserSchema; import java.util.ArrayList; import java.util.Collections; @@ -22,9 +17,6 @@ import java.util.Map; import java.util.Set; -import static org.labkey.api.audit.query.AbstractAuditDomainKind.NEW_RECORD_PROP_NAME; -import static org.labkey.api.audit.query.AbstractAuditDomainKind.OLD_RECORD_PROP_NAME; - public class ModulePropertiesAuditProvider extends AbstractAuditTypeProvider implements AuditTypeProvider { public static final String AUDIT_EVENT_TYPE = "ModulePropertyEvents"; diff --git a/api/src/org/labkey/api/audit/query/AbstractAuditDomainKind.java b/api/src/org/labkey/api/audit/query/AbstractAuditDomainKind.java index 9add67980cd..6b48c6f29ac 100644 --- a/api/src/org/labkey/api/audit/query/AbstractAuditDomainKind.java +++ b/api/src/org/labkey/api/audit/query/AbstractAuditDomainKind.java @@ -62,11 +62,11 @@ public abstract class AbstractAuditDomainKind extends DomainKind { - private static String XAR_SUBSTITUTION_SCHEMA_NAME = "SchemaName"; - private static String XAR_SUBSTITUTION_TABLE_NAME = "TableName"; + private static final String XAR_SUBSTITUTION_SCHEMA_NAME = "SchemaName"; + private static final String XAR_SUBSTITUTION_TABLE_NAME = "TableName"; - private static String DOMAIN_NAMESPACE_PREFIX_TEMPLATE = "%s-${SchemaName}"; - private static String DOMAIN_LSID_TEMPLATE = "${FolderLSIDBase}:${TableName}"; + private static final String DOMAIN_NAMESPACE_PREFIX_TEMPLATE = "%s-${SchemaName}"; + private static final String DOMAIN_LSID_TEMPLATE = "${FolderLSIDBase}:${TableName}"; private static final Set _baseFields; private static final Set _reservedNames = new HashSet<>(); @@ -235,13 +235,13 @@ public void deletePropertyDescriptor(Domain domain, User user, PropertyDescripto } @Override - public JSONObject getDomainKindProperties(GWTDomain domain, Container container, User user) + public JSONObject getDomainKindProperties(GWTDomain domain, Container container, User user) { throw new UnsupportedOperationException(); } @Override - public Domain createDomain(GWTDomain domain, JSONObject arguments, Container container, User user, @Nullable TemplateInfo templateInfo, boolean forUpdate) + public Domain createDomain(GWTDomain domain, JSONObject arguments, Container container, User user, @Nullable TemplateInfo templateInfo, boolean forUpdate) { throw new UnsupportedOperationException(); } diff --git a/api/src/org/labkey/api/audit/query/AuditDisplayColumnFactory.java b/api/src/org/labkey/api/audit/query/AuditDisplayColumnFactory.java index 2ab3475957e..a5c2acf5523 100644 --- a/api/src/org/labkey/api/audit/query/AuditDisplayColumnFactory.java +++ b/api/src/org/labkey/api/audit/query/AuditDisplayColumnFactory.java @@ -25,6 +25,6 @@ */ public interface AuditDisplayColumnFactory extends DisplayColumnFactory { - public void init(ColumnInfo columnInfo); - public int getPosition(); + void init(ColumnInfo columnInfo); + int getPosition(); } diff --git a/api/src/org/labkey/api/cloud/CloudWatchService.java b/api/src/org/labkey/api/cloud/CloudWatchService.java index 752136fd2bf..7a6917c6054 100644 --- a/api/src/org/labkey/api/cloud/CloudWatchService.java +++ b/api/src/org/labkey/api/cloud/CloudWatchService.java @@ -5,7 +5,6 @@ import org.labkey.api.services.ServiceRegistry; import java.nio.file.Path; -import java.util.function.BiConsumer; public interface CloudWatchService { diff --git a/api/src/org/labkey/api/collections/ArrayListMap.java b/api/src/org/labkey/api/collections/ArrayListMap.java index ded0c81be6c..64df314459e 100644 --- a/api/src/org/labkey/api/collections/ArrayListMap.java +++ b/api/src/org/labkey/api/collections/ArrayListMap.java @@ -442,56 +442,56 @@ public void test() ArrayListMap a = createAndPopulate(); { - assertEquals(a.get("Z"), "one"); - assertEquals(a.get(0), "one"); - assertEquals(a.get("B"), "two"); - assertEquals(a.get(1), "two"); - assertEquals(a.get("C"), "three"); - assertEquals(a.get(2), "three"); - assertEquals(a.get("D"), "four"); - assertEquals(a.get(3), "four"); + assertEquals("one", a.get("Z")); + assertEquals("one", a.get(0)); + assertEquals("two", a.get("B")); + assertEquals("two", a.get(1)); + assertEquals("three", a.get("C")); + assertEquals("three", a.get(2)); + assertEquals("four", a.get("D")); + assertEquals("four", a.get(3)); } { var it = a.iterator(); assertTrue(it.hasNext()); - assertEquals(it.next(), "one"); + assertEquals("one", it.next()); assertTrue(it.hasNext()); - assertEquals(it.next(), "two"); + assertEquals("two", it.next()); assertTrue(it.hasNext()); - assertEquals(it.next(), "three"); + assertEquals("three", it.next()); assertTrue(it.hasNext()); - assertEquals(it.next(), "four"); + assertEquals("four", it.next()); assertFalse(it.hasNext()); } { var it = a.entrySet().iterator(); assertTrue(it.hasNext()); - assertEquals(it.next().getKey(), "Z"); - assertEquals(it.next().getKey(), "B"); - assertEquals(it.next().getKey(), "C"); - assertEquals(it.next().getKey(), "D"); + assertEquals("Z", it.next().getKey()); + assertEquals("B", it.next().getKey()); + assertEquals("C", it.next().getKey()); + assertEquals("D", it.next().getKey()); assertFalse(it.hasNext()); } { var it = a.keySet().iterator(); assertTrue(it.hasNext()); - assertEquals(it.next(), "Z"); - assertEquals(it.next(), "B"); - assertEquals(it.next(), "C"); - assertEquals(it.next(), "D"); + assertEquals("Z", it.next()); + assertEquals("B", it.next()); + assertEquals("C", it.next()); + assertEquals("D", it.next()); assertFalse(it.hasNext()); } { var it = a.values().iterator(); assertTrue(it.hasNext()); - assertEquals(it.next(), "one"); - assertEquals(it.next(), "two"); - assertEquals(it.next(), "three"); - assertEquals(it.next(), "four"); + assertEquals("one", it.next()); + assertEquals("two", it.next()); + assertEquals("three", it.next()); + assertEquals("four", it.next()); assertFalse(it.hasNext()); } @@ -503,8 +503,8 @@ public void test() a.put("F", "six"); b.put("G", "SEVEN"); - assertEquals(a.get("Z"), "one"); - assertEquals(b.get("Z"), "ONE"); + assertEquals("one", a.get("Z")); + assertEquals("ONE", b.get("Z")); assertFalse(a.containsKey("E")); assertNull(a.get("E")); diff --git a/api/src/org/labkey/api/collections/BoundMap.java b/api/src/org/labkey/api/collections/BoundMap.java index a2aae1f30d2..3fcec8a87b3 100644 --- a/api/src/org/labkey/api/collections/BoundMap.java +++ b/api/src/org/labkey/api/collections/BoundMap.java @@ -115,11 +115,7 @@ public Object get(Object key) return bound._getter.invoke(_bean); } } - catch (IllegalAccessException x) - { - throw new RuntimeException(x); - } - catch (InvocationTargetException x) + catch (IllegalAccessException | InvocationTargetException x) { throw new RuntimeException(x); } diff --git a/api/src/org/labkey/api/collections/NullPreventingSet.java b/api/src/org/labkey/api/collections/NullPreventingSet.java index 025c3f7f0ef..4520d0ed5af 100644 --- a/api/src/org/labkey/api/collections/NullPreventingSet.java +++ b/api/src/org/labkey/api/collections/NullPreventingSet.java @@ -30,7 +30,7 @@ */ public class NullPreventingSet implements Set { - private Set _set; + private final Set _set; public NullPreventingSet(Set set) { @@ -64,14 +64,14 @@ public Iterator iterator() @Override @NotNull - public Object[] toArray() + public Object @NotNull [] toArray() { return _set.toArray(); } @Override @NotNull - public T[] toArray(T[] a) + public T @NotNull [] toArray(T @NotNull [] a) { return _set.toArray(a); } @@ -93,25 +93,25 @@ public boolean remove(Object o) } @Override - public boolean containsAll(Collection c) + public boolean containsAll(@NotNull Collection c) { return _set.containsAll(c); } @Override - public boolean addAll(Collection c) + public boolean addAll(@NotNull Collection c) { return _set.addAll(c); } @Override - public boolean retainAll(Collection c) + public boolean retainAll(@NotNull Collection c) { return _set.retainAll(c); } @Override - public boolean removeAll(Collection c) + public boolean removeAll(@NotNull Collection c) { return _set.removeAll(c); } diff --git a/api/src/org/labkey/api/collections/OneBasedList.java b/api/src/org/labkey/api/collections/OneBasedList.java index d042090b2d1..4776e33f8b0 100644 --- a/api/src/org/labkey/api/collections/OneBasedList.java +++ b/api/src/org/labkey/api/collections/OneBasedList.java @@ -31,12 +31,12 @@ public class OneBasedList extends IndexMappingList, E> { public OneBasedList() { - super(new ArrayList()); + super(new ArrayList<>()); } public OneBasedList(int initialCapacity) { - super(new ArrayList(initialCapacity)); + super(new ArrayList<>(initialCapacity)); } public OneBasedList(List list) diff --git a/api/src/org/labkey/api/collections/SparseBitSet.java b/api/src/org/labkey/api/collections/SparseBitSet.java index f66d0047538..7e1289aee2b 100644 --- a/api/src/org/labkey/api/collections/SparseBitSet.java +++ b/api/src/org/labkey/api/collections/SparseBitSet.java @@ -1546,9 +1546,9 @@ protected static final void throwIndexOutOfBoundsException(int i, int j) if (i == Integer.MAX_VALUE) s += "(i=" + i + ")"; if (j < 0) - s += (s.length() == 0 ? "" : ", ") + "(j=" + j + ") < 0"; + s += (s.isEmpty() ? "" : ", ") + "(j=" + j + ") < 0"; if (i > j) - s += (s.length() == 0 ? "" : ", ") + "(i=" + i + ") > (j=" + j + ")"; + s += (s.isEmpty() ? "" : ", ") + "(i=" + i + ") > (j=" + j + ")"; throw new IndexOutOfBoundsException(s); } @@ -1639,7 +1639,6 @@ protected final void resize(int index) * operation * @param op the AbstractStrategy class defining the operation to be * executed - * @exception IndexOutOfBoundsException * @since 1.6 * @see AbstractStrategy */ @@ -1754,7 +1753,6 @@ corresponding lengths (if any). */ /* Do not need level3 block, so remove it, and move on. */ if (haveA2) a2[u2] = null; - u3 = 0; } else { @@ -2006,7 +2004,7 @@ private void readObject(ObjectInputStream s) throws IOException, * * @see #statistics(String[]) */ - public static enum Statistics + public enum Statistics { /** * The size of the bit set, as give by the size() method. @@ -2469,7 +2467,7 @@ protected boolean block(int base, int u3, int v3, long[] a3, long[] b3) * 0| 0 - * 1| - -
      */
-    protected class EqualsStrategy extends AbstractStrategy
+    protected static class EqualsStrategy extends AbstractStrategy
     {
         boolean result; // Used to hold result of the comparison
 
@@ -2573,7 +2571,7 @@ protected boolean block(int base, int u3, int v3, long[] a3, long[] b3)
      *         0| 0 0
      *         1| 1 1 
      */
-    protected class IntersectsStrategy extends AbstractStrategy
+    protected static class IntersectsStrategy extends AbstractStrategy
     {
         /**
          *  The boolean result of the intersects scan Strategy is kept here.
diff --git a/api/src/org/labkey/api/data/AbstractForeignKey.java b/api/src/org/labkey/api/data/AbstractForeignKey.java
index 2ce3b716456..4fd779cc3cf 100644
--- a/api/src/org/labkey/api/data/AbstractForeignKey.java
+++ b/api/src/org/labkey/api/data/AbstractForeignKey.java
@@ -15,7 +15,6 @@
  */
 package org.labkey.api.data;
 
-import org.apache.commons.collections.map.CaseInsensitiveMap;
 import org.apache.logging.log4j.LogManager;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -242,7 +241,7 @@ protected void initTableAndColumnNames()
                 if (_columnName == null)
                 {
                     List pkColumns = table.getPkColumns();
-                    if (pkColumns != null && pkColumns.size() > 0)
+                    if (pkColumns != null && !pkColumns.isEmpty())
                     {
                         int first = 0;
                         if (pkColumns.size() > 1 && isContainerColumn(pkColumns.get(0)))
diff --git a/api/src/org/labkey/api/data/AbstractParticipantCategory.java b/api/src/org/labkey/api/data/AbstractParticipantCategory.java
index d7588a81a9e..914e1a939ee 100644
--- a/api/src/org/labkey/api/data/AbstractParticipantCategory.java
+++ b/api/src/org/labkey/api/data/AbstractParticipantCategory.java
@@ -212,7 +212,7 @@ public int hashCode()
 
     public boolean canEdit(Container container, User user)
     {
-        return canEdit(container, user, new ArrayList());
+        return canEdit(container, user, new ArrayList<>());
     }
 
     public boolean canEdit(Container container, User user, List errors)
@@ -240,7 +240,7 @@ public boolean canEdit(Container container, User user, List err
 
     public boolean canDelete(Container container, User user)
     {
-        return canDelete(container, user, new ArrayList());
+        return canDelete(container, user, new ArrayList<>());
     }
 
     public boolean canDelete(Container container, User user, List errors)
diff --git a/api/src/org/labkey/api/data/AbstractTableInfo.java b/api/src/org/labkey/api/data/AbstractTableInfo.java
index e8eca0662bd..9a8be988497 100644
--- a/api/src/org/labkey/api/data/AbstractTableInfo.java
+++ b/api/src/org/labkey/api/data/AbstractTableInfo.java
@@ -568,6 +568,7 @@ public void setTitleColumn(String titleColumn, boolean defaultTitleColumn)
         _hasDefaultTitleColumn = defaultTitleColumn;
     }
 
+    @Override
     public void setAllowCalculatedColumns(boolean allowCalculatedColumns)
     {
         _allowCalculatedColumns = allowCalculatedColumns;
@@ -625,6 +626,19 @@ public MutableColumnInfo getMutableColumnOrThrow(@NotNull String colName)
         return result;
     }
 
+    /** @return a BaseColumnInfo, will throw if column doesn't exist or exists and is locked */
+    @NotNull
+    public MutableColumnInfo getMutableColumnOrThrow(@NotNull FieldKey fieldKey)
+    {
+        MutableColumnInfo result = getMutableColumn(fieldKey);
+        if (result == null)
+        {
+            UserSchema schema = getUserSchema();
+            throw new IllegalArgumentException("Could not find column '" + fieldKey + "' in " + (schema == null ? "" : (schema.getName() + ".")) + getName() + (schema == null ? "" : (" in " + schema.getContainer().getPath())));
+        }
+        return result;
+    }
+
     /**
      * @param resolveIfNeeded false if only the already-added columns should be checked, and resolveColumn() should
      *                        not be called. Useful because some implementations may have expensive checks they
@@ -775,9 +789,6 @@ public MutableColumnInfo addColumn(MutableColumnInfo column)
      * should hold onto columnInfo references by FieldKey, and not by reference.
 
      * during construction.
-     * @param updated
-     * @param existing
-     * @return
      */
     public ColumnInfo replaceColumn(ColumnInfo updated, ColumnInfo existing)
     {
@@ -956,9 +967,8 @@ public StringExpression getUpdateURL(@Nullable Set columns, Container
             containerContext = container;
 
         // Include the ContainerContext FieldKey if it hasn't already been included.
-        if (columns != null && containerContext instanceof ContainerContext.FieldKeyContext)
+        if (columns != null && containerContext instanceof ContainerContext.FieldKeyContext fieldKeyContext)
         {
-            ContainerContext.FieldKeyContext fieldKeyContext = (ContainerContext.FieldKeyContext) containerContext;
             Set s = new HashSet<>(columns);
             s.add(fieldKeyContext.getFieldKey());
             columns = s;
@@ -984,9 +994,8 @@ public StringExpression getDetailsURL(@Nullable Set columns, Container
             containerContext = container;
 
         // Include the ContainerContext FieldKey if it hasn't already been included.
-        if (columns != null && containerContext instanceof ContainerContext.FieldKeyContext)
+        if (columns != null && containerContext instanceof ContainerContext.FieldKeyContext fieldKeyContext)
         {
-            ContainerContext.FieldKeyContext fieldKeyContext = (ContainerContext.FieldKeyContext) containerContext;
             Set s = new HashSet<>(columns);
             s.add(fieldKeyContext.getFieldKey());
             columns = s;
diff --git a/api/src/org/labkey/api/data/BaseColumnInfo.java b/api/src/org/labkey/api/data/BaseColumnInfo.java
index a78f9aa1e47..21c4cb767f6 100644
--- a/api/src/org/labkey/api/data/BaseColumnInfo.java
+++ b/api/src/org/labkey/api/data/BaseColumnInfo.java
@@ -57,8 +57,6 @@
 import org.labkey.data.xml.PropertiesType;
 
 import java.beans.Introspector;
-import java.io.IOException;
-import java.io.Writer;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.sql.ResultSet;
@@ -104,7 +102,7 @@ public class BaseColumnInfo extends ColumnRenderPropertiesImpl implements Mutabl
     private boolean _isReadOnly = false;
     private boolean _isUserEditable = true;
     private boolean _isUnselectable = false;
-    private TableInfo _parentTable = null;
+    private TableInfo _parentTable;
     protected DatabaseIdentifier _metaDataName = null;
     protected DatabaseIdentifier _selectName = null;
     protected ColumnInfo _displayField;
@@ -1394,7 +1392,7 @@ public static String labelFromName(String name)
         if (name == null)
             return null;
 
-        if (name.length() == 0)
+        if (name.isEmpty())
             return name;
 
         StringBuilder buf = new StringBuilder(name.length() + 10);
@@ -1430,7 +1428,7 @@ public static String legalNameFromName(String name)
         if (name == null)
             return null;
 
-        if (name.length() == 0)
+        if (name.isEmpty())
             return null;
 
         StringBuilder buf = new StringBuilder(name.length());
@@ -1460,7 +1458,7 @@ public static String propNameFromName(String name)
         if (name == null)
             return null;
 
-        if (name.length() == 0)
+        if (name.isEmpty())
             return null;
 
         return Introspector.decapitalize(legalNameFromName(name));
@@ -1470,7 +1468,7 @@ public static String propNameFromName(String name)
     // TODO why is there here? and not something like RequestHelper or PageFlowUtil
     public static boolean booleanFromString(String str)
     {
-        if (null == str || str.trim().length() == 0)
+        if (null == str || str.trim().isEmpty())
             return false;
         if (str.equals("0") || str.equalsIgnoreCase("false"))
             return false;
@@ -1788,7 +1786,7 @@ public static Collection createFromDatabaseMetaData(String schem
                     }
                     else
                     {
-                        assert importedKeys.size() > 0;
+                        assert !importedKeys.isEmpty();
                         ImportedKey key = importedKeys.get(fkName);
                         key.pkColumnNames.add(pkColumnName);
                         key.fkColumnNames.add(colName);
diff --git a/api/src/org/labkey/api/data/BaseSelector.java b/api/src/org/labkey/api/data/BaseSelector.java
index 785c700cb11..39a53798734 100644
--- a/api/src/org/labkey/api/data/BaseSelector.java
+++ b/api/src/org/labkey/api/data/BaseSelector.java
@@ -605,7 +605,7 @@ private  void fillValues(BiFunction fn)
 
             while (iter.hasNext())
             {
-                RowMap rowMap = (RowMap)iter.next();
+                RowMap rowMap = iter.next();
                 //noinspection unchecked
                 K key = (K)rowMap.get(1);
                 //noinspection unchecked
@@ -651,7 +651,7 @@ private  void fillValues(BiFunction fn)
             {
                 //noinspection unchecked
                 RowMap rowMap = (RowMap)iter.next();
-                fillSet.add((K)rowMap.get(1));
+                fillSet.add(rowMap.get(1));
             }
             return null;
         });
diff --git a/api/src/org/labkey/api/data/BooleanFormat.java b/api/src/org/labkey/api/data/BooleanFormat.java
index c3bc8a61ebb..f3ca4c5e731 100644
--- a/api/src/org/labkey/api/data/BooleanFormat.java
+++ b/api/src/org/labkey/api/data/BooleanFormat.java
@@ -56,7 +56,7 @@ public class BooleanFormat extends Format
     /**
      * Static map of common parse associations
      */
-    private static HashMap _parseAssocs = new HashMap<>();
+    private static final HashMap _parseAssocs = new HashMap<>();
 
     static
     {
@@ -79,7 +79,7 @@ public class BooleanFormat extends Format
     protected String _false;
     protected String _null;
 
-    private static BooleanFormat _definstance = new BooleanFormat();
+    private static final BooleanFormat _definstance = new BooleanFormat();
 
 
     /**
@@ -188,7 +188,7 @@ public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition po
      */
     public static boolean testForNull(String source)
     {
-        return (null == source || source.length() == 0 || source.equalsIgnoreCase("null"));
+        return (null == source || source.isEmpty() || source.equalsIgnoreCase("null"));
     }
 
     /**
@@ -216,7 +216,7 @@ public Boolean parseObject(String source) throws ParseException
     @Override
     public Boolean parseObject(String source, ParsePosition pos)
     {
-        if(null == source || source.length() == 0 || !Character.isLetterOrDigit(source.codePointAt(0)))
+        if(null == source || source.isEmpty() || !Character.isLetterOrDigit(source.codePointAt(0)))
         {
             pos.setErrorIndex(pos.getIndex());
             return null;
@@ -273,7 +273,7 @@ public void testFormat()
             fmt = new BooleanFormat("Y;N; ");
             assertTrue(fmt.format(Boolean.TRUE).equals("Y"));
             assertTrue(fmt.format(Boolean.FALSE).equals("N"));
-            assertTrue(fmt.format(null).equals(""));
+            assertTrue(fmt.format(null).isEmpty());
 
             fmt = new BooleanFormat("Yes;No");
             assertTrue(fmt.format(Boolean.TRUE).equals("Yes"));
diff --git a/api/src/org/labkey/api/data/BuilderObjectFactory.java b/api/src/org/labkey/api/data/BuilderObjectFactory.java
index 10a276748d4..e488eec8280 100644
--- a/api/src/org/labkey/api/data/BuilderObjectFactory.java
+++ b/api/src/org/labkey/api/data/BuilderObjectFactory.java
@@ -46,7 +46,7 @@
 
 public class BuilderObjectFactory implements ObjectFactory
 {
-    private static Logger _log = LogManager.getLogger(BuilderObjectFactory.class);
+    private static final Logger _log = LogManager.getLogger(BuilderObjectFactory.class);
 
     private final Class _class;
     private final Class _classBuilder;
diff --git a/api/src/org/labkey/api/data/BuiltInButtonConfig.java b/api/src/org/labkey/api/data/BuiltInButtonConfig.java
index 4b7eef66551..9f23658601b 100644
--- a/api/src/org/labkey/api/data/BuiltInButtonConfig.java
+++ b/api/src/org/labkey/api/data/BuiltInButtonConfig.java
@@ -33,7 +33,7 @@ public class BuiltInButtonConfig implements ButtonConfig
 {
     private String _iconCls;
     private String _caption;
-    private String _originalCaption;
+    private final String _originalCaption;
     private String _insertAfter, _insertBefore;
     private Integer _insertPosition;
     private boolean _hidden = false;
diff --git a/api/src/org/labkey/api/data/ButtonBarConfig.java b/api/src/org/labkey/api/data/ButtonBarConfig.java
index 9e8b1fea912..4550f5c7e9d 100644
--- a/api/src/org/labkey/api/data/ButtonBarConfig.java
+++ b/api/src/org/labkey/api/data/ButtonBarConfig.java
@@ -307,9 +307,9 @@ private Class getPermission(ButtonBarItem item)
     private NavTree loadNavTree(ButtonMenuItem item)
     {
         NavTree tree = new NavTree(item.getText(), item.getTarget());
-        if (item.getOnClick() != null && item.getOnClick().length() > 0)
+        if (item.getOnClick() != null && !item.getOnClick().isEmpty())
             tree.setScript(item.getOnClick());
-        if (item.getIcon() != null && item.getIcon().length() > 0)
+        if (item.getIcon() != null && !item.getIcon().isEmpty())
             tree.setImageSrc(new ResourceURL(item.getIcon()));
         if (item.getItemArray() != null)
         {
diff --git a/api/src/org/labkey/api/data/CacheableWriter.java b/api/src/org/labkey/api/data/CacheableWriter.java
index 6c00ad1411a..8f4dc8295c9 100644
--- a/api/src/org/labkey/api/data/CacheableWriter.java
+++ b/api/src/org/labkey/api/data/CacheableWriter.java
@@ -48,7 +48,7 @@ public String toString()
     private String _contentType;
     private ContentDisposition _disposition;
     private int _size;
-    private ByteArrayOutputStream _bOut = new ByteArrayOutputStream();
+    private final ByteArrayOutputStream _bOut = new ByteArrayOutputStream();
     private byte[] _bytes;
 
     public CacheableWriter()
diff --git a/api/src/org/labkey/api/data/CachedResultSet.java b/api/src/org/labkey/api/data/CachedResultSet.java
index f5aaee45b7d..a0297373589 100644
--- a/api/src/org/labkey/api/data/CachedResultSet.java
+++ b/api/src/org/labkey/api/data/CachedResultSet.java
@@ -439,9 +439,8 @@ public BigDecimal _decimal(Object o, int scale) throws SQLException
     {
         if (null == o)
             return null;
-        if (o instanceof BigDecimal)
+        if (o instanceof BigDecimal d)
         {
-            BigDecimal d = (BigDecimal) o;
             if (d.scale() == scale)
                 return d;
             return d.setScale(scale);
@@ -709,13 +708,13 @@ public boolean isAfterLast()
     @Override
     public boolean isFirst()
     {
-        return _rowMaps.size() > 0 && _row == 0;
+        return !_rowMaps.isEmpty() && _row == 0;
     }
 
     @Override
     public boolean isLast()
     {
-        return _rowMaps.size() > 0 && _row == _rowMaps.size() - 1;
+        return !_rowMaps.isEmpty() && _row == _rowMaps.size() - 1;
     }
 
     @Override
diff --git a/api/src/org/labkey/api/data/ColumnHeaderType.java b/api/src/org/labkey/api/data/ColumnHeaderType.java
index 66a6661b390..fc86bacac1e 100644
--- a/api/src/org/labkey/api/data/ColumnHeaderType.java
+++ b/api/src/org/labkey/api/data/ColumnHeaderType.java
@@ -133,8 +133,8 @@ public String getText(DisplayColumn dc)
         }
     };
 
-    private String _optionText;
-    private String _description;
+    private final String _optionText;
+    private final String _description;
 
     ColumnHeaderType(String optionText, String description)
     {
@@ -166,7 +166,7 @@ public String getDescription()
 
     public abstract String getText(DisplayColumn dc);
 
-    private static Map _map;
+    private static final Map _map;
     static
     {
         _map = new CaseInsensitiveHashMap<>();
diff --git a/api/src/org/labkey/api/data/ColumnInfo.java b/api/src/org/labkey/api/data/ColumnInfo.java
index 589afd645b5..9052960d768 100644
--- a/api/src/org/labkey/api/data/ColumnInfo.java
+++ b/api/src/org/labkey/api/data/ColumnInfo.java
@@ -169,8 +169,6 @@ static int findColumn(ResultSet rs, String name)
      *         .append("FROM ").append(ti.getFromSql("tablelias"));
      * 
* - * @param tableAliasName - * @return */ SQLFragment getValueSql(String tableAliasName); diff --git a/api/src/org/labkey/api/data/CompareType.java b/api/src/org/labkey/api/data/CompareType.java index d545d5b134e..4cbd856abaa 100644 --- a/api/src/org/labkey/api/data/CompareType.java +++ b/api/src/org/labkey/api/data/CompareType.java @@ -397,7 +397,7 @@ public FilterClause createFilterClause(@NotNull FieldKey fieldKey, Object value) else { List values = new ArrayList<>(); - if (value != null && !value.toString().trim().equals("")) + if (value != null && !value.toString().trim().isEmpty()) { values.addAll(parseParams(value, getValueSeparator(), isNewLineSeparatorAllowed())); } @@ -478,7 +478,7 @@ public FilterClause createFilterClause(@NotNull FieldKey fieldKey, Object value) List values = new ArrayList<>(); if (value != null) { - if (value.toString().trim().equals("")) + if (value.toString().trim().isEmpty()) { values.add(null); } @@ -526,7 +526,7 @@ public FilterClause createFilterClause(@NotNull FieldKey fieldKey, Object value) List values = new ArrayList<>(); if (value != null) { - if (value.toString().trim().equals("")) + if (value.toString().trim().isEmpty()) { values.add(null); } @@ -1181,7 +1181,7 @@ public List getFieldKeys() @Override public Map.Entry toURLParam(String dataRegionPrefix) { - String key = dataRegionPrefix + _fieldKey.toString() + SimpleFilter.SEPARATOR_CHAR + getCompareType().getPreferredUrlKey(); + String key = dataRegionPrefix + _fieldKey + SimpleFilter.SEPARATOR_CHAR + getCompareType().getPreferredUrlKey(); return new Pair<>(key, toURLParamValue()); } } @@ -1374,11 +1374,9 @@ public static Object convertParamValue(ColumnRenderProperties colInfo, Object pa // No way to know what to convert it into return paramVal; } - if (!(paramVal instanceof String)) + if (!(paramVal instanceof String stringValue)) return paramVal; - String stringValue = (String)paramVal; - // Expand the magic 'me' value if the column is a userid or a user display name if (ME_FILTER_PARAM_VALUE.equals(stringValue)) { @@ -1411,12 +1409,11 @@ private static boolean isUserIdColumn(ColumnRenderProperties col) if (col.getJdbcType() != JdbcType.INTEGER) return false; - ForeignKey fk = null; + ForeignKey fk; String lookupSchemaName = null; String lookupQueryName = null; - if (col instanceof ColumnInfo) + if (col instanceof ColumnInfo colInfo) { - ColumnInfo colInfo = (ColumnInfo)col; String sqlTypeName = colInfo.getSqlTypeName(); if ("userid".equalsIgnoreCase(sqlTypeName)) return true; diff --git a/api/src/org/labkey/api/data/ConditionalFormat.java b/api/src/org/labkey/api/data/ConditionalFormat.java index 4a0c3a5faab..f57c81dd1a0 100644 --- a/api/src/org/labkey/api/data/ConditionalFormat.java +++ b/api/src/org/labkey/api/data/ConditionalFormat.java @@ -230,7 +230,7 @@ public static List convertFromXML(ConditionalFormatsType cond } catch (URISyntaxException e) { - throw new UnexpectedException(e); + throw UnexpectedException.wrap(e); } if (xmlFormat.isSetBold() && xmlFormat.getBold()) { @@ -335,9 +335,8 @@ private static boolean addToXML(List formats, Co { ConditionalFormatFilterType xmlFilter = xmlFormat.getFilters().addNewFilter(); - if (filterClause instanceof CompareType.AbstractCompareClause) + if (filterClause instanceof CompareType.AbstractCompareClause compareClause) { - CompareType.AbstractCompareClause compareClause = (CompareType.AbstractCompareClause)filterClause; xmlFilter.setOperator(compareClause.getCompareType().getXmlType()); String value = compareClause.toURLParamValue(); if (value != null) diff --git a/api/src/org/labkey/api/data/Constraint.java b/api/src/org/labkey/api/data/Constraint.java index 07a6fded057..e62d2aabccb 100644 --- a/api/src/org/labkey/api/data/Constraint.java +++ b/api/src/org/labkey/api/data/Constraint.java @@ -31,7 +31,7 @@ public class Constraint private String name; private CONSTRAINT_TYPES type; private boolean cluster; - private Collection columns = new LinkedHashSet<>(); + private Collection columns; public Constraint(@NotNull String tableName, @NotNull CONSTRAINT_TYPES type, boolean cluster, @Nullable Collection columns) { diff --git a/api/src/org/labkey/api/data/ContainerManager.java b/api/src/org/labkey/api/data/ContainerManager.java index bfe262dae25..413c76a6c22 100644 --- a/api/src/org/labkey/api/data/ContainerManager.java +++ b/api/src/org/labkey/api/data/ContainerManager.java @@ -2958,11 +2958,11 @@ private void testOneFolderType(FolderType folderType) LOG.info("testOneFolderType(" + folderType.getName() + "): creating container"); Container newFolder = createContainer(_testRoot, "folderTypeTest", TestContext.get().getUser()); FolderType ft = newFolder.getFolderType(); - assertEquals(ft, FolderType.NONE); + assertEquals(FolderType.NONE, ft); Container newFolderFromCache = getForId(newFolder.getId()); assertNotNull(newFolderFromCache); - assertEquals(newFolderFromCache.getFolderType(), FolderType.NONE); + assertEquals(FolderType.NONE, newFolderFromCache.getFolderType()); LOG.info("testOneFolderType(" + folderType.getName() + "): setting folder type"); newFolder.setFolderType(folderType, TestContext.get().getUser()); diff --git a/api/src/org/labkey/api/data/ContainerTable.java b/api/src/org/labkey/api/data/ContainerTable.java index 077d83bcb87..35f00212086 100644 --- a/api/src/org/labkey/api/data/ContainerTable.java +++ b/api/src/org/labkey/api/data/ContainerTable.java @@ -168,7 +168,7 @@ private void init(ActionURL url) containerDisplayColumn.setReadOnly(true); addColumn(containerDisplayColumn); - col = getMutableColumn("CreatedBy"); + getMutableColumn("CreatedBy"); var title = getMutableColumn("Title"); title.setURL(detailsURL); diff --git a/api/src/org/labkey/api/data/CrosstabAxis.java b/api/src/org/labkey/api/data/CrosstabAxis.java index 11053d042dd..21370d0b3d1 100644 --- a/api/src/org/labkey/api/data/CrosstabAxis.java +++ b/api/src/org/labkey/api/data/CrosstabAxis.java @@ -30,8 +30,8 @@ public class CrosstabAxis { private String _caption = null; - private ArrayList _dimensions = new ArrayList<>(); - private CrosstabSettings _settings = null; + private final ArrayList _dimensions = new ArrayList<>(); + private CrosstabSettings _settings; public CrosstabAxis(CrosstabSettings settings) { diff --git a/api/src/org/labkey/api/data/CrosstabMeasure.java b/api/src/org/labkey/api/data/CrosstabMeasure.java index 07f63165b72..b77371082e1 100644 --- a/api/src/org/labkey/api/data/CrosstabMeasure.java +++ b/api/src/org/labkey/api/data/CrosstabMeasure.java @@ -123,8 +123,8 @@ public boolean retainsForeignKey() } } - private ColumnInfo _sourceColumn = null; - private AggregateFunction _aggregateFunction = AggregateFunction.COUNT; + private ColumnInfo _sourceColumn; + private AggregateFunction _aggregateFunction; private String _caption; private DetailsURL _url; diff --git a/api/src/org/labkey/api/data/CrosstabMember.java b/api/src/org/labkey/api/data/CrosstabMember.java index e3458ad04f6..4c645171440 100644 --- a/api/src/org/labkey/api/data/CrosstabMember.java +++ b/api/src/org/labkey/api/data/CrosstabMember.java @@ -42,9 +42,9 @@ public class CrosstabMember public static final String CAPTION_NAME = "**caption**"; public static final String CAPTION_TOKEN = "${" + CAPTION_NAME + "}"; - private @Nullable Object _value = null; - private @Nullable String _caption = null; - private @NotNull FieldKey _dimensionFieldKey = null; + private @Nullable Object _value; + private @Nullable String _caption; + private @NotNull FieldKey _dimensionFieldKey; public CrosstabMember(@Nullable Object value, @NotNull CrosstabDimension dimension, @Nullable String caption) { diff --git a/api/src/org/labkey/api/data/CrosstabSettings.java b/api/src/org/labkey/api/data/CrosstabSettings.java index 3f2c9a0c617..480aabecee4 100644 --- a/api/src/org/labkey/api/data/CrosstabSettings.java +++ b/api/src/org/labkey/api/data/CrosstabSettings.java @@ -29,10 +29,10 @@ */ public class CrosstabSettings { - private TableInfo _sourceTable = null; - private CrosstabAxis _rowAxis = new CrosstabAxis(this); - private CrosstabAxis _colAxis = new CrosstabAxis(this); - private List _measures = new ArrayList<>(); + private TableInfo _sourceTable; + private final CrosstabAxis _rowAxis = new CrosstabAxis(this); + private final CrosstabAxis _colAxis = new CrosstabAxis(this); + private final List _measures = new ArrayList<>(); private String _instanceCountCaption = "Instance Count"; private SimpleFilter _sourceTableFilter; diff --git a/api/src/org/labkey/api/data/CrosstabTable.java b/api/src/org/labkey/api/data/CrosstabTable.java index 91a69455850..296f3ba89f7 100644 --- a/api/src/org/labkey/api/data/CrosstabTable.java +++ b/api/src/org/labkey/api/data/CrosstabTable.java @@ -43,11 +43,11 @@ public class CrosstabTable extends VirtualTable implements CrosstabTableInfo public static final String COL_INSTANCE_COUNT = "InstanceCount"; public static final String COL_SORT_PATTERN = "SortPattern"; - private CrosstabSettings _settings = null; - private List _colMembers = null; + private CrosstabSettings _settings; + private List _colMembers; private Filter _aggFilter = null; private boolean _orAggFilters = false; - private GroupTableInfo _groupTable = null; + private GroupTableInfo _groupTable; protected static final String AGG_ALIAS = "agg"; protected static final String AGG_OR_ALIAS = "aggo"; @@ -545,7 +545,7 @@ private String getSQLValue(JdbcType jdbcType, Object memberValue) else if (jdbcType.isText()) return "'" + memberValue.toString().replace("'", "''") + "'"; else if (jdbcType == JdbcType.BOOLEAN) - return "CAST('" + Boolean.valueOf(memberValue.toString()).toString() +"' AS " + getSqlDialect().getBooleanDataType() + ")"; + return "CAST('" + Boolean.valueOf(memberValue.toString()) +"' AS " + getSqlDialect().getBooleanDataType() + ")"; //if you get this, add support for the type you want. throw new IllegalArgumentException("Crosstab table info supports numeric and character types for the column dimension."); diff --git a/api/src/org/labkey/api/data/DataRegionSelection.java b/api/src/org/labkey/api/data/DataRegionSelection.java index be8fc08187f..2c3a6889bf8 100644 --- a/api/src/org/labkey/api/data/DataRegionSelection.java +++ b/api/src/org/labkey/api/data/DataRegionSelection.java @@ -464,7 +464,7 @@ public static int setSelectionForAll(QueryView view, String key, boolean checked private static List getSelectedItems(QueryView view, @NotNull Collection selectedValues) throws IOException { // Issue 48657: no need to query the region result set if we have no selectedValues - if (selectedValues.size() == 0) + if (selectedValues.isEmpty()) return new LinkedList<>(); var dataRegionContext = getDataRegionContext(view); diff --git a/api/src/org/labkey/api/data/DbSchema.java b/api/src/org/labkey/api/data/DbSchema.java index 52db560f0e3..94910a0deca 100644 --- a/api/src/org/labkey/api/data/DbSchema.java +++ b/api/src/org/labkey/api/data/DbSchema.java @@ -705,7 +705,7 @@ private void verify(String requestedName, DbSchema expected, DbSchema test) { assertNotNull(test); assertTrue(test.getTableNames().size() > 20); - assertSame("\"" + requestedName + "\" schema does not match \"" + expected.getDisplayName() + "\" schema", test, expected); + assertSame("\"" + requestedName + "\" schema does not match \"" + expected.getDisplayName() + "\" schema", expected, test); } } diff --git a/api/src/org/labkey/api/data/DbSequenceManager.java b/api/src/org/labkey/api/data/DbSequenceManager.java index 3512988e31e..b47158409ae 100644 --- a/api/src/org/labkey/api/data/DbSequenceManager.java +++ b/api/src/org/labkey/api/data/DbSequenceManager.java @@ -551,7 +551,7 @@ void _multiThreadIncrementStressTest(DbSequence seq) throws Throwable final long elapsed = System.currentTimeMillis() - start; final double perSecond = totalCount / (elapsed / 1000.0); - assertEquals(duplicateValues.size() + " duplicate values were detected: " + duplicateValues.toString(), 0, duplicateValues.size()); + assertEquals(duplicateValues.size() + " duplicate values were detected: " + duplicateValues, 0, duplicateValues.size()); assertEquals(totalCount, values.size()); for (long i = 0; i < threads * n; i++) diff --git a/api/src/org/labkey/api/data/DimensionColumnInfo.java b/api/src/org/labkey/api/data/DimensionColumnInfo.java index 7fd7e54b4eb..f197cf4bbe0 100644 --- a/api/src/org/labkey/api/data/DimensionColumnInfo.java +++ b/api/src/org/labkey/api/data/DimensionColumnInfo.java @@ -26,7 +26,7 @@ */ public class DimensionColumnInfo extends BaseColumnInfo { - private CrosstabDimension _crosstabDimension = null; + private CrosstabDimension _crosstabDimension; public DimensionColumnInfo(CrosstabTableInfo table, CrosstabDimension dimension) { diff --git a/api/src/org/labkey/api/data/ExceptionFramework.java b/api/src/org/labkey/api/data/ExceptionFramework.java index 9151291dd17..454ed666a6b 100644 --- a/api/src/org/labkey/api/data/ExceptionFramework.java +++ b/api/src/org/labkey/api/data/ExceptionFramework.java @@ -17,7 +17,6 @@ import org.labkey.api.data.dialect.SqlDialect; import org.labkey.api.util.DebugInfoDumper; -import org.springframework.dao.DataAccessException; import org.springframework.jdbc.UncategorizedSQLException; import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator; import org.springframework.jdbc.support.SQLExceptionTranslator; diff --git a/api/src/org/labkey/api/data/GroupTableInfo.java b/api/src/org/labkey/api/data/GroupTableInfo.java index 1baa9c65ae8..77413d25953 100644 --- a/api/src/org/labkey/api/data/GroupTableInfo.java +++ b/api/src/org/labkey/api/data/GroupTableInfo.java @@ -36,17 +36,17 @@ public class GroupTableInfo extends VirtualTable { private final static String ALIAS = "grp"; private final static String ALIAS_SOURCE = "src"; - private TableInfo _source; - private List _groupByCols; - private List _measures; - private SimpleFilter _sourceFilter; + private final TableInfo _source; + private final List _groupByCols; + private final List _measures; + private final SimpleFilter _sourceFilter; public GroupTableInfo(TableInfo source, SimpleFilter sourceFilter, List groupByCols, List measures) { super(source.getSchema(), ALIAS, source.getUserSchema()); - assert null != groupByCols && groupByCols.size() > 0 : "No group by columns passed to GroupTableInfo constructor!"; - assert null != measures && measures.size() > 0 : "No measures passed to GroupTableInfo constructor!"; + assert null != groupByCols && !groupByCols.isEmpty() : "No group by columns passed to GroupTableInfo constructor!"; + assert null != measures && !measures.isEmpty() : "No measures passed to GroupTableInfo constructor!"; _source = source; _groupByCols = groupByCols; diff --git a/api/src/org/labkey/api/data/GroupedResultSet.java b/api/src/org/labkey/api/data/GroupedResultSet.java index 33157b5c253..b0bf50cbe11 100644 --- a/api/src/org/labkey/api/data/GroupedResultSet.java +++ b/api/src/org/labkey/api/data/GroupedResultSet.java @@ -37,7 +37,7 @@ */ public class GroupedResultSet extends ResultSetImpl { - private int _columnIndex = 0; + private int _columnIndex; private int _rowOffset = 0; private int _lastRow = 0; private int _groupCount = 0; diff --git a/api/src/org/labkey/api/data/IndexInfo.java b/api/src/org/labkey/api/data/IndexInfo.java index 7d349833443..47266643ece 100644 --- a/api/src/org/labkey/api/data/IndexInfo.java +++ b/api/src/org/labkey/api/data/IndexInfo.java @@ -31,8 +31,8 @@ public class IndexInfo private static final Logger _log = LogManager.getLogger(IndexInfo.class); - private TableInfo.IndexType _type; - private List _columns; + private final TableInfo.IndexType _type; + private final List _columns; public IndexInfo(TableInfo.IndexType type, List columns) { diff --git a/api/src/org/labkey/api/data/InputColumn.java b/api/src/org/labkey/api/data/InputColumn.java index 2e9cad2f146..68f54c24e6e 100644 --- a/api/src/org/labkey/api/data/InputColumn.java +++ b/api/src/org/labkey/api/data/InputColumn.java @@ -17,9 +17,6 @@ import org.labkey.api.writer.HtmlWriter; -import java.io.IOException; -import java.io.Writer; - /** * Renders a bound ColumnInfo as an HTML form input in a grid view. */ diff --git a/api/src/org/labkey/api/data/JavaScriptDisplayColumn.java b/api/src/org/labkey/api/data/JavaScriptDisplayColumn.java index 1a2fc158e84..7725b97fc0a 100644 --- a/api/src/org/labkey/api/data/JavaScriptDisplayColumn.java +++ b/api/src/org/labkey/api/data/JavaScriptDisplayColumn.java @@ -25,7 +25,6 @@ import org.labkey.api.view.template.ClientDependency; import org.labkey.api.writer.HtmlWriter; -import java.io.IOException; import java.io.Writer; import java.util.Collection; import java.util.LinkedHashSet; diff --git a/api/src/org/labkey/api/data/JdbcType.java b/api/src/org/labkey/api/data/JdbcType.java index d3bf15a5832..c8d554162c4 100644 --- a/api/src/org/labkey/api/data/JdbcType.java +++ b/api/src/org/labkey/api/data/JdbcType.java @@ -670,27 +670,27 @@ public void testConvert() @Test public void testPromote() { - assertEquals(promote(NULL, INTEGER), INTEGER); - assertEquals(promote(NULL, VARCHAR), VARCHAR); - assertEquals(promote(NULL, TIMESTAMP), TIMESTAMP); - assertEquals(promote(SMALLINT, NULL), SMALLINT); - assertEquals(promote(REAL, NULL), REAL); - assertEquals(promote(LONGVARCHAR, NULL), LONGVARCHAR); - - assertEquals(promote(INTEGER, DOUBLE), DOUBLE); - assertEquals(promote(INTEGER, SMALLINT), INTEGER); - assertEquals(promote(INTEGER, DECIMAL), DECIMAL); - assertEquals(promote(DECIMAL, DOUBLE), DOUBLE); - - assertEquals(promote(VARCHAR, DOUBLE), VARCHAR); - assertEquals(promote(VARCHAR, SMALLINT), VARCHAR); - assertEquals(promote(INTEGER, VARCHAR), VARCHAR); - assertEquals(promote(DECIMAL, VARCHAR), VARCHAR); - - assertEquals(promote(TIME, DATE), TIMESTAMP); - - assertEquals(promote(BOOLEAN, DATE), OTHER); - assertEquals(promote(VARBINARY, INTEGER), OTHER); + assertEquals(INTEGER, promote(NULL, INTEGER)); + assertEquals(VARCHAR, promote(NULL, VARCHAR)); + assertEquals(TIMESTAMP, promote(NULL, TIMESTAMP)); + assertEquals(SMALLINT, promote(SMALLINT, NULL)); + assertEquals(REAL, promote(REAL, NULL)); + assertEquals(LONGVARCHAR, promote(LONGVARCHAR, NULL)); + + assertEquals(DOUBLE, promote(INTEGER, DOUBLE)); + assertEquals(INTEGER, promote(INTEGER, SMALLINT)); + assertEquals(DECIMAL, promote(INTEGER, DECIMAL)); + assertEquals(DOUBLE, promote(DECIMAL, DOUBLE)); + + assertEquals(VARCHAR, promote(VARCHAR, DOUBLE)); + assertEquals(VARCHAR, promote(VARCHAR, SMALLINT)); + assertEquals(VARCHAR, promote(INTEGER, VARCHAR)); + assertEquals(VARCHAR, promote(DECIMAL, VARCHAR)); + + assertEquals(TIMESTAMP, promote(TIME, DATE)); + + assertEquals(OTHER, promote(BOOLEAN, DATE)); + assertEquals(OTHER, promote(VARBINARY, INTEGER)); } @Test diff --git a/api/src/org/labkey/api/data/LoggingResultSetWrapper.java b/api/src/org/labkey/api/data/LoggingResultSetWrapper.java index 69095207f00..b77b625f339 100644 --- a/api/src/org/labkey/api/data/LoggingResultSetWrapper.java +++ b/api/src/org/labkey/api/data/LoggingResultSetWrapper.java @@ -15,18 +15,15 @@ */ package org.labkey.api.data; -import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.labkey.api.audit.AuditLogService; import org.labkey.api.util.Pair; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; /** * Created by davebradlee on 9/15/14. diff --git a/api/src/org/labkey/api/data/MaterializedQueryHelper.java b/api/src/org/labkey/api/data/MaterializedQueryHelper.java index 29b2cbe3d8d..690d7015b98 100644 --- a/api/src/org/labkey/api/data/MaterializedQueryHelper.java +++ b/api/src/org/labkey/api/data/MaterializedQueryHelper.java @@ -37,6 +37,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Random; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -64,7 +65,8 @@ public static class Materialized private final ArrayList _invalidators = new ArrayList<>(3); protected final Lock _loadingLock = new ReentrantLock(); - public enum LoadingState { BEFORELOAD, LOADING, LOADED, ERROR }; + public enum LoadingState { BEFORELOAD, LOADING, LOADED, ERROR } + public final AtomicReference _loadingState = new AtomicReference<>(LoadingState.BEFORELOAD); public RuntimeException _loadException = null; @@ -190,7 +192,7 @@ enum CacheCheck public static abstract class Invalidator { - private int _coalesceDelay = 0; + private final int _coalesceDelay = 0; public CacheCheck checkValid(long createdTime) { @@ -307,7 +309,7 @@ protected boolean removeEldestEntry(Map.Entry eldest) protected MaterializedQueryHelper(String prefix, DbScope scope, SQLFragment select, @Nullable SQLFragment uptodate, Supplier supplier, @Nullable Collection indexes, long maxTimeToCache, boolean isSelectIntoSql) { - _prefix = StringUtils.defaultString(prefix,"mat"); + _prefix = Objects.toString(prefix,"mat"); _scope = scope; _selectQuery = select; _uptodateQuery = uptodate; @@ -359,7 +361,7 @@ public synchronized void uncache(final Container c) } - private Set _pending = null; + private final Set _pending = null; // this is a method so you can subclass MaterializedQueryHelper protected String getUpToDateKey() diff --git a/api/src/org/labkey/api/data/MultiValuedRenderContext.java b/api/src/org/labkey/api/data/MultiValuedRenderContext.java index 096c6165222..245b1016d9c 100644 --- a/api/src/org/labkey/api/data/MultiValuedRenderContext.java +++ b/api/src/org/labkey/api/data/MultiValuedRenderContext.java @@ -131,9 +131,9 @@ public Object get(Object key) public static class TestCase extends Assert { - private FieldKey _fk1 = FieldKey.fromParts("Parent", "Child"); - private FieldKey _fk2 = FieldKey.fromParts("Standalone"); - private FieldKey _otherFK = FieldKey.fromParts("NotInRow"); + private final FieldKey _fk1 = FieldKey.fromParts("Parent", "Child"); + private final FieldKey _fk2 = FieldKey.fromParts("Standalone"); + private final FieldKey _otherFK = FieldKey.fromParts("NotInRow"); @Test public void testMatchingValues() @@ -203,7 +203,7 @@ public void testMismatchedValues() private class TestRenderContext extends RenderContext { - private Map _values; + private final Map _values; public TestRenderContext(Map values) { diff --git a/api/src/org/labkey/api/data/NameGeneratorState.java b/api/src/org/labkey/api/data/NameGeneratorState.java index 5011de75e1e..2b10c77b068 100644 --- a/api/src/org/labkey/api/data/NameGeneratorState.java +++ b/api/src/org/labkey/api/data/NameGeneratorState.java @@ -291,12 +291,12 @@ private String genName(@NotNull Map rowMap, Map ctx = additionalContext(rowMap, parentDatas, parentSamples, sampleCounts, extraProps, altNameGenerator); StringExpressionFactory.FieldKeyStringExpression expression = activeNameGenerator.getParsedNameExpression(); - String name = null; + String name; if (expression instanceof NameGenerator.NameGenerationExpression) name = ((NameGenerator.NameGenerationExpression) expression).eval(ctx, _prefixCounterSequences); else name = expression.eval(ctx); - if (name == null || name.length() == 0) + if (name == null || name.isEmpty()) throw new IllegalArgumentException("The data provided are not sufficient to create a name using the naming pattern '" + expression.getSource() + "'. Check the pattern syntax and data values."); return name; diff --git a/api/src/org/labkey/api/data/ParameterMapStatement.java b/api/src/org/labkey/api/data/ParameterMapStatement.java index 65397ce4450..3d40f87bb97 100644 --- a/api/src/org/labkey/api/data/ParameterMapStatement.java +++ b/api/src/org/labkey/api/data/ParameterMapStatement.java @@ -155,9 +155,8 @@ public ParameterMapStatement(@NotNull DbScope scope, Connection conn, SQLFragmen for (int i = 0; i < paramList.size(); i++) { Object o = paramList.get(i); - if (o instanceof Parameter) + if (o instanceof Parameter p) { - Parameter p = (Parameter)o; if (!paramMap.containsKey(p)) paramMap.put(p, new IntegerArray()); paramMap.get(p).add(i+1); @@ -204,7 +203,7 @@ private void init(PreparedStatement stmt, Collection parameters, @Nul { _dialect = _scope.getSqlDialect(); _map = new CaseInsensitiveHashMap<>(parameters.size() * 2); - _parameters = parameters.toArray(new Parameter[parameters.size()]); + _parameters = parameters.toArray(new Parameter[0]); _stmt = stmt; for (int i=0 ; i<_parameters.length ; i++) diff --git a/api/src/org/labkey/api/data/Project.java b/api/src/org/labkey/api/data/Project.java index 0f7e89c9a8d..810207d52b7 100644 --- a/api/src/org/labkey/api/data/Project.java +++ b/api/src/org/labkey/api/data/Project.java @@ -27,7 +27,7 @@ */ public class Project implements Serializable { - private @NotNull Container _c; + private final @NotNull Container _c; public Project(@NotNull Container c) { diff --git a/api/src/org/labkey/api/data/PropertyManager.java b/api/src/org/labkey/api/data/PropertyManager.java index 394e3cdbdd8..cc78f979361 100644 --- a/api/src/org/labkey/api/data/PropertyManager.java +++ b/api/src/org/labkey/api/data/PropertyManager.java @@ -800,7 +800,7 @@ private void testPropertyStore(PropertyStore store, PropertyStoreTest test) for (String category : test.getCategories()) { Map m = store.getProperties(user, child, category); - assertSame(m, AbstractPropertyStore.NULL_MAP); + assertSame(AbstractPropertyStore.NULL_MAP, m); } } @@ -818,15 +818,15 @@ private void testProperties(PropertyStore store, User user, Container test, Stri m.save(); m = store.getWritableProperties(user, test, category, false); - assertEquals(m.get("foo"), "bar"); - assertEquals(m.get("this"), "that"); + assertEquals("bar", m.get("foo")); + assertEquals("that", m.get("this")); assertFalse(m.containsKey("zoo")); m.remove("this"); m.save(); Map map = store.getProperties(user, test, category); - assertEquals(map.get("foo"), "bar"); + assertEquals("bar", map.get("foo")); assertFalse(map.containsKey("this")); assertFalse(map.containsKey("zoo")); diff --git a/api/src/org/labkey/api/data/PropertyStorageSpec.java b/api/src/org/labkey/api/data/PropertyStorageSpec.java index 3ea16a85024..66a40909c0e 100644 --- a/api/src/org/labkey/api/data/PropertyStorageSpec.java +++ b/api/src/org/labkey/api/data/PropertyStorageSpec.java @@ -27,7 +27,6 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.Set; diff --git a/api/src/org/labkey/api/data/RemapCache.java b/api/src/org/labkey/api/data/RemapCache.java index 4a5716f3898..e60cb2f3ca6 100644 --- a/api/src/org/labkey/api/data/RemapCache.java +++ b/api/src/org/labkey/api/data/RemapCache.java @@ -46,7 +46,7 @@ public RemapCache(boolean allowBulkLoads) _allowBulkLoads = allowBulkLoads; } - class Key + static class Key { final SchemaKey _schemaKey; final String _queryName; diff --git a/api/src/org/labkey/api/data/RenderContext.java b/api/src/org/labkey/api/data/RenderContext.java index ba625786a23..731c9afa9e4 100644 --- a/api/src/org/labkey/api/data/RenderContext.java +++ b/api/src/org/labkey/api/data/RenderContext.java @@ -233,10 +233,10 @@ public static List getSelectColumns(List displayColum assert null != (displayColumns = Collections.unmodifiableList(displayColumns)); assert Table.checkAllColumns(tinfo, tinfo.getColumns(), "RenderContext.getSelectColumns() tinfo.getColumns()"); - Set ret = new NullPreventingSet<>(new LinkedHashSet()); + Set ret = new NullPreventingSet<>(new LinkedHashSet<>()); LinkedHashSet keys = new LinkedHashSet<>(); - if (null == displayColumns || displayColumns.size() == 0) + if (null == displayColumns || displayColumns.isEmpty()) { ret.addAll(tinfo.getColumns()); } @@ -612,7 +612,7 @@ public boolean isEmpty() @Override public boolean containsKey(Object key) { - if (key instanceof FieldKey) + if (key instanceof FieldKey f) { if (null != _results) { @@ -620,7 +620,6 @@ public boolean containsKey(Object key) return true; } // - FieldKey f = (FieldKey) key; key = f.getParent() == null ? f.getName() : f.encode(); // } @@ -690,15 +689,13 @@ public Set keySet() /** * Overrides get to look first in the map & if not found there look in the current row * - * @param key - * @return */ @Override public Object get(Object key) { Object val = null; - if (key instanceof FieldKey) + if (key instanceof FieldKey f) { if (null != _results && _results.hasColumn((FieldKey) key)) { @@ -735,7 +732,6 @@ public Object get(Object key) // NOTE: Ideally we should not need to convert FieldKey to String at all // but _row is currently a map (not ) - FieldKey f = (FieldKey) key; key = f.getParent() == null ? f.getName() : f.encode(); // 13607 : Nonconforming field names in datasets cause data loss on edit @@ -878,7 +874,7 @@ public HtmlString getErrors(String paramName) list = errors.getGlobalErrors(); else list = errors.getFieldErrors(paramName); - if (list == null || list.size() == 0) + if (list == null || list.isEmpty()) return HtmlString.EMPTY_STRING; Set uniqueErrorStrs = new TreeSet<>(); diff --git a/api/src/org/labkey/api/data/SchemaTableInfo.java b/api/src/org/labkey/api/data/SchemaTableInfo.java index 3df40b08008..8f45396f2f3 100644 --- a/api/src/org/labkey/api/data/SchemaTableInfo.java +++ b/api/src/org/labkey/api/data/SchemaTableInfo.java @@ -1098,7 +1098,7 @@ else if (pair.second instanceof StringExpressionFactory.URLStringExpression) } } - if (templates.size() == 0) + if (templates.isEmpty()) { URLHelper url = PageFlowUtil.urlProvider(QueryUrls.class).urlCreateExcelTemplate(ctx.getContainer(), getPublicSchemaName(), getName()); url.addParameter("headerType", ColumnHeaderType.ImportField.name()); diff --git a/api/src/org/labkey/api/data/SimpleFilter.java b/api/src/org/labkey/api/data/SimpleFilter.java index 71d9424fbcd..d2f24d75bbc 100644 --- a/api/src/org/labkey/api/data/SimpleFilter.java +++ b/api/src/org/labkey/api/data/SimpleFilter.java @@ -438,7 +438,7 @@ public Object[] getParamVals() if (clause.getParamVals() != null) result.addAll(Arrays.asList(clause.getParamVals())); } - return result.toArray(new Object[result.size()]); + return result.toArray(new Object[0]); } @Override @@ -763,7 +763,7 @@ else if (!isNegated()) return in.toString(); } -; + private void handleEmptyParams(DatabaseIdentifier alias, SQLFragment in) { if (isIncludeNull()) diff --git a/api/src/org/labkey/api/data/Sort.java b/api/src/org/labkey/api/data/Sort.java index b40e50c9b38..87e2802477a 100644 --- a/api/src/org/labkey/api/data/Sort.java +++ b/api/src/org/labkey/api/data/Sort.java @@ -21,7 +21,6 @@ import org.labkey.api.collections.CaseInsensitiveHashSet; import org.labkey.api.data.dialect.SqlDialect; import org.labkey.api.query.FieldKey; -import org.labkey.api.sql.LabKeySql; import org.labkey.api.util.URLHelper; import java.util.ArrayList; diff --git a/api/src/org/labkey/api/data/SqlExecutingSelector.java b/api/src/org/labkey/api/data/SqlExecutingSelector.java index b78b2b6e077..11310aed408 100644 --- a/api/src/org/labkey/api/data/SqlExecutingSelector.java +++ b/api/src/org/labkey/api/data/SqlExecutingSelector.java @@ -511,9 +511,8 @@ private void initializeStatement(Connection conn, Statement stmt, @Nullable Asyn // If this is a background request then push the original stack trace into the statement wrapper so it gets // logged and stored in the query profiler. - if (stmt instanceof StatementWrapper) + if (stmt instanceof StatementWrapper sw) { - StatementWrapper sw = (StatementWrapper)stmt; sw.setStackTrace(asyncRequest.getCreationStackTrace()); sw.setRequestThread(true); // AsyncRequests aren't really background threads; treat them as request threads. sw.setQueryLogging(getQueryLogging()); @@ -521,9 +520,8 @@ private void initializeStatement(Connection conn, Statement stmt, @Nullable Asyn } else { - if (stmt instanceof StatementWrapper) + if (stmt instanceof StatementWrapper sw) { - StatementWrapper sw = (StatementWrapper)stmt; sw.setQueryLogging(getQueryLogging()); } } diff --git a/api/src/org/labkey/api/data/SqlSelectorTestCase.java b/api/src/org/labkey/api/data/SqlSelectorTestCase.java index 721ab06dfb2..0d4c569f5ab 100644 --- a/api/src/org/labkey/api/data/SqlSelectorTestCase.java +++ b/api/src/org/labkey/api/data/SqlSelectorTestCase.java @@ -127,13 +127,13 @@ public void testJdbcUncached() throws SQLException if (scope.getSqlDialect().isPostgreSQL()) { assertNotEquals(conn, conn2); - assertEquals(conn2.getTransactionIsolation(), TRANSACTION_READ_UNCOMMITTED); + assertEquals(TRANSACTION_READ_UNCOMMITTED, conn2.getTransactionIsolation()); assertFalse(conn2.getAutoCommit()); } else { assertEquals(conn, conn2); - assertEquals(conn2.getTransactionIsolation(), TRANSACTION_READ_COMMITTED); + assertEquals(TRANSACTION_READ_COMMITTED, conn2.getTransactionIsolation()); assertTrue(conn2.getAutoCommit()); } } diff --git a/api/src/org/labkey/api/data/StatementUtils.java b/api/src/org/labkey/api/data/StatementUtils.java index 26bf066a1a0..9a96b5efff5 100644 --- a/api/src/org/labkey/api/data/StatementUtils.java +++ b/api/src/org/labkey/api/data/StatementUtils.java @@ -65,7 +65,7 @@ public class StatementUtils public enum Operation {insert, update, merge} // configuration parameters - private Operation _operation = Operation.insert; + private Operation _operation; private SqlDialect _dialect; private final TableInfo _targetTable; private Set _keyColumnNames = null; // override the primary key of _table @@ -487,10 +487,9 @@ public ParameterMapStatement createStatement(Connection conn, @Nullable Containe public ParameterMapStatement createStatement(Connection conn, @Nullable Container c, User user, boolean checkUpdatableColumns) throws SQLException, TableInsertUpdateDataIterator.NoUpdatableColumnInDataException { - if (!(_targetTable instanceof UpdateableTableInfo)) + if (!(_targetTable instanceof UpdateableTableInfo updatable)) throw new IllegalArgumentException("Table must be an UpdateableTableInfo"); - UpdateableTableInfo updatable = (UpdateableTableInfo) _targetTable; TableInfo table = updatable.getSchemaTableInfo(); if (table.getTableType() != DatabaseTableType.TABLE || null == table.getMetaDataIdentifier()) @@ -607,9 +606,9 @@ public ParameterMapStatement createStatement(Connection conn, @Nullable Containe throw new IllegalStateException("Domains are only supported for sql server and postgres"); objectIdVar = _dialect.isPostgreSQL() ? "_$objectid$_" : "@_objectid_"; - sqlfDeclare.append("DECLARE ").append(objectIdVar).append(" INT").appendEOS();; + sqlfDeclare.append("DECLARE ").append(objectIdVar).append(" INT").appendEOS(); objectURIVar = _dialect.isPostgreSQL() ? "_$objecturi$_" : "@_objecturi_"; - sqlfDeclare.append("DECLARE ").append(objectURIVar).append(" ").append(_dialect.getSqlTypeName(JdbcType.VARCHAR)).append("(300)").appendEOS();; + sqlfDeclare.append("DECLARE ").append(objectURIVar).append(" ").append(_dialect.getSqlTypeName(JdbcType.VARCHAR)).append("(300)").appendEOS(); useVariables = _dialect.isPostgreSQL(); ParameterHolder containerParameter = createParameter("container", JdbcType.GUID); @@ -638,13 +637,13 @@ public ParameterMapStatement createStatement(Connection conn, @Nullable Containe sqlfInsertObject.append( null == ownerObjectId ? "NULL" : String.valueOf(ownerObjectId) ).append(" AS OwnerObjectId"); sqlfInsertObject.append(" WHERE NOT EXISTS (SELECT ObjectURI FROM exp.Object WHERE Container = "); appendParameterOrVariable(sqlfInsertObject, containerParameter); - sqlfInsertObject.append(" AND ").append(sqlfWhereObjectURI).append(")").appendEOS();; + sqlfInsertObject.append(" AND ").append(sqlfWhereObjectURI).append(")").appendEOS(); // re-grab the object's ObjectId, in case it was just inserted sqlfSelectObject.append(setKeyword).append(objectIdVar).append(" = ("); sqlfSelectObject.append("SELECT ObjectId FROM exp.Object WHERE Container = "); appendParameterOrVariable(sqlfSelectObject, containerParameter); - sqlfSelectObject.append(" AND ").append(sqlfWhereObjectURI).append(")").appendEOS();; + sqlfSelectObject.append(" AND ").append(sqlfWhereObjectURI).append(")").appendEOS(); if (Operation.insert != _operation && (!properties.isEmpty() || !_vocabularyProperties.isEmpty())) { @@ -668,7 +667,7 @@ public ParameterMapStatement createStatement(Connection conn, @Nullable Containe if (objectURIVar == null) { objectURIVar = _dialect.isPostgreSQL() ? "_$objecturi$_" : "@_objecturi_"; - sqlfDeclare.append("DECLARE ").append(objectURIVar).append(" ").append(_dialect.getSqlTypeName(JdbcType.VARCHAR)).append("(300)").appendEOS();; + sqlfDeclare.append("DECLARE ").append(objectURIVar).append(" ").append(_dialect.getSqlTypeName(JdbcType.VARCHAR)).append("(300)").appendEOS(); } if (!objectUriPreselectSet && (hasObjectURIColumn || !_vocabularyProperties.isEmpty())) @@ -774,7 +773,7 @@ else if (column.getName().equalsIgnoreCase(updatable.getObjectURIColumnName()) & } else { - if (null != _skipColumnNames && _skipColumnNames.contains(StringUtils.defaultString(remap.get(name),name))) + if (null != _skipColumnNames && _skipColumnNames.contains(Objects.toString(remap.get(name),name))) continue; ParameterHolder ph = createParameter(column); appendParameterOrVariable(valueSQL, ph); @@ -880,7 +879,7 @@ else if (column.getName().equalsIgnoreCase(updatable.getObjectURIColumnName()) & throw new TableInsertUpdateDataIterator.NoUpdatableColumnInDataException(table.getName()); sqlfUpdate.appendIdentifier(keys.values().iterator().next().getSelectIdentifier()); - sqlfUpdate.append(" = 'noop' WHERE 1 <> 1").appendEOS();; + sqlfUpdate.append(" = 'noop' WHERE 1 <> 1").appendEOS(); } else { @@ -1033,7 +1032,7 @@ else if (_dialect.isSqlServer()) call.add(ph.p); comma = ","; } - fn.append("\n)").appendEOS();; + fn.append("\n)").appendEOS(); fn.append("CREATE FUNCTION ").append(fnName).append("(").append(typeName).append(") "); fn.append("RETURNS "); if (null != sqlfSelectIds) @@ -1088,7 +1087,7 @@ else if (_dialect.isSqlServer()) .forEach(fn::append); if (null == sqlfSelectIds) { - fn.append("RETURN").appendEOS();; + fn.append("RETURN").appendEOS(); } else { diff --git a/api/src/org/labkey/api/data/StringWrapperDynaClass.java b/api/src/org/labkey/api/data/StringWrapperDynaClass.java index 880135a283d..9d3abef01db 100644 --- a/api/src/org/labkey/api/data/StringWrapperDynaClass.java +++ b/api/src/org/labkey/api/data/StringWrapperDynaClass.java @@ -64,7 +64,7 @@ protected void init(String className, Map> propTypes) dynaPropList.add(dynaProp); _dynaPropMap.put(key, dynaProp); } - _dynaProps = dynaPropList.toArray(new DynaProperty[dynaPropList.size()]); + _dynaProps = dynaPropList.toArray(new DynaProperty[0]); } @Override diff --git a/api/src/org/labkey/api/data/Table.java b/api/src/org/labkey/api/data/Table.java index b84382fd664..71cb01b91e0 100644 --- a/api/src/org/labkey/api/data/Table.java +++ b/api/src/org/labkey/api/data/Table.java @@ -75,6 +75,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; /** @@ -819,7 +820,8 @@ public static K insert(@Nullable User user, TableInfo table, K fieldsIn) { // note if(version) is not an no-op, it protects the isautoinc test from version columns implemented using sequences if (column.isVersionColumn()) - versionColumn = column; + { + } else if (column.isAutoIncrement()) autoIncColumn = column; @@ -1618,13 +1620,12 @@ public static boolean checkColumn(TableInfo table, ColumnInfo column, String pre public static ParameterMapStatement deleteStatement(Connection conn, TableInfo tableDelete /*, Set columns */) throws SQLException { - if (!(tableDelete instanceof UpdateableTableInfo)) + if (!(tableDelete instanceof UpdateableTableInfo updatable)) throw new IllegalArgumentException(); if (null == conn) conn = tableDelete.getSchema().getScope().getConnection(); - UpdateableTableInfo updatable = (UpdateableTableInfo)tableDelete; TableInfo table = updatable.getSchemaTableInfo(); if (!(table instanceof SchemaTableInfo)) @@ -1682,7 +1683,7 @@ public static ParameterMapStatement deleteStatement(Connection conn, TableInfo t SQLFragment sqlfSelectKey = new SQLFragment(); if (null != objectIdColumnName) { - String keyName = StringUtils.defaultString(objectIdColumnName, objectURIColumnName); + String keyName = Objects.toString(objectIdColumnName, objectURIColumnName); ColumnInfo keyCol = table.getColumn(keyName); sqlfSelectKey.append("SELECT ").appendIdentifier(keyCol.getSelectIdentifier()); sqlfSelectKey.append("FROM ").append(table.getFromSQL("X")); diff --git a/api/src/org/labkey/api/data/TableInfo.java b/api/src/org/labkey/api/data/TableInfo.java index d396f31d651..69523006ed4 100644 --- a/api/src/org/labkey/api/data/TableInfo.java +++ b/api/src/org/labkey/api/data/TableInfo.java @@ -456,7 +456,7 @@ default List> getValidatedImportTemplates(ViewContext ctx) * Domain may or may not exist even if DomainKind is available. */ @Nullable - DomainKind getDomainKind(); + DomainKind getDomainKind(); /** * Returns a QueryUpdateService implementation for this TableInfo, @@ -648,8 +648,7 @@ void fireRowTrigger(Container c, User user, TriggerType type, boolean before, in * * @return FieldKey of the Container column. */ - @Nullable - public FieldKey getContainerFieldKey(); + @Nullable FieldKey getContainerFieldKey(); /** * Returns whether this table supports audit tracking of insert, updates and deletes by implementing the @@ -761,7 +760,7 @@ default boolean hasDeleteURLOverride() default boolean allowQueryTableURLOverrides() { return false; - }; + } /** * Max PHI across all columns in the table. diff --git a/api/src/org/labkey/api/data/TableInfoGetter.java b/api/src/org/labkey/api/data/TableInfoGetter.java index 196bb2e8ee2..28d5967328f 100644 --- a/api/src/org/labkey/api/data/TableInfoGetter.java +++ b/api/src/org/labkey/api/data/TableInfoGetter.java @@ -22,5 +22,5 @@ */ public interface TableInfoGetter { - public TableInfo getTableInfo(); + TableInfo getTableInfo(); } diff --git a/api/src/org/labkey/api/data/TableResultSet.java b/api/src/org/labkey/api/data/TableResultSet.java index 133edde54a1..e1127f87941 100644 --- a/api/src/org/labkey/api/data/TableResultSet.java +++ b/api/src/org/labkey/api/data/TableResultSet.java @@ -54,5 +54,5 @@ default T getWrapped(Class clz) if (clz.isAssignableFrom(this.getClass())) return (T)this; return null; - }; + } } diff --git a/api/src/org/labkey/api/data/TableSelector.java b/api/src/org/labkey/api/data/TableSelector.java index b97348ca203..2cce02d4442 100644 --- a/api/src/org/labkey/api/data/TableSelector.java +++ b/api/src/org/labkey/api/data/TableSelector.java @@ -17,7 +17,6 @@ package org.labkey.api.data; import org.apache.commons.collections4.MultiValuedMap; -import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -395,7 +394,6 @@ public Results getResultsAsync(final boolean cache, final boolean scrollable, Ht * Setting this options asks the TableSelector to add additional display columns to the generated SQL, as well * as forcing the results to be sorted. - * @param forDisplay * @return this */ public TableSelector setForDisplay(boolean forDisplay) @@ -406,7 +404,6 @@ public TableSelector setForDisplay(boolean forDisplay) /** * This forces the results to be sorted as they would be for setForDisplay(true) - * @param forceSort * @return this */ public TableSelector setForceSortForDisplay(boolean forceSort) diff --git a/api/src/org/labkey/api/data/TableSelectorTestCase.java b/api/src/org/labkey/api/data/TableSelectorTestCase.java index 78681c58c53..63a8f61e4be 100644 --- a/api/src/org/labkey/api/data/TableSelectorTestCase.java +++ b/api/src/org/labkey/api/data/TableSelectorTestCase.java @@ -456,7 +456,7 @@ private void testOffsetAndLimit(TableSelector selector, Class clazz) thro int offset = 2; MutableInt testCount = new MutableInt(0); - selector.forEach(clazz, new ForEachBlock() + selector.forEach(clazz, new ForEachBlock<>() { @Override public void exec(K object) throws StopIteratingException diff --git a/api/src/org/labkey/api/data/TableViewForm.java b/api/src/org/labkey/api/data/TableViewForm.java index 3eb48be2f1c..7254abb1e69 100644 --- a/api/src/org/labkey/api/data/TableViewForm.java +++ b/api/src/org/labkey/api/data/TableViewForm.java @@ -34,8 +34,6 @@ import org.labkey.api.action.NullSafeBindException; import org.labkey.api.action.SpringActionController; import org.labkey.api.collections.CaseInsensitiveHashMap; -import org.labkey.api.dataiterator.DataIteratorUtil; -import org.labkey.api.query.QueryUpdateForm; import org.labkey.api.query.SchemaKey; import org.labkey.api.security.permissions.DeletePermission; import org.labkey.api.security.permissions.InsertPermission; @@ -596,9 +594,8 @@ else if (column.getName().contains("\"") && getViewContext().getRequest() instan } // Check if there was a file uploaded for the column's value - if (values.get(column.getName()) == null && File.class.equals(column.getJavaClass()) && getRequest() instanceof MultipartHttpServletRequest) + if (values.get(column.getName()) == null && File.class.equals(column.getJavaClass()) && getRequest() instanceof MultipartHttpServletRequest request) { - MultipartHttpServletRequest request = (MultipartHttpServletRequest) getRequest(); MultipartFile f = request.getFile(getFormFieldName(column)); // Only set the parameter value if there was a form element that was posted if (f != null) diff --git a/api/src/org/labkey/api/data/TempTableInClauseGenerator.java b/api/src/org/labkey/api/data/TempTableInClauseGenerator.java index 953cc56faf0..b3970dd2b89 100644 --- a/api/src/org/labkey/api/data/TempTableInClauseGenerator.java +++ b/api/src/org/labkey/api/data/TempTableInClauseGenerator.java @@ -189,7 +189,7 @@ public static class TestCase private static final List INTEGERS = Arrays.asList(1, 2, 3, 4); private static final List STRINGS = Arrays.asList("a", "b", "c", "d"); - private DbScope _scope = CoreSchema.getInstance().getSchema().getScope(); + private final DbScope _scope = CoreSchema.getInstance().getSchema().getScope(); @Before public void init() diff --git a/api/src/org/labkey/api/data/TempTableTracker.java b/api/src/org/labkey/api/data/TempTableTracker.java index 7833ac611aa..bc9d62e0709 100644 --- a/api/src/org/labkey/api/data/TempTableTracker.java +++ b/api/src/org/labkey/api/data/TempTableTracker.java @@ -246,7 +246,7 @@ else if (s.charAt(0) == '-') continue; String schemaName = parts[0].trim(); String tableName = parts[1].trim(); - if (schemaName.length() == 0 || tableName.length() == 0) + if (schemaName.isEmpty() || tableName.isEmpty()) continue; track(schemaName, tableName, noref); } diff --git a/api/src/org/labkey/api/data/UserDefinedButtonConfig.java b/api/src/org/labkey/api/data/UserDefinedButtonConfig.java index 1afa1b629a8..c46456b4a1a 100644 --- a/api/src/org/labkey/api/data/UserDefinedButtonConfig.java +++ b/api/src/org/labkey/api/data/UserDefinedButtonConfig.java @@ -201,7 +201,7 @@ private String processURL(RenderContext ctx, String url) private void processURLs(RenderContext ctx, NavTree tree) { - if (tree.getHref() != null && tree.getHref().length() > 0) + if (tree.getHref() != null && !tree.getHref().isEmpty()) tree.setHref(processURL(ctx, tree.getHref())); for (NavTree child : tree.getChildren()) processURLs(ctx, child); @@ -212,11 +212,10 @@ private String getWrappedOnClick(RenderContext ctx, String originalOnClick) if (originalOnClick == null) return null; - StringBuilder onClickWrapper = new StringBuilder(); - onClickWrapper.append("var dataRegionName = ").append(PageFlowUtil.jsString(ctx.getCurrentRegion().getName())).append("; "); - onClickWrapper.append("var dataRegion = LABKEY.DataRegions[dataRegionName]; "); - onClickWrapper.append(originalOnClick); - return onClickWrapper.toString(); + String onClickWrapper = "var dataRegionName = " + PageFlowUtil.jsString(ctx.getCurrentRegion().getName()) + "; " + + "var dataRegion = LABKEY.DataRegions[dataRegionName]; " + + originalOnClick; + return onClickWrapper; } @Override diff --git a/api/src/org/labkey/api/data/UserSchemaCustomizer.java b/api/src/org/labkey/api/data/UserSchemaCustomizer.java index adcd4b912c8..96c5423a628 100644 --- a/api/src/org/labkey/api/data/UserSchemaCustomizer.java +++ b/api/src/org/labkey/api/data/UserSchemaCustomizer.java @@ -63,7 +63,7 @@ public static UserSchemaCustomizer create(SchemaCustomizerType xmlSchemaCustomiz return null; String className = xmlSchemaCustomizer.getClass1(); - if (className == null || className.length() == 0) + if (className == null || className.isEmpty()) throw new MinorConfigurationException("Schema customizer requires class attribute"); try diff --git a/api/src/org/labkey/api/data/WhitespacePreservingDisplayColumnFactory.java b/api/src/org/labkey/api/data/WhitespacePreservingDisplayColumnFactory.java index db9141503d5..1f247f59739 100644 --- a/api/src/org/labkey/api/data/WhitespacePreservingDisplayColumnFactory.java +++ b/api/src/org/labkey/api/data/WhitespacePreservingDisplayColumnFactory.java @@ -17,7 +17,6 @@ import org.jetbrains.annotations.NotNull; import org.labkey.api.util.HtmlString; -import org.labkey.api.util.PageFlowUtil; /** * Renders the value in HTML preserving whitespace, including spaces and newlines. diff --git a/api/src/org/labkey/api/data/dialect/JdbcMetaDataTest.java b/api/src/org/labkey/api/data/dialect/JdbcMetaDataTest.java index 02f3443a4ea..597867da5f1 100644 --- a/api/src/org/labkey/api/data/dialect/JdbcMetaDataTest.java +++ b/api/src/org/labkey/api/data/dialect/JdbcMetaDataTest.java @@ -29,7 +29,7 @@ private void test(String viewName, TableInfo expected) { TableInfo testTable = _testSchema.getTable(viewName); assertNotNull("Failed to find view " + viewName, testTable); - assertEquals(testTable.getTableType(), DatabaseTableType.VIEW); + assertEquals(DatabaseTableType.VIEW, testTable.getTableType()); assertEquals(expected.getColumns().size(), testTable.getColumns().size()); assertEquals(new TableSelector(expected).getRowCount(), new TableSelector(testTable).getMapArray().length); } diff --git a/api/src/org/labkey/api/data/dialect/MutatingSqlDetector.java b/api/src/org/labkey/api/data/dialect/MutatingSqlDetector.java index b6e138dce59..47060eb05f8 100644 --- a/api/src/org/labkey/api/data/dialect/MutatingSqlDetector.java +++ b/api/src/org/labkey/api/data/dialect/MutatingSqlDetector.java @@ -158,7 +158,7 @@ public boolean character(char c, int index) } }); - return _firstWord.length() > 0; + return !_firstWord.isEmpty(); } public String getFirstWord() diff --git a/api/src/org/labkey/api/data/dialect/SqlDialect.java b/api/src/org/labkey/api/data/dialect/SqlDialect.java index 2dcd625ad7f..3ccc5fd4937 100644 --- a/api/src/org/labkey/api/data/dialect/SqlDialect.java +++ b/api/src/org/labkey/api/data/dialect/SqlDialect.java @@ -837,7 +837,7 @@ public SQLFragment getColumnSelectName(String columnName) return new SQLFragment().appendIdentifier(makeLegalIdentifier(columnName)); } - private Map _validatedIds = new HashMap<>(); + private final Map _validatedIds = new HashMap<>(); private boolean validateIdentifier(DatabaseIdentifier id) { @@ -1988,35 +1988,20 @@ public void setParamValue(Object value) /** * Queries the database in a dialect-specific way to determine the procedure's parameter names, datatypes, and directions. - * @param scope - * @param procSchema - * @param procName * @return A map of parameter name / ParameterInfo pairs - * @throws SQLException */ public abstract Map getParametersFromDbMetadata(DbScope scope, String procSchema, String procName) throws SQLException; /** * Build the dialect-specific string to call the procedure, with the correct number and placement of parameter placeholders * - * @param procSchema - * @param procName - * @param paramCount The total number of parameters to include in the invocation string - * @param hasReturn true if the procedure has a return code/status, false if not * @param assignResult true if the call string should include an assignment (e.g., "? = CALL...) Some dialects always need this; for others it is dependent on return type - * @param procScope - * @return */ public abstract String buildProcedureCall(String procSchema, String procName, int paramCount, boolean hasReturn, boolean assignResult, DbScope procScope); /** * Register and set the input value for each INPUT or INPUT/OUTPUT parameter from the parameters map into the CallableStatement, and register * the output parameters. - * @param scope - * @param stmt - * @param parameters - * @param registerOutputAssignment true if the assigned result (see buildProcedureCall) of the proc also needs to be registered as an output parameter - * @throws SQLException */ public abstract void registerParameters(DbScope scope, CallableStatement stmt, Map parameters, boolean registerOutputAssignment) throws SQLException; diff --git a/api/src/org/labkey/api/data/generator/DataGenerator.java b/api/src/org/labkey/api/data/generator/DataGenerator.java index 760396cb66d..f6681316aa5 100644 --- a/api/src/org/labkey/api/data/generator/DataGenerator.java +++ b/api/src/org/labkey/api/data/generator/DataGenerator.java @@ -109,7 +109,7 @@ public class DataGenerator implements ContainerU protected Map _sampleTypeCounts = new HashMap<>(); protected Map _dataClassCounts = new HashMap<>(); - public record NamingPatternData(String prefix, Long startGenId) {}; + public record NamingPatternData(String prefix, Long startGenId) {} // Map from type name to a pair of name prefix and suffix (genId) start value // TODO perhaps not needed anymore since we can select somewhat randomly from existing samples? @@ -141,6 +141,7 @@ public DataGenerator(PipelineJob job, T config) _config = config; } + @Override public Container getContainer() { return _container; @@ -151,6 +152,7 @@ public void setContainer(Container container) _container = container; } + @Override public User getUser() { return _user; diff --git a/api/src/org/labkey/api/data/generator/DataGeneratorRegistry.java b/api/src/org/labkey/api/data/generator/DataGeneratorRegistry.java index e1384a9abbc..997f53b74ad 100644 --- a/api/src/org/labkey/api/data/generator/DataGeneratorRegistry.java +++ b/api/src/org/labkey/api/data/generator/DataGeneratorRegistry.java @@ -13,7 +13,7 @@ public enum DataType { WorkflowJobs, Notebooks, PlateSets, - }; + } private static final Map _dataGeneratorMap = new HashMap<>(); diff --git a/api/src/org/labkey/api/data/measurement/Measurement.java b/api/src/org/labkey/api/data/measurement/Measurement.java index 7b45ccb06f5..85f7c8b73f7 100644 --- a/api/src/org/labkey/api/data/measurement/Measurement.java +++ b/api/src/org/labkey/api/data/measurement/Measurement.java @@ -25,7 +25,7 @@ public enum Kind { Mass, Volume, - Count; + Count } public enum Unit @@ -453,11 +453,11 @@ public void testEquals() { Measurement measurement = new Measurement("43.2", "g", "milligrams"); assertNotEquals("non-unit object", "43.2 g", measurement); - assertNotEquals("different amounts", measurement, new Measurement("23.4", "g", "milligrams")); - assertEquals("same units", measurement, new Measurement("43.2", "g", "mg")); - assertEquals("different units", measurement, new Measurement("43200", "mg", "mg")); - assertEquals("no normalizing unit", measurement, new Measurement("43200", "mg", null)); - assertEquals("case-insensitive", measurement, new Measurement("43200", "MilliGRAMS", null)); + assertNotEquals("different amounts", new Measurement("23.4", "g", "milligrams"), measurement); + assertEquals("same units", new Measurement("43.2", "g", "mg"), measurement); + assertEquals("different units", new Measurement("43200", "mg", "mg"), measurement); + assertEquals("no normalizing unit", new Measurement("43200", "mg", null), measurement); + assertEquals("case-insensitive", new Measurement("43200", "MilliGRAMS", null), measurement); } @Test diff --git a/api/src/org/labkey/api/data/statistics/CurveFit.java b/api/src/org/labkey/api/data/statistics/CurveFit.java index c836b2aed4b..48deec62bf3 100644 --- a/api/src/org/labkey/api/data/statistics/CurveFit.java +++ b/api/src/org/labkey/api/data/statistics/CurveFit.java @@ -44,25 +44,21 @@ default JSONObject toJSON() /** * Sets the data that this curve fit will be applied to. - * @param data */ void setData(DoublePoint[] data); /** * Returns the data associated with this curve fit. - * @return */ DoublePoint[] getData(); /** * Returns the parameters necessary to represent the fitted curve - * @return */ P getParameters() throws FitFailedException; /** * Initialize parameters using an external source - * @param parameters */ void setParameters(P parameters); void setParameters(JSONObject json); @@ -77,7 +73,6 @@ default JSONObject toJSON() /** * Sets whether all calculations and points generated are performed using a log base 10 X axis scale. By default * this is set to true. - * @param logXScale */ void setLogXScale(boolean logXScale); @@ -96,7 +91,6 @@ default JSONObject toJSON() /** * Calculates the fit error : r squared (or coefficient of determination) of the fitted curve - * @return */ double getFitError() throws FitFailedException; diff --git a/api/src/org/labkey/api/data/statistics/StatsService.java b/api/src/org/labkey/api/data/statistics/StatsService.java index 42d5a69da09..19e5ca9ac6c 100644 --- a/api/src/org/labkey/api/data/statistics/StatsService.java +++ b/api/src/org/labkey/api/data/statistics/StatsService.java @@ -18,7 +18,6 @@ import org.jetbrains.annotations.Nullable; import org.labkey.api.services.ServiceRegistry; -import java.awt.geom.Arc2D; import java.util.Arrays; import java.util.Collection; @@ -48,10 +47,10 @@ enum CurveFitType LINEAR("Linear", "linear"), NONE("None", "none"); - private String _label; - private String _colSuffix; + private final String _label; + private final String _colSuffix; - private CurveFitType(String label, String colSuffix) + CurveFitType(String label, String colSuffix) { _label = label; _colSuffix = colSuffix; @@ -94,9 +93,9 @@ enum AUCType POSITIVE("Positive"), NEGATIVE("Negative"); - private String _label; + private final String _label; - private AUCType(String label) + AUCType(String label) { _label = label; } @@ -110,7 +109,6 @@ public String getLabel() /** * Factory to return a statistics instance for the specified data * @param data an array of data to compute statistics over - * @return */ MathStat getStats(double[] data); MathStat getStats(Collection data); diff --git a/api/src/org/labkey/api/data/triggers/ScriptTriggerFactory.java b/api/src/org/labkey/api/data/triggers/ScriptTriggerFactory.java index 920d993ceb3..a8a51a41c41 100644 --- a/api/src/org/labkey/api/data/triggers/ScriptTriggerFactory.java +++ b/api/src/org/labkey/api/data/triggers/ScriptTriggerFactory.java @@ -59,7 +59,7 @@ public Collection createTrigger(@Nullable Container c, TableInfo table, } catch (ScriptException e) { - throw new UnexpectedException(e); + throw UnexpectedException.wrap(e); } } diff --git a/api/src/org/labkey/api/data/validator/LengthValidator.java b/api/src/org/labkey/api/data/validator/LengthValidator.java index 3ad883c46a4..2aace6b1984 100644 --- a/api/src/org/labkey/api/data/validator/LengthValidator.java +++ b/api/src/org/labkey/api/data/validator/LengthValidator.java @@ -33,9 +33,8 @@ public LengthValidator(String columnName, int scale) @Override public String _validate(int rowNum, Object value) { - if (value instanceof String) + if (value instanceof String s) { - String s = (String)value; if (s.length() > scale) return "Value is too long for column '" + _columnName + "', a maximum length of " + scale + " is allowed. The supplied value, '" + StringUtils.abbreviateMiddle(s, "...", 50) + "', was " + s.length() + " characters long."; } diff --git a/api/src/org/labkey/api/data/validator/NumberValidator.java b/api/src/org/labkey/api/data/validator/NumberValidator.java index 30ac5c26df7..49e00619cba 100644 --- a/api/src/org/labkey/api/data/validator/NumberValidator.java +++ b/api/src/org/labkey/api/data/validator/NumberValidator.java @@ -30,10 +30,10 @@ public String _validate(int rowNum, Object value) { if (!(value instanceof Number)) return null; - Double d = ((Number)value).doubleValue(); - if (d.isInfinite()) + double d = ((Number)value).doubleValue(); + if (Double.isInfinite(d)) return "Infinity is not a valid value for column '" + _columnName + "'"; - if (d.isNaN()) + if (Double.isNaN(d)) return "NaN is not a valid value for column '" + _columnName + "'"; return null; } diff --git a/api/src/org/labkey/api/data/validator/RequiredValidator.java b/api/src/org/labkey/api/data/validator/RequiredValidator.java index d4de9097f2b..5c26a25fe9a 100644 --- a/api/src/org/labkey/api/data/validator/RequiredValidator.java +++ b/api/src/org/labkey/api/data/validator/RequiredValidator.java @@ -42,17 +42,16 @@ protected String _validate(int rowNum, Object value) if (null == value) break checkRequired; - if (value instanceof String && ((String)value).length() == 0) + if (value instanceof String && ((String) value).isEmpty()) { if (allowES) return null; else break checkRequired; } - if (!(value instanceof MvFieldWrapper)) + if (!(value instanceof MvFieldWrapper mv)) return null; - MvFieldWrapper mv = (MvFieldWrapper)value; if (null != mv.getValue()) return null; diff --git a/api/src/org/labkey/api/data/validator/RowValidator.java b/api/src/org/labkey/api/data/validator/RowValidator.java index bb88fc1e6c3..bffe8bb5c2c 100644 --- a/api/src/org/labkey/api/data/validator/RowValidator.java +++ b/api/src/org/labkey/api/data/validator/RowValidator.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.labkey.api.data.validator; - -public interface RowValidator -{ - // CONSIDER: pass a row map or DataIterator? - public String validate(); -} +package org.labkey.api.data.validator; + +public interface RowValidator +{ + // CONSIDER: pass a row map or DataIterator? + String validate(); +} diff --git a/api/src/org/labkey/api/data/views/DataViewProvider.java b/api/src/org/labkey/api/data/views/DataViewProvider.java index 1cb705dac92..b958dfc8529 100644 --- a/api/src/org/labkey/api/data/views/DataViewProvider.java +++ b/api/src/org/labkey/api/data/views/DataViewProvider.java @@ -31,7 +31,7 @@ */ public interface DataViewProvider { - public interface Type + interface Type { String getName(); String getDescription(); @@ -67,11 +67,10 @@ default List getViews(ViewContext context, @Nullable String schema * Perform any first time initialization of the provider before a request to return views, this * is generally called once per provider to perform any first time initialization. * - * @param context */ void initialize(ContainerUser context) throws Exception; - public interface EditInfo + interface EditInfo { // the list of actions that are allowed enum Actions @@ -122,7 +121,6 @@ enum ThumbnailType * @param id the unique identifier for the data object being updated. * @param props the map of properties that are changing * - * @throws org.labkey.api.query.ValidationException */ void validateProperties(Container container, User user, String id, Map props) throws ValidationException; @@ -132,22 +130,17 @@ enum ThumbnailType * @param id the unique identifier for the data object being updated. * @param props the map of properties to update * - * @throws Exception */ void updateProperties(ViewContext context, String id, Map props) throws Exception; /** * Return the array of actions that this edit provider supports - * @param container - * @param user - * @return */ Actions[] getAllowableActions(Container container, User user); /** * Deletes the view identified by the id * @param id the unique identifier for the data object being updated. - * @throws ValidationException */ void deleteView(Container container, User user, String id) throws ValidationException; } diff --git a/api/src/org/labkey/api/data/views/DefaultProviderType.java b/api/src/org/labkey/api/data/views/DefaultProviderType.java index d86951774fb..dc520083968 100644 --- a/api/src/org/labkey/api/data/views/DefaultProviderType.java +++ b/api/src/org/labkey/api/data/views/DefaultProviderType.java @@ -21,9 +21,9 @@ */ public class DefaultProviderType implements DataViewProvider.Type { - private String _name; - private String _description; - private boolean _showByDefault; + private final String _name; + private final String _description; + private final boolean _showByDefault; public DefaultProviderType(String name, String description, boolean showByDefault) { @@ -62,10 +62,9 @@ public int hashCode() @Override public boolean equals(Object obj) { - if (!(obj instanceof DefaultProviderType)) + if (!(obj instanceof DefaultProviderType type)) return false; - DefaultProviderType type = (DefaultProviderType)obj; if (!type.getName().equals(this.getName())) return false; return true; diff --git a/api/src/org/labkey/api/data/views/DefaultViewInfo.java b/api/src/org/labkey/api/data/views/DefaultViewInfo.java index 9c6fc0b2756..3ce7425e6ed 100644 --- a/api/src/org/labkey/api/data/views/DefaultViewInfo.java +++ b/api/src/org/labkey/api/data/views/DefaultViewInfo.java @@ -34,11 +34,11 @@ */ public class DefaultViewInfo implements DataViewInfo { - private String _id; + private final String _id; private String _reportId; - private DataViewProvider.Type _dataType; - private String _name; - private Container _container; + private final DataViewProvider.Type _dataType; + private final String _name; + private final Container _container; private String _type; private String _description; diff --git a/api/src/org/labkey/api/data/views/ProviderType.java b/api/src/org/labkey/api/data/views/ProviderType.java index f2479537c7b..b532d5603cc 100644 --- a/api/src/org/labkey/api/data/views/ProviderType.java +++ b/api/src/org/labkey/api/data/views/ProviderType.java @@ -21,9 +21,9 @@ */ public class ProviderType implements DataViewProvider.Type { - private String _name; - private String _description; - private boolean _showByDefault; + private final String _name; + private final String _description; + private final boolean _showByDefault; public ProviderType(String name, String description, boolean showByDefault) { @@ -62,10 +62,9 @@ public int hashCode() @Override public boolean equals(Object obj) { - if (!(obj instanceof ProviderType)) + if (!(obj instanceof ProviderType type)) return false; - ProviderType type = (ProviderType)obj; if (!type.getName().equals(this.getName())) return false; return true; diff --git a/api/src/org/labkey/api/dataiterator/AbstractDataIterator.java b/api/src/org/labkey/api/dataiterator/AbstractDataIterator.java index 646e1897726..bfc86a47044 100644 --- a/api/src/org/labkey/api/dataiterator/AbstractDataIterator.java +++ b/api/src/org/labkey/api/dataiterator/AbstractDataIterator.java @@ -23,10 +23,10 @@ import java.util.HashSet; import java.util.Map; +import java.util.Objects; import java.util.Set; import static org.apache.commons.lang3.StringUtils.defaultIfBlank; -import static org.apache.commons.lang3.StringUtils.defaultString; /** * User: matthewb @@ -61,7 +61,7 @@ public AbstractDataIterator setDebugName(String name) @Override public String getDebugName() { - return defaultString(_debugName, getClass().getSimpleName()); + return Objects.toString(_debugName, getClass().getSimpleName()); } diff --git a/api/src/org/labkey/api/dataiterator/AttachmentDataIterator.java b/api/src/org/labkey/api/dataiterator/AttachmentDataIterator.java index 435a0b57a1c..926f6a516e8 100644 --- a/api/src/org/labkey/api/dataiterator/AttachmentDataIterator.java +++ b/api/src/org/labkey/api/dataiterator/AttachmentDataIterator.java @@ -91,7 +91,7 @@ public boolean next() for (_AttachmentUploadHelper p : attachmentColumns) { Object attachmentValue = get(p.index); - String filename = null; + String filename; AttachmentFile attachmentFile; if (null == attachmentValue) diff --git a/api/src/org/labkey/api/dataiterator/DataIteratorUtil.java b/api/src/org/labkey/api/dataiterator/DataIteratorUtil.java index 3d2acfbd109..f72bce5f1a7 100644 --- a/api/src/org/labkey/api/dataiterator/DataIteratorUtil.java +++ b/api/src/org/labkey/api/dataiterator/DataIteratorUtil.java @@ -186,8 +186,6 @@ public String getMatchedName(@Nullable String name) /** * Update rowMap content based on passed in col. * For example, the original rowMap may contain encoded field name. This util substitute the key in rowMap to reflect the actual col name - * @param col - * @param rowMap * @return If rowMap has been updated */ public boolean updateRowMap(@NotNull ColumnInfo col, Map rowMap) diff --git a/api/src/org/labkey/api/dataiterator/LoggingDataIterator.java b/api/src/org/labkey/api/dataiterator/LoggingDataIterator.java index d1b1dad8ca8..2b2e31cf535 100644 --- a/api/src/org/labkey/api/dataiterator/LoggingDataIterator.java +++ b/api/src/org/labkey/api/dataiterator/LoggingDataIterator.java @@ -33,7 +33,7 @@ public class LoggingDataIterator extends AbstractDataIterator implements ScrollableDataIterator, MapDataIterator { static Logger _staticLog = LogHelper.getLogger(LoggingDataIterator.class, "Transformations and mappings during many types of data imports and ETLs"); - Logger _log = _staticLog; + Logger _log; Level _pri = Level.DEBUG; DataIterator _data; diff --git a/api/src/org/labkey/api/dataiterator/MapDataIterator.java b/api/src/org/labkey/api/dataiterator/MapDataIterator.java index fdfb55f5636..c1810858df4 100644 --- a/api/src/org/labkey/api/dataiterator/MapDataIterator.java +++ b/api/src/org/labkey/api/dataiterator/MapDataIterator.java @@ -16,18 +16,14 @@ package org.labkey.api.dataiterator; import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.labkey.api.collections.ArrayListMap; import org.labkey.api.collections.CaseInsensitiveHashMap; -import org.labkey.api.collections.CaseInsensitiveHashSet; import org.labkey.api.collections.CaseInsensitiveTreeSet; import org.labkey.api.data.ColumnInfo; import org.labkey.api.query.BatchValidationException; -import org.labkey.api.util.ExceptionUtil; import org.labkey.api.util.logging.LogHelper; -import org.labkey.api.view.HttpView; import java.io.IOException; import java.util.ArrayList; diff --git a/api/src/org/labkey/api/dataiterator/NameExpressionDataIterator.java b/api/src/org/labkey/api/dataiterator/NameExpressionDataIterator.java index 0f8a3e49200..0ead39c9aac 100644 --- a/api/src/org/labkey/api/dataiterator/NameExpressionDataIterator.java +++ b/api/src/org/labkey/api/dataiterator/NameExpressionDataIterator.java @@ -35,17 +35,17 @@ public class NameExpressionDataIterator extends WrapperDataIterator { private final DataIteratorContext _context; - private Map> _nameGeneratorMap = new HashMap<>(); - private Map _newNames = new HashMap<>(); + private final Map> _nameGeneratorMap = new HashMap<>(); + private final Map _newNames = new HashMap<>(); private final Integer _nameCol; - private Integer _expressionCol; - private TableInfo _parentTable; - private Container _container; - private Function _getNonConflictCountFn; - private String _counterSeqPrefix; + private final Integer _expressionCol; + private final TableInfo _parentTable; + private final Container _container; + private final Function _getNonConflictCountFn; + private final String _counterSeqPrefix; private boolean _allowUserSpecifiedNames = true; // whether manual names specification is allowed or only name expression generation - private List>> _extraPropsFns = new ArrayList<>(); - private Map _importAliases = null; + private final List>> _extraPropsFns = new ArrayList<>(); + private Map _importAliases; public NameExpressionDataIterator(DataIterator di, DataIteratorContext context, @Nullable TableInfo parentTable, @Nullable Container container, Function getNonConflictCountFn, String counterSeqPrefix, @Nullable Map importAliases) { diff --git a/api/src/org/labkey/api/dataiterator/QueryDataIteratorBuilder.java b/api/src/org/labkey/api/dataiterator/QueryDataIteratorBuilder.java index 5357c0641c9..7ed127c15a4 100644 --- a/api/src/org/labkey/api/dataiterator/QueryDataIteratorBuilder.java +++ b/api/src/org/labkey/api/dataiterator/QueryDataIteratorBuilder.java @@ -39,8 +39,6 @@ import java.util.List; import java.util.Map; -import static org.labkey.api.data.DataRegion.MessagePart.filter; - /** * User: matthew * Date: 5/11/13 @@ -85,7 +83,7 @@ public QueryDataIteratorBuilder(QuerySchema schema, String query, String sql, Si _schema = schema; _container = _schema.getContainer(); _user = _schema.getUser(); - _schemaKey = ((UserSchema)_schema).getSchemaPath(); + _schemaKey = _schema.getSchemaPath(); _queryName = query; _sql = sql; diff --git a/api/src/org/labkey/api/dataiterator/SimpleTranslator.java b/api/src/org/labkey/api/dataiterator/SimpleTranslator.java index 593b9c38f97..2d0561be275 100644 --- a/api/src/org/labkey/api/dataiterator/SimpleTranslator.java +++ b/api/src/org/labkey/api/dataiterator/SimpleTranslator.java @@ -542,7 +542,6 @@ public Object get() * @param isDerivationField if this field is a child only field * @param presentDerivationWarning the warning msg to log if a child field is present for a parent record * @param presentNonDerivationWarning the warning msg to log if a parent field is present for a child record - * @return */ private Object getDerivationData(Object thisValue, int derivationDataColInd, boolean isDerivationField, @Nullable String presentDerivationWarning, @Nullable String presentNonDerivationWarning) { @@ -828,7 +827,7 @@ public Object convert(Object value) { if (!validMissingValue(mv)) { - getRowError().addFieldError(_data.getColumnInfo(index).getName(),"Value is not a valid missing value indicator: " + mv.toString()); + getRowError().addFieldError(_data.getColumnInfo(index).getName(),"Value is not a valid missing value indicator: " + mv); return null; } @@ -1035,7 +1034,7 @@ else if (_missing == RemapMissingBehavior.Null) } } - protected class NullColumn implements Supplier + protected static class NullColumn implements Supplier { @Override public Object get() @@ -1703,7 +1702,7 @@ protected class PairedSequenceColumn implements Supplier private final int _batchSize; // sequence state - private Map _sequences = new HashMap<>(); + private final Map _sequences = new HashMap<>(); public PairedSequenceColumn(@Nullable Integer columnIndex, Container seqContainer, String sequencePrefix, CounterDefinition counterDefinition, List pairedIndexes, @Nullable Integer seqId, @Nullable Integer batchSize) { @@ -1820,7 +1819,7 @@ protected class FileColumn implements Supplier private final int _index; private final String _dirName; private final String _fileRootPath; - private Map _savedFiles = new HashMap<>(); + private final Map _savedFiles = new HashMap<>(); public FileColumn(User user, Container c, String name, int idx, String dirName, String fileRootPath) { @@ -2001,9 +2000,8 @@ public Object getConstantValue(int i) return _data.getConstantValue(((PassthroughColumn)c).index); if (c instanceof AliasColumn) return getConstantValue(((AliasColumn)c).index); - if (c instanceof SimpleConvertColumn) + if (c instanceof SimpleConvertColumn scc) { - SimpleConvertColumn scc = (SimpleConvertColumn)c; return scc.convert(_data.getConstantValue(scc.index)); } if (c instanceof TimestampColumn) diff --git a/api/src/org/labkey/api/dataiterator/StatementDataIterator.java b/api/src/org/labkey/api/dataiterator/StatementDataIterator.java index 7ace4293c30..aeb3a9650fb 100644 --- a/api/src/org/labkey/api/dataiterator/StatementDataIterator.java +++ b/api/src/org/labkey/api/dataiterator/StatementDataIterator.java @@ -206,7 +206,7 @@ void init() (null != mvName ? getMvParameter(stmt, mvName) : null))); } } - _bindings[set] = bindings.toArray(new Triple[bindings.size()]); + _bindings[set] = bindings.toArray(new Triple[0]); } _currentStmt = _stmts[0]; _currentBinding = _bindings[0]; diff --git a/api/src/org/labkey/api/dataiterator/TableInsertDataIteratorBuilder.java b/api/src/org/labkey/api/dataiterator/TableInsertDataIteratorBuilder.java index 91f439b860d..d0db0708b9b 100644 --- a/api/src/org/labkey/api/dataiterator/TableInsertDataIteratorBuilder.java +++ b/api/src/org/labkey/api/dataiterator/TableInsertDataIteratorBuilder.java @@ -16,7 +16,7 @@ public class TableInsertDataIteratorBuilder implements DataIteratorBuilder final Container container; Set keyColumns = null; Set addlSkipColumns = null; - Set dontUpdate = null; + Set dontUpdate; boolean commitRowsBeforeContinuing = false; private Set vocabularyProperties; Map remapSchemaColumns = null; diff --git a/api/src/org/labkey/api/dataiterator/TableInsertUpdateDataIterator.java b/api/src/org/labkey/api/dataiterator/TableInsertUpdateDataIterator.java index 2e7e377fd11..f007536ebf4 100644 --- a/api/src/org/labkey/api/dataiterator/TableInsertUpdateDataIterator.java +++ b/api/src/org/labkey/api/dataiterator/TableInsertUpdateDataIterator.java @@ -64,7 +64,7 @@ public class TableInsertUpdateDataIterator extends StatementDataIterator impleme private Set _adhocPropColumns = new LinkedHashSet<>(); private boolean _skipCurrentIterator = false; // if StatementUtils generates a bad or meaningless (empty) statement, skip this iterator - private boolean _failOnEmptyUpdate; + private final boolean _failOnEmptyUpdate; private boolean _preferPKOverObjectUriAsKey = false; @@ -140,7 +140,7 @@ public static DataIterator create(DataIteratorBuilder data, TableInfo table, @Nu ret = emb; } - if (null != vocabularyColumns && vocabularyColumns.size() > 0) + if (null != vocabularyColumns && !vocabularyColumns.isEmpty()) { ti.setAdhocPropColumns(vocabularyColumns); } diff --git a/api/src/org/labkey/api/dataiterator/WrapperDataIterator.java b/api/src/org/labkey/api/dataiterator/WrapperDataIterator.java index 2498182fa5f..8c8b6189354 100644 --- a/api/src/org/labkey/api/dataiterator/WrapperDataIterator.java +++ b/api/src/org/labkey/api/dataiterator/WrapperDataIterator.java @@ -15,12 +15,12 @@ */ package org.labkey.api.dataiterator; -import org.apache.commons.lang3.StringUtils; import org.labkey.api.data.ColumnInfo; import org.labkey.api.query.BatchValidationException; import java.io.IOException; import java.util.Map; +import java.util.Objects; /** * User: matthewb @@ -45,7 +45,7 @@ public void setDebugName(String name) @Override public String getDebugName() { - return StringUtils.defaultString(_debugName, getClass().getSimpleName()); + return Objects.toString(_debugName, getClass().getSimpleName()); } @Override diff --git a/api/src/org/labkey/api/defaults/DefaultValueService.java b/api/src/org/labkey/api/defaults/DefaultValueService.java index 50a79feb0b8..f2b5e93eb62 100644 --- a/api/src/org/labkey/api/defaults/DefaultValueService.java +++ b/api/src/org/labkey/api/defaults/DefaultValueService.java @@ -40,7 +40,7 @@ public interface DefaultValueService { - static final String DOMAIN_DEFAULT_VALUE_LSID_PREFIX = "DomainDefaultValue"; + String DOMAIN_DEFAULT_VALUE_LSID_PREFIX = "DomainDefaultValue"; static DefaultValueService get() { diff --git a/api/src/org/labkey/api/docker/DockerService.java b/api/src/org/labkey/api/docker/DockerService.java index 4edca2f1d71..6fa0fe602ca 100644 --- a/api/src/org/labkey/api/docker/DockerService.java +++ b/api/src/org/labkey/api/docker/DockerService.java @@ -109,7 +109,7 @@ enum DockerConfigKey appArmorProfile("APPARMOR_PROFILE"), labKeyHostIP("LABKEY_HOST_IP"); - private String _altName; + private final String _altName; private boolean _isInt = false; DockerConfigKey(String altName) @@ -286,6 +286,7 @@ default ImageConfigBuilder addWritableVolume(String imagePath, String hostPath) ImageConfigBuilder setCapDrops(String... capDrops); + @Override ImageConfig build(); } diff --git a/api/src/org/labkey/api/exp/AbstractParameter.java b/api/src/org/labkey/api/exp/AbstractParameter.java index 8a8e28d8113..33ad142c805 100644 --- a/api/src/org/labkey/api/exp/AbstractParameter.java +++ b/api/src/org/labkey/api/exp/AbstractParameter.java @@ -280,14 +280,7 @@ else if (type.equals(SimpleTypeNames.PROPERTY_URI)) val = stringValue; } } - catch (ConversionException e) - { - log.error("Failed to load value " + stringValue - + ". Declared as type ;" + type + "' Saved as string instead"); - type = SimpleTypeNames.STRING; - val = stringValue; - } - catch (NumberFormatException e) + catch (ConversionException | NumberFormatException e) { log.error("Failed to load value " + stringValue + ". Declared as type ;" + type + "' Saved as string instead"); diff --git a/api/src/org/labkey/api/exp/DuplicateMaterialException.java b/api/src/org/labkey/api/exp/DuplicateMaterialException.java index cde47d27230..c14bf5b0354 100644 --- a/api/src/org/labkey/api/exp/DuplicateMaterialException.java +++ b/api/src/org/labkey/api/exp/DuplicateMaterialException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + package org.labkey.api.exp; /** @@ -22,7 +22,7 @@ */ public class DuplicateMaterialException extends ExperimentException { - private String _colName; + private final String _colName; public DuplicateMaterialException(String message, String colName) { diff --git a/api/src/org/labkey/api/exp/ExperimentRunListView.java b/api/src/org/labkey/api/exp/ExperimentRunListView.java index dde3a595b5b..ce5827a8c43 100644 --- a/api/src/org/labkey/api/exp/ExperimentRunListView.java +++ b/api/src/org/labkey/api/exp/ExperimentRunListView.java @@ -188,7 +188,7 @@ protected void populateButtonBar(DataView view, ButtonBar bar) addToExperimentButton.addMenuItem("Create new run group...", javascript); List experiments = ExperimentService.get().getExperiments(c, getViewContext().getUser(), true, false); - if (experiments.size() > 0) + if (!experiments.isEmpty()) { addToExperimentButton.addSeparator(); } diff --git a/api/src/org/labkey/api/exp/ImportTypesHelper.java b/api/src/org/labkey/api/exp/ImportTypesHelper.java index fecdf3969bd..811dd90b495 100644 --- a/api/src/org/labkey/api/exp/ImportTypesHelper.java +++ b/api/src/org/labkey/api/exp/ImportTypesHelper.java @@ -221,7 +221,7 @@ public static ImportPropertyDescriptorsList getImportPropertyDescriptors(Collect String columnName = pd.getName(); - if (columnName.length() == 0) + if (columnName.isEmpty()) { String e = "'property' field is required"; if (!errors.contains(e)) @@ -242,7 +242,7 @@ public static ImportPropertyDescriptorsList getImportPropertyDescriptors(Collect pd.setContainer(container); String propertyURI = StringUtils.trimToEmpty(pd.getPropertyURI()); - if (propertyURI.length() == 0) + if (propertyURI.isEmpty()) { pd.setPropertyURI(domainURI + "." + Lsid.encodePart(columnName)); } @@ -288,7 +288,7 @@ public static ImportPropertyDescriptorsList getImportPropertyDescriptors(Collect public static class Builder implements org.labkey.api.data.Builder, MutableColumnConceptProperties { private PropertyType _type; - private Container _container; + private final Container _container; private String _propertyURI; private String _name; private String _label; diff --git a/api/src/org/labkey/api/exp/Lsid.java b/api/src/org/labkey/api/exp/Lsid.java index c4d815a22a1..847b339bebc 100644 --- a/api/src/org/labkey/api/exp/Lsid.java +++ b/api/src/org/labkey/api/exp/Lsid.java @@ -33,6 +33,7 @@ import java.net.URLDecoder; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.Objects; import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase; import static org.apache.commons.lang3.StringUtils.repeat; @@ -62,7 +63,7 @@ public Lsid(String s) this.src = b.src; this.authority = b.getAuthority(); this.namespace = b.getNamespace(); - this.objectId = StringUtils.defaultString(b.getObjectId(),""); + this.objectId = Objects.toString(b.getObjectId(),""); this.version = b.getVersion(); this.valid = b.valid; } @@ -81,7 +82,7 @@ public Lsid(String namespace, String objectId) this.src = b.src; this.authority = b.getAuthority(); this.namespace = b.getNamespace(); - this.objectId = StringUtils.defaultString(b.getObjectId(),""); + this.objectId = Objects.toString(b.getObjectId(),""); this.version = b.getVersion(); this.valid = true; } @@ -100,7 +101,7 @@ public Lsid(String namespacePrefix, String namespaceSuffix, @NotNull String obje this.src = b.src; this.authority = b.getAuthority(); this.namespace = b.getNamespace(); - this.objectId = StringUtils.defaultString(b.getObjectId(),""); + this.objectId = Objects.toString(b.getObjectId(),""); this.version = b.getVersion(); this.valid = true; } @@ -111,7 +112,7 @@ private Lsid(String src, String authority, String namespace, String objectId, St this.src = src; this.authority = authority; this.namespace = namespace; - this.objectId = StringUtils.defaultString(objectId,""); + this.objectId = Objects.toString(objectId,""); this.version = version; this.valid = valid; } @@ -214,10 +215,9 @@ public boolean isValid() public boolean equals(Object o) { - if (null == o || !(o instanceof Lsid)) + if (null == o || !(o instanceof Lsid lsid)) return false; - Lsid lsid = (Lsid) o; if (!valid) return StringUtils.equals(toString(),lsid.toString()); @@ -244,7 +244,7 @@ public int hashCode() public String toString() { if (!valid) - return StringUtils.defaultString(src,""); + return Objects.toString(src,""); String encodedAuthority = encodePart(authority); String encodedNamespace = encodePart(namespace); @@ -351,7 +351,7 @@ public static class LsidBuilder implements Builder protected String namespace = ""; protected String objectId = ""; protected String version = null; - protected boolean valid = false; + protected boolean valid; private String prefix = ""; private String suffix = ""; @@ -467,7 +467,7 @@ public String toString() public String getAuthority() { - return StringUtils.defaultString(authority,""); + return Objects.toString(authority,""); } public LsidBuilder setAuthority(String authority) @@ -478,12 +478,12 @@ public LsidBuilder setAuthority(String authority) public String getNamespace() { - return StringUtils.defaultString(namespace, ""); + return Objects.toString(namespace, ""); } public String getObjectId() { - return StringUtils.defaultString(objectId, ""); + return Objects.toString(objectId, ""); } public LsidBuilder setObjectId(String objectId) @@ -688,7 +688,7 @@ public void testEncodeWithPlus() assertEquals("SampleSet", lsid.getNamespacePrefix()); assertEquals("Folder-4", lsid.getNamespaceSuffix()); assertEquals("Repro+Set", lsid.getObjectId()); - assertEquals(null, lsid.getVersion()); + assertNull(lsid.getVersion()); } @Test diff --git a/api/src/org/labkey/api/exp/ObjectProperty.java b/api/src/org/labkey/api/exp/ObjectProperty.java index f1af272521c..36f6923dc8a 100644 --- a/api/src/org/labkey/api/exp/ObjectProperty.java +++ b/api/src/org/labkey/api/exp/ObjectProperty.java @@ -139,9 +139,8 @@ private void init(String objectURI, Container container, String propertyURI, Pro this.typeTag = propertyType.getStorageType(); //TODO: For resource, need to override with known type this.rangeURI = propertyType.getTypeUri(); - if (value instanceof MvFieldWrapper) + if (value instanceof MvFieldWrapper wrapper) { - MvFieldWrapper wrapper = (MvFieldWrapper)value; this.mvIndicator = wrapper.getMvIndicator(); value = wrapper.getValue(); } @@ -242,10 +241,9 @@ public boolean equals(Object o) if (null == o) return false; - if (!(o instanceof ObjectProperty)) + if (!(o instanceof ObjectProperty pv)) return false; - ObjectProperty pv = (ObjectProperty) o; if (pv.getObjectId() != objectId || !pv.getPropertyURI().equals(propertyURI)) return false; diff --git a/api/src/org/labkey/api/exp/OntologyManager.java b/api/src/org/labkey/api/exp/OntologyManager.java index 2f8e5f75e63..c5fd1af0111 100644 --- a/api/src/org/labkey/api/exp/OntologyManager.java +++ b/api/src/org/labkey/api/exp/OntologyManager.java @@ -2714,7 +2714,7 @@ static ParameterMapStatement getUpdateStmt(Connection conn, User user, TableInfo public static void insertPropertyDescriptors(User user, List pds) throws SQLException { - if (null == pds || 0 == pds.size()) + if (null == pds || pds.isEmpty()) return; TableInfo t = getTinfoPropertyDescriptor(); try (Connection conn = t.getSchema().getScope().getConnection(); @@ -2736,7 +2736,7 @@ public static void insertPropertyDescriptors(User user, List public static void updatePropertyDescriptors(User user, List pds) throws SQLException { - if (null == pds || 0 == pds.size()) + if (null == pds || pds.isEmpty()) return; TableInfo t = getTinfoPropertyDescriptor(); try (Connection conn = t.getSchema().getScope().getConnection(); @@ -2790,7 +2790,6 @@ public static PropertyDescriptor updatePropertyDescriptor(PropertyDescriptor pd) * @param ownerObjectLsid The "owner" object or "parent" object, which isn't necessarily same as the object. For example, samples use the ExpSampleType as the owner object. * @param insertNullValues When true, a null value will be inserted if the value is null, otherwise any existing property value will be deleted if the value is null. * @return The inserted ObjectProperty or null - * @throws ValidationException */ public static ObjectProperty updateObjectProperty(User user, Container container, PropertyDescriptor pd, String lsid, Object value, @Nullable String ownerObjectLsid, boolean insertNullValues) throws ValidationException { @@ -2881,7 +2880,7 @@ public static PropertyUsages findPropertyUsages(@NotNull User user, @NotNull Pro List fields = List.of(objectId, objectId_objectURI, objectId_container); var colMap = QueryService.get().getColumns(getTinfoObjectProperty(), fields); - int usageCount = 0; + int usageCount; List objects = new ArrayList<>(maxUsageCount); SimpleFilter filter = new SimpleFilter(FieldKey.fromParts("propertyId"), pd.getPropertyId(), CompareType.EQUAL); diff --git a/api/src/org/labkey/api/exp/PropertyDescriptor.java b/api/src/org/labkey/api/exp/PropertyDescriptor.java index f607e384250..6f5884d1ef4 100644 --- a/api/src/org/labkey/api/exp/PropertyDescriptor.java +++ b/api/src/org/labkey/api/exp/PropertyDescriptor.java @@ -433,9 +433,8 @@ public boolean equals(Object obj) public void copyTo(ColumnRenderPropertiesImpl to) { super.copyTo(to); - if (to instanceof PropertyDescriptor) + if (to instanceof PropertyDescriptor toPD) { - PropertyDescriptor toPD = (PropertyDescriptor)to; toPD._containerId = _containerId; // ? toPD._lookupContainer = _lookupContainer; toPD._lookupSchema = _lookupSchema; diff --git a/api/src/org/labkey/api/exp/PropertyType.java b/api/src/org/labkey/api/exp/PropertyType.java index 5e454972298..c0978bd286d 100644 --- a/api/src/org/labkey/api/exp/PropertyType.java +++ b/api/src/org/labkey/api/exp/PropertyType.java @@ -924,7 +924,7 @@ public Object getPreviewValue(@Nullable String prefix) private final Class javaType; private final Class[] additionalTypes; - private static Map uriToProperty = null; + private static Map uriToProperty; private static Map xarToProperty = null; PropertyType(String typeURI, diff --git a/api/src/org/labkey/api/exp/TemplateInfo.java b/api/src/org/labkey/api/exp/TemplateInfo.java index 884e3a473a0..6826fdf51d1 100644 --- a/api/src/org/labkey/api/exp/TemplateInfo.java +++ b/api/src/org/labkey/api/exp/TemplateInfo.java @@ -17,7 +17,6 @@ import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.lang3.StringUtils; import org.labkey.api.data.JdbcType; import org.labkey.api.util.JsonUtil; diff --git a/api/src/org/labkey/api/exp/XarContext.java b/api/src/org/labkey/api/exp/XarContext.java index 2a4880b0323..880dd8f78b1 100644 --- a/api/src/org/labkey/api/exp/XarContext.java +++ b/api/src/org/labkey/api/exp/XarContext.java @@ -190,7 +190,7 @@ public File findFile(String path, File relativeFile) String pathWithDrive = path; if (null != drivePrefix) { - if (path.length() > 0 && path.charAt(0) != '\\' && path.charAt(0) != '/') + if (!path.isEmpty() && path.charAt(0) != '\\' && path.charAt(0) != '/') { pathWithDrive = drivePrefix + "/" + path; } diff --git a/api/src/org/labkey/api/exp/api/AssayDomainType.java b/api/src/org/labkey/api/exp/api/AssayDomainType.java index 170fe64f9ea..69d6bfa3f5d 100644 --- a/api/src/org/labkey/api/exp/api/AssayDomainType.java +++ b/api/src/org/labkey/api/exp/api/AssayDomainType.java @@ -23,8 +23,8 @@ */ public class AssayDomainType implements IAssayDomainType { - private String name; - private String prefix; + private final String name; + private final String prefix; AssayDomainType(String name) { diff --git a/api/src/org/labkey/api/exp/api/DataType.java b/api/src/org/labkey/api/exp/api/DataType.java index 97243197e79..481bde1b1c9 100644 --- a/api/src/org/labkey/api/exp/api/DataType.java +++ b/api/src/org/labkey/api/exp/api/DataType.java @@ -59,9 +59,7 @@ public boolean matches(Lsid lsid) public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof DataType)) return false; - - DataType dataType = (DataType) o; + if (!(o instanceof DataType dataType)) return false; return !(_namespacePrefix != null ? !_namespacePrefix.equals(dataType._namespacePrefix) : dataType._namespacePrefix != null); } diff --git a/api/src/org/labkey/api/exp/api/DefaultExperimentSaveHandler.java b/api/src/org/labkey/api/exp/api/DefaultExperimentSaveHandler.java index 16dcc57c32f..7f6bafd8014 100644 --- a/api/src/org/labkey/api/exp/api/DefaultExperimentSaveHandler.java +++ b/api/src/org/labkey/api/exp/api/DefaultExperimentSaveHandler.java @@ -147,7 +147,7 @@ public ExpExperiment handleBatch(ViewContext context, JSONObject batchJsonObject // Make sure that all the runs are considered part of the batch List runsToAdd = new ArrayList<>(runs); runsToAdd.removeAll(existingRuns); - batch.addRuns(context.getUser(), runsToAdd.toArray(new ExpRun[runsToAdd.size()])); + batch.addRuns(context.getUser(), runsToAdd.toArray(new ExpRun[0])); assert checkRunsInBatch(batch, runsToAdd) : "Runs should be in current batch: " + batch; // Remove any runs that are no longer part of the batch @@ -184,7 +184,7 @@ private boolean checkRunsInBatch(ExpExperiment batch, Collection runs) */ protected JSONArray serializeRunData(ViewContext context, ExpRun run, JSONObject runJson, ExpProtocol protocol, ExpExperiment batch) { - if (runJson.has(AssayJSONConverter.DATA_ROWS) && runJson.getJSONArray(AssayJSONConverter.DATA_ROWS).length() > 0) + if (runJson.has(AssayJSONConverter.DATA_ROWS) && !runJson.getJSONArray(AssayJSONConverter.DATA_ROWS).isEmpty()) { throw new UnsupportedOperationException("Run data is not supported for runs which are not associated with an Assay."); } diff --git a/api/src/org/labkey/api/exp/api/DomainKindDesign.java b/api/src/org/labkey/api/exp/api/DomainKindDesign.java index 64d304762a2..d122b9d3e09 100644 --- a/api/src/org/labkey/api/exp/api/DomainKindDesign.java +++ b/api/src/org/labkey/api/exp/api/DomainKindDesign.java @@ -1,6 +1,5 @@ package org.labkey.api.exp.api; -import com.fasterxml.jackson.databind.ObjectMapper; import org.labkey.api.gwt.client.model.GWTDomain; import org.labkey.api.util.JsonUtil; diff --git a/api/src/org/labkey/api/exp/api/ExpRunEditor.java b/api/src/org/labkey/api/exp/api/ExpRunEditor.java index 12bed4cfa30..cf9aa9097ad 100644 --- a/api/src/org/labkey/api/exp/api/ExpRunEditor.java +++ b/api/src/org/labkey/api/exp/api/ExpRunEditor.java @@ -10,9 +10,9 @@ */ public class ExpRunEditor { - private ActionURL _editUrl; - private String _displayName; - private String _protocolName; + private final ActionURL _editUrl; + private final String _displayName; + private final String _protocolName; public ExpRunEditor(String displayName, String protocolName, ActionURL editUrl) { diff --git a/api/src/org/labkey/api/exp/api/ExperimentJSONConverter.java b/api/src/org/labkey/api/exp/api/ExperimentJSONConverter.java index cf2a6450fba..b0ea3438c60 100644 --- a/api/src/org/labkey/api/exp/api/ExperimentJSONConverter.java +++ b/api/src/org/labkey/api/exp/api/ExperimentJSONConverter.java @@ -62,7 +62,6 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.TreeMap; import java.util.stream.Collectors; import static org.labkey.api.exp.api.ExpData.DATA_INPUTS_PREFIX; diff --git a/api/src/org/labkey/api/exp/api/ExperimentService.java b/api/src/org/labkey/api/exp/api/ExperimentService.java index 729dcb1f9af..5e369154827 100644 --- a/api/src/org/labkey/api/exp/api/ExperimentService.java +++ b/api/src/org/labkey/api/exp/api/ExperimentService.java @@ -832,7 +832,6 @@ static void validateParentAlias(Map aliasMap, Set reserv * subsequent steps will be organized sequentially. * @param user user with insert permissions * @return the saved ExpProtocol - * @throws ExperimentException */ ExpProtocol insertProtocol(@NotNull ExpProtocol baseProtocol, @Nullable List steps, @Nullable Map> predecessors, User user) throws ExperimentException; @@ -1077,8 +1076,6 @@ List getExpProtocolsWithParameterValue( * @param name The legacy name of the object * @param dataType: One of "SampleSet", "SampleType", "Material", "Sample", "Data", "DataClass" * @param effectiveDate The effective date that the legacy name was active - * @param c - * @param cf * @return The exp.object.rowId with legacy name at the effectiveDate of specified dataType */ Integer getObjectIdWithLegacyName(String name, String dataType, Date effectiveDate, Container c, @Nullable ContainerFilter cf); @@ -1137,8 +1134,6 @@ List getExpProtocolsWithParameterValue( /** * From a list of barcodes, find material lsids * @param uniqueIds A list of barcodes - * @param user - * @param container * @return map of barcode and lsid */ @NotNull Map> getUniqueIdLsids(List uniqueIds, User user, Container container); diff --git a/api/src/org/labkey/api/exp/api/FilterProtocolInputCriteria.java b/api/src/org/labkey/api/exp/api/FilterProtocolInputCriteria.java index 35bcc15e560..8c285f536d3 100644 --- a/api/src/org/labkey/api/exp/api/FilterProtocolInputCriteria.java +++ b/api/src/org/labkey/api/exp/api/FilterProtocolInputCriteria.java @@ -69,7 +69,7 @@ public FilterProtocolInputCriteria(@Nullable String config) } catch (URISyntaxException e) { - throw new UnexpectedException(e); + throw UnexpectedException.wrap(e); } } diff --git a/api/src/org/labkey/api/exp/api/ProvenanceService.java b/api/src/org/labkey/api/exp/api/ProvenanceService.java index 13ece654202..e98c48766b1 100644 --- a/api/src/org/labkey/api/exp/api/ProvenanceService.java +++ b/api/src/org/labkey/api/exp/api/ProvenanceService.java @@ -172,11 +172,8 @@ void deleteProvenanceByLsids( /** * Extract the provenance map information from the data rows * - * @param context - * @param params a ProvenanceRecordingParams object * @param rows the input rows * @param responseRows the inserted or updated rows - * @return */ List> createProvenanceMapFromRows(ViewContext context, ProvenanceRecordingParams params, JSONArray rows, List> responseRows); diff --git a/api/src/org/labkey/api/exp/api/SampleTypeDomainKind.java b/api/src/org/labkey/api/exp/api/SampleTypeDomainKind.java index 160160a7c16..e3c55d3286c 100644 --- a/api/src/org/labkey/api/exp/api/SampleTypeDomainKind.java +++ b/api/src/org/labkey/api/exp/api/SampleTypeDomainKind.java @@ -63,6 +63,7 @@ import org.labkey.api.security.permissions.DesignSampleTypePermission; import org.labkey.api.util.PageFlowUtil; import org.labkey.api.util.StringUtilsLabKey; +import org.labkey.api.util.UnexpectedException; import org.labkey.api.view.ActionURL; import org.labkey.api.view.NotFoundException; import org.labkey.api.writer.ContainerUser; @@ -399,7 +400,7 @@ public ValidationException updateDomain(GWTDomain domainDesign, Container container) { List errors = new ArrayList<>(); List warnings = new ArrayList<>(); @@ -444,7 +445,7 @@ public NameExpressionValidationResult validateNameExpressions(SampleTypeDomainKi } @Override - public void validateOptions(Container container, User user, SampleTypeDomainKindProperties options, String name, Domain domain, GWTDomain updatedDomainDesign) + public void validateOptions(Container container, User user, SampleTypeDomainKindProperties options, String name, Domain domain, GWTDomain updatedDomainDesign) { super.validateOptions(container, user, options, name, domain, updatedDomainDesign); @@ -512,7 +513,7 @@ public void validateOptions(Container container, User user, SampleTypeDomainKind } catch (IOException e) { - e.printStackTrace(); + throw UnexpectedException.wrap(e); } final Set finalExistingAliases = existingAliases; @@ -541,15 +542,15 @@ public void validateOptions(Container container, User user, SampleTypeDomainKind } @Override - public Domain createDomain(GWTDomain domain, @Nullable SampleTypeDomainKindProperties arguments, Container container, User user, @Nullable TemplateInfo templateInfo, boolean forUpdate) + public Domain createDomain(GWTDomain domain, @Nullable SampleTypeDomainKindProperties arguments, Container container, User user, @Nullable TemplateInfo templateInfo, boolean forUpdate) { String name = StringUtils.trimToNull(domain.getName()); if (name == null) throw new IllegalArgumentException("SampleSet name required"); String description = domain.getDescription(); - List properties = (List)domain.getFields(true); - List indices = (List)domain.getIndices(); + List properties = domain.getFields(true); + List indices = domain.getIndices(); int idCol1 = -1; int idCol2 = -1; @@ -570,7 +571,7 @@ public Domain createDomain(GWTDomain domain, @Nullable SampleTypeDomainKindPrope { //These are outdated but some clients still use them, or have existing sample types that do. List idCols = (arguments.getIdCols() != null) ? arguments.getIdCols() : Collections.emptyList(); - idCol1 = idCols.size() > 0 ? idCols.get(0) : -1; + idCol1 = !idCols.isEmpty() ? idCols.get(0) : -1; idCol2 = idCols.size() > 1 ? idCols.get(1) : -1; idCol3 = idCols.size() > 2 ? idCols.get(2) : -1; parentCol = arguments.getParentCol() != null ? arguments.getParentCol() : -1; @@ -640,7 +641,7 @@ public UpdateableTableInfo.ObjectUriType getObjectUriColumn() } @Override - public SampleTypeDomainKindProperties getDomainKindProperties(GWTDomain domain, Container container, User user) + public SampleTypeDomainKindProperties getDomainKindProperties(GWTDomain domain, Container container, User user) { ExpSampleType sampleType = domain != null ? SampleTypeService.get().getSampleType(domain.getDomainURI()) : null; return new SampleTypeDomainKindProperties(sampleType); diff --git a/api/src/org/labkey/api/exp/property/AbstractDomainKind.java b/api/src/org/labkey/api/exp/property/AbstractDomainKind.java index 5966606ecc0..cf1e35b1fe2 100644 --- a/api/src/org/labkey/api/exp/property/AbstractDomainKind.java +++ b/api/src/org/labkey/api/exp/property/AbstractDomainKind.java @@ -114,7 +114,7 @@ public Domain createDomain(GWTDomain domain, T arguments, } @Override - public @Nullable T getDomainKindProperties(GWTDomain domain, Container container, User user) + public @Nullable T getDomainKindProperties(GWTDomain domain, Container container, User user) { return null; } diff --git a/api/src/org/labkey/api/exp/property/DomainAuditProvider.java b/api/src/org/labkey/api/exp/property/DomainAuditProvider.java index dabc5019385..4f4634368b8 100644 --- a/api/src/org/labkey/api/exp/property/DomainAuditProvider.java +++ b/api/src/org/labkey/api/exp/property/DomainAuditProvider.java @@ -32,7 +32,6 @@ import org.labkey.api.data.TableInfo; import org.labkey.api.exp.PropertyDescriptor; import org.labkey.api.exp.PropertyType; -import org.labkey.api.query.DetailsURL; import org.labkey.api.query.FieldKey; import org.labkey.api.query.UserSchema; import org.labkey.api.util.HtmlString; diff --git a/api/src/org/labkey/api/exp/property/DomainKind.java b/api/src/org/labkey/api/exp/property/DomainKind.java index d6bce31c447..ad6cd4ef74e 100644 --- a/api/src/org/labkey/api/exp/property/DomainKind.java +++ b/api/src/org/labkey/api/exp/property/DomainKind.java @@ -141,7 +141,7 @@ public Set getReservedPropertyNamePrefixes() * @param user User * @return Return object that holds DomainKind specific properties. */ - abstract public @Nullable T getDomainKindProperties(GWTDomain domain, Container container, User user); + abstract public @Nullable T getDomainKindProperties(GWTDomain domain, Container container, User user); /** * Create a Domain appropriate for this DomainKind. @@ -162,8 +162,6 @@ public Set getReservedPropertyNamePrefixes() * @param options Any domain kind specific properties/options. * @param container Container * @param user User - * @param includeWarnings - * @param auditUserComment * @return A list of errors collected during the update. */ abstract public ValidationException updateDomain(GWTDomain original, GWTDomain update, @@ -171,8 +169,6 @@ abstract public ValidationException updateDomain(GWTDomain getBaseProperties(@Nullable Domain domain); @@ -188,8 +183,6 @@ abstract public ValidationException updateDomain(GWTDomain getAdditionalProtectedProperties(Domain domain) { @@ -385,7 +378,7 @@ public UpdateableTableInfo.ObjectUriType getObjectUriColumn() * @param domain the existing domain object for the create/save action * @param updatedDomainDesign the updated domain design being sent for the create/save action */ - public void validateOptions(Container container, User user, T options, String name, Domain domain, GWTDomain updatedDomainDesign) + public void validateOptions(Container container, User user, T options, String name, Domain domain, GWTDomain updatedDomainDesign) { boolean isUpdate = domain != null; @@ -396,7 +389,7 @@ public void validateOptions(Container container, User user, T options, String na throw new UnauthorizedException("You don't have permission to edit this domain"); } - public NameExpressionValidationResult validateNameExpressions(T options, GWTDomain domainDesign, Container container) + public NameExpressionValidationResult validateNameExpressions(T options, GWTDomain domainDesign, Container container) { return null; } diff --git a/api/src/org/labkey/api/exp/property/DomainPropertyAuditProvider.java b/api/src/org/labkey/api/exp/property/DomainPropertyAuditProvider.java index 35d679d6782..0b48e114797 100644 --- a/api/src/org/labkey/api/exp/property/DomainPropertyAuditProvider.java +++ b/api/src/org/labkey/api/exp/property/DomainPropertyAuditProvider.java @@ -147,7 +147,7 @@ public TableInfo getLookupTableInfo() public static class DomainPropertyAuditDomainKind extends AbstractAuditDomainKind { private static final String NAME = "DomainPropertyAuditDomain"; - private static String NAMESPACE_PREFIX = "Audit-" + NAME; + private static final String NAMESPACE_PREFIX = "Audit-" + NAME; private final Set _fields; diff --git a/api/src/org/labkey/api/exp/property/DomainUtil.java b/api/src/org/labkey/api/exp/property/DomainUtil.java index da36ec67a7b..5d6507f78dc 100644 --- a/api/src/org/labkey/api/exp/property/DomainUtil.java +++ b/api/src/org/labkey/api/exp/property/DomainUtil.java @@ -696,7 +696,7 @@ public static Domain createDomain(DomainTemplate template, Container container, public static Domain createDomain( String kindName, - GWTDomain domain, + GWTDomain domain, Map arguments, Container container, User user, @@ -705,7 +705,7 @@ public static Domain createDomain( boolean forUpdate) throws ValidationException { // Create a copy of the GWTDomain to ensure the template's Domain is not modified - domain = new GWTDomain(domain); + domain = new GWTDomain<>(domain); DomainKind kind = PropertyService.get().getDomainKindByName(kindName); if (kind == null) diff --git a/api/src/org/labkey/api/exp/property/ExperimentProperty.java b/api/src/org/labkey/api/exp/property/ExperimentProperty.java index 3d935ed6aa3..f2bcedbcf61 100644 --- a/api/src/org/labkey/api/exp/property/ExperimentProperty.java +++ b/api/src/org/labkey/api/exp/property/ExperimentProperty.java @@ -20,7 +20,7 @@ public class ExperimentProperty { - static private String EXPERIMENT_PROPERTY_URIBASE = "urn:exp.labkey.org/#"; + static private final String EXPERIMENT_PROPERTY_URIBASE = "urn:exp.labkey.org/#"; static public SystemProperty COMMENT = new SystemProperty(EXPERIMENT_PROPERTY_URIBASE + "Comment", PropertyType.STRING); static public SystemProperty LOGTEXT = new SystemProperty(EXPERIMENT_PROPERTY_URIBASE + "LogText", PropertyType.STRING); diff --git a/api/src/org/labkey/api/exp/property/PropertyService.java b/api/src/org/labkey/api/exp/property/PropertyService.java index 88552a91c7f..7a10bb5cb65 100644 --- a/api/src/org/labkey/api/exp/property/PropertyService.java +++ b/api/src/org/labkey/api/exp/property/PropertyService.java @@ -107,11 +107,11 @@ static void setInstance(PropertyService impl) Pair> createDomain(Container container, DomainDescriptorType xDomain); - DomainKind getDomainKind(String typeURI); + DomainKind getDomainKind(String typeURI); - DomainKind getDomainKindByName(String name); + DomainKind getDomainKindByName(String name); - void registerDomainKind(DomainKind type); + void registerDomainKind(DomainKind type); /** register a property validator type */ void registerValidatorKind(ValidatorKind kind); diff --git a/api/src/org/labkey/api/exp/query/ExpSchema.java b/api/src/org/labkey/api/exp/query/ExpSchema.java index 3efd20a133b..2348e8c7ff3 100644 --- a/api/src/org/labkey/api/exp/query/ExpSchema.java +++ b/api/src/org/labkey/api/exp/query/ExpSchema.java @@ -420,7 +420,7 @@ public enum SampleStateType SampleTypeService.SampleOperations.AddToPicklist )); - Set _permittedOps = Collections.emptySet(); + Set _permittedOps; SampleStateType(Set permittedOps) { @@ -431,7 +431,7 @@ public Set getPermittedOps() { return _permittedOps; } - }; + } /** diff --git a/api/src/org/labkey/api/exp/xar/LsidUtils.java b/api/src/org/labkey/api/exp/xar/LsidUtils.java index 2d0893f719b..dfad4993771 100644 --- a/api/src/org/labkey/api/exp/xar/LsidUtils.java +++ b/api/src/org/labkey/api/exp/xar/LsidUtils.java @@ -36,9 +36,9 @@ */ public class LsidUtils { - private static Logger _log = LogManager.getLogger(LsidUtils.class); + private static final Logger _log = LogManager.getLogger(LsidUtils.class); - private static Pattern REPLACEMENT_PATTERN = Pattern.compile("\\Q${\\E(.*?)\\Q}\\E"); + private static final Pattern REPLACEMENT_PATTERN = Pattern.compile("\\Q${\\E(.*?)\\Q}\\E"); private static MapReplacer createMapReplacer(XarContext context, String declaredType, String baseType) { diff --git a/api/src/org/labkey/api/exp/xar/Replacer.java b/api/src/org/labkey/api/exp/xar/Replacer.java index 988e8e41433..847b9fca995 100644 --- a/api/src/org/labkey/api/exp/xar/Replacer.java +++ b/api/src/org/labkey/api/exp/xar/Replacer.java @@ -24,9 +24,9 @@ */ public interface Replacer { - public String getReplacement(String original) throws XarFormatException; + String getReplacement(String original) throws XarFormatException; - public static class CompoundReplacer implements Replacer + class CompoundReplacer implements Replacer { private final Replacer _replacer1; private final Replacer _replacer2; diff --git a/api/src/org/labkey/api/files/FileListener.java b/api/src/org/labkey/api/files/FileListener.java index 94542c8c2f5..858d1f54306 100644 --- a/api/src/org/labkey/api/files/FileListener.java +++ b/api/src/org/labkey/api/files/FileListener.java @@ -34,7 +34,7 @@ */ public interface FileListener { - public String getSourceName(); + String getSourceName(); /** * Called AFTER the file (or directory) has already been created on disk @@ -76,7 +76,7 @@ default void fileDeleted(@NotNull Path deleted, @Nullable User user, @Nullable C * List file paths in the database this FileListener is aware of. * @param container If not null, list files in the given container, otherwise from all containers. */ - public Collection listFiles(@Nullable Container container); // Nobody really calls this + Collection listFiles(@Nullable Container container); // Nobody really calls this // public Collection listFilePaths(@Nullable Container container); /** @@ -93,5 +93,5 @@ default void fileDeleted(@NotNull Path deleted, @Nullable User user, @Nullable C *
  • SourceName
  • * */ - public SQLFragment listFilesQuery(); + SQLFragment listFilesQuery(); } diff --git a/api/src/org/labkey/api/formSchema/Field.java b/api/src/org/labkey/api/formSchema/Field.java index ca5943c3a28..5118a3b17bc 100644 --- a/api/src/org/labkey/api/formSchema/Field.java +++ b/api/src/org/labkey/api/formSchema/Field.java @@ -27,43 +27,43 @@ public interface Field * The name of the field to be rendered in the client. * @return the name of the field */ - public String getName(); + String getName(); /** * The label rendered by the client. * @return The label for the field */ - public String getLabel(); + String getLabel(); /** * The placeholder text used when a field has not been filled out yet. * @return placeholder text */ - public String getPlaceholder(); + String getPlaceholder(); /** * The text used to explain what the field is used for, or what the expected value should be. * @return text used for help tooltips */ - public String getHelpText(); + String getHelpText(); /** * The href used to link to documentation, rendered with helpText. * @return href pointing to documentation */ - public String getHelpTextHref(); + String getHelpTextHref(); /** * Whether or not a field is required. Required fields cannot be empty or null. * @return required status of the field */ - public Boolean getRequired(); + Boolean getRequired(); /** * The default value to use if the user enters nothing in the field. * @return the default value of the field */ - public T getDefaultValue(); + T getDefaultValue(); /** * The type of field, this is used by the client to determine what type of input to render. While this is typically @@ -71,5 +71,5 @@ public interface Field * YesNoMaybe field that returns "select" for its type, and always has the Options Yes, No, and Maybe. * @return the type of input the client should render */ - public String getType(); + String getType(); } diff --git a/api/src/org/labkey/api/issues/AbstractIssuesListDefDomainKind.java b/api/src/org/labkey/api/issues/AbstractIssuesListDefDomainKind.java index 1fe8ba5fc32..a145e5b3b7e 100644 --- a/api/src/org/labkey/api/issues/AbstractIssuesListDefDomainKind.java +++ b/api/src/org/labkey/api/issues/AbstractIssuesListDefDomainKind.java @@ -281,7 +281,7 @@ public Class getTypeClass() } @Override - public @Nullable IssuesDomainKindProperties getDomainKindProperties(GWTDomain domain, Container container, User user) + public @Nullable IssuesDomainKindProperties getDomainKindProperties(GWTDomain domain, Container container, User user) { return IssuesListDefService.get().getIssueDomainKindProperties(container, domain != null ? domain.getName() : null); } @@ -297,7 +297,7 @@ public Class getTypeClass() } @Override - public Domain createDomain(GWTDomain domain, IssuesDomainKindProperties arguments, Container container, User user, @Nullable TemplateInfo templateInfo, boolean forUpdate) + public Domain createDomain(GWTDomain domain, IssuesDomainKindProperties arguments, Container container, User user, @Nullable TemplateInfo templateInfo, boolean forUpdate) { int issueDefId; try (DbScope.Transaction transaction = ExperimentService.get().getSchema().getScope().ensureTransaction(_lock)) @@ -315,8 +315,8 @@ public Domain createDomain(GWTDomain domain, IssuesDomainKindProperties argument issueDefId = IssuesListDefService.get().createIssueListDef(container, user, providerName, name, singularNoun, pluralNoun); - List properties = (List)domain.getFields(); - List indices = (List)domain.getIndices(); + List properties = domain.getFields(); + List indices = domain.getIndices(); Domain newDomain = IssuesListDefService.get().getDomainFromIssueDefId(issueDefId, container, user, true); if (newDomain != null) @@ -339,10 +339,10 @@ public Domain createDomain(GWTDomain domain, IssuesDomainKindProperties argument newDomain.setPropertyIndices(indices, lowerReservedNames); // set default values on the base properties - DomainKind domainKind = newDomain.getDomainKind(); - if (domainKind instanceof AbstractIssuesListDefDomainKind) + DomainKind domainKind = newDomain.getDomainKind(); + if (domainKind instanceof AbstractIssuesListDefDomainKind listDK) { - setDefaultValues(newDomain, ((AbstractIssuesListDefDomainKind)domainKind).getRequiredProperties()); + setDefaultValues(newDomain, listDK.getRequiredProperties()); } newDomain.save(user); } diff --git a/api/src/org/labkey/api/issues/IssueService.java b/api/src/org/labkey/api/issues/IssueService.java index 0cde4a85b87..19f682d09fc 100644 --- a/api/src/org/labkey/api/issues/IssueService.java +++ b/api/src/org/labkey/api/issues/IssueService.java @@ -39,7 +39,6 @@ static void setInstance(IssueService impl) * in this interface. * @param issueId - The id of the issue to fetch * @param updates - The map which represents the changes to the existing issue that should be applied. - * @return */ @Nullable Issue getIssueForUpdate(Container container, User user, Integer issueId, Map updates); diff --git a/api/src/org/labkey/api/issues/IssuesListDefProvider.java b/api/src/org/labkey/api/issues/IssuesListDefProvider.java index 845a00d83a3..d5b3652449b 100644 --- a/api/src/org/labkey/api/issues/IssuesListDefProvider.java +++ b/api/src/org/labkey/api/issues/IssuesListDefProvider.java @@ -32,7 +32,7 @@ public interface IssuesListDefProvider String getDescription(); default Domain getDomain() { - DomainKind domainKind = getDomainKind(); + DomainKind domainKind = getDomainKind(); if (null != domainKind) return PropertyService.get().getDomain(getDomainContainer(), domainKind.generateDomainURI(IssuesSchema.SCHEMA_NAME, getName(), getDomainContainer(), null)); return null; @@ -44,7 +44,7 @@ static Container getDomainContainer() } @Nullable - DomainKind getDomainKind(); + DomainKind getDomainKind(); default boolean isEnabled(Container container) { diff --git a/api/src/org/labkey/api/issues/IssuesListDefService.java b/api/src/org/labkey/api/issues/IssuesListDefService.java index d3f420d0cfc..edb5e54e9b4 100644 --- a/api/src/org/labkey/api/issues/IssuesListDefService.java +++ b/api/src/org/labkey/api/issues/IssuesListDefService.java @@ -94,7 +94,6 @@ ValidationException updateIssueDefinition(Container container, User user, GWTDom * Get the set of registered issue list definition providers that are enabled based on the given container (most likely * based on the set of active modules for that container). * @param container the container to check for enabled providers - * @return */ List getEnabledIssuesListDefProviders(Container container); @@ -180,7 +179,6 @@ ValidationException updateIssueDefinition(Container container, User user, GWTDom /** * Clears the issue list definition cache - * @param container */ void uncache(Container container); diff --git a/api/src/org/labkey/api/iterator/BeanIterator.java b/api/src/org/labkey/api/iterator/BeanIterator.java index f0c318be4ba..381fcace5ac 100644 --- a/api/src/org/labkey/api/iterator/BeanIterator.java +++ b/api/src/org/labkey/api/iterator/BeanIterator.java @@ -27,8 +27,8 @@ */ public class BeanIterator implements CloseableIterator { - private CloseableIterator> _mapIter; - private ObjectFactory _factory; + private final CloseableIterator> _mapIter; + private final ObjectFactory _factory; public BeanIterator(CloseableIterator> mapIter, Class clazz) { diff --git a/api/src/org/labkey/api/iterator/CloseableIterator.java b/api/src/org/labkey/api/iterator/CloseableIterator.java index 303bde0e415..ee5ac941f12 100644 --- a/api/src/org/labkey/api/iterator/CloseableIterator.java +++ b/api/src/org/labkey/api/iterator/CloseableIterator.java @@ -15,10 +15,7 @@ */ package org.labkey.api.iterator; -import org.labkey.api.query.ValidationException; - import java.io.Closeable; -import java.io.IOException; import java.util.Iterator; /** diff --git a/api/src/org/labkey/api/jsp/JspClassLoader.java b/api/src/org/labkey/api/jsp/JspClassLoader.java index dc6f5308ecc..7f00130da8a 100644 --- a/api/src/org/labkey/api/jsp/JspClassLoader.java +++ b/api/src/org/labkey/api/jsp/JspClassLoader.java @@ -105,7 +105,7 @@ private boolean scanForJspJars() _log.error("initLoader exception", mURLe); } } - cl = new URLClassLoader(urls.toArray(new URL[urls.size()]), Thread.currentThread().getContextClassLoader()); + cl = new URLClassLoader(urls.toArray(new URL[0]), Thread.currentThread().getContextClassLoader()); _loader.set(cl); } return cl; diff --git a/api/src/org/labkey/api/jsp/JspLoader.java b/api/src/org/labkey/api/jsp/JspLoader.java index 6d8021556af..c2a11522fc4 100644 --- a/api/src/org/labkey/api/jsp/JspLoader.java +++ b/api/src/org/labkey/api/jsp/JspLoader.java @@ -31,7 +31,7 @@ public class JspLoader { - private static Logger _log = LogManager.getLogger(JspLoader.class); + private static final Logger _log = LogManager.getLogger(JspLoader.class); private static final JspClassLoader _jspClassLoader; static diff --git a/api/src/org/labkey/api/jsp/RecompilingJspClassLoader.java b/api/src/org/labkey/api/jsp/RecompilingJspClassLoader.java index eae991994aa..bd4101ceb70 100644 --- a/api/src/org/labkey/api/jsp/RecompilingJspClassLoader.java +++ b/api/src/org/labkey/api/jsp/RecompilingJspClassLoader.java @@ -217,7 +217,7 @@ private JspCompilationException(String jspFilePath, File jspFile, String errors) private static void logJspPath(File jspSource, String errors) { int idx = errors.indexOf("_jsp.java:"); - String path = ""; + String path; if (idx != -1) { int begin = idx + 10; diff --git a/api/src/org/labkey/api/jsp/taglib/AutoCompleteTag.java b/api/src/org/labkey/api/jsp/taglib/AutoCompleteTag.java index 34baac0fdf3..7fb050e3222 100644 --- a/api/src/org/labkey/api/jsp/taglib/AutoCompleteTag.java +++ b/api/src/org/labkey/api/jsp/taglib/AutoCompleteTag.java @@ -81,25 +81,24 @@ public void doTag() throws IOException // TODO: SafeToRenderBuilder String renderId = "auto-complete-div-" + UniqueID.getRequestScopedUID(HttpView.currentRequest()); - StringBuilder sb = new StringBuilder() - .append("\n") - .append("
    "); + String sb = "\n" + + "
    "; Writer out = getWriter(); - out.write(sb.toString()); + out.write(sb); } // Allow subclasses to override to provide a generic Writer (not a JspWriter) diff --git a/api/src/org/labkey/api/jsp/taglib/ErrorsTag.java b/api/src/org/labkey/api/jsp/taglib/ErrorsTag.java index 0e9743ea521..72b75293e01 100644 --- a/api/src/org/labkey/api/jsp/taglib/ErrorsTag.java +++ b/api/src/org/labkey/api/jsp/taglib/ErrorsTag.java @@ -54,9 +54,8 @@ public int doStartTag() throws JspException if (s.startsWith(BindingResult.MODEL_KEY_PREFIX)) { Object o = pageContext.getAttribute(s, PageContext.REQUEST_SCOPE); - if (!(o instanceof BindingResult)) + if (!(o instanceof BindingResult errors)) continue; - BindingResult errors = (BindingResult)o; if (null != errors.getAllErrors()) for (ObjectError m : errors.getAllErrors()) { diff --git a/api/src/org/labkey/api/module/AdminLinkManager.java b/api/src/org/labkey/api/module/AdminLinkManager.java index b102017d156..858329fa844 100644 --- a/api/src/org/labkey/api/module/AdminLinkManager.java +++ b/api/src/org/labkey/api/module/AdminLinkManager.java @@ -64,6 +64,6 @@ public interface Listener * in the container before adding links. User might not be an administrator in this container (could be a troubleshooter, * for example). */ - public void addAdminLinks(NavTree adminNavTree, Container container, User user); + void addAdminLinks(NavTree adminNavTree, Container container, User user); } } diff --git a/api/src/org/labkey/api/module/FolderTypeManager.java b/api/src/org/labkey/api/module/FolderTypeManager.java index 66006d80690..2175ab924da 100644 --- a/api/src/org/labkey/api/module/FolderTypeManager.java +++ b/api/src/org/labkey/api/module/FolderTypeManager.java @@ -325,7 +325,7 @@ public String getDescription() { return "Comma-separated list of folder types to disable on this server"; } - }; + } } private static final String SCOPE_FOLDER_TYPES = "FolderTypes"; diff --git a/api/src/org/labkey/api/module/ModuleDependencySorter.java b/api/src/org/labkey/api/module/ModuleDependencySorter.java index d50b6375283..aac12caf743 100644 --- a/api/src/org/labkey/api/module/ModuleDependencySorter.java +++ b/api/src/org/labkey/api/module/ModuleDependencySorter.java @@ -131,7 +131,7 @@ private Module findModuleWithoutDependencies(List>> dep StringBuilder sb = new StringBuilder(); for (Pair> dependencyInfo : dependencies) { - if (sb.length() > 0) + if (!sb.isEmpty()) { sb.append(", "); } @@ -141,7 +141,7 @@ private Module findModuleWithoutDependencies(List>> dep // Generate an SVG diagram that shows all remaining dependencies graphModuleDependencies(dependencies, "involved"); - throw new IllegalArgumentException("Unable to resolve module dependencies. The following modules are somehow involved: " + sb.toString()); + throw new IllegalArgumentException("Unable to resolve module dependencies. The following modules are somehow involved: " + sb); } @@ -258,14 +258,14 @@ public void testGoodDependencies() ModuleDependencySorter sorter = new ModuleDependencySorter(); List sortedModules = sorter.sortModulesByDependencies(testModules); assertEquals(sortedModules.size(), testModules.size()); - assertEquals(sortedModules.get(0).getName(), "e"); - assertEquals(sortedModules.get(1).getName(), "d"); - assertEquals(sortedModules.get(2).getName(), "g"); - assertEquals(sortedModules.get(3).getName(), "f"); - assertEquals(sortedModules.get(4).getName(), "h"); - assertEquals(sortedModules.get(5).getName(), "c"); - assertEquals(sortedModules.get(6).getName(), "b"); - assertEquals(sortedModules.get(7).getName(), "a"); + assertEquals("e", sortedModules.get(0).getName()); + assertEquals("d", sortedModules.get(1).getName()); + assertEquals("g", sortedModules.get(2).getName()); + assertEquals("f", sortedModules.get(3).getName()); + assertEquals("h", sortedModules.get(4).getName()); + assertEquals("c", sortedModules.get(5).getName()); + assertEquals("b", sortedModules.get(6).getName()); + assertEquals("a", sortedModules.get(7).getName()); } } } diff --git a/api/src/org/labkey/api/module/ModuleProperty.java b/api/src/org/labkey/api/module/ModuleProperty.java index 7f8ef85c2bf..31f7d3cf191 100644 --- a/api/src/org/labkey/api/module/ModuleProperty.java +++ b/api/src/org/labkey/api/module/ModuleProperty.java @@ -62,7 +62,7 @@ public class ModuleProperty private String _description = null; private boolean _showDescriptionInline = false; private int _inputFieldWidth = 300; - private InputType _inputType = InputType.text; + private InputType _inputType; private List