Search in sources :

Example 11 with TaskStatus

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

the class HumanTaskJPQLQueryBuilder method buildClaimableQuery.

private Query buildClaimableQuery() {
    boolean hasStatus = false;
    List<TaskStatus> statuses = queryCriteria.getStatuses();
    if (statuses != null && !statuses.isEmpty()) {
        hasStatus = true;
    }
    boolean hasTaskName = false;
    if (!StringUtils.isEmpty(queryCriteria.getTaskName())) {
        hasTaskName = true;
    }
    StringBuilder query = new StringBuilder(SELECT_DISTINCT_TASKS + JOIN_HUMAN_ROLES_JOIN_ORG_ENTITIES + OE_NAME_IN_NAMES + AND + HR_TYPE_ROLE_TYPE + (hasTaskName ? AND + FILTER_BY_TASKNAME : "") + AND + T_TYPE_TASK_TYPE + AND + T_TENANT_ID_TENANT_ID + AND + T_STATUS_IN_TASK_STATUSES + generateOrderedByQuery());
    Query claimableTasksQuery = em.createQuery(query.toString()).setMaxResults(queryCriteria.getPageSize()).setFirstResult(queryCriteria.getPageSize() * queryCriteria.getPageNumber());
    List<String> rolesAndNamesList = getNameListForUser(queryCriteria.getCaller(), true);
    claimableTasksQuery.setParameter(NAMES, rolesAndNamesList);
    claimableTasksQuery.setParameter(TENANT_ID, queryCriteria.getCallerTenantId());
    claimableTasksQuery.setParameter(ROLE_TYPE, GenericHumanRoleDAO.GenericHumanRoleType.POTENTIAL_OWNERS);
    claimableTasksQuery.setParameter(TASK_TYPE, TaskType.TASK);
    if (hasStatus) {
        claimableTasksQuery.setParameter(TASK_STATUSES, statuses);
    } else {
        List<TaskStatus> statusList = Arrays.asList(TaskStatus.READY);
        claimableTasksQuery.setParameter(TASK_STATUSES, statusList);
    }
    if (hasTaskName) {
        claimableTasksQuery.setParameter(TASK_NAME, queryCriteria.getTaskName());
    }
    return claimableTasksQuery;
}
Also used : Query(javax.persistence.Query) TaskStatus(org.wso2.carbon.humantask.core.dao.TaskStatus)

Example 12 with TaskStatus

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

the class HumanTaskJPQLQueryBuilder method buildNotificationsQuery.

// Creates the JPQL query to list notifications applicable for a particular user.
private Query buildNotificationsQuery() {
    boolean hasStatus = false;
    List<TaskStatus> statuses = queryCriteria.getStatuses();
    if (statuses != null && !statuses.isEmpty()) {
        hasStatus = true;
    }
    boolean hasTaskName = false;
    if (!StringUtils.isEmpty(queryCriteria.getTaskName())) {
        hasTaskName = true;
    }
    Query notificationsQuery = em.createQuery(SELECT_DISTINCT_TASKS + JOIN_HUMAN_ROLES_JOIN_ORG_ENTITIES + OE_NAME_IN_NAMES + AND + HR_TYPE_ROLE_TYPE + AND + T_TENANT_ID_TENANT_ID + AND + T_TYPE_TASK_TYPE + (hasTaskName ? AND + FILTER_BY_TASKNAME : "") + (hasStatus ? AND + T_STATUS_IN_TASK_STATUSES : "") + generateOrderedByQuery()).setMaxResults(queryCriteria.getPageSize()).setFirstResult(queryCriteria.getPageSize() * queryCriteria.getPageNumber());
    notificationsQuery.setParameter(TENANT_ID, queryCriteria.getCallerTenantId());
    List<String> rolesAndNamesList = getNameListForUser(queryCriteria.getCaller(), true);
    notificationsQuery.setParameter(NAMES, rolesAndNamesList);
    notificationsQuery.setParameter(ROLE_TYPE, GenericHumanRoleDAO.GenericHumanRoleType.NOTIFICATION_RECIPIENTS);
    notificationsQuery.setParameter(TASK_TYPE, TaskType.NOTIFICATION);
    if (hasTaskName) {
        notificationsQuery.setParameter(TASK_NAME, queryCriteria.getTaskName());
    }
    if (hasStatus) {
        notificationsQuery.setParameter(TASK_STATUSES, statuses);
    }
    return notificationsQuery;
}
Also used : Query(javax.persistence.Query) TaskStatus(org.wso2.carbon.humantask.core.dao.TaskStatus)

Example 13 with TaskStatus

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

the class HumanTaskJPQLQueryBuilder method buildAdministrableTasksQuery.

private Query buildAdministrableTasksQuery() {
    boolean hasStatus = false;
    List<TaskStatus> statuses = queryCriteria.getStatuses();
    if (statuses != null && !statuses.isEmpty()) {
        hasStatus = true;
    }
    boolean hasTaskName = false;
    if (!StringUtils.isEmpty(queryCriteria.getTaskName())) {
        hasTaskName = true;
    }
    Query administrableTasksQuery = em.createQuery(SELECT_DISTINCT_TASKS + JOIN_HUMAN_ROLES_JOIN_ORG_ENTITIES + OE_NAME_IN_NAMES + AND + HR_TYPE_ROLE_TYPE + (hasTaskName ? AND + FILTER_BY_TASKNAME : "") + AND + T_TYPE_TASK_TYPE + AND + T_TENANT_ID_TENANT_ID + (hasStatus ? AND + T_STATUS_IN_TASK_STATUSES : "") + generateOrderedByQuery()).setMaxResults(queryCriteria.getPageSize()).setFirstResult(queryCriteria.getPageSize() * queryCriteria.getPageNumber());
    List<String> rolesAndNamesList = getNameListForUser(queryCriteria.getCaller(), true);
    administrableTasksQuery.setParameter(NAMES, rolesAndNamesList);
    administrableTasksQuery.setParameter(TENANT_ID, queryCriteria.getCallerTenantId());
    administrableTasksQuery.setParameter(ROLE_TYPE, GenericHumanRoleDAO.GenericHumanRoleType.BUSINESS_ADMINISTRATORS);
    administrableTasksQuery.setParameter(TASK_TYPE, TaskType.TASK);
    if (hasStatus) {
        administrableTasksQuery.setParameter(TASK_STATUSES, statuses);
    }
    if (hasTaskName) {
        administrableTasksQuery.setParameter(TASK_NAME, queryCriteria.getTaskName());
    }
    return administrableTasksQuery;
}
Also used : Query(javax.persistence.Query) TaskStatus(org.wso2.carbon.humantask.core.dao.TaskStatus)

Example 14 with TaskStatus

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

the class HumanTaskJPQLQueryBuilder method buildAllTasksCountQuery.

private Query buildAllTasksCountQuery() {
    boolean hasStatus = false;
    List<TaskStatus> statuses = queryCriteria.getStatuses();
    if (statuses != null && !statuses.isEmpty()) {
        hasStatus = true;
    }
    boolean hasTaskName = false;
    if (!StringUtils.isEmpty(queryCriteria.getTaskName())) {
        hasTaskName = true;
    }
    Query allTasksQuery = em.createQuery(" SELECT COUNT(DISTINCT t) FROM org.wso2.carbon.humantask.core.dao.jpa" + ".openjpa.model.Task t " + JOIN_HUMAN_ROLES_JOIN_ORG_ENTITIES + OE_NAME_IN_NAMES + AND + (hasStatus ? T_STATUS_IN_TASK_STATUSES + AND : "") + T_TYPE_TASK_TYPE + (hasTaskName ? AND + FILTER_BY_TASKNAME : "") + AND + T_TENANT_ID_TENANT_ID);
    List<String> rolesAndNamesList = getNameListForUser(queryCriteria.getCaller(), true);
    allTasksQuery.setParameter(NAMES, rolesAndNamesList);
    allTasksQuery.setParameter(TENANT_ID, queryCriteria.getCallerTenantId());
    allTasksQuery.setParameter(TASK_TYPE, TaskType.TASK);
    if (hasStatus) {
        allTasksQuery.setParameter(TASK_STATUSES, statuses);
    }
    if (hasTaskName) {
        allTasksQuery.setParameter(TASK_NAME, queryCriteria.getTaskName());
    }
    return allTasksQuery;
}
Also used : Query(javax.persistence.Query) TaskStatus(org.wso2.carbon.humantask.core.dao.TaskStatus)

Example 15 with TaskStatus

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

the class HumanTaskJPQLQueryBuilder method buildAllTasksQuery.

private Query buildAllTasksQuery() {
    boolean hasStatus = false;
    List<TaskStatus> statuses = queryCriteria.getStatuses();
    if (statuses != null && !statuses.isEmpty()) {
        hasStatus = true;
    }
    boolean hasTaskName = false;
    if (!StringUtils.isEmpty(queryCriteria.getTaskName())) {
        hasTaskName = true;
    }
    Query allTasksQuery = em.createQuery(" SELECT DISTINCT t FROM org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task t " + JOIN_HUMAN_ROLES_JOIN_ORG_ENTITIES + OE_NAME_IN_NAMES + AND + (hasStatus ? T_STATUS_IN_TASK_STATUSES + AND : "") + T_TYPE_TASK_TYPE + (hasTaskName ? AND + FILTER_BY_TASKNAME : "") + AND + T_TENANT_ID_TENANT_ID + generateOrderedByQuery()).setMaxResults(queryCriteria.getPageSize()).setFirstResult(queryCriteria.getPageSize() * queryCriteria.getPageNumber());
    List<String> rolesAndNamesList = getNameListForUser(queryCriteria.getCaller(), true);
    allTasksQuery.setParameter(NAMES, rolesAndNamesList);
    allTasksQuery.setParameter(TENANT_ID, queryCriteria.getCallerTenantId());
    allTasksQuery.setParameter(TASK_TYPE, TaskType.TASK);
    if (hasStatus) {
        allTasksQuery.setParameter(TASK_STATUSES, statuses);
    }
    if (hasTaskName) {
        allTasksQuery.setParameter(TASK_NAME, queryCriteria.getTaskName());
    }
    return allTasksQuery;
}
Also used : Query(javax.persistence.Query) TaskStatus(org.wso2.carbon.humantask.core.dao.TaskStatus)

Aggregations

TaskStatus (org.wso2.carbon.humantask.core.dao.TaskStatus)14 Query (javax.persistence.Query)11 ArrayList (java.util.ArrayList)2 TaskDAO (org.wso2.carbon.humantask.core.dao.TaskDAO)2 Calendar (java.util.Calendar)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 URI (org.apache.axis2.databinding.types.URI)1 IllegalArgumentFault (org.wso2.carbon.humantask.client.api.IllegalArgumentFault)1 IllegalStateFault (org.wso2.carbon.humantask.client.api.IllegalStateFault)1 TStatus (org.wso2.carbon.humantask.client.api.types.TStatus)1 TTaskSimpleQueryResultSet (org.wso2.carbon.humantask.client.api.types.TTaskSimpleQueryResultSet)1 HumanTaskDAOConnection (org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection)1 SimpleQueryCriteria (org.wso2.carbon.humantask.core.dao.SimpleQueryCriteria)1 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)1