use of com.axelor.team.db.TeamTask in project axelor-open-suite by axelor.
the class TeamTaskServiceImpl method updateNextTask.
@Override
@Transactional
public void updateNextTask(TeamTask teamTask) {
TeamTask nextTeamTask = teamTask.getNextTeamTask();
if (nextTeamTask != null) {
updateModuleFields(teamTask, nextTeamTask);
teamTaskRepo.save(nextTeamTask);
updateNextTask(nextTeamTask);
}
}
use of com.axelor.team.db.TeamTask in project axelor-open-suite by axelor.
the class TeamTaskServiceImpl method generateTasks.
@Override
@Transactional
public void generateTasks(TeamTask teamTask, Frequency frequency) {
List<LocalDate> taskDates = Beans.get(FrequencyService.class).getDates(frequency, teamTask.getTaskDate(), frequency.getEndDate());
taskDates.removeIf(date -> date.equals(teamTask.getTaskDate()));
// limit how many TeamTask will be generated at once
Integer limitNumberTasksGenerated = Beans.get(AppBaseService.class).getAppBase().getLimitNumberTasksGenerated();
if (taskDates.size() > limitNumberTasksGenerated) {
taskDates = taskDates.subList(0, limitNumberTasksGenerated);
}
TeamTask lastTask = teamTask;
for (LocalDate date : taskDates) {
TeamTask newTeamTask = teamTaskRepo.copy(teamTask, false);
setModuleFields(teamTask, date, newTeamTask);
teamTaskRepo.save(newTeamTask);
lastTask.setNextTeamTask(newTeamTask);
teamTaskRepo.save(lastTask);
lastTask = newTeamTask;
}
}
use of com.axelor.team.db.TeamTask in project axelor-open-suite by axelor.
the class TeamTaskServiceImpl method removeNextTasks.
@Override
@Transactional
public void removeNextTasks(TeamTask teamTask) {
List<TeamTask> teamTasks = getAllNextTasks(teamTask);
teamTask.setNextTeamTask(null);
teamTask.setHasDateOrFrequencyChanged(false);
teamTaskRepo.save(teamTask);
for (TeamTask teamTaskToRemove : teamTasks) {
teamTaskRepo.remove(teamTaskToRemove);
}
}
use of com.axelor.team.db.TeamTask in project axelor-open-suite by axelor.
the class TeamTaskBaseRepository method copy.
@Override
public TeamTask copy(TeamTask entity, boolean deep) {
TeamTask task = super.copy(entity, deep);
task.setAssignedTo(null);
task.setTaskDate(null);
task.setPriority(null);
return task;
}
use of com.axelor.team.db.TeamTask in project axelor-open-suite by axelor.
the class TeamTaskServiceImpl method getAllNextTasks.
/**
* Returns next tasks from given {@link TeamTask}.
*/
public List<TeamTask> getAllNextTasks(TeamTask teamTask) {
List<TeamTask> teamTasks = new ArrayList<>();
TeamTask current = teamTask;
while (current.getNextTeamTask() != null) {
current = current.getNextTeamTask();
teamTasks.add(current);
}
for (TeamTask tt : teamTasks) {
tt.setNextTeamTask(null);
teamTaskRepo.save(tt);
}
return teamTasks;
}
Aggregations