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