Search in sources :

Example 1 with RunAsUser

use of ca.corefacility.bioinformatics.irida.service.analysis.annotations.RunAsUser in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxyAsync method executeAnalysis.

/**
 * Executes the passed prepared {@link AnalysisSubmission} in an execution
 * manager.
 *
 * @param analysisSubmission
 *            The {@link AnalysisSubmission} to execute.
 * @return A {@link Future} with an {@link AnalysisSubmission} for the
 *         analysis submitted.
 * @throws ExecutionManagerException
 *             If there was an exception submitting the analysis to the
 *             execution manager.
 * @throws IridaWorkflowException If there was an issue with the IRIDA workflow.
 */
@RunAsUser("#analysisSubmission.getSubmitter()")
public Future<AnalysisSubmission> executeAnalysis(AnalysisSubmission analysisSubmission) throws ExecutionManagerException, IridaWorkflowException {
    checkNotNull(analysisSubmission, "analysisSubmission is null");
    checkNotNull(analysisSubmission.getRemoteAnalysisId(), "remote analyis id is null");
    checkNotNull(analysisSubmission.getWorkflowId(), "workflowId is null");
    logger.debug("Running submission for " + analysisSubmission);
    logger.trace("Preparing files for " + analysisSubmission);
    PreparedWorkflowGalaxy preparedWorkflow = workspaceService.prepareAnalysisFiles(analysisSubmission);
    WorkflowInputsGalaxy input = preparedWorkflow.getWorkflowInputs();
    String libraryId = preparedWorkflow.getRemoteDataId();
    logger.trace("Executing " + analysisSubmission);
    galaxyWorkflowService.runWorkflow(input);
    analysisSubmission.setAnalysisState(AnalysisState.RUNNING);
    analysisSubmission.setRemoteInputDataId(libraryId);
    analysisSubmission = analysisSubmissionService.update(analysisSubmission);
    return new AsyncResult<>(analysisSubmission);
}
Also used : PreparedWorkflowGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy) WorkflowInputsGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy) AsyncResult(org.springframework.scheduling.annotation.AsyncResult) RunAsUser(ca.corefacility.bioinformatics.irida.service.analysis.annotations.RunAsUser)

Example 2 with RunAsUser

use of ca.corefacility.bioinformatics.irida.service.analysis.annotations.RunAsUser in project irida by phac-nml.

the class AnalysisSubmissionSampleProcessorImpl method updateSamples.

/**
 * {@inheritDoc}
 */
@Override
@RunAsUser("#analysisSubmission.getSubmitter()")
@Transactional(propagation = Propagation.REQUIRES_NEW)
@PreAuthorize("hasPermission(#analysisSubmission, 'canUpdateSamplesFromAnalysisSubmission')")
public void updateSamples(AnalysisSubmission analysisSubmission) throws PostProcessingException {
    if (!analysisSubmission.getUpdateSamples()) {
        logger.trace("Will not update samples from results for submission=" + analysisSubmission);
    } else {
        logger.debug("Updating sample from results for submission=" + analysisSubmission);
        Set<Sample> samples = sampleRepository.findSamplesForAnalysisSubmission(analysisSubmission);
        Analysis analysis = analysisSubmission.getAnalysis();
        checkNotNull(analysis, "No analysis associated with submission " + analysisSubmission);
        checkNotNull(samples, "No samples associated with submission " + analysisSubmission);
        AnalysisSampleUpdater analysisSampleUpdaterService = analysisSampleUpdaterMap.get(analysis.getAnalysisType());
        if (analysisSampleUpdaterService != null) {
            // re-reading submission to ensure file paths are correct
            analysisSubmission = analysisSubmissionService.read(analysisSubmission.getId());
            analysisSampleUpdaterService.update(samples, analysisSubmission);
        } else {
            logger.debug("No associated object for updating samples for analysis of type " + analysis.getAnalysisType());
        }
    }
}
Also used : Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisSampleUpdater(ca.corefacility.bioinformatics.irida.pipeline.results.AnalysisSampleUpdater) RunAsUser(ca.corefacility.bioinformatics.irida.service.analysis.annotations.RunAsUser) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

RunAsUser (ca.corefacility.bioinformatics.irida.service.analysis.annotations.RunAsUser)2 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)1 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)1 PreparedWorkflowGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy)1 WorkflowInputsGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy)1 AnalysisSampleUpdater (ca.corefacility.bioinformatics.irida.pipeline.results.AnalysisSampleUpdater)1 AsyncResult (org.springframework.scheduling.annotation.AsyncResult)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 Transactional (org.springframework.transaction.annotation.Transactional)1