use of ca.corefacility.bioinformatics.irida.model.enums.AnalysisState in project irida by phac-nml.
the class AnalysisSubmissionServiceImplIT method testGetStateForAnalysisSubmissionSuccess.
/**
* Tests successfully getting a state for an analysis submission.
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetStateForAnalysisSubmissionSuccess() {
AnalysisState state = analysisSubmissionService.getStateForAnalysisSubmission(1L);
assertEquals(AnalysisState.SUBMITTING, state);
}
use of ca.corefacility.bioinformatics.irida.model.enums.AnalysisState in project irida by phac-nml.
the class AnalysesListingService method getPagedSubmissions.
/**
* Get a {@link DataTablesResponse} for {@link AnalysisSubmission}s based upon the {@link User}, and the {@link Project}
*
* @param params {@link DataTablesParams}
* @param locale {@link Locale}
* @param user {@link User}
* @param project {@link Project}
* @return {@link DataTablesResponse}
* @throws IridaWorkflowNotFoundException If the requested workflow doesn't exist
* @throws ExecutionManagerException If the submission cannot be read properly
*/
public DataTablesResponse getPagedSubmissions(DataTablesParams params, Locale locale, User user, Project project) throws IridaWorkflowNotFoundException, ExecutionManagerException {
/*
Check the DataTableParams to see if any search conditions are present
*/
Map<String, String> searchMap = params.getSearchMap();
AnalysisState state = searchMap.containsKey("analysisState") ? AnalysisState.valueOf(searchMap.get("analysisState")) : null;
String name = searchMap.getOrDefault("name", null);
/*
Workflow Ids are a special consideration.
The actual ids need to be look up based on the name passed.
*/
Set<UUID> workflowIds = null;
if (searchMap.containsKey("workflow")) {
AnalysisType workflowType = AnalysisType.fromString(searchMap.get("workflow"));
Set<IridaWorkflow> workflows = iridaWorkflowsService.getAllWorkflowsByType(workflowType);
workflowIds = workflows.stream().map(IridaWorkflow::getWorkflowIdentifier).collect(Collectors.toSet());
}
Page<AnalysisSubmission> page;
PageRequest pageRequest = new PageRequest(params.getCurrentPage(), params.getLength(), params.getSort());
if (user != null) {
// if user is set, get submissions for the user
page = analysisSubmissionService.listSubmissionsForUser(params.getSearchValue(), name, state, user, workflowIds, pageRequest);
} else if (project != null) {
// if the project is set, get submissions for the project
page = analysisSubmissionService.listSubmissionsForProject(params.getSearchValue(), name, state, workflowIds, project, pageRequest);
} else {
// if neither is set, get admin page
page = analysisSubmissionService.listAllSubmissions(params.getSearchValue(), name, state, workflowIds, pageRequest);
}
/*
IRIDA DataTables response expects and object that implements the DataTablesResponseModel interface.
*/
List<DataTablesResponseModel> data = new ArrayList<>();
for (AnalysisSubmission submission : page.getContent()) {
// Each AnalysisSubmission needs to be converted into a DTAnalysis.
data.add(createDataTablesAnalysis(submission, locale));
}
return new DataTablesResponse(params, page, data);
}
Aggregations