Skip to content

Commit 8d4f1a4

Browse files
Minor NextFlow fixes (#472)
1 parent 8b13c2a commit 8d4f1a4

File tree

6 files changed

+36
-57
lines changed

6 files changed

+36
-57
lines changed

nextflow/src/org/labkey/nextflow/NextFlowController.java

Lines changed: 27 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.labkey.nextflow;
22

3-
import lombok.Data;
43
import lombok.Getter;
54
import lombok.Setter;
65
import org.apache.commons.lang3.StringUtils;
@@ -9,7 +8,6 @@
98
import org.labkey.api.action.ApiSimpleResponse;
109
import org.labkey.api.action.FormViewAction;
1110
import org.labkey.api.action.MutatingApiAction;
12-
import org.labkey.api.action.SimpleViewAction;
1311
import org.labkey.api.action.SpringActionController;
1412
import org.labkey.api.admin.AdminUrls;
1513
import org.labkey.api.data.PropertyManager;
@@ -22,7 +20,6 @@
2220
import org.labkey.api.security.AdminConsoleAction;
2321
import org.labkey.api.security.RequiresPermission;
2422
import org.labkey.api.security.permissions.AdminOperationsPermission;
25-
import org.labkey.api.security.permissions.InsertPermission;
2623
import org.labkey.api.security.permissions.ReadPermission;
2724
import org.labkey.api.security.permissions.SiteAdminPermission;
2825
import org.labkey.api.util.Button;
@@ -34,7 +31,6 @@
3431
import org.labkey.api.util.URLHelper;
3532
import org.labkey.api.util.element.Select;
3633
import org.labkey.api.util.logging.LogHelper;
37-
import org.labkey.api.view.ActionURL;
3834
import org.labkey.api.view.HtmlView;
3935
import org.labkey.api.view.JspView;
4036
import org.labkey.api.view.NavTree;
@@ -45,10 +41,7 @@
4541
import org.springframework.validation.Errors;
4642
import org.springframework.web.servlet.ModelAndView;
4743

48-
import javax.swing.text.html.FormView;
49-
5044
import java.io.File;
51-
import java.nio.file.Paths;
5245
import java.util.Arrays;
5346
import java.util.List;
5447

@@ -60,7 +53,6 @@
6053
import static org.labkey.api.util.DOM.Attribute.value;
6154
import static org.labkey.api.util.DOM.DIV;
6255
import static org.labkey.api.util.DOM.INPUT;
63-
import static org.labkey.api.util.DOM.LI;
6456
import static org.labkey.api.util.DOM.LK.FORM;
6557
import static org.labkey.api.util.DOM.UL;
6658
import static org.labkey.api.util.DOM.at;
@@ -78,32 +70,6 @@ public NextFlowController()
7870
setActionResolver(_actionResolver);
7971
}
8072

81-
@RequiresPermission(ReadPermission.class)
82-
public static class BeginAction extends SimpleViewAction<Object>
83-
{
84-
@Override
85-
public ModelAndView getView(Object o, BindException errors)
86-
{
87-
boolean enabled = NextFlowManager.get().isEnabled(getContainer());
88-
return new HtmlView("NextFlow",
89-
DIV(
90-
DIV("NextFlow integration is " + (enabled ? "enabled" : "disabled") + " in this " + (getContainer().isProject() ? "project" : "folder") + "."),
91-
DIV(
92-
getContainer().hasPermission(getUser(), SiteAdminPermission.class) ?
93-
new Button.ButtonBuilder("Enable/Disable").href(new ActionURL(NextFlowEnableAction.class, getContainer())).build() : null,
94-
" ",
95-
enabled && getContainer().hasPermission(getUser(), InsertPermission.class) ?
96-
new Button.ButtonBuilder("Run NextFlow Analysis").href(new ActionURL(NextFlowRunAction.class, getContainer())).build() : null)));
97-
}
98-
99-
@Override
100-
public void addNavTrail(NavTree root)
101-
{
102-
root.addChild("NextFlow");
103-
}
104-
}
105-
106-
10773
@RequiresPermission(SiteAdminPermission.class)
10874
public static class DeleteNextFlowConfigurationAction extends MutatingApiAction<Object>
10975
{
@@ -215,8 +181,8 @@ public void setEnabled(Boolean enabled)
215181
}
216182
}
217183

218-
@RequiresPermission(SiteAdminPermission.class)
219-
public static class NextFlowEnableAction extends FormViewAction<EnabledForm>
184+
@RequiresPermission(ReadPermission.class)
185+
public static class BeginAction extends FormViewAction<EnabledForm>
220186
{
221187
@Override
222188
public void validateCommand(EnabledForm target, Errors errors)
@@ -227,21 +193,30 @@ public void validateCommand(EnabledForm target, Errors errors)
227193
@Override
228194
public ModelAndView getView(EnabledForm form, boolean reshow, BindException errors)
229195
{
230-
Boolean status = NextFlowManager.get().getEnabledState(getContainer());
231-
boolean inheritedStatus = NextFlowManager.get().isEnabled(getContainer().getParent());
232-
233-
return new HtmlView("Enable/Disable NextFlow",
234-
FORM(at(method, "POST"),
235-
DIV(INPUT(at(type, "radio", name, "enabled", value, Boolean.TRUE.toString(), (status == Boolean.TRUE ? checked : null), null)),
236-
"Enabled"),
237-
DIV(INPUT(at(type, "radio", name, "enabled", value, Boolean.FALSE.toString(), (status == Boolean.FALSE ? checked : null), null)),
238-
"Disabled"),
239-
DIV(INPUT(at(type, "radio", name, "enabled", value, "", (status == null ? checked : null), null)),
240-
getContainer().isRoot() ?
241-
"Unset" :
242-
"Inherited from " + getContainer().getParent().getPath() + " (currently " + (inheritedStatus ? "enabled" : "disabled") + ")"),
243-
new Button.ButtonBuilder("Save").submit(true).build(), " ",
244-
new Button.ButtonBuilder("Cancel").href(getContainer().getStartURL(getUser())).build()));
196+
if (getUser().hasSiteAdminPermission())
197+
{
198+
Boolean status = NextFlowManager.get().getEnabledState(getContainer());
199+
boolean inheritedStatus = NextFlowManager.get().isEnabled(getContainer().getParent());
200+
201+
return new HtmlView("Enable or Disable NextFlow",
202+
FORM(at(method, "POST"),
203+
DIV(INPUT(at(type, "radio", name, "enabled", value, Boolean.TRUE.toString(), (status == Boolean.TRUE ? checked : null), null)),
204+
"Enabled"),
205+
DIV(INPUT(at(type, "radio", name, "enabled", value, Boolean.FALSE.toString(), (status == Boolean.FALSE ? checked : null), null)),
206+
"Disabled"),
207+
DIV(INPUT(at(type, "radio", name, "enabled", value, "", (status == null ? checked : null), null)),
208+
getContainer().isRoot() ?
209+
"Unset" :
210+
"Inherited from " + getContainer().getParent().getPath() + " (currently " + (inheritedStatus ? "enabled" : "disabled") + ")"),
211+
new Button.ButtonBuilder("Save").submit(true).build(), " ",
212+
new Button.ButtonBuilder("Cancel").href(getContainer().getStartURL(getUser())).build()));
213+
}
214+
else
215+
{
216+
return new HtmlView("NextFlow Integration Status",
217+
DIV("NextFlow integration is " + (NextFlowManager.get().isEnabled(getContainer()) ? "enabled" : "disabled") + " in this " + (getContainer().isProject() ? "project" : "folder") + ".")
218+
);
219+
}
245220
}
246221

247222
@Override
@@ -254,7 +229,7 @@ public boolean handlePost(EnabledForm form, BindException errors)
254229
@Override
255230
public void addNavTrail(NavTree root)
256231
{
257-
root.addChild("Enable/Disable NextFlow");
232+
root.addChild("NextFlow Integration Status");
258233
}
259234

260235
@Override

nextflow/src/org/labkey/nextflow/NextFlowManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private void checkArgs(NextFlowConfiguration config, BindException errors)
4848
errors.rejectValue("nextFlowConfigFilePath", ERROR_MSG, "NextFlow config file path is required");
4949

5050
Path configPath = Paths.get(config.getNextFlowConfigFilePath());
51-
if (Files.isDirectory(configPath))
51+
if (!Files.isDirectory(configPath))
5252
{
5353
errors.rejectValue("nextFlowConfigFilePath", ERROR_MSG, "NextFlow config file path must be a directory");
5454
}

nextflow/src/org/labkey/nextflow/NextFlowModule.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ protected void startupAfterSpringConfig(ModuleContext moduleContext)
2929
protected void init()
3030
{
3131
addController(NextFlowController.NAME, NextFlowController.class);
32-
33-
PipelineService.get().registerPipelineProvider(new NextFlowPipelineProvider(this));
3432
}
3533

3634
@Override

nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static NextFlowPipelineJob create(ViewBackgroundInfo info, @NotNull PipeR
4141
Path log = jobDir.resolve(jobName + ".log");
4242
FileUtil.createDirectory(jobDir);
4343

44-
Path config = createConfig(templateConfig, log.getParent(), jobDir, info.getContainer());
44+
Path config = createConfig(templateConfig, parentDir, jobDir, info.getContainer());
4545

4646
return new NextFlowPipelineJob(info, root, config, inputFiles, log);
4747
}

nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineProvider.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ public NextFlowPipelineProvider(NextFlowModule owningModule)
1919
super(NAME, owningModule);
2020
}
2121

22+
@Override
23+
public boolean isShowActionsIfModuleInactive()
24+
{
25+
// We rely on a setting that folder admins can't control to determine if NextFlow is available
26+
return true;
27+
}
28+
2229
@Override
2330
public void updateFileProperties(ViewContext context, PipeRoot pr, PipelineDirectory directory, boolean includeAll)
2431
{

nextflow/src/org/labkey/nextflow/pipeline/NextFlowRunTask.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.labkey.api.pipeline.PipelineJobException;
99
import org.labkey.api.pipeline.RecordedAction;
1010
import org.labkey.api.pipeline.RecordedActionSet;
11-
import org.labkey.api.pipeline.ToolExecutionException;
1211
import org.labkey.api.pipeline.WorkDirectoryTask;
1312
import org.labkey.api.security.SecurityManager;
1413
import org.labkey.api.util.FileType;

0 commit comments

Comments
 (0)