use of org.jbpm.workflow.core.node.HumanTaskNode in project jbpm by kiegroup.
the class ChecklistItemFactory method getPendingChecklistItems.
private static void getPendingChecklistItems(NodeContainer container, List<ChecklistItem> result, String processId) {
for (Node node : container.getNodes()) {
if (node instanceof HumanTaskNode) {
Work workItem = ((HumanTaskNode) node).getWork();
int priority = 0;
String priorityString = (String) workItem.getParameter("Priority");
if (priorityString != null) {
try {
priority = new Integer(priorityString);
} catch (NumberFormatException e) {
// Do nothing
}
}
String actorId = (String) workItem.getParameter("ActorId");
if (actorId != null && actorId.trim().length() == 0) {
actorId = null;
}
String groupId = (String) workItem.getParameter("GroupId");
if (groupId != null && groupId.trim().length() == 0) {
groupId = null;
}
String actors = null;
if (actorId == null) {
if (groupId == null) {
actors = "";
} else {
actors = groupId;
}
} else {
if (groupId == null) {
actors = actorId;
} else {
actors = actorId + "," + groupId;
}
}
Status status = Status.Pending;
if (((HumanTaskNode) node).getDefaultIncomingConnections().size() == 0) {
status = Status.Optional;
}
result.add(createChecklistItem((String) workItem.getParameter("TaskName"), "HumanTaskNode", actors, (String) workItem.getParameter("Comment"), priority, processId, status));
} else if (node instanceof NodeContainer) {
getPendingChecklistItems((NodeContainer) node, result, processId);
} else {
String docs = (String) node.getMetaData().get("Documentation");
if (docs != null) {
int position = docs.indexOf("OrderingNb=");
if (position >= 0) {
int end = docs.indexOf(";", position + 1);
String orderingNumber = docs.substring(position + 11, end);
Status status = Status.Pending;
if (((NodeImpl) node).getDefaultIncomingConnections().size() == 0 && !(node instanceof StartNode)) {
status = Status.Optional;
}
result.add(createChecklistItem(node.getName(), node.getClass().getSimpleName(), "", orderingNumber, 0, processId, status));
}
}
}
}
}
use of org.jbpm.workflow.core.node.HumanTaskNode in project jbpm by kiegroup.
the class HumanTaskNodeHandler method handleNode.
public void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
HumanTaskNode humanTaskNode = (HumanTaskNode) node;
final String swimlane = element.getAttribute("swimlane");
if (swimlane != null && !"".equals(swimlane)) {
humanTaskNode.setSwimlane(swimlane);
}
}
use of org.jbpm.workflow.core.node.HumanTaskNode in project jbpm by kiegroup.
the class UserTaskHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
HumanTaskNode humanTaskNode = (HumanTaskNode) node;
writeNode("userTask", humanTaskNode, xmlDump, metaDataType);
xmlDump.append(">" + EOL);
writeExtensionElements(humanTaskNode, xmlDump);
writeIO(humanTaskNode, xmlDump);
String ownerString = (String) humanTaskNode.getWork().getParameter("ActorId");
if (ownerString != null) {
String[] owners = ownerString.split(",");
for (String owner : owners) {
xmlDump.append(" <potentialOwner>" + EOL + " <resourceAssignmentExpression>" + EOL + " <formalExpression>" + owner + "</formalExpression>" + EOL + " </resourceAssignmentExpression>" + EOL + " </potentialOwner>" + EOL);
}
}
endNode("userTask", xmlDump);
}
use of org.jbpm.workflow.core.node.HumanTaskNode in project jbpm by kiegroup.
the class UserTaskHandler method handleNode.
protected void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
HumanTaskNode humanTaskNode = (HumanTaskNode) node;
Work work = humanTaskNode.getWork();
work.setName("Human Task");
Map<String, String> dataInputs = new HashMap<String, String>();
Map<String, String> dataOutputs = new HashMap<String, String>();
List<String> owners = new ArrayList<String>();
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
// ioSpec and data{Input,Output}Spec handled in super.handleNode(...)
if ("potentialOwner".equals(nodeName)) {
String owner = readPotentialOwner(xmlNode, humanTaskNode);
if (owner != null) {
owners.add(owner);
}
}
xmlNode = xmlNode.getNextSibling();
}
if (owners.size() > 0) {
String owner = owners.get(0);
for (int i = 1; i < owners.size(); i++) {
owner += "," + owners.get(i);
}
humanTaskNode.getWork().setParameter("ActorId", owner);
}
humanTaskNode.getWork().setParameter("NodeName", humanTaskNode.getName());
}
use of org.jbpm.workflow.core.node.HumanTaskNode in project jbpm by kiegroup.
the class ProcessHandler method checkBoundaryEventCompensationHandler.
/**
* This logic belongs in {@link RuleFlowProcessValidator} -- except that {@link Association}s are a jbpm-bpmn2 class,
* and {@link RuleFlowProcessValidator} is a jbpm-flow class..
* </p>
* Maybe we should have a BPMNProcessValidator class?
*
* @param association The association to check.
* @param source The source of the association.
* @param target The target of the association.
*/
private static void checkBoundaryEventCompensationHandler(Association association, Node source, Node target) {
// - event node is boundary event node
if (!(source instanceof BoundaryEventNode)) {
throw new IllegalArgumentException("(Compensation) activities may only be associated with Boundary Event Nodes (not with" + source.getClass().getSimpleName() + " nodes [node " + ((String) source.getMetaData().get("UniqueId")) + "].");
}
BoundaryEventNode eventNode = (BoundaryEventNode) source;
// - event node has compensationEvent
List<EventFilter> eventFilters = eventNode.getEventFilters();
boolean compensationCheckPassed = false;
if (eventFilters != null) {
for (EventFilter filter : eventFilters) {
if (filter instanceof EventTypeFilter) {
String type = ((EventTypeFilter) filter).getType();
if (type != null && type.equals("Compensation")) {
compensationCheckPassed = true;
}
}
}
}
if (!compensationCheckPassed) {
throw new IllegalArgumentException("An Event [" + ((String) eventNode.getMetaData("UniqueId")) + "] linked from an association [" + association.getId() + "] must be a (Boundary) Compensation Event.");
}
// - boundary event node is attached to the correct type of node?
/**
* Tasks:
* business: RuleSetNode
* manual: WorkItemNode
* receive: WorkItemNode
* script: ActionNode
* send: WorkItemNode
* service: WorkItemNode
* task: WorkItemNode
* user: HumanTaskNode
*/
String attachedToId = eventNode.getAttachedToNodeId();
Node attachedToNode = null;
for (Node node : eventNode.getNodeContainer().getNodes()) {
if (attachedToId.equals(node.getMetaData().get("UniqueId"))) {
attachedToNode = node;
break;
}
}
if (attachedToNode == null) {
throw new IllegalArgumentException("Boundary Event [" + ((String) eventNode.getMetaData("UniqueId")) + "] is not attached to a node [" + attachedToId + "] that can be found.");
}
if (!(attachedToNode instanceof RuleSetNode || attachedToNode instanceof WorkItemNode || attachedToNode instanceof ActionNode || attachedToNode instanceof HumanTaskNode || attachedToNode instanceof CompositeNode || attachedToNode instanceof SubProcessNode)) {
throw new IllegalArgumentException("Compensation Boundary Event [" + ((String) eventNode.getMetaData("UniqueId")) + "] must be attached to a task or sub-process.");
}
// - associated node is a task or subProcess
compensationCheckPassed = false;
if (target instanceof WorkItemNode || target instanceof HumanTaskNode || target instanceof CompositeContextNode || target instanceof SubProcessNode) {
compensationCheckPassed = true;
} else if (target instanceof ActionNode) {
Object nodeTypeObj = ((ActionNode) target).getMetaData("NodeType");
if (nodeTypeObj != null && nodeTypeObj.equals("ScriptTask")) {
compensationCheckPassed = true;
}
}
if (!compensationCheckPassed) {
throw new IllegalArgumentException("An Activity [" + ((String) ((NodeImpl) target).getMetaData("UniqueId")) + "] associated with a Boundary Compensation Event must be a Task or a (non-Event) Sub-Process");
}
// - associated node does not have outgoingConnections of it's own
compensationCheckPassed = true;
NodeImpl targetNode = (NodeImpl) target;
Map<String, List<org.kie.api.definition.process.Connection>> connectionsMap = targetNode.getOutgoingConnections();
ConnectionImpl outgoingConnection = null;
for (String connectionType : connectionsMap.keySet()) {
List<org.kie.api.definition.process.Connection> connections = connectionsMap.get(connectionType);
if (connections != null && !connections.isEmpty()) {
for (org.kie.api.definition.process.Connection connection : connections) {
Object hiddenObj = connection.getMetaData().get("hidden");
if (hiddenObj != null && ((Boolean) hiddenObj)) {
continue;
}
outgoingConnection = (ConnectionImpl) connection;
compensationCheckPassed = false;
break;
}
}
}
if (!compensationCheckPassed) {
throw new IllegalArgumentException("A Compensation Activity [" + ((String) targetNode.getMetaData("UniqueId")) + "] may not have any outgoing connection [" + (String) outgoingConnection.getMetaData("UniqueId") + "]");
}
}
Aggregations