Search in sources :

Example 6 with AnalysisState

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);
}
Also used : AnalysisState(ca.corefacility.bioinformatics.irida.model.enums.AnalysisState) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 7 with AnalysisState

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);
}
Also used : AnalysisType(ca.corefacility.bioinformatics.irida.model.enums.AnalysisType) AnalysisState(ca.corefacility.bioinformatics.irida.model.enums.AnalysisState) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) PageRequest(org.springframework.data.domain.PageRequest) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse)

Aggregations

AnalysisState (ca.corefacility.bioinformatics.irida.model.enums.AnalysisState)7 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)5 Test (org.junit.Test)2 PageRequest (org.springframework.data.domain.PageRequest)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 WithMockUser (org.springframework.security.test.context.support.WithMockUser)2 ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)1 NoPercentageCompleteException (ca.corefacility.bioinformatics.irida.exceptions.NoPercentageCompleteException)1 AnalysisType (ca.corefacility.bioinformatics.irida.model.enums.AnalysisType)1 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)1 JobError (ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError)1 GalaxyWorkflowStatus (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus)1 DataTablesResponse (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse)1 DataTablesResponseModel (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel)1 DTAnalysis (ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnalysis)1 Sort (org.springframework.data.domain.Sort)1 Authentication (org.springframework.security.core.Authentication)1