Search in sources :

Example 1 with DTAnalysis

use of ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnalysis in project irida by phac-nml.

the class AnalysesListingService method createDataTablesAnalysis.

/**
 * Convert a {@link AnalysisSubmission} to a {@link DTAnalysis} to be used by DataTables on the client.
 *
 * @param submission {@link AnalysisSubmission}
 * @param locale     {@link Locale}
 * @return {@link DTAnalysis}
 * @throws IridaWorkflowNotFoundException If the requested workflow doesn't exist
 * @throws ExecutionManagerException      If the submission cannot be read properly
 */
private DTAnalysis createDataTablesAnalysis(AnalysisSubmission submission, Locale locale) throws IridaWorkflowNotFoundException, ExecutionManagerException {
    Long id = submission.getId();
    String name = submission.getName();
    String submitter = submission.getSubmitter().getLabel();
    Date createdDate = submission.getCreatedDate();
    float percentComplete = 0;
    AnalysisState analysisState = submission.getAnalysisState();
    JobError error = null;
    if (analysisState.equals(AnalysisState.ERROR)) {
        error = getFirstJobError(submission);
    } else {
        percentComplete = analysisSubmissionService.getPercentCompleteForAnalysisSubmission(submission.getId());
    }
    String workflowType = iridaWorkflowsService.getIridaWorkflow(submission.getWorkflowId()).getWorkflowDescription().getAnalysisType().toString();
    String workflow = messageSource.getMessage("workflow." + workflowType + ".title", null, locale);
    String state = messageSource.getMessage("analysis.state." + analysisState.toString(), null, locale);
    Long duration = 0L;
    if (analysisState.equals(AnalysisState.COMPLETED)) {
        duration = getDurationInMilliseconds(submission.getCreatedDate(), submission.getAnalysis().getCreatedDate());
    }
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    boolean updatePermission = updateAnalysisPermission.isAllowed(authentication, submission);
    return new DTAnalysis(id, name, submitter, percentComplete, createdDate, workflow, state, error, duration, updatePermission);
}
Also used : AnalysisState(ca.corefacility.bioinformatics.irida.model.enums.AnalysisState) Authentication(org.springframework.security.core.Authentication) JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError) DTAnalysis(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnalysis)

Aggregations

AnalysisState (ca.corefacility.bioinformatics.irida.model.enums.AnalysisState)1 JobError (ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError)1 DTAnalysis (ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnalysis)1 Authentication (org.springframework.security.core.Authentication)1