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;
}
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;
}
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;
}
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;
}
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;
}
}
}
Aggregations