Skip to content

Commit 602e800

Browse files
Adopt FileLike for more pipeline APIs (#943)
1 parent 11660ba commit 602e800

58 files changed

Lines changed: 255 additions & 512 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

flow/src/org/labkey/flow/controllers/executescript/AnalysisScriptController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ else if (form.getFile() == null || form.getFile().length == 0)
291291
}
292292
else
293293
{
294-
files.addAll(form.getValidatedFiles(getContainer()));
294+
files.addAll(form.getValidatedFiles(getContainer()).stream().map(FileLike::toNioPathForRead).map(Path::toFile).toList());
295295
}
296296

297297
Set<File> usedPaths = new HashSet<>();
@@ -390,7 +390,7 @@ protected ModelAndView uploadRuns(ImportRunsForm form, BindException errors) thr
390390
if (form.isCurrent())
391391
files = Collections.singletonList(pr.resolvePath(form.getPath()));
392392
else
393-
files = form.getValidatedFiles(form.getContainer());
393+
files = form.getValidatedFiles(form.getContainer()).stream().map(FileLike::toNioPathForRead).map(Path::toFile).toList();
394394

395395
// validate target study
396396
Container targetStudy = getTargetStudy(form.getTargetStudy(), errors);
@@ -544,7 +544,7 @@ public class ImportAnalysisFromPipelineAction extends SimpleViewAction<PipelineP
544544
@Override
545545
public ModelAndView getView(PipelinePathForm form, BindException errors)
546546
{
547-
Path f = form.getValidatedSinglePath(getContainer());
547+
FileLike f = form.getValidatedSingleFile(getContainer());
548548
PipeRoot root = Objects.requireNonNull(PipelineService.get().findPipelineRoot(getContainer()));
549549
String workspacePath = "/" + root.relativePath(f).replace('\\', '/');
550550

flow/src/org/labkey/flow/controllers/run/RunController.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
import org.labkey.flow.query.FlowTableType;
8787
import org.labkey.flow.view.ExportAnalysisForm;
8888
import org.labkey.flow.view.ExportAnalysisManifest;
89+
import org.labkey.vfs.FileLike;
8990
import org.springframework.validation.BindException;
9091
import org.springframework.validation.Errors;
9192
import org.springframework.web.servlet.ModelAndView;
@@ -604,13 +605,13 @@ else if (_wells != null && !_wells.isEmpty())
604605
return _success = true;
605606
}
606607

607-
private void writeManifest(String manifestJson, String dir) throws IOException
608+
private void writeManifest(String manifestJson, File dir) throws IOException
608609
{
609610
if (manifestJson == null || manifestJson.isEmpty())
610611
return;
611612

612613

613-
File file = new File(dir,MANIFEST_FILENAME);
614+
File file = FileUtil.appendName(dir, MANIFEST_FILENAME);
614615
FileOutputStream statisticsFile = new FileOutputStream(file);
615616

616617
try (PrintWriter pw = PrintWriters.getPrintWriter(statisticsFile))
@@ -694,7 +695,7 @@ URLHelper onExportComplete(ExportAnalysisForm form, VirtualFile vf, SampleIdMap<
694695
ViewBackgroundInfo vbi = new ViewBackgroundInfo(getContainer(), getUser(), null);
695696

696697
ExportAnalysisManifest analysisManifest = buildExportAnalysisManifest(form, files);
697-
writeManifest(analysisManifest.toJSON(), vf.getLocation());
698+
writeManifest(analysisManifest.toJSON(), location);
698699

699700
PipelineJob job = new ExportToScriptJob(_guid, _exportToScriptPath, _exportToScriptCommandLine, _exportToScriptFormat, form.getLabel(), location, _exportToScriptTimeout, _exportToScriptDeleteOnComplete, vbi, root);
700701
String jobGuid = null;
@@ -780,7 +781,7 @@ public ExportToScriptJob(String guid, String exportToScriptPath, String exportTo
780781
_deleteOnComplete = deleteOnComplete;
781782

782783
// setup the log file
783-
File logFile = FileUtil.appendName(root.getLogDirectory(), FileUtil.makeFileNameWithTimestamp("export-to-script", "log"));
784+
FileLike logFile = root.getLogDirectoryFileLike(true).resolveChild(FileUtil.makeFileNameWithTimestamp("export-to-script", "log"));
784785
setLogFile(logFile);
785786
}
786787

flow/src/org/labkey/flow/data/FlowAssayProvider.java

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@
2727
import org.labkey.api.exp.OntologyManager;
2828
import org.labkey.api.exp.XarContext;
2929
import org.labkey.api.exp.api.ExpData;
30-
import org.labkey.api.exp.api.ExpExperiment;
3130
import org.labkey.api.exp.api.ExpProtocol;
3231
import org.labkey.api.exp.api.ExpRun;
33-
import org.labkey.api.exp.api.IAssayDomainType;
3432
import org.labkey.api.exp.property.Domain;
3533
import org.labkey.api.exp.property.DomainProperty;
3634
import org.labkey.api.gwt.client.DefaultValueType;
@@ -68,7 +66,6 @@
6866
import org.labkey.flow.script.FlowPipelineProvider;
6967
import org.labkey.flow.view.FlowQueryView;
7068
import org.labkey.flow.webparts.AnalysesWebPart;
71-
import org.springframework.validation.BindException;
7269
import org.springframework.web.servlet.ModelAndView;
7370
import org.springframework.web.servlet.mvc.Controller;
7471

@@ -214,7 +211,7 @@ public Domain getResultsDomain(ExpProtocol protocol, boolean forUpdate)
214211
}
215212

216213
@Override
217-
public AssayRunCreator getRunCreator()
214+
public AssayRunCreator<?> getRunCreator()
218215
{
219216
throw new UnsupportedOperationException();
220217
}
@@ -399,18 +396,6 @@ public DefaultValueType getDefaultValueDefault(Domain domain)
399396
throw new UnsupportedOperationException();
400397
}
401398

402-
@Override
403-
public boolean hasCustomView(IAssayDomainType domainType, boolean details)
404-
{
405-
return false;
406-
}
407-
408-
@Override
409-
public ModelAndView createBeginView(ViewContext context, ExpProtocol protocol)
410-
{
411-
return null;
412-
}
413-
414399
@Override
415400
public ModelAndView createBatchesView(ViewContext context, ExpProtocol protocol)
416401
{
@@ -423,12 +408,6 @@ public ModelAndView createBatchesView(ViewContext context, ExpProtocol protocol)
423408
return view;
424409
}
425410

426-
@Override
427-
public ModelAndView createBatchDetailsView(ViewContext context, ExpProtocol protocol, ExpExperiment batch)
428-
{
429-
return null;
430-
}
431-
432411
@Override
433412
public ModelAndView createRunsView(ViewContext context, ExpProtocol protocol)
434413
{
@@ -437,18 +416,6 @@ public ModelAndView createRunsView(ViewContext context, ExpProtocol protocol)
437416
return new FlowQueryView(form);
438417
}
439418

440-
@Override
441-
public ModelAndView createRunDetailsView(ViewContext context, ExpProtocol protocol, ExpRun run)
442-
{
443-
return null;
444-
}
445-
446-
@Override
447-
public ModelAndView createResultsView(ViewContext context, ExpProtocol protocol, BindException errors)
448-
{
449-
return null;
450-
}
451-
452419
@Override
453420
public ModelAndView createResultDetailsView(ViewContext context, ExpProtocol protocol, ExpData data, Object dataRowId)
454421
{

flow/src/org/labkey/flow/script/AbstractExternalAnalysisJob.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.labkey.api.pipeline.PipelineService;
3737
import org.labkey.api.query.FieldKey;
3838
import org.labkey.api.security.User;
39+
import org.labkey.api.util.FileUtil;
3940
import org.labkey.api.util.Pair;
4041
import org.labkey.api.view.ActionURL;
4142
import org.labkey.api.view.ViewBackgroundInfo;
@@ -383,7 +384,7 @@ protected FlowRun saveAnalysis(User user, Container container, FlowExperiment ex
383384
MultiValuedMap<String, String> sampleIdToNameMap) throws Exception
384385
{
385386
// Fake file URI set on the FCSFile/FCSAnalsyis ExpData to ensure it's recognized by the FlowDataHandler.
386-
URI dataFileURI = new File(externalAnalysisFile.getParent(), "attributes.flowdata.xml").toURI();
387+
URI dataFileURI = FileUtil.appendName(externalAnalysisFile.getParentFile(), "attributes.flowdata.xml").toURI();
387388

388389
// Prepare comp matrices for saving
389390
Map<CompensationMatrix, AttributeSet> compMatrixMap = new HashMap<>();

flow/src/org/labkey/flow/script/FlowJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ protected void runPostAnalysisJobs()
202202
info("Running post-analysis jobs...");
203203
for (FlowReportJob job : jobs)
204204
{
205-
job.setLogFile(getLogFile());
205+
job.setLogFile(getLogFileLike());
206206
job.setLogLevel(getLogLevel());
207207
job.setSubmitted();
208208
job.run();

flow/src/org/labkey/flow/script/ScriptXarSource.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import org.labkey.api.exp.XarSource;
2323
import org.labkey.api.pipeline.PipelineJob;
2424
import org.labkey.api.util.FileUtil;
25+
import org.labkey.vfs.FileLike;
26+
import org.labkey.vfs.FileSystemLike;
2527

2628
import java.io.File;
2729
import java.io.FileWriter;
@@ -85,8 +87,8 @@ public ExperimentArchiveDocument getDocument()
8587

8688

8789
@Override
88-
public Path getLogFilePath()
90+
public FileLike getLogFilePath()
8991
{
90-
return _logFile.toPath();
92+
return FileSystemLike.wrapFile(_logFile);
9193
}
9294
}

luminex/src/org/labkey/luminex/LuminexAssayProvider.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import org.labkey.api.assay.AssayDataType;
5252
import org.labkey.api.assay.AssayPipelineProvider;
5353
import org.labkey.api.assay.AssayProtocolSchema;
54-
import org.labkey.api.assay.AssayRunCreator;
5554
import org.labkey.api.assay.AssayRunDatabaseContext;
5655
import org.labkey.api.assay.AssayRunUploadContext;
5756
import org.labkey.api.assay.AssayTableMetadata;
@@ -113,7 +112,7 @@ public LuminexProtocolSchema createProtocolSchema(User user, Container container
113112
public void registerLsidHandler()
114113
{
115114
super.registerLsidHandler();
116-
LsidManager.get().registerHandler(LUMINEX_DATA_ROW_LSID_PREFIX, new LsidManager.ExpObjectLsidHandler()
115+
LsidManager.get().registerHandler(LUMINEX_DATA_ROW_LSID_PREFIX, new LsidManager.ExpObjectLsidHandler<>()
117116
{
118117
@Override
119118
public ExpData getObject(Lsid lsid)
@@ -454,7 +453,7 @@ public void deleteProtocol(ExpProtocol protocol, User user, @Nullable final Stri
454453
}
455454

456455
@Override
457-
public AssayRunDatabaseContext createRunDatabaseContext(ExpRun run, User user, HttpServletRequest request)
456+
public AssayRunDatabaseContext<?> createRunDatabaseContext(ExpRun run, User user, HttpServletRequest request)
458457
{
459458
return new LuminexRunDatabaseContext(run, user, request);
460459
}
@@ -466,7 +465,7 @@ public AssayRunAsyncContext<?> createRunAsyncContext(AssayRunUploadContext<?> co
466465
}
467466

468467
@Override
469-
public AssayRunCreator getRunCreator()
468+
public LuminexRunCreator getRunCreator()
470469
{
471470
return new LuminexRunCreator(this);
472471
}

luminex/src/org/labkey/luminex/LuminexExclusionPipelineJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public LuminexExclusionPipelineJob(ViewBackgroundInfo info, PipeRoot root, Lumin
4444
{
4545
super(LuminexAssayProvider.NAME, info, root);
4646

47-
setLogFile(root.getLogDirectoryFileLike(true).resolveChild(FileUtil.makeFileNameWithTimestamp("luminex_exclusion", "log")).toNioPathForWrite());
47+
setLogFile(root.getLogDirectoryFileLike(true).resolveChild(FileUtil.makeFileNameWithTimestamp("luminex_exclusion", "log")));
4848

4949
_form = form;
5050
_exclusionType = LuminexManager.ExclusionType.valueOf(form.getTableName());

luminex/src/org/labkey/luminex/query/WellExclusionTable.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,18 @@ public WellExclusionTable(LuminexProtocolSchema schema, ContainerFilter cf, bool
7373
{
7474
super(LuminexProtocolSchema.getTableInfoWellExclusion(), schema, cf, filter);
7575

76-
getMutableColumn("DataId").setLabel("Data File");
77-
getMutableColumn("DataId").setFk(new ExpSchema(schema.getUser(), schema.getContainer()).getDataIdForeignKey(cf));
76+
getMutableColumnOrThrow("DataId").setLabel("Data File");
77+
getMutableColumnOrThrow("DataId").setFk(new ExpSchema(schema.getUser(), schema.getContainer()).getDataIdForeignKey(cf));
7878

79-
getMutableColumn("Analytes").setFk(new MultiValuedForeignKey(new LookupForeignKey(cf, "WellExclusionId", null)
79+
getMutableColumnOrThrow("Analytes").setFk(new MultiValuedForeignKey(new LookupForeignKey(cf, "WellExclusionId", null)
8080
{
8181
@Override
8282
public TableInfo getLookupTableInfo()
8383
{
8484
return _userSchema.createWellExclusionAnalyteTable(getLookupContainerFilter());
8585
}
8686
}, "AnalyteId"));
87-
getMutableColumn("Analytes").setUserEditable(false);
87+
getMutableColumnOrThrow("Analytes").setUserEditable(false);
8888

8989
SQLFragment joinSQL = new SQLFragment(" FROM ");
9090
joinSQL.append(LuminexProtocolSchema.getTableInfoDataRow(), "dr");
@@ -123,8 +123,7 @@ public Object getDisplayValue(RenderContext ctx)
123123
if (null != result)
124124
{
125125
// get the list of unique wells (by splitting the concatenated string)
126-
TreeSet<String> uniqueWells = new TreeSet<>();
127-
uniqueWells.addAll(Arrays.asList(result.toString().split(MultiValuedRenderContext.VALUE_DELIMITER_REGEX)));
126+
TreeSet<String> uniqueWells = new TreeSet<>(Arrays.asList(result.toString().split(MultiValuedRenderContext.VALUE_DELIMITER_REGEX)));
128127

129128
// put the unique wells back into a comma separated string
130129
StringBuilder sb = new StringBuilder();
@@ -332,7 +331,7 @@ private void rerunTransformScripts(BatchValidationException errors) throws Query
332331
for (ExpRun run : _runsToRefresh)
333332
{
334333
AssayProvider provider = AssayService.get().getProvider(run);
335-
AssayRunDatabaseContext context = provider.createRunDatabaseContext(run, _userSchema.getUser(), null);
334+
AssayRunDatabaseContext<?> context = provider.createRunDatabaseContext(run, _userSchema.getUser(), null);
336335
provider.getRunCreator().saveExperimentRun(context, AssayService.get().findBatch(run), run, false, null);
337336
}
338337
}

luminex/test/src/org/labkey/test/tests/luminex/LuminexPositivityTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.junit.BeforeClass;
2020
import org.junit.Test;
2121
import org.junit.experimental.categories.Category;
22+
import org.labkey.api.util.FileUtil;
2223
import org.labkey.test.BaseWebDriverTest;
2324
import org.labkey.test.Locator;
2425
import org.labkey.test.TestFileUtils;
@@ -57,7 +58,7 @@ public final class LuminexPositivityTest extends LuminexTest
5758
private Boolean _expectedNegativeControlValue = false;
5859
private Boolean _newNegativeControlValue = false;
5960
private static final String _negControlAnalyte = _analyteNames.get(1);
60-
private static final File POSITIVITY_RTRANSFORM_SCRIPT_FILE = new File(TestFileUtils.getLabKeyRoot(), "server/modules/commonAssays/luminex/resources/transformscripts/description_parsing_example.pl");
61+
private static final File POSITIVITY_RTRANSFORM_SCRIPT_FILE = FileUtil.appendPath(TestFileUtils.getLabKeyRoot(), org.labkey.api.util.Path.parse("server/modules/commonAssays/luminex/resources/transformscripts/description_parsing_example.pl"));
6162
private static final String RUN_ID_BASE = "Positivity";
6263

6364
@BeforeClass

0 commit comments

Comments
 (0)