Search in sources :

Example 1 with AnalysisSampleUpdater

use of ca.corefacility.bioinformatics.irida.pipeline.results.AnalysisSampleUpdater 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

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