Search in sources :

Example 66 with Transactional

use of javax.transaction.Transactional in project irida by phac-nml.

the class AnalysisSubmissionServiceImpl method createSingleSampleSubmission.

/**
 * {@inheritDoc}
 */
@Override
@Transactional
@PreAuthorize("hasRole('ROLE_USER')")
public Collection<AnalysisSubmission> createSingleSampleSubmission(IridaWorkflow workflow, Long ref, List<SingleEndSequenceFile> sequenceFiles, List<SequenceFilePair> sequenceFilePairs, Map<String, String> params, IridaWorkflowNamedParameters namedParameters, String name, String analysisDescription, List<Project> projectsToShare, boolean writeResultsToSamples) {
    final Collection<AnalysisSubmission> createdSubmissions = new HashSet<AnalysisSubmission>();
    // Single end reads
    IridaWorkflowDescription description = workflow.getWorkflowDescription();
    if (description.acceptsSingleSequenceFiles()) {
        final Map<Sample, SingleEndSequenceFile> samplesMap = sequencingObjectService.getUniqueSamplesForSequencingObjects(Sets.newHashSet(sequenceFiles));
        for (final Map.Entry<Sample, SingleEndSequenceFile> entry : samplesMap.entrySet()) {
            Sample s = entry.getKey();
            SingleEndSequenceFile file = entry.getValue();
            // Build the analysis submission
            AnalysisSubmission.Builder builder = AnalysisSubmission.builder(workflow.getWorkflowIdentifier());
            builder.name(name + "_" + s.getSampleName());
            builder.inputFiles(ImmutableSet.of(file));
            builder.updateSamples(writeResultsToSamples);
            builder.priority(AnalysisSubmission.Priority.MEDIUM);
            // Add reference file
            if (ref != null && description.requiresReference()) {
                // Note: This cannot be empty if through the UI if the
                // pipeline required a reference file.
                ReferenceFile referenceFile = referenceFileRepository.findOne(ref);
                builder.referenceFile(referenceFile);
            }
            if (description.acceptsParameters()) {
                if (namedParameters != null) {
                    builder.withNamedParameters(namedParameters);
                } else {
                    if (!params.isEmpty()) {
                        // Note: This cannot be empty if through the UI if
                        // the pipeline required params.
                        builder.inputParameters(params);
                    }
                }
            }
            // Create the submission
            createdSubmissions.add(create(builder.build()));
        }
    }
    // Paired end reads
    if (description.acceptsPairedSequenceFiles()) {
        final Map<Sample, SequenceFilePair> samplesMap = sequencingObjectService.getUniqueSamplesForSequencingObjects(Sets.newHashSet(sequenceFilePairs));
        for (final Map.Entry<Sample, SequenceFilePair> entry : samplesMap.entrySet()) {
            Sample s = entry.getKey();
            SequenceFilePair filePair = entry.getValue();
            // Build the analysis submission
            AnalysisSubmission.Builder builder = AnalysisSubmission.builder(workflow.getWorkflowIdentifier());
            builder.name(name + "_" + s.getSampleName());
            builder.inputFiles(ImmutableSet.of(filePair));
            builder.updateSamples(writeResultsToSamples);
            // Add reference file
            if (ref != null && description.requiresReference()) {
                ReferenceFile referenceFile = referenceFileRepository.findOne(ref);
                builder.referenceFile(referenceFile);
            }
            if (description.acceptsParameters()) {
                if (namedParameters != null) {
                    builder.withNamedParameters(namedParameters);
                } else {
                    if (!params.isEmpty()) {
                        // Note: This cannot be empty if through the UI if
                        // the pipeline required params.
                        builder.inputParameters(params);
                    }
                }
            }
            // Add description to submission, can be null
            builder.analysisDescription(analysisDescription);
            // Create the submission
            createdSubmissions.add(create(builder.build()));
        }
    }
    // Share with the required projects
    for (AnalysisSubmission submission : createdSubmissions) {
        for (Project project : projectsToShare) {
            pasRepository.save(new ProjectAnalysisSubmissionJoin(project, submission));
        }
    }
    return createdSubmissions;
}
Also used : ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) Project(ca.corefacility.bioinformatics.irida.model.project.Project) IridaWorkflowDescription(ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription) ProjectAnalysisSubmissionJoin(ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin) ImmutableMap(com.google.common.collect.ImmutableMap) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(javax.transaction.Transactional)

Example 67 with Transactional

use of javax.transaction.Transactional in project irida by phac-nml.

the class AnalysisSubmissionServiceImpl method delete.

/**
 * {@inheritDoc}
 */
@Override
@PreAuthorize("hasRole('ROLE_ADMIN') or hasPermission(#id, 'canUpdateAnalysisSubmission')")
@Transactional
public void delete(Long id) throws EntityNotFoundException {
    final AnalysisSubmission submission = read(id);
    if (AnalysisCleanedState.NOT_CLEANED.equals(submission.getAnalysisCleanedState())) {
        // We're "CLEANING" it right now!
        submission.setAnalysisCleanedState(AnalysisCleanedState.CLEANING);
        try {
            analysisExecutionService.cleanupSubmission(submission).get();
        } catch (final ExecutionManagerException e) {
            logger.error("Failed to cleanup analysis submission before deletion," + " but proceeding with deletion anyway.", e);
        } catch (final Throwable e) {
            logger.error("An unexpected exception happened when cleaning the analysis submission," + " but proceeding with deletion anyway.", e);
        }
    } else {
        logger.debug("Not cleaning submission [" + id + "] when deleting, it's already cleaned.");
    }
    super.delete(id);
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(javax.transaction.Transactional)

Example 68 with Transactional

use of javax.transaction.Transactional in project irida by phac-nml.

the class AnalysisSubmissionServiceImpl method createMultipleSampleSubmission.

/**
 * {@inheritDoc}
 */
@Transactional
@PreAuthorize("hasRole('ROLE_USER')")
public AnalysisSubmission createMultipleSampleSubmission(IridaWorkflow workflow, Long ref, List<SingleEndSequenceFile> sequenceFiles, List<SequenceFilePair> sequenceFilePairs, Map<String, String> params, IridaWorkflowNamedParameters namedParameters, String name, String newAnalysisDescription, List<Project> projectsToShare, boolean writeResultsToSamples) {
    AnalysisSubmission.Builder builder = AnalysisSubmission.builder(workflow.getWorkflowIdentifier());
    builder.name(name);
    builder.priority(AnalysisSubmission.Priority.MEDIUM);
    builder.updateSamples(writeResultsToSamples);
    IridaWorkflowDescription description = workflow.getWorkflowDescription();
    // Add reference file
    if (ref != null && description.requiresReference()) {
        ReferenceFile referenceFile = referenceFileRepository.findOne(ref);
        builder.referenceFile(referenceFile);
    }
    // Add any single end sequencing files.
    if (description.acceptsSingleSequenceFiles()) {
        if (!sequenceFiles.isEmpty()) {
            builder.inputFiles(Sets.newHashSet(sequenceFiles));
        }
    }
    // Add any paired end sequencing files.
    if (description.acceptsPairedSequenceFiles()) {
        if (!sequenceFilePairs.isEmpty()) {
            builder.inputFiles(Sets.newHashSet(sequenceFilePairs));
        }
    }
    if (description.acceptsParameters()) {
        if (namedParameters != null) {
            builder.withNamedParameters(namedParameters);
        } else {
            if (!params.isEmpty()) {
                // Note: This cannot be empty if through the UI if
                // the pipeline required params.
                builder.inputParameters(params);
            }
        }
    }
    // Add description to submission, can be null
    builder.analysisDescription(newAnalysisDescription);
    // Create the submission
    AnalysisSubmission submission = create(builder.build());
    // Share with the required projects
    for (Project project : projectsToShare) {
        pasRepository.save(new ProjectAnalysisSubmissionJoin(project, submission));
    }
    return submission;
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) IridaWorkflowDescription(ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription) ProjectAnalysisSubmissionJoin(ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(javax.transaction.Transactional)

Example 69 with Transactional

use of javax.transaction.Transactional in project irida by phac-nml.

the class MetadataTemplateServiceImpl method createMetadataTemplateInProject.

/**
 * {@inheritDoc}
 */
@Override
@PreAuthorize("hasPermission(#project, 'isProjectOwner')")
@Transactional
public ProjectMetadataTemplateJoin createMetadataTemplateInProject(MetadataTemplate template, Project project) {
    template = create(template);
    ProjectMetadataTemplateJoin join = pmtRepository.save(new ProjectMetadataTemplateJoin(project, template));
    return join;
}
Also used : ProjectMetadataTemplateJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectMetadataTemplateJoin) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(javax.transaction.Transactional)

Example 70 with Transactional

use of javax.transaction.Transactional in project irida by phac-nml.

the class UserGroupServiceImpl method create.

/**
 * {@inheritDoc}
 */
@Override
@PreAuthorize("hasRole('ROLE_USER')")
@Transactional
public UserGroup create(UserGroup object) throws EntityExistsException, ConstraintViolationException {
    final UserGroup ug = super.create(object);
    final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    final User currentUser = userRepository.loadUserByUsername(auth.getName());
    addUserToGroup(currentUser, ug, UserGroupRole.GROUP_OWNER);
    return ug;
}
Also used : User(ca.corefacility.bioinformatics.irida.model.user.User) Authentication(org.springframework.security.core.Authentication) UserGroup(ca.corefacility.bioinformatics.irida.model.user.group.UserGroup) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(javax.transaction.Transactional)

Aggregations

Transactional (javax.transaction.Transactional)299 Test (org.junit.Test)99 PostResult (org.collectiveone.common.dto.PostResult)29 ArrayList (java.util.ArrayList)24 UserDO (org.neusoft.neubbs.entity.UserDO)21 Timestamp (java.sql.Timestamp)18 TopicDO (org.neusoft.neubbs.entity.TopicDO)18 Initiative (org.collectiveone.modules.initiatives.Initiative)16 GetResult (org.collectiveone.common.dto.GetResult)15 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)13 TopicReplyDO (org.neusoft.neubbs.entity.TopicReplyDO)13 HashMap (java.util.HashMap)12 Date (java.util.Date)11 AppUser (org.collectiveone.modules.users.AppUser)11 UUID (java.util.UUID)10 RolesAllowed (javax.annotation.security.RolesAllowed)10 PeerReviewedAssignation (org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 IOException (java.io.IOException)9 TopicContentDO (org.neusoft.neubbs.entity.TopicContentDO)9