use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.
the class GetInput method execute.
@Override
public void execute() {
authorise();
TaskDAO task = getTask();
checkPreConditions();
checkState();
if (StringUtils.isNotEmpty(partName)) {
inputElement = CommonTaskUtil.getMessagePart(task.getInputMessage(), partName);
} else {
inputElement = (Element) task.getInputMessage().getBodyData().getFirstChild().getFirstChild();
}
checkPostConditions();
}
use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.
the class CommonTaskUtil method setTaskOverrideContextAttributes.
public static void setTaskOverrideContextAttributes(TaskDAO task, Map<String, Element> headerElements) {
// TODO fix this for remaining properties.
try {
if (headerElements != null) {
Element contextRequest = headerElements.get(HumanTaskConstants.HT_CONTEXT_REQUEST);
if (contextRequest != null) {
if (!TaskType.NOTIFICATION.equals(task.getType())) {
// Notification can't be skipped.
NodeList nodeList = contextRequest.getElementsByTagNameNS(HumanTaskConstants.HT_CONTEXT_NAMESPACE, HumanTaskConstants.HT_CONTEXT_IS_SKIPABLE);
if (nodeList != null && nodeList.getLength() > 0) {
Node isSkipable = nodeList.item(0);
task.setSkipable(Boolean.parseBoolean(isSkipable.getTextContent()));
}
}
NodeList nodeList = contextRequest.getElementsByTagNameNS(HumanTaskConstants.HT_CONTEXT_NAMESPACE, HumanTaskConstants.HT_CONTEXT_PRIORITY);
if (nodeList != null && nodeList.getLength() > 0) {
Node priority = nodeList.item(0);
task.setPriority(Integer.parseInt(priority.getTextContent()));
}
}
}
} catch (Exception e) {
log.error("Error while setting override attributes to task", e);
}
}
use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.
the class CommonTaskUtil method processDeadlines.
/**
* Process the deadlines for the given task.
*
* @param task : The task object.
* @param taskConf : The task configuration for this task.
* @param evalContext : The task's eval context.
*/
public static void processDeadlines(TaskDAO task, TaskConfiguration taskConf, EvaluationContext evalContext) {
// TODO is it possible to process deadlines once per a task definition and set the duration per a task instance?
TDeadlines deadlines = taskConf.getDeadlines();
if (deadlines != null) {
TDeadline[] startDeadlines = deadlines.getStartDeadlineArray();
TDeadline[] completionDeadlines = deadlines.getCompletionDeadlineArray();
for (TDeadline deadline : startDeadlines) {
DeadlineDAO startDeadline = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getDaoConnectionFactory().getConnection().createDeadline();
startDeadline.setStatus(TaskStatus.IN_PROGRESS);
startDeadline.setName((deadline.getName() == null ? "startDeadline" : deadline.getName()));
startDeadline.setTask(task);
startDeadline.setDeadlineDate(calculateDeadline(task, deadline, taskConf, evalContext).getTime());
task.addDeadline(startDeadline);
}
for (TDeadline deadline : completionDeadlines) {
Deadline completionDeadline = new Deadline();
completionDeadline.setStatus(TaskStatus.COMPLETED);
completionDeadline.setName((deadline.getName() == null ? "completionDeadline" : deadline.getName()));
completionDeadline.setTask(task);
completionDeadline.setDeadlineDate(calculateDeadline(task, deadline, taskConf, evalContext).getTime());
task.addDeadline(completionDeadline);
}
}
}
use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.
the class CommonTaskUtil method getAssignableUserNameList.
/**
* Returns the list of assignable user name list.
*
* @param task : The task object.
* @param excludeActualOwner : Whether to exclude the actual owner from the returned list.
* @return : the list of assignable user name list.
*/
public static List<String> getAssignableUserNameList(TaskDAO task, boolean excludeActualOwner) {
List<String> allPotentialOwners = new ArrayList<String>();
GenericHumanRoleDAO ghr = task.getGenericHumanRole(GenericHumanRole.GenericHumanRoleType.POTENTIAL_OWNERS);
RegistryService registryService = HumanTaskServiceComponent.getRegistryService();
for (OrganizationalEntityDAO orgEntity : ghr.getOrgEntities()) {
if (OrganizationalEntityDAO.OrganizationalEntityType.GROUP.equals(orgEntity.getOrgEntityType())) {
String roleName = orgEntity.getName();
UserRealm userRealm;
try {
userRealm = registryService.getUserRealm(task.getTenantId());
String[] assignableUsersArray = userRealm.getUserStoreManager().getUserListOfRole(roleName);
allPotentialOwners.addAll(Arrays.asList(assignableUsersArray));
} catch (RegistryException e) {
throw new HumanTaskRuntimeException("Cannot locate user realm for tenant id " + task.getTenantId());
} catch (UserStoreException e) {
throw new HumanTaskRuntimeException("Error retrieving the UserStoreManager " + task.getTenantId(), e);
}
} else if (OrganizationalEntityDAO.OrganizationalEntityType.USER.equals(orgEntity.getOrgEntityType())) {
allPotentialOwners.add(orgEntity.getName());
}
}
OrganizationalEntityDAO actualOwner = getActualOwner(task);
if (excludeActualOwner && actualOwner != null) {
allPotentialOwners.remove(actualOwner.getName());
}
return allPotentialOwners;
}
use of org.wso2.carbon.humantask.core.dao.TaskDAO in project carbon-business-process by wso2.
the class CommonTaskUtil method hasPotentialOwners.
/**
* Checks whether the given TaskDAO has potential owners.
*
* @param task : The task to be checked for potential owners.
* @return : true if the task has potential owners.
*/
public static boolean hasPotentialOwners(TaskDAO task) {
PeopleQueryEvaluator pqe = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getPeopleQueryEvaluator();
boolean hasPotentialOwners = false;
for (GenericHumanRoleDAO humanRoleDAO : task.getHumanRoles()) {
if (GenericHumanRoleDAO.GenericHumanRoleType.POTENTIAL_OWNERS.equals(humanRoleDAO.getType()) && humanRoleDAO.getOrgEntities() != null && humanRoleDAO.getOrgEntities().size() > 0) {
try {
pqe.checkOrgEntitiesExist(humanRoleDAO.getOrgEntities());
hasPotentialOwners = true;
} catch (HumanTaskRuntimeException ex) {
hasPotentialOwners = false;
}
}
}
return hasPotentialOwners;
}
Aggregations