Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.labkey.elispot.plate.PlateInfo;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -72,7 +71,7 @@ public BackgroundSubtractionJob(String provider, ViewBackgroundInfo info, PipeRo
{
super(provider, info, root);

File logFile = FileUtil.createTempFile("backgroundSubtractionJob", ".log", root.getLogDirectory());
FileLike logFile = FileUtil.createTempFile("backgroundSubtractionJob", ".log", root.getLogDirectory(true));
setLogFile(logFile);

_runs = runs;
Expand Down
15 changes: 7 additions & 8 deletions flow/enginesrc/org/labkey/flow/persist/AttributeSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
import org.labkey.flow.flowdata.xml.Graph;
import org.labkey.flow.flowdata.xml.Keyword;
import org.labkey.flow.flowdata.xml.Statistic;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.net.URI;
Expand Down Expand Up @@ -95,8 +94,7 @@ public AttributeSet(FlowData data, URI uri)
{
Set<String> aliases = new LinkedHashSet<>();
_keywordAliases.put(name, aliases);
for (String alias : keyword.getAliases().getAliasArray())
aliases.add(alias);
Collections.addAll(aliases, keyword.getAliases().getAliasArray());
}
}
}
Expand Down Expand Up @@ -381,12 +379,13 @@ public Collection<GraphSpec> getGraphAliases(GraphSpec spec)
return Collections.unmodifiableCollection(aliases);
}

public void save(File file, DataBaseType dbt) throws Exception
public void save(FileLike file, DataBaseType dbt) throws Exception
{
dbt.setDataFileUrl(file.toURI().toString());
OutputStream os = new FileOutputStream(file);
save(os);
os.close();
try (OutputStream os = file.openOutputStream())
{
save(os);
}
}

public void save(OutputStream os) throws Exception
Expand Down
6 changes: 3 additions & 3 deletions flow/src/org/labkey/flow/FlowSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ static private FileLike getTempAnalysisDirectory()
*
* @return File object representing the Flow analysis working directory.
*/
static public File getWorkingDirectory()
static public FileLike getWorkingDirectory()
{
//Get admin provided setting if it exists
String path = getWorkingDirectoryPath();
if (path != null)
return new File(path);
return FileSystemLike.wrapFile(new File(path));

// Otherwise default to the
return FileSystemLike.toFile(getTempAnalysisDirectory());
return getTempAnalysisDirectory();
}

static public String getWorkingDirectoryPath()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,12 @@ protected ModelAndView uploadRuns(ImportRunsForm form, BindException errors) thr
}

validatePipeline();
List<File> files;
List<FileLike> files;
PipeRoot pr = PipelineService.get().findPipelineRoot(getContainer());
if (form.isCurrent())
files = Collections.singletonList(pr.resolvePath(form.getPath()));
files = Collections.singletonList(pr.resolvePathToFileLike(form.getPath()));
else
files = form.getValidatedFiles(form.getContainer()).stream().map(FileLike::toNioPathForRead).map(Path::toFile).toList();
files = form.getValidatedFiles(form.getContainer());

// validate target study
Container targetStudy = getTargetStudy(form.getTargetStudy(), errors);
Expand Down Expand Up @@ -736,7 +736,7 @@ private void getWorkspace(ImportAnalysisForm form, Errors errors)
// - absolute (run path)
// - a file-browser path (relative to pipe root but starts with '/')
// - a file-browser path (relative to pipe root and doesn't start with '/')
private File getDir(String path, Errors errors)
private FileLike getDir(String path, Errors errors)
{
PipeRoot root = getPipeRoot();
File dir = new File(path);
Expand All @@ -758,11 +758,11 @@ private File getDir(String path, Errors errors)
errors.reject(ERROR_MSG, "The path specified must be a directory containing FCS files.");
return null;
}
return dir;
return FileSystemLike.wrapFile(dir);
}

// Get the directory to use as the file path root of the flow analysis run.
private File getRunPathRoot(List<File> keywordDirs, SampleIdMap<FlowFCSFile> resolvedFCSFiles)
private FileLike getRunPathRoot(List<FileLike> keywordDirs, SampleIdMap<FlowFCSFile> resolvedFCSFiles)
{
if (keywordDirs != null && !keywordDirs.isEmpty())
{
Expand All @@ -782,7 +782,7 @@ private File getRunPathRoot(List<File> keywordDirs, SampleIdMap<FlowFCSFile> res
FlowRun flowRun = fcsFile.getRun();
ExpRun expRun = flowRun != null ? flowRun.getExperimentRun() : null;
if (expRun != null)
return expRun.getFilePathRoot();
return expRun.getFilePathFileLike();
}
}
}
Expand All @@ -792,7 +792,7 @@ private File getRunPathRoot(List<File> keywordDirs, SampleIdMap<FlowFCSFile> res

// Get the path to either the previously imported keyword run or
// to the selected pipeline browser directory under the pipeline root.
private List<File> getKeywordDirs(ImportAnalysisForm form, Errors errors)
private List<FileLike> getKeywordDirs(ImportAnalysisForm form, Errors errors)
{
String path = null;
if (form.getKeywordDir() != null && form.getKeywordDir().length > 0)
Expand All @@ -803,7 +803,7 @@ private List<File> getKeywordDirs(ImportAnalysisForm form, Errors errors)

if (path != null)
{
File keywordDir = getDir(path, errors);
FileLike keywordDir = getDir(path, errors);
if (errors.hasErrors())
return null;

Expand Down Expand Up @@ -1115,7 +1115,7 @@ else if (fcsFilesOption == SelectFCSFileOption.Previous)
else if (fcsFilesOption == SelectFCSFileOption.Browse)
{
WorkspaceData workspaceData = form.getWorkspace();
List<File> keywordDirs = getKeywordDirs(form, errors);
List<FileLike> keywordDirs = getKeywordDirs(form, errors);
if (keywordDirs == null || keywordDirs.isEmpty())
errors.reject(ERROR_MSG, "No directory selected");

Expand All @@ -1125,7 +1125,7 @@ else if (fcsFilesOption == SelectFCSFileOption.Browse)
if (errors.hasErrors())
return;

File keywordDir = keywordDirs.get(0);
FileLike keywordDir = keywordDirs.get(0);

// Translate selected keyword directory into a existing keyword run if possible.
FlowRun existingKeywordRun = null;
Expand Down Expand Up @@ -1160,7 +1160,7 @@ else if (fcsFilesOption == SelectFCSFileOption.Browse)
Map<String, SelectedSamples.ResolvedSample> rows = new HashMap<>();
for (ISampleInfo sampleInfo : sampleInfos)
{
File sampleFile = FileUtil.appendName(keywordDir, sampleInfo.getLabel());
FileLike sampleFile = keywordDir.resolveChild(sampleInfo.getLabel());
boolean exists = sampleFile.exists();
if (exists)
found = true;
Expand Down Expand Up @@ -1316,7 +1316,7 @@ else if (workspace instanceof FlowJoWorkspace)

private void stepChooseAnalysis(ImportAnalysisForm form, BindException errors)
{
List<File> keywordDirs = getKeywordDirs(form, errors);
List<FileLike> keywordDirs = getKeywordDirs(form, errors);
if (errors.hasErrors())
return;

Expand Down Expand Up @@ -1358,8 +1358,8 @@ private void stepChooseAnalysis(ImportAnalysisForm form, BindException errors)

if (keywordDirs != null)
{
for (File keywordDir : keywordDirs)
if (experiment.hasRun(keywordDir, null))
for (FileLike keywordDir : keywordDirs)
if (experiment.hasRun(keywordDir.toNioPathForRead().toFile(), null))
{
errors.reject(ERROR_MSG, "The '" + experiment.getName() + "' analysis folder already contains the FCS files from '" + keywordDir + "'.");
return;
Expand Down Expand Up @@ -1388,7 +1388,7 @@ private void stepChooseAnalysis(ImportAnalysisForm form, BindException errors)

private void stepConfirm(ImportAnalysisForm form, BindException errors) throws Exception
{
List<File> keywordDirs = getKeywordDirs(form, errors);
List<FileLike> keywordDirs = getKeywordDirs(form, errors);
if (errors.hasErrors())
return;

Expand Down Expand Up @@ -1421,7 +1421,7 @@ private void stepConfirm(ImportAnalysisForm form, BindException errors) throws E
throw new IllegalArgumentException("Wrong container");

WorkspaceData workspaceData = form.getWorkspace();
File pipelineFile = null;
FileLike pipelineFile = null;
ViewBackgroundInfo info = getViewBackgroundInfo();
if (getPipeRoot() == null)
{
Expand All @@ -1431,11 +1431,11 @@ private void stepConfirm(ImportAnalysisForm form, BindException errors) throws E
else
{
if (workspaceData.getPath() != null)
pipelineFile = getPipeRoot().resolvePath(workspaceData.getPath());
pipelineFile = getPipeRoot().resolvePathToFileLike(workspaceData.getPath());
}

// Choose a run path root for the imported analysis based upon the input FCS files.
File runFilePathRoot = getRunPathRoot(keywordDirs, selectedFCSFiles);
FileLike runFilePathRoot = getRunPathRoot(keywordDirs, selectedFCSFiles);

AnalysisEngine analysisEngine = getAnalysisEngine(form);
if (errors.hasErrors())
Expand Down Expand Up @@ -1465,9 +1465,9 @@ private void stepConfirm(ImportAnalysisForm form, BindException errors) throws E
else if (AnalysisEngine.Archive == analysisEngine)
{
assert (workspaceData.getWorkspaceObject() instanceof ExternalAnalysis);
File originalFile = pipelineFile;
FileLike originalFile = pipelineFile;
if (workspaceData.getOriginalPath() != null)
originalFile = root.resolvePath(workspaceData.getOriginalPath());
originalFile = root.resolvePathToFileLike(workspaceData.getOriginalPath());
job = new ImportResultsJob(info, getPipeRoot(), experiment,
AnalysisEngine.Archive, pipelineFile, originalFile,
runFilePathRoot,
Expand Down
25 changes: 9 additions & 16 deletions flow/src/org/labkey/flow/controllers/run/RunController.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import org.labkey.flow.view.ExportAnalysisForm;
import org.labkey.flow.view.ExportAnalysisManifest;
import org.labkey.vfs.FileLike;
import org.labkey.vfs.FileSystemLike;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.web.servlet.ModelAndView;
Expand All @@ -96,7 +97,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -605,16 +605,12 @@ else if (_wells != null && !_wells.isEmpty())
return _success = true;
}

private void writeManifest(String manifestJson, File dir) throws IOException
private void writeManifest(String manifestJson, FileLike dir) throws IOException
{
if (manifestJson == null || manifestJson.isEmpty())
return;


File file = FileUtil.appendName(dir, MANIFEST_FILENAME);
FileOutputStream statisticsFile = new FileOutputStream(file);

try (PrintWriter pw = PrintWriters.getPrintWriter(statisticsFile))
try (PrintWriter pw = PrintWriters.getPrintWriter(dir.resolveChild(MANIFEST_FILENAME).openOutputStream()))
{
pw.write(manifestJson);
}
Expand Down Expand Up @@ -690,7 +686,7 @@ URLHelper onExportComplete(ExportAnalysisForm form, VirtualFile vf, SampleIdMap<

case Script:
// after exporting the files, execute script as a pipeline job
File location = new File(vf.getLocation());
FileLike location = FileSystemLike.wrapFile(new File(vf.getLocation()));
PipeRoot root = PipelineService.get().findPipelineRoot(getContainer());
ViewBackgroundInfo vbi = new ViewBackgroundInfo(getContainer(), getUser(), null);

Expand Down Expand Up @@ -742,7 +738,7 @@ private static class ExportToScriptJob extends PipelineJob
private final String _exportToScriptCommandLine;
private final String _exportToScriptFormat;
private final String _label;
private final File _location;
private final FileLike _location;
private final Integer _timeout;
private final boolean _deleteOnComplete;

Expand All @@ -753,7 +749,7 @@ protected ExportToScriptJob(
@JsonProperty("_exportToScriptCommandLine") String exportToScriptCommandLine,
@JsonProperty("_exportToScriptFormat") String exportToScriptFormat,
@JsonProperty("_label") String label,
@JsonProperty("_location") File location,
@JsonProperty("_location") FileLike location,
@JsonProperty("_timeout") Integer timeout,
@JsonProperty("_deleteOnComplete") boolean deleteOnComplete
)
Expand All @@ -768,7 +764,7 @@ protected ExportToScriptJob(
_deleteOnComplete = deleteOnComplete;
}

public ExportToScriptJob(String guid, String exportToScriptPath, String exportToScriptCommandLine, String exportToScriptFormat, String label, File location, Integer timeout, boolean deleteOnComplete, ViewBackgroundInfo info, @NotNull PipeRoot root)
public ExportToScriptJob(String guid, String exportToScriptPath, String exportToScriptCommandLine, String exportToScriptFormat, String label, FileLike location, Integer timeout, boolean deleteOnComplete, ViewBackgroundInfo info, @NotNull PipeRoot root)
{
super(null, info, root);
_guid = guid;
Expand All @@ -781,7 +777,7 @@ public ExportToScriptJob(String guid, String exportToScriptPath, String exportTo
_deleteOnComplete = deleteOnComplete;

// setup the log file
FileLike logFile = root.getLogDirectoryFileLike(true).resolveChild(FileUtil.makeFileNameWithTimestamp("export-to-script", "log"));
FileLike logFile = root.getLogDirectory(true).resolveChild(FileUtil.makeFileNameWithTimestamp("export-to-script", "log"));
setLogFile(logFile);
}

Expand All @@ -799,10 +795,7 @@ public URLHelper getStatusHref()
urlHelper = new URLHelper(url);
}
}
catch (Exception e)
{
urlHelper = null;
}
catch (Exception ignored) {}
return urlHelper;
}

Expand Down
3 changes: 1 addition & 2 deletions flow/src/org/labkey/flow/data/FlowCompensationMatrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.labkey.api.query.FieldKey;
import org.labkey.api.query.QueryRowReference;
import org.labkey.api.security.User;
import org.labkey.api.util.FileUtil;
import org.labkey.api.view.ActionURL;
import org.labkey.flow.FlowSettings;
import org.labkey.flow.analysis.model.CompensationMatrix;
Expand Down Expand Up @@ -88,7 +87,7 @@ static public FlowCompensationMatrix create(User user, Container container, Stri
{
data = svc.createData(container, FlowDataType.CompensationMatrix, name);
}
data.setDataFileURI(FileUtil.appendName(FlowSettings.getWorkingDirectory(), "compensation." + FlowDataHandler.EXT_DATA).toURI());
data.setDataFileURI(FlowSettings.getWorkingDirectory().resolveChild("compensation." + FlowDataHandler.EXT_DATA).toURI());
data.save(user);
AttributeSetHelper.doSave(attrs, user, data, log);
flowComp = (FlowCompensationMatrix) FlowDataObject.fromData(data);
Expand Down
Loading