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