use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.
the class TaskRunningServiceImpl method submitLocalTask.
@Override
public <T extends Task> String submitLocalTask(T task) {
this.checkTask(task);
TaskCommand taskCommand = task.getTaskCommand();
this.checkTaskCommand(taskCommand);
final String taskId = task.getTaskCommand().getTaskId();
if (TaskRunningServiceImpl.log.isDebugEnabled()) {
TaskRunningServiceImpl.log.debug("Submitting local task with id: " + taskId);
}
final SubmittedTaskLocal submittedTask = new SubmittedTaskLocal(task.getTaskCommand(), taskPostProcessing);
final ExecutingTask<TaskResult> executingTask = new ExecutingTask<TaskResult>(task, taskCommand);
executingTask.setStatusCallback(new ExecutingTask.TaskLifecycleHandler() {
@Override
public void onFailure(Throwable e) {
TaskRunningServiceImpl.log.error(e, e);
submittedTask.updateStatus(SubmittedTask.Status.FAILED, new Date());
}
@Override
public void onFinish() {
submittedTask.updateStatus(SubmittedTask.Status.COMPLETED, new Date());
}
@Override
public void onStart() {
submittedTask.updateStatus(SubmittedTask.Status.RUNNING, new Date());
}
});
executingTask.setProgressAppender(new LogBasedProgressAppender(taskId, new ProgressUpdateCallback() {
private final Queue<String> progressUpdates = submittedTask.getProgressUpdates();
@Override
public void addProgressUpdate(String message) {
progressUpdates.add(message);
}
}));
ListenableFuture<TaskResult> future = executorService.submit(executingTask);
submittedTask.setFuture(future);
// Currently we have only email notification.
if (taskCommand.isEmailAlert()) {
submittedTask.addEmailAlert();
}
submittedTasks.put(taskId, submittedTask);
return taskId;
}
use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.
the class BioAssayOutlierProcessingTaskImpl method execute.
@Override
public TaskResult execute() {
Collection<BioAssay> bioAssays = bioAssayService.load(taskCommand.getBioAssayIds());
if (bioAssays.isEmpty()) {
throw new RuntimeException("Could not locate the bioassays");
}
if (taskCommand.isRevert()) {
sampleRemoveService.unmarkAsMissing(bioAssays);
} else {
sampleRemoveService.markAsMissing(bioAssays);
}
bioAssays = bioAssayService.thaw(bioAssays);
Collection<BioAssayValueObject> flagged = new HashSet<>();
for (BioAssay ba : bioAssays) {
flagged.add(new BioAssayValueObject(ba, false));
}
return new TaskResult(taskCommand, flagged);
}
use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.
the class ArrayDesignRepeatScanTaskImpl method execute.
@Override
public TaskResult execute() {
ArrayDesign ad = taskCommand.getArrayDesign();
ad = arrayDesignService.thaw(ad);
Collection<BioSequence> sequences = ArrayDesignSequenceAlignmentServiceImpl.getSequences(ad);
RepeatScan scanner = new RepeatScan();
scanner.repeatScan(sequences);
return new TaskResult(taskCommand, new ModelAndView(new RedirectView("/", true)));
}
use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.
the class DifferentialExpressionAnalysisTaskImpl method execute.
@Override
public TaskResult execute() {
if (taskCommand instanceof DifferentialExpressionAnalysisRemoveTaskCommand) {
DifferentialExpressionAnalysis toRemove = ((DifferentialExpressionAnalysisRemoveTaskCommand) taskCommand).getToRemove();
if (toRemove == null) {
throw new IllegalArgumentException("Analysis to remove must not be null");
}
log.info("Removing analysis ...");
this.differentialExpressionAnalysisService.remove(toRemove);
return new TaskResult(taskCommand, true);
}
Collection<DifferentialExpressionAnalysis> results = doAnalysis();
Collection<DifferentialExpressionAnalysis> minimalResults = new HashSet<>();
for (DifferentialExpressionAnalysis r : results) {
/* Don't send the full analysis to the space. Instead, create a minimal result. */
DifferentialExpressionAnalysis minimalResult = DifferentialExpressionAnalysis.Factory.newInstance();
minimalResult.setName(r.getName());
minimalResult.setDescription(r.getDescription());
minimalResult.setAuditTrail(r.getAuditTrail());
minimalResults.add(minimalResult);
}
return new TaskResult(taskCommand, minimalResults);
}
Aggregations