|
1 | 1 | package org.labkey.api.singlecell.pipeline; |
2 | 2 |
|
| 3 | +import org.apache.commons.lang3.StringUtils; |
3 | 4 | import org.jetbrains.annotations.Nullable; |
4 | 5 | import org.json.JSONObject; |
| 6 | +import org.labkey.api.pipeline.PipelineJob; |
| 7 | +import org.labkey.api.sequenceanalysis.pipeline.PipelineStepProvider; |
5 | 8 | import org.labkey.api.sequenceanalysis.pipeline.ToolParameterDescriptor; |
6 | 9 |
|
7 | 10 | public class SeuratToolParameter extends ToolParameterDescriptor |
8 | 11 | { |
9 | 12 | private String _rName; |
| 13 | + private boolean _includeIfEmptyOrNull; |
10 | 14 |
|
11 | | - public SeuratToolParameter(String name, String label, String description, String fieldXtype, @Nullable Object defaultValue, @Nullable JSONObject additionalExtConfig, String rName) |
| 15 | + public SeuratToolParameter(String name, String label, String description, String fieldXtype, @Nullable Object defaultValue, @Nullable JSONObject additionalExtConfig, String rName, boolean includeIfEmptyOrNull) |
12 | 16 | { |
13 | 17 | super(null, name, label, description, fieldXtype, defaultValue, additionalExtConfig); |
14 | 18 |
|
15 | 19 | _rName = rName; |
| 20 | + _includeIfEmptyOrNull = includeIfEmptyOrNull; |
16 | 21 | } |
17 | 22 |
|
18 | 23 | public static SeuratToolParameter create(String name, String label, String description, String fieldXtype, @Nullable JSONObject additionalExtConfig, @Nullable Object defaultValue) |
19 | 24 | { |
20 | | - return new SeuratToolParameter(name, label, description, fieldXtype, defaultValue, additionalExtConfig, null); |
| 25 | + return new SeuratToolParameter(name, label, description, fieldXtype, defaultValue, additionalExtConfig, null, true); |
21 | 26 | } |
22 | 27 |
|
23 | | - public static SeuratToolParameter create(String name, String label, String description, String fieldXtype, @Nullable JSONObject additionalExtConfig, @Nullable Object defaultValue, String rName) |
| 28 | + public static SeuratToolParameter create(String name, String label, String description, String fieldXtype, @Nullable JSONObject additionalExtConfig, @Nullable Object defaultValue, String rName, boolean includeIfEmptyOrNull) |
24 | 29 | { |
25 | | - return new SeuratToolParameter(name, label, description, fieldXtype, defaultValue, additionalExtConfig, rName); |
| 30 | + return new SeuratToolParameter(name, label, description, fieldXtype, defaultValue, additionalExtConfig, rName, includeIfEmptyOrNull); |
26 | 31 | } |
27 | 32 |
|
28 | 33 | public String getVariableName() |
29 | 34 | { |
30 | 35 | return _rName == null ? getName() : _rName; |
31 | 36 | } |
| 37 | + |
| 38 | + public boolean shouldIncludeInMarkdown(PipelineJob job, PipelineStepProvider provider, int stepIdx) |
| 39 | + { |
| 40 | + if (!_includeIfEmptyOrNull) |
| 41 | + { |
| 42 | + return StringUtils.trimToNull(extractValue(job, provider, stepIdx)) != null; |
| 43 | + } |
| 44 | + |
| 45 | + return true; |
| 46 | + } |
32 | 47 | } |
0 commit comments