Skip to content

Commit 5c3e57b

Browse files
committed
Allow single cell handlers to use default value in the case that no value for the parameter is provided at all in JSON
1 parent b21c66c commit 5c3e57b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

SequenceAnalysis/api-src/org/labkey/api/sequenceanalysis/pipeline/ToolParameterDescriptor.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,22 @@ public <ParamType> ParamType extractValue(PipelineJob job, PipelineStepProvider<
187187
return this.extractValue(job, provider, stepIdx, clazz, null);
188188
}
189189

190+
public boolean hasValueInJson(PipelineJob job, PipelineStepProvider<?> provider, int stepIdx)
191+
{
192+
String key = getJsonParamName(provider, stepIdx);
193+
JSONObject jobParams;
194+
if (job instanceof HasJobParams)
195+
{
196+
jobParams = ((HasJobParams)job).getParameterJson();
197+
}
198+
else
199+
{
200+
jobParams = new JSONObject(job.getParameters());
201+
}
202+
203+
return jobParams.has(key);
204+
}
205+
190206
public <ParamType> ParamType extractValue(PipelineJob job, PipelineStepProvider<?> provider, int stepIdx, Class<ParamType> clazz, @Nullable ParamType defaultValue)
191207
{
192208
String key = getJsonParamName(provider, stepIdx);

singlecell/api-src/org/labkey/api/singlecell/pipeline/AbstractSingleCellPipelineStep.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,13 @@ public String getDockerHomeDir()
383383
protected void addParameterVariables(SeuratToolParameter pd, List<String> body)
384384
{
385385
String val = StringUtils.trimToNull(pd.extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx()));
386+
387+
// Note: use this only if there is no value provided at all in JSON
388+
if (pd.getDefaultValue() != null && !pd.hasValueInJson(getPipelineCtx().getJob(), getProvider(), getStepIdx()))
389+
{
390+
val = String.valueOf(pd.getDefaultValue());
391+
}
392+
386393
if (val == null)
387394
{
388395
body.add((pd.getVariableName() + " <- NULL"));

0 commit comments

Comments
 (0)