Search in sources :

Example 41 with TaskDAO

use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.

the class HumanTaskDAOConnectionImpl method searchTasks.

public List<TaskDAO> searchTasks(SimpleQueryCriteria queryCriteria) {
    HumanTaskJPQLQueryBuilder queryBuilder = new HumanTaskJPQLQueryBuilder(queryCriteria, entityManager);
    Query taskQuery = queryBuilder.build();
    return taskQuery.getResultList();
}
Also used : Query(javax.persistence.Query) HumanTaskJPQLQueryBuilder(org.wso2.carbon.humantask.core.dao.sql.HumanTaskJPQLQueryBuilder)

Example 42 with TaskDAO

use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.

the class HumanTaskEngine method createTask.

// create task logic.
private TaskDAO createTask(WSDLAwareMessage message, HumanTaskBaseConfiguration taskConfiguration, int tenantId) throws HumanTaskException {
    TaskCreationContext creationContext = new TaskCreationContext();
    creationContext.setTaskConfiguration(taskConfiguration);
    creationContext.setTenantId(tenantId);
    creationContext.setMessageBodyParts(message.getBodyPartElements());
    creationContext.setMessageHeaderParts(message.getHeaderPartElements());
    creationContext.setPeopleQueryEvaluator(peopleQueryEvaluator);
    TaskDAO task = getDaoConnectionFactory().getConnection().createTask(creationContext);
    creationContext.injectExpressionEvaluationContext(task);
    return task;
}
Also used : TaskDAO(org.wso2.carbon.humantask.core.dao.TaskDAO) TaskCreationContext(org.wso2.carbon.humantask.core.dao.TaskCreationContext)

Example 43 with TaskDAO

use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.

the class Activate method checkPreConditions.

/**
 * Checks the Pre-conditions before executing the task operation.
 */
@Override
protected void checkPreConditions() {
    checkForValidTask();
    TaskDAO task = getTask();
    if (task.getActivationTime() == null) {
        throw new HumanTaskRuntimeException(String.format("The task[id:%d] does not have a defined activation time.", task.getId()));
    }
    if (task.getActivationTime().before(new Date())) {
        throw new HumanTaskRuntimeException(String.format("The task[id:%d] activation time has already expired.", task.getId()));
    }
    if (CommonTaskUtil.getOrgEntitiesForRole(task, GenericHumanRoleDAO.GenericHumanRoleType.POTENTIAL_OWNERS).size() < 1) {
        throw new HumanTaskIllegalStateException(String.format("The are no matching users for the " + "task's[id:%d] potential owners", task.getId()));
    }
}
Also used : TaskDAO(org.wso2.carbon.humantask.core.dao.TaskDAO) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) HumanTaskIllegalStateException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException) Date(java.util.Date)

Example 44 with TaskDAO

use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.

the class Delegate method checkPreConditions.

/**
 * Checks the Pre-conditions before executing the task operation.
 */
@Override
protected void checkPreConditions() {
    checkForValidTask();
    OrganizationalEntityDAO caller = getOperationInvoker();
    TaskDAO task = getTask();
    // if the delegatee is not an existing user
    if (!getEngine().getPeopleQueryEvaluator().isExistingUser(delegatee.getName())) {
        String errMsg = String.format("The user[%s] cannot delegate task[id:%d] to the given" + " delegatee[name:%s] as he/she does not exist in the user store", caller.getName(), task.getId(), delegatee.getName());
        log.error(errMsg);
        throw new HumanTaskIllegalArgumentException(errMsg);
    }
    if (isExcludedOwner(delegatee.getName())) {
        String errMsg = String.format("The user[%s] cannot delegate task[id:%d] to the given" + " delegatee[name:%s] as he/she is an exclude owner for this task.", caller.getName(), task.getId(), delegatee.getName());
        log.error(errMsg);
        throw new HumanTaskIllegalArgumentException(errMsg);
    }
    // if the task is in reserved or in-progress we have to release it first.
    if (TaskStatus.RESERVED.equals(task.getStatus()) || TaskStatus.IN_PROGRESS.equals(task.getStatus())) {
        // task releasing can be done only by bus admins and the actual owner.
        List<GenericHumanRoleDAO.GenericHumanRoleType> allowedRoles = new ArrayList<GenericHumanRoleDAO.GenericHumanRoleType>();
        allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.BUSINESS_ADMINISTRATORS);
        allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.ACTUAL_OWNER);
        try {
            authoriseRoles(allowedRoles);
        } catch (Exception ex) {
            String err = String.format("The task[id:%d] can be only delegated after it's released. " + "But for the task to be released you need to be a business " + "administrator or the actual owner of the task. " + "Given user[%s] is not in those roles!", task.getId(), caller.getName());
            log.error(err);
            throw new HumanTaskIllegalAccessException(err, ex);
        }
        task.release();
    }
    // Add delegatee as a potential owner.
    GenericHumanRoleDAO potentialOwnersRole = task.getGenericHumanRole(GenericHumanRoleDAO.GenericHumanRoleType.POTENTIAL_OWNERS);
    if (getEngine().getPeopleQueryEvaluator().isOrgEntityInRole(delegatee, potentialOwnersRole)) {
        task.persistToPotentialOwners(delegatee);
    }
}
Also used : HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) ArrayList(java.util.ArrayList) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 45 with TaskDAO

use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.

the class DeleteComment method execute.

@Override
public void execute() {
    authorise();
    TaskDAO task = getTask();
    checkPreConditions();
    checkState();
    task.deleteComment(updatingCommentId);
    processTaskEvent();
    checkPostConditions();
}
Also used : TaskDAO(org.wso2.carbon.humantask.core.dao.TaskDAO)

Aggregations

TaskDAO (org.wso2.carbon.humantask.core.dao.TaskDAO)27 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)16 HumanTaskEngine (org.wso2.carbon.humantask.core.engine.HumanTaskEngine)7 HumanTaskIllegalAccessException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException)7 HumanTaskIllegalStateException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException)7 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)7 UserStoreException (org.wso2.carbon.user.core.UserStoreException)7 Element (org.w3c.dom.Element)6 HumanTaskDAOConnection (org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection)6 HumanTaskException (org.wso2.carbon.humantask.core.engine.HumanTaskException)6 HumanTaskIllegalArgumentException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException)6 QName (javax.xml.namespace.QName)5 HumanTaskBaseConfiguration (org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration)5 TaskConfiguration (org.wso2.carbon.humantask.core.store.TaskConfiguration)5 HumanTaskIllegalOperationException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException)4 URI (org.apache.axis2.databinding.types.URI)3 NodeList (org.w3c.dom.NodeList)3 PeopleQueryEvaluator (org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator)3 ExpressionEvaluationContext (org.wso2.carbon.humantask.core.engine.runtime.ExpressionEvaluationContext)3 EvaluationContext (org.wso2.carbon.humantask.core.engine.runtime.api.EvaluationContext)3