use of com.enonic.xp.task.TaskProgress in project xp by enonic.
the class TaskMapper method serialize.
@Override
public void serialize(final MapGenerator gen) {
gen.value("description", this.taskInfo.getDescription());
gen.value("id", this.taskInfo.getId().toString());
gen.value("name", this.taskInfo.getName());
gen.value("state", this.taskInfo.getState().toString());
gen.value("application", this.taskInfo.getApplication().toString());
gen.value("user", this.taskInfo.getUser().toString());
gen.value("startTime", this.taskInfo.getStartTime());
final TaskProgress progress = this.taskInfo.getProgress();
gen.map("progress");
gen.value("info", progress.getInfo());
gen.value("current", progress.getCurrent());
gen.value("total", progress.getTotal());
gen.end();
}
use of com.enonic.xp.task.TaskProgress in project xp by enonic.
the class LocalTaskManagerImpl method updateProgress.
private void updateProgress(final TaskId taskId, final String message) {
final TaskInfoHolder ctx = tasks.get(taskId);
if (ctx == null) {
return;
}
final TaskInfo taskInfo = ctx.getTaskInfo();
final TaskProgress updatedProgress = taskInfo.getProgress().copy().info(message).build();
final TaskInfo updatedInfo = taskInfo.copy().progress(updatedProgress).build();
final TaskInfoHolder updatedCtx = ctx.copy().taskInfo(updatedInfo).build();
tasks.put(taskId, updatedCtx);
eventPublisher.publish(TaskEvents.updated(updatedInfo));
}
use of com.enonic.xp.task.TaskProgress in project xp by enonic.
the class TaskEvents method task.
private static Event task(String type, final TaskInfo taskInfo) {
if (taskInfo == null) {
return null;
}
final TaskProgress progress = taskInfo.getProgress();
final ImmutableMap<Object, Object> taskProgressAsMap = ImmutableMap.builder().put("info", progress.getInfo()).put("current", progress.getCurrent()).put("total", progress.getTotal()).build();
return Event.create(type).distributed(true).value("description", taskInfo.getDescription()).value("id", taskInfo.getId().toString()).value("name", taskInfo.getName()).value("state", taskInfo.getState().toString()).value("progress", taskProgressAsMap).value("application", taskInfo.getApplication().toString()).value("user", taskInfo.getUser().toString()).value("startTime", taskInfo.getStartTime().toString()).build();
}
use of com.enonic.xp.task.TaskProgress in project xp by enonic.
the class LocalTaskManagerImpl method updateProgress.
private void updateProgress(final TaskId taskId, final int current, final int total) {
final TaskInfoHolder ctx = tasks.get(taskId);
if (ctx == null) {
return;
}
final TaskInfo taskInfo = ctx.getTaskInfo();
final TaskProgress updatedProgress = taskInfo.getProgress().copy().current(current).total(total).build();
final TaskInfo updatedInfo = taskInfo.copy().progress(updatedProgress).build();
final TaskInfoHolder updatedCtx = ctx.copy().taskInfo(updatedInfo).build();
tasks.put(taskId, updatedCtx);
eventPublisher.publish(TaskEvents.updated(updatedInfo));
}
Aggregations