Search in sources :

Example 1 with NotificationScheduler

use of org.wso2.carbon.humantask.core.scheduler.NotificationScheduler in project carbon-business-process by wso2.

the class HumanTaskServer method initNotificationScheduler.

/**
 * Notification scheduler initialisation.
 */
private void initNotificationScheduler() {
    NotificationScheduler notificationScheduler = new NotificationScheduler();
    taskEngine.setNotificationScheduler(notificationScheduler);
}
Also used : NotificationScheduler(org.wso2.carbon.humantask.core.scheduler.NotificationScheduler)

Example 2 with NotificationScheduler

use of org.wso2.carbon.humantask.core.scheduler.NotificationScheduler in project carbon-business-process by wso2.

the class HumanTaskDAOConnectionImpl method createTask.

public TaskDAO createTask(TaskCreationContext creationContext) throws HumanTaskException {
    HumanTaskBuilderImpl taskBuilder = new HumanTaskBuilderImpl();
    if (log.isDebugEnabled()) {
        log.debug("Creating task instance for task " + creationContext.getTaskConfiguration().getName());
    }
    MessageDAO inputMessage = createMessage(creationContext);
    inputMessage.setMessageType(MessageDAO.MessageType.INPUT);
    taskBuilder.addTaskCreationContext(creationContext).addInputMessage(inputMessage);
    TaskDAO task = taskBuilder.build();
    entityManager.persist(task);
    try {
        creationContext.injectExpressionEvaluationContext(task);
        JPATaskUtil.processGenericHumanRoles(task, creationContext.getTaskConfiguration(), creationContext.getPeopleQueryEvaluator(), creationContext.getEvalContext());
        JPATaskUtil.processPresentationElements(task, creationContext.getTaskConfiguration(), creationContext);
        if (task.getType().equals(TaskType.TASK)) {
            CommonTaskUtil.nominate(task, creationContext.getPeopleQueryEvaluator());
        } else if (task.getType().equals(TaskType.NOTIFICATION)) {
            task.setStatus(TaskStatus.READY);
            notificationScheduler = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getNotificationScheduler();
            notificationScheduler.checkForNotificationTasks(creationContext.getTaskConfiguration(), creationContext, task);
        }
        task.setPriority(CommonTaskUtil.calculateTaskPriority(creationContext.getTaskConfiguration(), creationContext.getEvalContext()));
        CommonTaskUtil.setTaskToMessage(task);
        if (TaskType.TASK.equals(task.getType())) {
            CommonTaskUtil.processDeadlines(task, (TaskConfiguration) creationContext.getTaskConfiguration(), creationContext.getEvalContext());
            CommonTaskUtil.scheduleDeadlines(task);
        }
        // Setting HumanTask context override attributes
        CommonTaskUtil.setTaskOverrideContextAttributes(task, creationContext.getMessageHeaderParts());
        HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getEventProcessor().processEvent(CommonTaskUtil.createNewTaskEvent(task));
    } catch (HumanTaskRuntimeException ex) {
        String errorMsg = "Error occurred after task creation for Task ID: " + task.getId() + ". Cause: " + ex.getMessage();
        log.error(errorMsg);
        task.setStatus(TaskStatus.ERROR);
        throw ex;
    }
    return task;
}
Also used : HumanTaskBuilderImpl(org.wso2.carbon.humantask.core.dao.jpa.openjpa.util.HumanTaskBuilderImpl) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Aggregations

HumanTaskBuilderImpl (org.wso2.carbon.humantask.core.dao.jpa.openjpa.util.HumanTaskBuilderImpl)1 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)1 NotificationScheduler (org.wso2.carbon.humantask.core.scheduler.NotificationScheduler)1