Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor NextFlow fixes #472

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 27 additions & 52 deletions nextflow/src/org/labkey/nextflow/NextFlowController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.labkey.nextflow;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -78,32 +70,6 @@ public NextFlowController()
setActionResolver(_actionResolver);
}

@RequiresPermission(ReadPermission.class)
public static class BeginAction extends SimpleViewAction<Object>
{
@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<Object>
{
Expand Down Expand Up @@ -215,8 +181,8 @@ public void setEnabled(Boolean enabled)
}
}

@RequiresPermission(SiteAdminPermission.class)
public static class NextFlowEnableAction extends FormViewAction<EnabledForm>
@RequiresPermission(ReadPermission.class)
public static class BeginAction extends FormViewAction<EnabledForm>
{
@Override
public void validateCommand(EnabledForm target, Errors errors)
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nextflow/src/org/labkey/nextflow/NextFlowManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 0 additions & 2 deletions nextflow/src/org/labkey/nextflow/NextFlowModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ protected void startupAfterSpringConfig(ModuleContext moduleContext)
protected void init()
{
addController(NextFlowController.NAME, NextFlowController.class);

PipelineService.get().registerPipelineProvider(new NextFlowPipelineProvider(this));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading