Search in sources :

Example 6 with TeamTask

use of com.axelor.team.db.TeamTask in project axelor-open-suite by axelor.

the class WkfUserActionServiceImpl method createUserAction.

@Override
@Transactional
public void createUserAction(WkfTaskConfig wkfTaskConfig, DelegateExecution execution) {
    String title = wkfTaskConfig.getTaskEmailTitle();
    if (title == null) {
        return;
    }
    try {
        FullContext wkfContext = getModelCtx(wkfTaskConfig, execution);
        if (wkfContext != null) {
            title = processTitle(title, wkfContext);
        }
        TeamTask teamTask = new TeamTask(title);
        teamTask.setStatus("new");
        if (wkfTaskConfig.getDeadlineFieldPath() != null) {
            teamTask.setTaskDate(getDeadLineDate(wkfTaskConfig.getDeadlineFieldPath(), wkfContext));
        }
        if (teamTask.getTaskDate() == null) {
            teamTask.setTaskDate(LocalDate.now());
        }
        String userPath = getUserPath(wkfTaskConfig, execution.getProcessDefinitionId());
        if (userPath != null) {
            teamTask.setAssignedTo(getUser(userPath, wkfContext));
        }
        String url = Beans.get(WkfEmailService.class).createUrl(wkfContext, wkfTaskConfig.getDefaultForm());
        teamTask.setDescription(String.format(DESCRIPTION, execution.getCurrentActivityName(), url, url));
        teamTaskRepository.save(teamTask);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}
Also used : FullContext(com.axelor.apps.tool.context.FullContext) TeamTask(com.axelor.team.db.TeamTask) Transactional(com.google.inject.persist.Transactional)

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