Search in sources :

Example 11 with AnalysisType

use of ca.corefacility.bioinformatics.irida.model.enums.AnalysisType 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)

Example 12 with AnalysisType

use of ca.corefacility.bioinformatics.irida.model.enums.AnalysisType in project irida by phac-nml.

the class PipelineController method getPipelineLaunchPage.

/**
 * Get the Pipeline Selection Page
 *
 * @param model
 * 		{@link Model}
 * @param locale
 * 		Current users {@link Locale}
 *
 * @return location of the pipeline selection page.
 */
@RequestMapping
public String getPipelineLaunchPage(final Model model, Locale locale) {
    Set<AnalysisType> workflows = workflowsService.getRegisteredWorkflowTypes();
    List<Map<String, String>> flows = new ArrayList<>(workflows.size());
    workflows.stream().forEach(type -> {
        IridaWorkflow flow = null;
        try {
            flow = workflowsService.getDefaultWorkflowByType(type);
            IridaWorkflowDescription description = flow.getWorkflowDescription();
            String name = type.toString();
            String key = "workflow." + name;
            flows.add(ImmutableMap.of("name", name, "id", description.getId().toString(), "title", messageSource.getMessage(key + ".title", null, locale), "description", messageSource.getMessage(key + ".description", null, locale)));
        } catch (IridaWorkflowNotFoundException e) {
            logger.error("Workflow not found - See stack:", e);
        }
    });
    flows.sort((f1, f2) -> f1.get("name").compareTo(f2.get("name")));
    model.addAttribute("counts", getCartSummaryMap());
    model.addAttribute("workflows", flows);
    return URL_LAUNCH;
}
Also used : AnalysisType(ca.corefacility.bioinformatics.irida.model.enums.AnalysisType) IridaWorkflowNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) ArrayList(java.util.ArrayList) IridaWorkflowDescription(ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AnalysisType (ca.corefacility.bioinformatics.irida.model.enums.AnalysisType)12 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)10 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)5 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)4 IridaWorkflowNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 Path (java.nio.file.Path)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)2 IridaWorkflowDescription (ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription)2 ResourceCollection (ca.corefacility.bioinformatics.irida.web.assembler.resource.ResourceCollection)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Map (java.util.Map)2 UUID (java.util.UUID)2 ModelMap (org.springframework.ui.ModelMap)2 IridaWorkflowDefaultException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowDefaultException)1 AnalysisState (ca.corefacility.bioinformatics.irida.model.enums.AnalysisState)1 Project (ca.corefacility.bioinformatics.irida.model.project.Project)1 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)1 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)1