Skip to content

Commit 292646b

Browse files
Adopt FileLike for more pipeline APIs (#183)
1 parent f4de40b commit 292646b

File tree

6 files changed

+17
-27
lines changed

6 files changed

+17
-27
lines changed

genotyping/src/org/labkey/genotyping/GenotypingController.java

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,8 @@ public boolean handlePost(ImportReadsForm form, BindException errors) throws Exc
973973
{
974974
if (null == form.getReadsPath())
975975
{
976-
File readsFile = form.getValidatedSingleFile(getContainer());
977-
form.setReadsPath(readsFile.getPath());
976+
FileLike readsFile = form.getValidatedSingleFile(getContainer());
977+
form.setReadsPath(readsFile.toNioPathForRead().toFile().getPath());
978978
return false;
979979
}
980980

@@ -1395,24 +1395,15 @@ public boolean handlePost(PipelinePathForm form, BindException errors) throws IO
13951395
{
13961396
Container container = getContainer();
13971397
// Manual upload of genotyping analysis; pipeline provider posts to this action with matches file.
1398-
Path singleFile = form.getValidatedSinglePath(container);
1398+
FileLike singleFile = form.getValidatedSingleFile(container);
1399+
FileLike analysisDir = singleFile.getParent();
13991400

1400-
if (form.getPipeRoot(container).getRootFileLike().isDescendant(singleFile.toUri()))
1401-
{
1402-
1403-
FileLike matches = form.getPipeRoot(container).resolvePathToFileLike(singleFile.toString());
1404-
FileLike analysisDir = matches.getParent();
1401+
// Load properties to determine the run.
1402+
Properties props = GenotypingManager.get().readProperties(analysisDir);
1403+
int analysisId = Integer.parseInt((String) props.get("analysis"));
1404+
importAnalysis(analysisId, analysisDir, getUser());
14051405

1406-
// Load properties to determine the run.
1407-
Properties props = GenotypingManager.get().readProperties(analysisDir);
1408-
int analysisId = Integer.parseInt((String) props.get("analysis"));
1409-
importAnalysis(analysisId, analysisDir, getUser());
1410-
1411-
return true;
1412-
}
1413-
1414-
errors.reject(ERROR_MSG, "File was not found under the pipeline root");
1415-
return false;
1406+
return true;
14161407
}
14171408

14181409
@Override

genotyping/src/org/labkey/genotyping/Import454ReadsJob.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import com.fasterxml.jackson.annotation.JsonCreator;
1919
import com.fasterxml.jackson.annotation.JsonProperty;
20-
import org.apache.commons.lang3.StringUtils;
20+
import org.apache.commons.lang3.Strings;
2121
import org.labkey.api.data.DbScope;
2222
import org.labkey.api.data.RuntimeSQLException;
2323
import org.labkey.api.data.Table;
@@ -69,7 +69,7 @@ public Import454ReadsJob(ViewBackgroundInfo info, PipeRoot root, File reads, Gen
6969
super(Import454ReadsPipelineProvider.NAME, info, root, run);
7070
FileLike verifiedFileLike = FileSystemLike.getVerifiedFileLike(root.getContainer(), reads.getAbsolutePath());
7171
_reads = FileSystemLike.toFile(verifiedFileLike);
72-
setLogFile(verifiedFileLike.getParent().resolveChild(FileUtil.makeFileNameWithTimestamp("import_reads", "log")).toNioPathForWrite());
72+
setLogFile(verifiedFileLike.getParent().resolveChild(FileUtil.makeFileNameWithTimestamp("import_reads", "log")));
7373
}
7474

7575
@Override
@@ -91,7 +91,7 @@ public void run()
9191
}
9292
catch (SQLException se)
9393
{
94-
if (RuntimeSQLException.isConstraintException(se) && StringUtils.containsIgnoreCase(se.getMessage(), "uq_reads_name"))
94+
if (RuntimeSQLException.isConstraintException(se) && Strings.CI.contains(se.getMessage(), "uq_reads_name"))
9595
throw new RuntimeException("A readname in this file already exists in the database; this run may have been imported previously", se);
9696
else
9797
throw se;
@@ -126,8 +126,7 @@ private void importReads() throws IOException, SQLException, PipelineJobExceptio
126126

127127
try (TabLoader loader = new TabLoader(_reads, true))
128128
{
129-
List<ColumnDescriptor> columns = new ArrayList<>();
130-
columns.addAll(Arrays.asList(loader.getColumns()));
129+
List<ColumnDescriptor> columns = new ArrayList<>(Arrays.asList(loader.getColumns()));
131130

132131
for (ColumnDescriptor col : columns)
133132
{

genotyping/src/org/labkey/genotyping/ImportAnalysisJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public ImportAnalysisJob(ViewBackgroundInfo info, PipeRoot root, FileLike pipeli
6161
super("Import Analysis", info, root);
6262
_dir = pipelineDir;
6363
_analysis = analysis;
64-
setLogFile(_dir.resolveChild(FileUtil.makeFileNameWithTimestamp("import_analysis", "log")).toNioPathForWrite());
64+
setLogFile(_dir.resolveChild(FileUtil.makeFileNameWithTimestamp("import_analysis", "log")));
6565

6666
if (!_dir.exists())
6767
throw new IllegalArgumentException("Pipeline directory does not exist: " + _dir.toNioPathForRead().toAbsolutePath());

genotyping/src/org/labkey/genotyping/ImportIlluminaReadsJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public ImportIlluminaReadsJob(ViewBackgroundInfo info, PipeRoot root, File sampl
7777
FileLike verifiedFileLike = FileSystemLike.getVerifiedFileLike(root.getContainer(), sampleFile.getAbsolutePath());
7878
_sampleFile = FileSystemLike.toFile(verifiedFileLike);
7979
_fastqPrefix = fastqPrefix;
80-
setLogFile(verifiedFileLike.getParent().resolveChild(FileUtil.makeFileNameWithTimestamp("import_reads", "log")).toNioPathForWrite());
80+
setLogFile(verifiedFileLike.getParent().resolveChild(FileUtil.makeFileNameWithTimestamp("import_reads", "log")));
8181
}
8282

8383
@Override

genotyping/src/org/labkey/genotyping/ImportPacBioReadsJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public ImportPacBioReadsJob(ViewBackgroundInfo info, PipeRoot root, File sampleF
7373
FileLike verifiedFileLike = FileSystemLike.getVerifiedFileLike(root.getContainer(), sampleFile.getAbsolutePath());
7474
_sampleFile = FileSystemLike.toFile(verifiedFileLike);
7575
_fastqPrefix = fastqPrefix;
76-
setLogFile(verifiedFileLike.getParent().resolveChild(FileUtil.makeFileNameWithTimestamp("import_pacbio_reads", "log")).toNioPathForWrite());
76+
setLogFile(verifiedFileLike.getParent().resolveChild(FileUtil.makeFileNameWithTimestamp("import_pacbio_reads", "log")));
7777
}
7878

7979
@Override

genotyping/src/org/labkey/genotyping/SubmitAnalysisJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public SubmitAnalysisJob(ViewBackgroundInfo info, PipeRoot root, FileLike reads,
110110
throw new MinorConfigurationException("Can't create analysis directory: " + _analysisDir.getPath());
111111
}
112112

113-
setLogFile(_analysisDir.resolveChild(FileUtil.makeFileNameWithTimestamp("submit_analysis", "log")).toNioPathForWrite());
113+
setLogFile(_analysisDir.resolveChild(FileUtil.makeFileNameWithTimestamp("submit_analysis", "log")));
114114
info("Creating analysis directory: " + _analysisDir.getName());
115115
_analysis.setPath(FileUtil.getAbsolutePath(_analysisDir.toNioPathForRead()));
116116
_analysis.setFileName(_analysisDir.getName());

0 commit comments

Comments
 (0)