Search in sources :

Example 41 with Analysis

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis in project irida by phac-nml.

the class AnalysisController method getSharedProjectsForAnalysis.

/**
 * Get the status of projects that can be shared with the given analysis
 *
 * @param submissionId
 *            the {@link AnalysisSubmission} id
 * @return a list of {@link AnalysisController.SharedProjectResponse}
 */
@RequestMapping(value = "/ajax/{submissionId}/share", method = RequestMethod.GET)
@ResponseBody
public List<SharedProjectResponse> getSharedProjectsForAnalysis(@PathVariable Long submissionId) {
    AnalysisSubmission submission = analysisSubmissionService.read(submissionId);
    // Input files
    // - Paired
    Set<SequenceFilePair> inputFilePairs = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(submission, SequenceFilePair.class);
    // get projects already shared with submission
    Set<Project> projectsShared = projectService.getProjectsForAnalysisSubmission(submission).stream().map(ProjectAnalysisSubmissionJoin::getSubject).collect(Collectors.toSet());
    // get available projects
    Set<Project> projectsInAnalysis = projectService.getProjectsForSequencingObjects(inputFilePairs);
    List<SharedProjectResponse> projectResponses = projectsShared.stream().map(p -> new SharedProjectResponse(p, true)).collect(Collectors.toList());
    // Create response for shared projects
    projectResponses.addAll(projectsInAnalysis.stream().filter(p -> !projectsShared.contains(p)).map(p -> new SharedProjectResponse(p, false)).collect(Collectors.toList()));
    projectResponses.sort(new Comparator<SharedProjectResponse>() {

        @Override
        public int compare(SharedProjectResponse p1, SharedProjectResponse p2) {
            return p1.getProject().getName().compareTo(p2.getProject().getName());
        }
    });
    return projectResponses;
}
Also used : PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) AnalysisType(ca.corefacility.bioinformatics.irida.model.enums.AnalysisType) ProjectService(ca.corefacility.bioinformatics.irida.service.ProjectService) FileUtilities(ca.corefacility.bioinformatics.irida.ria.utilities.FileUtilities) Model(org.springframework.ui.Model) MetadataTemplateField(ca.corefacility.bioinformatics.irida.model.sample.MetadataTemplateField) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) AnalysisSubmissionService(ca.corefacility.bioinformatics.irida.service.AnalysisSubmissionService) MetadataTemplate(ca.corefacility.bioinformatics.irida.model.sample.MetadataTemplate) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Path(java.nio.file.Path) JsonParseException(com.fasterxml.jackson.core.JsonParseException) ProjectMetadataTemplateJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectMetadataTemplateJoin) IridaWorkflowNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) SequencingObjectService(ca.corefacility.bioinformatics.irida.service.SequencingObjectService) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) MediaType(org.springframework.http.MediaType) Collectors(java.util.stream.Collectors) AnalysesListingService(ca.corefacility.bioinformatics.irida.ria.web.services.AnalysesListingService) Principal(java.security.Principal) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) User(ca.corefacility.bioinformatics.irida.model.user.User) SampleService(ca.corefacility.bioinformatics.irida.service.sample.SampleService) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) Authentication(org.springframework.security.core.Authentication) java.util(java.util) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException) UpdateAnalysisSubmissionPermission(ca.corefacility.bioinformatics.irida.security.permissions.analysis.UpdateAnalysisSubmissionPermission) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) EntityNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException) Controller(org.springframework.stereotype.Controller) MetadataEntry(ca.corefacility.bioinformatics.irida.model.sample.metadata.MetadataEntry) MetadataTemplateService(ca.corefacility.bioinformatics.irida.service.sample.MetadataTemplateService) ToolExecution(ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution) MessageSource(org.springframework.context.MessageSource) Logger(org.slf4j.Logger) Files(java.nio.file.Files) AnalysisState(ca.corefacility.bioinformatics.irida.model.enums.AnalysisState) DataTablesRequest(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.config.DataTablesRequest) IridaWorkflowsService(ca.corefacility.bioinformatics.irida.service.workflow.IridaWorkflowsService) HttpServletResponse(javax.servlet.http.HttpServletResponse) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) Project(ca.corefacility.bioinformatics.irida.model.project.Project) ProjectAnalysisSubmissionJoin(ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin) AnalysisOutputFileInfo(ca.corefacility.bioinformatics.irida.ria.web.analysis.dto.AnalysisOutputFileInfo) AnalysisOutputFile(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile) java.io(java.io) UserService(ca.corefacility.bioinformatics.irida.service.user.UserService) JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) DataTablesParams(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) Project(ca.corefacility.bioinformatics.irida.model.project.Project) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)

Aggregations

Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)41 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)30 Test (org.junit.Test)28 AnalysisOutputFile (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile)21 WithMockUser (org.springframework.security.test.context.support.WithMockUser)19 Path (java.nio.file.Path)17 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)14 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)12 ToolExecution (ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution)12 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)11 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)9 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)7 ToolsClient (com.github.jmchilton.blend4j.galaxy.ToolsClient)7 WorkflowsClient (com.github.jmchilton.blend4j.galaxy.WorkflowsClient)7 History (com.github.jmchilton.blend4j.galaxy.beans.History)7 Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)7 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)6 AnalysisType (ca.corefacility.bioinformatics.irida.model.enums.AnalysisType)5 Scanner (java.util.Scanner)5 ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)4