public SaveTaskCmd(TaskImpl task) {
this.task = task;
}
public String execute(Environment environment) throws Exception {
DbSession dbSession = environment.get(DbSession.class);
if (task.isNew()) {
if (task.getSuperTaskDbid()!=null) {
TaskImpl parentTask = (TaskImpl) dbSession.get(TaskImpl.class, task.getSuperTaskDbid());
parentTask.addSubTask(task);
task.setSuperTaskDbid(null);
}
dbSession.save(task);
HistoryEvent.fire(new TaskCreated(task));
} else {
dbSession.update(task);
HistoryEvent.fire(new TaskUpdated(task));
}
return task.getId();