use of org.kie.api.definition.process.Node in project drools by kiegroup.
the class WorkingMemoryLogger method createNodeId.
private String createNodeId(NodeInstance nodeInstance) {
Node node = nodeInstance.getNode();
if (node == null) {
return "";
}
Object uniqueIdObj = node.getMetaData().get("UniqueId");
String nodeId;
if (uniqueIdObj == null) {
nodeId = "" + node.getId();
} else {
nodeId = (String) uniqueIdObj;
}
NodeContainer nodeContainer = node.getNodeContainer();
while (nodeContainer != null) {
if (nodeContainer instanceof Node) {
node = (Node) nodeContainer;
nodeContainer = node.getNodeContainer();
// TODO fix this filter out hidden compositeNode inside ForEach node
if (!(nodeContainer.getClass().getName().endsWith("ForEachNode"))) {
nodeId = node.getId() + ":" + nodeId;
}
} else {
break;
}
}
return nodeId;
}
use of org.kie.api.definition.process.Node in project jbpm by kiegroup.
the class ProcessBuilderImpl method generateRules.
private String generateRules(final Process process) {
StringBuffer builder = new StringBuffer();
if (process instanceof WorkflowProcessImpl) {
WorkflowProcessImpl ruleFlow = (WorkflowProcessImpl) process;
builder.append("package " + ruleFlow.getPackageName() + "\n");
Set<String> imports = ruleFlow.getImports();
if (imports != null) {
for (String importString : imports) {
builder.append("import " + importString + ";\n");
}
}
List<String> functionImports = ruleFlow.getFunctionImports();
if (functionImports != null) {
for (String importString : functionImports) {
builder.append("import function " + importString + ";\n");
}
}
Map<String, String> globals = ruleFlow.getGlobals();
if (globals != null) {
for (Map.Entry<String, String> entry : globals.entrySet()) {
builder.append("global " + entry.getValue() + " " + entry.getKey() + ";\n");
}
}
Node[] nodes = ruleFlow.getNodes();
generateRules(nodes, process, builder);
}
return builder.toString();
}
use of org.kie.api.definition.process.Node in project jbpm by kiegroup.
the class XmlWorkflowProcessDumper method visitConnections.
private void visitConnections(Node[] nodes, StringBuilder xmlDump, boolean includeMeta) {
List<Connection> connections = new ArrayList<Connection>();
for (Node node : nodes) {
for (List<Connection> connectionList : node.getIncomingConnections().values()) {
connections.addAll(connectionList);
}
}
xmlDump.append(" <connections>" + EOL);
for (Connection connection : connections) {
visitConnection(connection, xmlDump, includeMeta);
}
xmlDump.append(" </connections>" + EOL + EOL);
}
use of org.kie.api.definition.process.Node in project jbpm by kiegroup.
the class ChecklistItemFactory method getRelevantNodes.
private static void getRelevantNodes(NodeContainer container, Map<String, String> result) {
for (Node node : container.getNodes()) {
if (node instanceof NodeContainer) {
getRelevantNodes((NodeContainer) node, result);
}
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);
String nodeId = (String) node.getMetaData().get("UniqueId");
if (nodeId == null) {
nodeId = ((NodeImpl) node).getUniqueId();
}
result.put(nodeId, orderingNumber);
}
}
}
}
use of org.kie.api.definition.process.Node in project jbpm by kiegroup.
the class ProcessServiceImpl method getActiveBoundaryNodesSignals.
protected List<String> getActiveBoundaryNodesSignals(ProcessInstance processInstance, Collection<NodeInstance> activeNodes) {
WorkflowProcessInstance workflowProcessInstance = (WorkflowProcessInstance) processInstance;
ArrayList<Node> processNodesList = new ArrayList(Arrays.asList(((RuleFlowProcessInstance) workflowProcessInstance).getNodeContainer().getNodes()));
List<String> activeBoundaryNodesSignals = new ArrayList<>();
Map<String, NodeInstance> uniqueIdNodeInstanceMap = new HashMap<>();
for (NodeInstance activeNode : activeNodes) {
uniqueIdNodeInstanceMap.put((String) activeNode.getNode().getMetaData().get("UniqueId"), activeNode);
}
try {
for (Node processNode : processNodesList) {
if (processNode instanceof BoundaryEventNode && uniqueIdNodeInstanceMap.containsKey(((BoundaryEventNode) processNode).getAttachedToNodeId())) {
activeBoundaryNodesSignals.add(VariableUtil.resolveVariable((String) processNode.getMetaData().get("SignalName"), uniqueIdNodeInstanceMap.get(((BoundaryEventNode) processNode).getAttachedToNodeId())));
}
}
return activeBoundaryNodesSignals;
} catch (Exception e) {
logger.debug("Unable to retrieve boundary event nodes for active nodes in processInstance {}", processInstance.getId());
return new ArrayList<>();
}
}
Aggregations