Search in sources :

Example 1 with Status

use of org.jbpm.examples.checklist.ChecklistItem.Status 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));
                }
            }
        }
    }
}
Also used : Status(org.jbpm.examples.checklist.ChecklistItem.Status) StartNode(org.jbpm.workflow.core.node.StartNode) NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode) StartNode(org.jbpm.workflow.core.node.StartNode) Node(org.kie.api.definition.process.Node) Work(org.jbpm.process.core.Work) NodeContainer(org.kie.api.definition.process.NodeContainer) HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode)

Aggregations

Status (org.jbpm.examples.checklist.ChecklistItem.Status)1 Work (org.jbpm.process.core.Work)1 NodeImpl (org.jbpm.workflow.core.impl.NodeImpl)1 HumanTaskNode (org.jbpm.workflow.core.node.HumanTaskNode)1 StartNode (org.jbpm.workflow.core.node.StartNode)1 Node (org.kie.api.definition.process.Node)1 NodeContainer (org.kie.api.definition.process.NodeContainer)1