From df2a57d3318bfeb07dfffa77c2f9decb4da9ea22 Mon Sep 17 00:00:00 2001 From: Lum Date: Tue, 9 Dec 2025 11:31:47 -0800 Subject: [PATCH 1/2] Render file watcher run as field as a dropdown --- .../labkey/api/pipeline/PipelineJobService.java | 3 ++- .../pipeline/api/PipelineJobServiceImpl.java | 15 ++++++++++++--- .../org/labkey/pipeline/createPipelineTrigger.jsp | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/api/src/org/labkey/api/pipeline/PipelineJobService.java b/api/src/org/labkey/api/pipeline/PipelineJobService.java index 47caf4f7d25..a694fae5de5 100644 --- a/api/src/org/labkey/api/pipeline/PipelineJobService.java +++ b/api/src/org/labkey/api/pipeline/PipelineJobService.java @@ -21,6 +21,7 @@ import org.labkey.api.data.Container; import org.labkey.api.formSchema.FormSchema; import org.labkey.api.pipeline.file.PathMapper; +import org.labkey.api.security.User; import org.labkey.api.util.QuietCloser; import java.io.FileNotFoundException; @@ -192,7 +193,7 @@ enum LocationType RemoteExecutionEngine } - FormSchema getFormSchema(Container container); + FormSchema getFormSchema(Container container, User user); /** @return true if the current instance is the web server, which has access to more resources including the * primary database, or false if we're on a remote server diff --git a/pipeline/src/org/labkey/pipeline/api/PipelineJobServiceImpl.java b/pipeline/src/org/labkey/pipeline/api/PipelineJobServiceImpl.java index ae015697d91..541f236cee4 100644 --- a/pipeline/src/org/labkey/pipeline/api/PipelineJobServiceImpl.java +++ b/pipeline/src/org/labkey/pipeline/api/PipelineJobServiceImpl.java @@ -65,6 +65,9 @@ import org.labkey.api.pipeline.trigger.PipelineTriggerRegistry; import org.labkey.api.pipeline.trigger.PipelineTriggerType; import org.labkey.api.reports.report.r.RReport; +import org.labkey.api.security.SecurityManager; +import org.labkey.api.security.User; +import org.labkey.api.security.permissions.InsertPermission; import org.labkey.api.util.FileUtil; import org.labkey.api.util.JunitUtil; import org.labkey.api.util.MemTracker; @@ -672,7 +675,7 @@ public PipelineStatusFile.JobStore getJobStore() } @Override - public FormSchema getFormSchema(Container container) + public FormSchema getFormSchema(Container container, User user) { List> typeOptions = new ArrayList<>(); for (PipelineTriggerType pipelineTriggerType : PipelineTriggerRegistry.get().getTypes()) @@ -696,7 +699,13 @@ public FormSchema getFormSchema(Container container) for (FileAnalysisTaskPipeline task : tasks) taskOptions.add(new Option<>(task.getId().toString(), task.getDescription())); - String usernameHelpText = "The file watcher will run as this user in the pipeline. Some tasks may require this user to have admin permissions."; + List> userOptions = new ArrayList<>(SecurityManager.getUsersWithPermissions(container, Set.of(InsertPermission.class)).stream() + .map(u -> new Option<>(u.getDisplayName(user), u.getDisplayName(user))) + .toList()); + // allow empty selection + userOptions.add(new Option<>("", "")); + + String usernameHelpText = "The file watcher will run as this user in the pipeline. Users in this list have insert permissions for the folder. Some tasks may require this user to have admin permissions."; String assayProviderHelpText = "Use this provider for running assay import runs. This will be the name of the assay type eg : General or " + "the name of a module based assay."; String baseHref = "https://www.labkey.org/Documentation/wiki-page.view?name=fileWatchCreate#"; @@ -708,7 +717,7 @@ public FormSchema getFormSchema(Container container) new TextareaField("description", "Description", null, false, ""), new SelectField<>("type", "Type", null, true, typeDefaultValue, typeOptions), new SelectField<>("pipelineId", "Pipeline Task", "Select a Pipeline Task", true, null, taskOptions), - new TextField("username", "Run as Username", null, false, null, usernameHelpText, usernameHref), + new SelectField("username", "Run as Username", null, false, "", userOptions, usernameHelpText, usernameHref), new TextField("assay provider", "Assay Provider", "General", false, null, assayProviderHelpText, assayProviderHref), new CheckboxField("enabled", "Enable this Trigger", false, true) ); diff --git a/pipeline/src/org/labkey/pipeline/createPipelineTrigger.jsp b/pipeline/src/org/labkey/pipeline/createPipelineTrigger.jsp index 38fae95adb1..01fc1c8e6ce 100644 --- a/pipeline/src/org/labkey/pipeline/createPipelineTrigger.jsp +++ b/pipeline/src/org/labkey/pipeline/createPipelineTrigger.jsp @@ -59,7 +59,7 @@ String uniqueId = "" + UniqueID.getServerSessionScopedUID(); String appId = "create-pipeline-trigger-" + uniqueId; - FormSchema detailsFormSchema = PipelineJobService.get().getFormSchema(getContainer()); + FormSchema detailsFormSchema = PipelineJobService.get().getFormSchema(getContainer(), getUser()); Map taskFormSchemas = new HashMap<>(); Map customFieldFormSchemas = new HashMap<>(); Map tasksHelpText = new HashMap<>(); From 99e85c765afd9ae1bb854d6f1777f2ecb9ca99c9 Mon Sep 17 00:00:00 2001 From: Lum Date: Wed, 10 Dec 2025 11:41:39 -0800 Subject: [PATCH 2/2] Run as user field is now required. --- .../src/org/labkey/pipeline/api/PipelineJobServiceImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pipeline/src/org/labkey/pipeline/api/PipelineJobServiceImpl.java b/pipeline/src/org/labkey/pipeline/api/PipelineJobServiceImpl.java index 541f236cee4..2c14abd8626 100644 --- a/pipeline/src/org/labkey/pipeline/api/PipelineJobServiceImpl.java +++ b/pipeline/src/org/labkey/pipeline/api/PipelineJobServiceImpl.java @@ -702,8 +702,6 @@ public FormSchema getFormSchema(Container container, User user) List> userOptions = new ArrayList<>(SecurityManager.getUsersWithPermissions(container, Set.of(InsertPermission.class)).stream() .map(u -> new Option<>(u.getDisplayName(user), u.getDisplayName(user))) .toList()); - // allow empty selection - userOptions.add(new Option<>("", "")); String usernameHelpText = "The file watcher will run as this user in the pipeline. Users in this list have insert permissions for the folder. Some tasks may require this user to have admin permissions."; String assayProviderHelpText = "Use this provider for running assay import runs. This will be the name of the assay type eg : General or " + @@ -717,7 +715,7 @@ public FormSchema getFormSchema(Container container, User user) new TextareaField("description", "Description", null, false, ""), new SelectField<>("type", "Type", null, true, typeDefaultValue, typeOptions), new SelectField<>("pipelineId", "Pipeline Task", "Select a Pipeline Task", true, null, taskOptions), - new SelectField("username", "Run as Username", null, false, "", userOptions, usernameHelpText, usernameHref), + new SelectField("username", "Run as Username", null, true, null, userOptions, usernameHelpText, usernameHref), new TextField("assay provider", "Assay Provider", "General", false, null, assayProviderHelpText, assayProviderHref), new CheckboxField("enabled", "Enable this Trigger", false, true) );