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);
}
Aggregations