use of org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator in project carbon-business-process by wso2.
the class LiteralBasedOrgEntityProvider method addOrgEntitiesForOrganizationEntityNode.
public static void addOrgEntitiesForOrganizationEntityNode(Node orgEntityNode, PeopleQueryEvaluator pqe, List<OrganizationalEntityDAO> orgEntityList) {
// Org entity node should contain either a user elements or group elements
if (orgEntityNode.getNodeType() == Node.ELEMENT_NODE) {
NodeList userList = ((Element) orgEntityNode).getElementsByTagNameNS(HumanTaskConstants.userQname.getNamespaceURI(), HumanTaskConstants.userQname.getLocalPart());
for (int j = 0; j < userList.getLength(); j++) {
Node item = userList.item(j);
NodeList childNodes = item.getChildNodes();
if (childNodes.getLength() == 1) {
Node textNode = childNodes.item(0);
if (textNode != null && textNode.getNodeType() == Node.TEXT_NODE) {
String username = textNode.getNodeValue();
if (username != null) {
username = username.trim();
if (username.length() > 0) {
OrganizationalEntityDAO userOrgEntityForName = pqe.createUserOrgEntityForName(username);
orgEntityList.add(userOrgEntityForName);
}
}
}
}
}
NodeList groupList = ((Element) orgEntityNode).getElementsByTagNameNS(HumanTaskConstants.groupQname.getNamespaceURI(), HumanTaskConstants.groupQname.getLocalPart());
for (int j = 0; j < groupList.getLength(); j++) {
Node item = groupList.item(j);
NodeList childNodes = item.getChildNodes();
if (childNodes.getLength() == 1) {
Node textNode = childNodes.item(0);
if (textNode != null && textNode.getNodeType() == Node.TEXT_NODE) {
String groupName = textNode.getNodeValue();
if (groupName != null) {
groupName = groupName.trim();
if (groupName.length() > 0) {
OrganizationalEntityDAO groupOrgEntityForName = pqe.createGroupOrgEntityForRole(groupName);
orgEntityList.add(groupOrgEntityForName);
}
}
}
}
}
}
}
use of org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator in project carbon-business-process by wso2.
the class HumanTaskJPQLQueryBuilder method getNameListForUser.
private List<String> getNameListForUser(String userName, boolean includeUserName) {
List<String> roleNameList = new ArrayList<String>();
if (includeUserName) {
roleNameList.add(userName);
}
PeopleQueryEvaluator peopleQueryEvaluator = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getPeopleQueryEvaluator();
roleNameList.addAll(peopleQueryEvaluator.getRoleNameListForUser(userName));
return roleNameList;
}
use of org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator 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.engine.PeopleQueryEvaluator in project carbon-business-process by wso2.
the class Nominate method checkPreConditions.
/**
* Checks the Pre-conditions before executing the task operation.
*/
@Override
protected void checkPreConditions() {
PeopleQueryEvaluator pqe = getEngine().getPeopleQueryEvaluator();
pqe.checkOrgEntitiesExist(nominees);
// Check for Excluded Owners.
GenericHumanRoleDAO excludedOwnerRoles = getTask().getGenericHumanRole(GenericHumanRoleDAO.GenericHumanRoleType.EXCLUDED_OWNERS);
if (excludedOwnerRoles != null) {
List<OrganizationalEntityDAO> excludedOrgEntities = excludedOwnerRoles.getOrgEntities();
// Case 1 : Matching Excluded OrgEntity List.
for (OrganizationalEntityDAO nominee : nominees) {
for (OrganizationalEntityDAO excludedOrgEntity : excludedOrgEntities) {
if (nominee.getOrgEntityType() == excludedOrgEntity.getOrgEntityType() && nominee.getName().equals(excludedOrgEntity.getName())) {
String errMsg = String.format("The task nomination failed. One nominee is in the excluded Owner List for task " + getTask().getId() + ".");
log.error(errMsg);
throw new HumanTaskIllegalArgumentException(errMsg);
}
}
}
// Case 2: Checking OrgEntity Users in Excluded OrgEntity Groups.
for (OrganizationalEntityDAO nominee : nominees) {
if (nominee.getOrgEntityType() == OrganizationalEntityDAO.OrganizationalEntityType.USER) {
List<String> roleNameListForUser = getEngine().getPeopleQueryEvaluator().getRoleNameListForUser(nominee.getName());
for (OrganizationalEntityDAO excludedOrgEntity : excludedOrgEntities) {
if (excludedOrgEntity.getOrgEntityType() == OrganizationalEntityDAO.OrganizationalEntityType.GROUP && roleNameListForUser.contains(excludedOrgEntity.getName())) {
String errMsg = String.format("The task nomination failed. One nominee is in an excluded Owner Group for task " + getTask().getId() + ".");
log.error(errMsg);
throw new HumanTaskIllegalArgumentException(errMsg);
}
}
}
}
}
}
Aggregations