Search in sources :

Example 6 with TaskStatus

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

the class HumanTaskJPQLQueryBuilder method buildRemoveTasksQuery.

private Query buildRemoveTasksQuery() {
    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 removeTasksQuery = em.createQuery(" DELETE FROM  org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task t  " + " WHERE t.status in :removableStatuses" + (hasTaskName ? AND + FILTER_BY_TASKNAME : ""));
    removeTasksQuery.setParameter("removableStatuses", queryCriteria.getStatuses());
    if (hasTaskName) {
        removeTasksQuery.setParameter(TASK_NAME, queryCriteria.getTaskName());
    }
    return removeTasksQuery;
}
Also used : Query(javax.persistence.Query) TaskStatus(org.wso2.carbon.humantask.core.dao.TaskStatus)

Example 7 with TaskStatus

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

the class HumanTaskJPQLQueryBuilder method buildNotificationsCountQuery.

// Creates the JPQL query to list notifications applicable for a particular user.
private Query buildNotificationsCountQuery() {
    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_COUNT + 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 : ""));
    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 8 with TaskStatus

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

the class HumanTaskJPQLQueryBuilder method buildClaimableCountQuery.

private Query buildClaimableCountQuery() {
    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_COUNT + 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);
    Query claimableTasksQuery = em.createQuery(query.toString());
    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);
    List<TaskStatus> statusList = Arrays.asList(TaskStatus.READY);
    claimableTasksQuery.setParameter(TASK_STATUSES, statusList);
    if (hasStatus) {
        claimableTasksQuery.setParameter(TASK_STATUSES, statuses);
    } else {
        List<TaskStatus> readyList = Arrays.asList(TaskStatus.READY);
        claimableTasksQuery.setParameter(TASK_STATUSES, readyList);
    }
    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 9 with TaskStatus

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

the class HumanTaskCoordinationProtocolManagementSkeleton method isTaskInFinalState.

private boolean isTaskInFinalState(final Long taskID) throws Exception {
    TaskDAO task = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<TaskDAO>() {

        public TaskDAO call() throws Exception {
            return HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getDaoConnectionFactory().getConnection().getTask(taskID);
        }
    });
    TaskStatus status = task.getStatus();
    boolean isInFinalState = false;
    if (TaskStatus.EXITED.equals(status) || TaskStatus.ERROR.equals(status) || TaskStatus.FAILED.equals(status) || TaskStatus.OBSOLETE.equals(status) || TaskStatus.COMPLETED.equals(status)) {
        isInFinalState = true;
    }
    return isInFinalState;
}
Also used : TaskDAO(org.wso2.carbon.humantask.core.dao.TaskDAO) TaskStatus(org.wso2.carbon.humantask.core.dao.TaskStatus)

Example 10 with TaskStatus

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

the class HumanTaskServerConfiguration method iniTaskCleanupConfig.

private void iniTaskCleanupConfig(TTaskCleanupConfig taskCleanupConfig) {
    if (taskCleanupConfig != null) {
        if (StringUtils.isNotEmpty(taskCleanupConfig.getCronExpression())) {
            if (CronExpression.isValidExpression(taskCleanupConfig.getCronExpression().trim())) {
                this.taskCleanupCronExpression = taskCleanupConfig.getCronExpression();
            } else {
                String warnMsg = String.format("The task clean up cron expression[%s] is invalid." + " Ignoring task clean up configurations! ", taskCleanupConfig.getCronExpression());
                log.warn(warnMsg);
                return;
            }
        }
        if (StringUtils.isNotEmpty(taskCleanupConfig.getStatuses())) {
            String[] removableStatusesArray = taskCleanupConfig.getStatuses().split(",");
            List<TaskStatus> removableTaskStatusList = new ArrayList<TaskStatus>();
            for (String removableStatus : removableStatusesArray) {
                for (TaskStatus taskStatusEnum : TaskStatus.values()) {
                    if (taskStatusEnum.toString().equals(removableStatus.trim())) {
                        removableTaskStatusList.add(taskStatusEnum);
                        break;
                    }
                }
            }
            this.removableTaskStatuses = removableTaskStatusList;
        }
    }
}
Also used : ArrayList(java.util.ArrayList) 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