Search in sources :

Example 1 with AnalysisAlreadySetException

use of ca.corefacility.bioinformatics.irida.exceptions.AnalysisAlreadySetException in project irida by phac-nml.

the class TestDataFactory method constructAnalysisSubmission.

public static AnalysisSubmission constructAnalysisSubmission() {
    Set<SequencingObject> files = new HashSet<>();
    files.add(constructSingleEndSequenceFile());
    Long id = 5L;
    final ReferenceFile rf = new ReferenceFile(files.iterator().next().getFiles().iterator().next().getFile());
    rf.setId(id);
    AnalysisSubmission analysisSubmission = AnalysisSubmission.builder(UUID.randomUUID()).name("submission-" + id).inputFiles(files).referenceFile(rf).build();
    analysisSubmission.setId(id);
    analysisSubmission.setAnalysisState(AnalysisState.COMPLETED);
    try {
        analysisSubmission.setAnalysis(constructAnalysis());
    } catch (final AnalysisAlreadySetException e) {
        // this should *never* happen, we just constructed
        // AnalysisSubmission above.
        fail();
    }
    return analysisSubmission;
}
Also used : SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) AnalysisAlreadySetException(ca.corefacility.bioinformatics.irida.exceptions.AnalysisAlreadySetException) HashSet(java.util.HashSet)

Example 2 with AnalysisAlreadySetException

use of ca.corefacility.bioinformatics.irida.exceptions.AnalysisAlreadySetException in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxyAsync method transferAnalysisResults.

/**
 * Downloads and saves the results of an {@link AnalysisSubmission} that was
 * previously submitted from an execution manager.
 *
 * @param submittedAnalysis
 *            An {@link AnalysisSubmission} that was previously submitted.
 * @return A {@link Future} with an {@link AnalysisSubmission} object
 *         containing information about the particular analysis.
 * @throws ExecutionManagerException
 *             If there was an issue with the execution manager.
 * @throws IridaWorkflowNotFoundException
 *             If the workflow for this submission could not be found in
 *             IRIDA.
 * @throws IOException
 *             If there was an error loading the analysis results from an
 *             execution manager.
 * @throws IridaWorkflowAnalysisTypeException
 *             If there was an issue building an {@link Analysis} object.
 */
@Transactional
public Future<AnalysisSubmission> transferAnalysisResults(AnalysisSubmission submittedAnalysis) throws ExecutionManagerException, IOException, IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException {
    checkNotNull(submittedAnalysis, "submittedAnalysis is null");
    checkNotNull(submittedAnalysis.getRemoteAnalysisId(), "remoteAnalysisId is null");
    if (!analysisSubmissionService.exists(submittedAnalysis.getId())) {
        throw new EntityNotFoundException("Could not find analysis submission for " + submittedAnalysis);
    }
    logger.debug("Getting results for " + submittedAnalysis);
    Analysis analysisResults = workspaceService.getAnalysisResults(submittedAnalysis);
    logger.trace("Saving results for " + submittedAnalysis);
    Analysis savedAnalysis = analysisService.create(analysisResults);
    // if samples should be updated, set to TRANSFERRED.  Otherwise just complete.
    if (submittedAnalysis.getUpdateSamples()) {
        submittedAnalysis.setAnalysisState(AnalysisState.TRANSFERRED);
    } else {
        submittedAnalysis.setAnalysisState(AnalysisState.COMPLETED);
    }
    try {
        submittedAnalysis.setAnalysis(savedAnalysis);
    } catch (AnalysisAlreadySetException e) {
        throw new ExecutionManagerException("Analysis already set", e);
    }
    AnalysisSubmission completedSubmission = analysisSubmissionService.update(submittedAnalysis);
    return new AsyncResult<>(completedSubmission);
}
Also used : Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) AnalysisAlreadySetException(ca.corefacility.bioinformatics.irida.exceptions.AnalysisAlreadySetException) EntityNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException) AsyncResult(org.springframework.scheduling.annotation.AsyncResult) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AnalysisAlreadySetException (ca.corefacility.bioinformatics.irida.exceptions.AnalysisAlreadySetException)2 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)2 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)1 ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)1 ReferenceFile (ca.corefacility.bioinformatics.irida.model.project.ReferenceFile)1 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)1 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)1 HashSet (java.util.HashSet)1 AsyncResult (org.springframework.scheduling.annotation.AsyncResult)1 Transactional (org.springframework.transaction.annotation.Transactional)1