use of com.axelor.apps.base.db.Frequency in project axelor-open-suite by axelor.
the class ProjectTaskProjectRepository method save.
@Override
public ProjectTask save(ProjectTask projectTask) {
List<String> composedNames = new ArrayList<>();
if (projectTask.getId() != null) {
composedNames.add("#" + projectTask.getId());
}
composedNames.add(projectTask.getName());
projectTask.setFullName(String.join(" ", composedNames));
ProjectTaskService projectTaskService = Beans.get(ProjectTaskService.class);
if (projectTask.getDoApplyToAllNextTasks() && projectTask.getNextProjectTask() != null && projectTask.getHasDateOrFrequencyChanged()) {
// remove next tasks
projectTaskService.removeNextTasks(projectTask);
// regenerate new tasks
projectTask.setIsFirst(true);
}
Frequency frequency = projectTask.getFrequency();
if (frequency != null && projectTask.getIsFirst() && projectTask.getNextProjectTask() == null) {
if (projectTask.getTaskDate() != null) {
if (frequency.getEndDate().isBefore(projectTask.getTaskDate())) {
throw new PersistenceException(I18n.get(IExceptionMessage.PROJECT_TASK_FREQUENCY_END_DATE_CAN_NOT_BE_BEFORE_TASK_DATE));
}
} else {
throw new PersistenceException(I18n.get(IExceptionMessage.PROJECT_TASK_FILL_TASK_DATE));
}
projectTaskService.generateTasks(projectTask, frequency);
}
if (projectTask.getDoApplyToAllNextTasks()) {
projectTaskService.updateNextTask(projectTask);
}
projectTask.setDoApplyToAllNextTasks(false);
projectTask.setHasDateOrFrequencyChanged(false);
return super.save(projectTask);
}
use of com.axelor.apps.base.db.Frequency in project axelor-open-suite by axelor.
the class FrequencyController method computeSummary.
/**
* Computes summary of the {@code Frequency} in context.
*/
public void computeSummary(ActionRequest request, ActionResponse response) {
Frequency frequency = request.getContext().asType(Frequency.class);
response.setValue("summary", Beans.get(FrequencyService.class).computeSummary(frequency));
}
use of com.axelor.apps.base.db.Frequency in project axelor-open-suite by axelor.
the class TeamTaskBaseRepository method save.
@Override
public TeamTask save(TeamTask teamTask) {
TeamTaskService teamTaskService = Beans.get(TeamTaskService.class);
if (teamTask.getDoApplyToAllNextTasks() && teamTask.getNextTeamTask() != null && teamTask.getHasDateOrFrequencyChanged()) {
// remove next tasks
teamTaskService.removeNextTasks(teamTask);
// regenerate new tasks
teamTask.setIsFirst(true);
}
Frequency frequency = teamTask.getFrequency();
if (frequency != null && teamTask.getIsFirst() && teamTask.getNextTeamTask() == null) {
if (teamTask.getTaskDate() != null) {
if (frequency.getEndDate().isBefore(teamTask.getTaskDate())) {
throw new PersistenceException(I18n.get("Frequency end date cannot be before task date."));
}
} else {
throw new PersistenceException(I18n.get("Please fill in task date."));
}
teamTaskService.generateTasks(teamTask, frequency);
}
if (teamTask.getDoApplyToAllNextTasks()) {
teamTaskService.updateNextTask(teamTask);
}
teamTask.setDoApplyToAllNextTasks(false);
teamTask.setHasDateOrFrequencyChanged(false);
return super.save(teamTask);
}
Aggregations