From d812f630192fa2c217a0a5901b2db1f6f18753db Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Sun, 15 Dec 2024 15:20:05 -0800 Subject: [PATCH] Minor NextFlow fixes --- .../labkey/nextflow/NextFlowController.java | 79 +++++++------------ .../org/labkey/nextflow/NextFlowManager.java | 2 +- .../org/labkey/nextflow/NextFlowModule.java | 2 - .../pipeline/NextFlowPipelineJob.java | 2 +- .../pipeline/NextFlowPipelineProvider.java | 7 ++ .../nextflow/pipeline/NextFlowRunTask.java | 1 - 6 files changed, 36 insertions(+), 57 deletions(-) diff --git a/nextflow/src/org/labkey/nextflow/NextFlowController.java b/nextflow/src/org/labkey/nextflow/NextFlowController.java index 0fe2de2f..b30bd5d5 100644 --- a/nextflow/src/org/labkey/nextflow/NextFlowController.java +++ b/nextflow/src/org/labkey/nextflow/NextFlowController.java @@ -1,6 +1,5 @@ package org.labkey.nextflow; -import lombok.Data; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.StringUtils; @@ -9,7 +8,6 @@ import org.labkey.api.action.ApiSimpleResponse; import org.labkey.api.action.FormViewAction; import org.labkey.api.action.MutatingApiAction; -import org.labkey.api.action.SimpleViewAction; import org.labkey.api.action.SpringActionController; import org.labkey.api.admin.AdminUrls; import org.labkey.api.data.PropertyManager; @@ -22,7 +20,6 @@ import org.labkey.api.security.AdminConsoleAction; import org.labkey.api.security.RequiresPermission; import org.labkey.api.security.permissions.AdminOperationsPermission; -import org.labkey.api.security.permissions.InsertPermission; import org.labkey.api.security.permissions.ReadPermission; import org.labkey.api.security.permissions.SiteAdminPermission; import org.labkey.api.util.Button; @@ -34,7 +31,6 @@ import org.labkey.api.util.URLHelper; import org.labkey.api.util.element.Select; import org.labkey.api.util.logging.LogHelper; -import org.labkey.api.view.ActionURL; import org.labkey.api.view.HtmlView; import org.labkey.api.view.JspView; import org.labkey.api.view.NavTree; @@ -45,10 +41,7 @@ import org.springframework.validation.Errors; import org.springframework.web.servlet.ModelAndView; -import javax.swing.text.html.FormView; - import java.io.File; -import java.nio.file.Paths; import java.util.Arrays; import java.util.List; @@ -60,7 +53,6 @@ import static org.labkey.api.util.DOM.Attribute.value; import static org.labkey.api.util.DOM.DIV; import static org.labkey.api.util.DOM.INPUT; -import static org.labkey.api.util.DOM.LI; import static org.labkey.api.util.DOM.LK.FORM; import static org.labkey.api.util.DOM.UL; import static org.labkey.api.util.DOM.at; @@ -78,32 +70,6 @@ public NextFlowController() setActionResolver(_actionResolver); } - @RequiresPermission(ReadPermission.class) - public static class BeginAction extends SimpleViewAction - { - @Override - public ModelAndView getView(Object o, BindException errors) - { - boolean enabled = NextFlowManager.get().isEnabled(getContainer()); - return new HtmlView("NextFlow", - DIV( - DIV("NextFlow integration is " + (enabled ? "enabled" : "disabled") + " in this " + (getContainer().isProject() ? "project" : "folder") + "."), - DIV( - getContainer().hasPermission(getUser(), SiteAdminPermission.class) ? - new Button.ButtonBuilder("Enable/Disable").href(new ActionURL(NextFlowEnableAction.class, getContainer())).build() : null, - " ", - enabled && getContainer().hasPermission(getUser(), InsertPermission.class) ? - new Button.ButtonBuilder("Run NextFlow Analysis").href(new ActionURL(NextFlowRunAction.class, getContainer())).build() : null))); - } - - @Override - public void addNavTrail(NavTree root) - { - root.addChild("NextFlow"); - } - } - - @RequiresPermission(SiteAdminPermission.class) public static class DeleteNextFlowConfigurationAction extends MutatingApiAction { @@ -215,8 +181,8 @@ public void setEnabled(Boolean enabled) } } - @RequiresPermission(SiteAdminPermission.class) - public static class NextFlowEnableAction extends FormViewAction + @RequiresPermission(ReadPermission.class) + public static class BeginAction extends FormViewAction { @Override public void validateCommand(EnabledForm target, Errors errors) @@ -227,21 +193,30 @@ public void validateCommand(EnabledForm target, Errors errors) @Override public ModelAndView getView(EnabledForm form, boolean reshow, BindException errors) { - Boolean status = NextFlowManager.get().getEnabledState(getContainer()); - boolean inheritedStatus = NextFlowManager.get().isEnabled(getContainer().getParent()); - - return new HtmlView("Enable/Disable NextFlow", - FORM(at(method, "POST"), - DIV(INPUT(at(type, "radio", name, "enabled", value, Boolean.TRUE.toString(), (status == Boolean.TRUE ? checked : null), null)), - "Enabled"), - DIV(INPUT(at(type, "radio", name, "enabled", value, Boolean.FALSE.toString(), (status == Boolean.FALSE ? checked : null), null)), - "Disabled"), - DIV(INPUT(at(type, "radio", name, "enabled", value, "", (status == null ? checked : null), null)), - getContainer().isRoot() ? - "Unset" : - "Inherited from " + getContainer().getParent().getPath() + " (currently " + (inheritedStatus ? "enabled" : "disabled") + ")"), - new Button.ButtonBuilder("Save").submit(true).build(), " ", - new Button.ButtonBuilder("Cancel").href(getContainer().getStartURL(getUser())).build())); + if (getUser().hasSiteAdminPermission()) + { + Boolean status = NextFlowManager.get().getEnabledState(getContainer()); + boolean inheritedStatus = NextFlowManager.get().isEnabled(getContainer().getParent()); + + return new HtmlView("Enable or Disable NextFlow", + FORM(at(method, "POST"), + DIV(INPUT(at(type, "radio", name, "enabled", value, Boolean.TRUE.toString(), (status == Boolean.TRUE ? checked : null), null)), + "Enabled"), + DIV(INPUT(at(type, "radio", name, "enabled", value, Boolean.FALSE.toString(), (status == Boolean.FALSE ? checked : null), null)), + "Disabled"), + DIV(INPUT(at(type, "radio", name, "enabled", value, "", (status == null ? checked : null), null)), + getContainer().isRoot() ? + "Unset" : + "Inherited from " + getContainer().getParent().getPath() + " (currently " + (inheritedStatus ? "enabled" : "disabled") + ")"), + new Button.ButtonBuilder("Save").submit(true).build(), " ", + new Button.ButtonBuilder("Cancel").href(getContainer().getStartURL(getUser())).build())); + } + else + { + return new HtmlView("NextFlow Integration Status", + DIV("NextFlow integration is " + (NextFlowManager.get().isEnabled(getContainer()) ? "enabled" : "disabled") + " in this " + (getContainer().isProject() ? "project" : "folder") + ".") + ); + } } @Override @@ -254,7 +229,7 @@ public boolean handlePost(EnabledForm form, BindException errors) @Override public void addNavTrail(NavTree root) { - root.addChild("Enable/Disable NextFlow"); + root.addChild("NextFlow Integration Status"); } @Override diff --git a/nextflow/src/org/labkey/nextflow/NextFlowManager.java b/nextflow/src/org/labkey/nextflow/NextFlowManager.java index e0325be0..e560e413 100644 --- a/nextflow/src/org/labkey/nextflow/NextFlowManager.java +++ b/nextflow/src/org/labkey/nextflow/NextFlowManager.java @@ -48,7 +48,7 @@ private void checkArgs(NextFlowConfiguration config, BindException errors) errors.rejectValue("nextFlowConfigFilePath", ERROR_MSG, "NextFlow config file path is required"); Path configPath = Paths.get(config.getNextFlowConfigFilePath()); - if (Files.isDirectory(configPath)) + if (!Files.isDirectory(configPath)) { errors.rejectValue("nextFlowConfigFilePath", ERROR_MSG, "NextFlow config file path must be a directory"); } diff --git a/nextflow/src/org/labkey/nextflow/NextFlowModule.java b/nextflow/src/org/labkey/nextflow/NextFlowModule.java index e9d769db..46853d27 100644 --- a/nextflow/src/org/labkey/nextflow/NextFlowModule.java +++ b/nextflow/src/org/labkey/nextflow/NextFlowModule.java @@ -29,8 +29,6 @@ protected void startupAfterSpringConfig(ModuleContext moduleContext) protected void init() { addController(NextFlowController.NAME, NextFlowController.class); - - PipelineService.get().registerPipelineProvider(new NextFlowPipelineProvider(this)); } @Override diff --git a/nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineJob.java b/nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineJob.java index b0250318..40455d8c 100644 --- a/nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineJob.java +++ b/nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineJob.java @@ -41,7 +41,7 @@ public static NextFlowPipelineJob create(ViewBackgroundInfo info, @NotNull PipeR Path log = jobDir.resolve(jobName + ".log"); FileUtil.createDirectory(jobDir); - Path config = createConfig(templateConfig, log.getParent(), jobDir, info.getContainer()); + Path config = createConfig(templateConfig, parentDir, jobDir, info.getContainer()); return new NextFlowPipelineJob(info, root, config, inputFiles, log); } diff --git a/nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineProvider.java b/nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineProvider.java index 328990e3..30ec70ce 100644 --- a/nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineProvider.java +++ b/nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineProvider.java @@ -19,6 +19,13 @@ public NextFlowPipelineProvider(NextFlowModule owningModule) super(NAME, owningModule); } + @Override + public boolean isShowActionsIfModuleInactive() + { + // We rely on a setting that folder admins can't control to determine if NextFlow is available + return true; + } + @Override public void updateFileProperties(ViewContext context, PipeRoot pr, PipelineDirectory directory, boolean includeAll) { diff --git a/nextflow/src/org/labkey/nextflow/pipeline/NextFlowRunTask.java b/nextflow/src/org/labkey/nextflow/pipeline/NextFlowRunTask.java index aea90fa8..8954963e 100644 --- a/nextflow/src/org/labkey/nextflow/pipeline/NextFlowRunTask.java +++ b/nextflow/src/org/labkey/nextflow/pipeline/NextFlowRunTask.java @@ -8,7 +8,6 @@ import org.labkey.api.pipeline.PipelineJobException; import org.labkey.api.pipeline.RecordedAction; import org.labkey.api.pipeline.RecordedActionSet; -import org.labkey.api.pipeline.ToolExecutionException; import org.labkey.api.pipeline.WorkDirectoryTask; import org.labkey.api.security.SecurityManager; import org.labkey.api.util.FileType;