public KnowledgeBase execute(Context context) { StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession(); return ksession.getKnowledgeBase(); }
public static ActivationIterator iterator(StatefulKnowledgeSession ksession) { return new ActivationIterator( ((InternalWorkingMemoryEntryPoint) ksession).getInternalWorkingMemory(), ksession.getKnowledgeBase() ); }
public void writeExternal(ObjectOutput out) throws IOException { // all we do is create marshall to a byte[] and write to the stream StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) getKnowledgeRuntime(); Marshaller marshaller = MarshallerFactory.newMarshaller( ksession.getKnowledgeBase(), new ObjectMarshallingStrategy[] { MarshallerFactory.newSerializeMarshallingStrategy() } ); ByteArrayOutputStream stream = new ByteArrayOutputStream(); marshaller.marshall( stream, (StatefulKnowledgeSession) getKnowledgeRuntime() ); stream.close(); byte[] bytes = stream.toByteArray(); out.writeInt( bytes.length ); out.write( bytes ); }
public static Process getProcessByName(String name) { KnowledgeBase kbase = getSession().getKnowledgeBase(); for (KnowledgePackage kpackage: kbase.getKnowledgePackages()) { for (Process process: kpackage.getProcesses()) { if (name.equals(process.getName())) { return process; } } } return null; }
public static List<Process> getProcesses() { List<Process> result = new ArrayList<Process>(); StatefulKnowledgeSessionUtil.getKnowledgeBaseManager().syncPackages(); KnowledgeBase kbase = getSession().getKnowledgeBase(); for (KnowledgePackage kpackage: kbase.getKnowledgePackages()) { result.addAll(kpackage.getProcesses()); } return result; }
public static Process getProcess(String processId) { KnowledgeBase kbase = getSession().getKnowledgeBase(); for (KnowledgePackage kpackage: kbase.getKnowledgePackages()) { for (Process process: kpackage.getProcesses()) { if (processId.equals(process.getId())) { return process; } } } return null; }
public static Map<ConnectionRef, Constraint> getNextGatewayConstraints(final StatefulKnowledgeSession inSession, final WorkflowProcessInstanceImpl inInstance, final Node inTaskNode) { final Map<ConnectionRef, Constraint> constraints = new HashMap<>(); final WorkflowProcess process = (WorkflowProcess) inSession.getKnowledgeBase().getProcess(inInstance.getProcessId()); for (Node node : process.getNodes()) { if (!node.equals(inTaskNode)) { continue; } final List<Connection> nodeConnections = node.getOutgoingConnections(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE); if (nodeConnections != null && !nodeConnections.isEmpty()) { for (Connection c : nodeConnections) { final Node nextNode = c.getTo(); if (nextNode instanceof Split) { constraints.putAll(((Split) nextNode).getConstraints()); return constraints; } } } break; } return constraints; }
public static Collection<NodeInstance> getActiveNodeInstances(long processInstanceId) { ProcessInstance processInstance = getSession().getProcessInstance(processInstanceId); if (processInstance != null){ ((ProcessInstanceImpl)processInstance).setProcess(getSession().getKnowledgeBase().getProcess(processInstance.getProcessId())); Collection<NodeInstance> activeNodes = ((WorkflowProcessInstance)processInstance).getNodeInstances(); activeNodes.addAll(collectActiveNodeInstances(activeNodes)); return activeNodes; } return null; }
public static List<Node> getProcessActiveNodeList(final StatefulKnowledgeSession inSession, final WorkflowProcessInstanceImpl inInstance) { final List<Node> nodes = new ArrayList<>(); final WorkflowProcess process = (WorkflowProcess) inSession.getKnowledgeBase().getProcess(inInstance.getProcessId()); for (Node node : process.getNodes()) { if (node instanceof EventNode && ((EventNode) node).getFrom() == null) { // a free-standing event, without an entry point; this would be a start of an "optional" branch nodes.add(node); } else { // a node that has an inbound connection; all nodes on the main branch are of this kind List<NodeInstance> nodeInstances = inInstance.getNodeInstances(node.getId()); if (nodeInstances != null && !nodeInstances.isEmpty()) { for (NodeInstance nodeInstance : nodeInstances) { Node nodeInstanceNode = process.getNode(nodeInstance.getNodeId()); nodes.add(0, nodeInstanceNode); } } } } return nodes; }
boolean dispose) throws Exception { Marshaller marshaller = MarshallerFactory.newMarshaller( ksession.getKnowledgeBase(), new ObjectMarshallingStrategy[]{ strategy } );