use of ca.corefacility.bioinformatics.irida.exceptions.galaxy.GalaxyDatasetException in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyTest method testGetAnalysisResultsFail.
/**
* Tests failure to get analysis results from Galaxy due to failure to get a
* dataset
*
* @throws IridaWorkflowNotFoundException
* @throws IOException
* @throws ExecutionManagerException
* @throws IridaWorkflowAnalysisTypeException
*/
@Test(expected = GalaxyDatasetException.class)
public void testGetAnalysisResultsFail() throws IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException, ExecutionManagerException, IOException {
submission = AnalysisSubmission.builder(workflowId).name("my analysis").inputFiles(singleInputFiles).referenceFile(referenceFile).build();
submission.setRemoteWorkflowId(WORKFLOW_ID);
submission.setRemoteAnalysisId(HISTORY_ID);
when(iridaWorkflowsService.getIridaWorkflow(workflowId)).thenReturn(iridaWorkflowSingle);
when(galaxyHistoriesService.getDatasetForFileInHistory(output1Filename, HISTORY_ID)).thenThrow(new GalaxyDatasetException());
workflowPreparation.getAnalysisResults(submission);
}
use of ca.corefacility.bioinformatics.irida.exceptions.galaxy.GalaxyDatasetException in project irida by phac-nml.
the class GalaxyHistoriesService method getDatasetForFileInHistory.
/**
* Gets a Dataset object for a file with the given name in the given history.
* @param filename The name of the file to get a Dataset object for.
* @param historyId The history id to look for the dataset.
* @return The corresponding dataset for the given file name.
* @throws GalaxyDatasetException If there was an issue when searching for a dataset.
*/
public Dataset getDatasetForFileInHistory(String filename, String historyId) throws GalaxyDatasetException {
checkNotNull(filename, "filename is null");
checkNotNull(historyId, "historyId is null");
List<HistoryContents> historyContentsList = historiesClient.showHistoryContents(historyId);
List<HistoryContents> matchingHistoryContents = historyContentsList.stream().filter((historyContents) -> filename.equals(historyContents.getName())).collect(Collectors.toList());
// if more than one matching history item
if (matchingHistoryContents.size() > 1) {
String historyIds = "[";
for (HistoryContents content : matchingHistoryContents) {
historyIds += content.getId() + ",";
}
historyIds += "]";
throw new GalaxyDatasetException("Found " + matchingHistoryContents.size() + " datasets for file " + filename + ": " + historyIds);
} else if (matchingHistoryContents.size() == 1) {
String dataId = matchingHistoryContents.get(0).getId();
if (dataId != null) {
Dataset dataset = historiesClient.showDataset(historyId, dataId);
if (dataset != null) {
return dataset;
}
}
}
throw new GalaxyDatasetNotFoundException("dataset for file " + filename + " not found in Galaxy history " + historyId);
}
Aggregations