Search in sources :

Example 1 with TeamTask

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);
    }
}
Also used : TeamTask(com.axelor.team.db.TeamTask) Transactional(com.google.inject.persist.Transactional)

Example 2 with TeamTask

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;
    }
}
Also used : TeamTask(com.axelor.team.db.TeamTask) LocalDate(java.time.LocalDate) Transactional(com.google.inject.persist.Transactional)

Example 3 with TeamTask

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);
    }
}
Also used : TeamTask(com.axelor.team.db.TeamTask) Transactional(com.google.inject.persist.Transactional)

Example 4 with TeamTask

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;
}
Also used : TeamTask(com.axelor.team.db.TeamTask)

Example 5 with TeamTask

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;
}
Also used : TeamTask(com.axelor.team.db.TeamTask) ArrayList(java.util.ArrayList)

Aggregations

TeamTask (com.axelor.team.db.TeamTask)6 Transactional (com.google.inject.persist.Transactional)4 FullContext (com.axelor.apps.tool.context.FullContext)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1