2020import org .labkey .api .util .StringUtilsLabKey ;
2121import org .labkey .api .util .logging .LogHelper ;
2222import org .labkey .api .view .ViewBackgroundInfo ;
23+ import org .labkey .api .writer .PrintWriters ;
2324import org .labkey .nextflow .NextFlowManager ;
25+ import org .labkey .vfs .FileLike ;
2426
2527import java .io .BufferedWriter ;
2628import java .io .File ;
@@ -35,29 +37,29 @@ public class NextFlowPipelineJob extends AbstractFileAnalysisJob
3537{
3638 protected static final Logger LOG = LogHelper .getLogger (NextFlowPipelineJob .class , "NextFlow jobs" );
3739
38- private Path config ;
40+ private FileLike config ;
3941
4042 @ SuppressWarnings ("unused" ) // For serialization
4143 protected NextFlowPipelineJob ()
4244 {}
4345
44- public static NextFlowPipelineJob create (ViewBackgroundInfo info , @ NotNull PipeRoot root , Path templateConfig , List <Path > inputFiles ) throws IOException
46+ public static NextFlowPipelineJob create (ViewBackgroundInfo info , @ NotNull PipeRoot root , Path templateConfig , List <FileLike > inputFiles ) throws IOException
4547 {
46- Path parentDir = inputFiles .get (0 ).getParent ();
48+ FileLike parentDir = inputFiles .get (0 ).getParent ();
4749
4850 String jobName = FileUtil .makeFileNameWithTimestamp ("NextFlow" );
49- Path jobDir = parentDir .resolve (jobName );
50- Path log = jobDir .resolve (jobName + ".log" );
51+ FileLike jobDir = parentDir .resolveChild (jobName );
52+ FileLike log = jobDir .resolveChild (jobName + ".log" );
5153 FileUtil .createDirectory (jobDir );
5254
53- Path config = createConfig (templateConfig , parentDir , jobDir , info .getContainer ());
55+ FileLike config = createConfig (templateConfig , parentDir , jobDir , info .getContainer ());
5456
5557 return new NextFlowPipelineJob (info , root , config , inputFiles , log );
5658 }
5759
58- public NextFlowPipelineJob (ViewBackgroundInfo info , @ NotNull PipeRoot root , Path config , List <Path > inputFiles , Path log ) throws IOException
60+ public NextFlowPipelineJob (ViewBackgroundInfo info , @ NotNull PipeRoot root , FileLike config , List <FileLike > inputFiles , FileLike log ) throws IOException
5961 {
60- super (new NextFlowProtocol (), NextFlowPipelineProvider .NAME , info , root , config .getFileName (). toString () , config , inputFiles , false , false );
62+ super (new NextFlowProtocol (), NextFlowPipelineProvider .NAME , info , root , config .getName () , config , inputFiles , false );
6163 this .config = config ;
6264 setLogFile (log );
6365 }
@@ -69,7 +71,7 @@ public JSONObject getJsonJobInfo(boolean includeInvocationCount)
6971 result .put ("container" , getContainer ().getPath ());
7072 result .put ("filePath" , getLogFilePath ().getParent ().toString ());
7173 result .put ("runName" , getNextFlowRunName (includeInvocationCount ));
72- result .put ("configFile" , getConfig ().getFileName (). toString ());
74+ result .put ("configFile" , getConfig ().getName ());
7375 return result ;
7476 }
7577
@@ -88,7 +90,7 @@ public ParamParser getInputParameters()
8890 }
8991
9092 /** Take the template config file and substitute in the values for this job */
91- private static Path createConfig (Path configTemplate , Path parentDir , Path jobDir , Container container ) throws IOException
93+ private static FileLike createConfig (Path configTemplate , FileLike parentDir , FileLike jobDir , Container container ) throws IOException
9294 {
9395 String template ;
9496 try (InputStream in = Files .newInputStream (configTemplate ))
@@ -104,8 +106,8 @@ private static Path createConfig(Path configTemplate, Path parentDir, Path jobDi
104106 uploadUrl = StringUtils .stripEnd (uploadUrl , "/" );
105107 substitutedContent = substitutedContent .replace ("${panorama.upload_url}" , "panorama.upload_url = '" + uploadUrl + "'" );
106108
107- Path substitutedFile = jobDir .resolve (configTemplate .getFileName ());
108- try (BufferedWriter writer = Files . newBufferedWriter (substitutedFile ))
109+ FileLike substitutedFile = jobDir .resolveChild (configTemplate .getFileName (). toString ());
110+ try (BufferedWriter writer = new BufferedWriter ( PrintWriters . getPrintWriter (substitutedFile . openOutputStream ()) ))
109111 {
110112 writer .write (substitutedContent );
111113 }
@@ -115,7 +117,7 @@ private static Path createConfig(Path configTemplate, Path parentDir, Path jobDi
115117 @ Override
116118 public String getDescription ()
117119 {
118- return "NextFlow analysis of " + StringUtilsLabKey .pluralize (getInputFilePaths ().size (), "file" ) + " using config: " + config .getFileName ();
120+ return "NextFlow analysis of " + StringUtilsLabKey .pluralize (getInputFilePaths ().size (), "file" ) + " using config: " + config .getName ();
119121 }
120122
121123 @ Override
@@ -131,7 +133,7 @@ public TaskId getTaskPipelineId()
131133 }
132134
133135 @ Override
134- public AbstractFileAnalysisJob createSingleFileJob (File file )
136+ public AbstractFileAnalysisJob createSingleFileJob (FileLike file )
135137 {
136138 throw new UnsupportedOperationException ();
137139 }
0 commit comments