|
18 | 18 | import org.labkey.api.data.SimpleFilter; |
19 | 19 | import org.labkey.api.data.TableInfo; |
20 | 20 | import org.labkey.api.data.TableSelector; |
| 21 | +import org.labkey.api.exp.api.DataType; |
| 22 | +import org.labkey.api.exp.api.ExpData; |
| 23 | +import org.labkey.api.exp.api.ExperimentService; |
| 24 | +import org.labkey.api.pipeline.PipeRoot; |
| 25 | +import org.labkey.api.pipeline.PipelineService; |
21 | 26 | import org.labkey.api.query.FieldKey; |
22 | 27 | import org.labkey.api.query.QueryService; |
23 | 28 | import org.labkey.api.security.User; |
24 | 29 | import org.labkey.api.security.UserManager; |
25 | 30 | import org.labkey.api.sequenceanalysis.RefNtSequenceModel; |
26 | 31 | import org.labkey.sequenceanalysis.SequenceAnalysisSchema; |
27 | 32 |
|
| 33 | +import java.io.File; |
28 | 34 | import java.io.IOException; |
29 | 35 | import java.io.StringWriter; |
30 | 36 | import java.util.Arrays; |
@@ -221,4 +227,31 @@ public void testTranslation() { |
221 | 227 | } |
222 | 228 | } |
223 | 229 | } |
| 230 | + |
| 231 | + public int createExpData(String relPath) { |
| 232 | + PipeRoot pr = PipelineService.get().getPipelineRootSetting(getContainer()); |
| 233 | + if (pr == null) |
| 234 | + { |
| 235 | + throw new IllegalArgumentException("Unable to find pipeline root"); |
| 236 | + } |
| 237 | + |
| 238 | + File f = new File(pr.getRootPath(), relPath); |
| 239 | + if (!f.exists()) |
| 240 | + { |
| 241 | + throw new IllegalArgumentException("Unable to find file: " + f.getPath()); |
| 242 | + } |
| 243 | + |
| 244 | + ExpData d = ExperimentService.get().getExpDataByURL(f, getContainer()); |
| 245 | + if (d != null) |
| 246 | + { |
| 247 | + return d.getRowId(); |
| 248 | + } |
| 249 | + |
| 250 | + d = ExperimentService.get().createData(getContainer(), new DataType("Output")); |
| 251 | + d.setDataFileURI(f.toURI()); |
| 252 | + d.setName(f.getName()); |
| 253 | + d.save(getUser()); |
| 254 | + |
| 255 | + return d.getRowId(); |
| 256 | + } |
224 | 257 | } |
0 commit comments