use of org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl in project jbpm by kiegroup.
the class JbpmJUnitBaseTestCase method assertNumOfIncommingConnections.
public void assertNumOfIncommingConnections(ProcessInstance process, String nodeName, int num) {
assertNodeExists(process, nodeName);
WorkflowProcessInstanceImpl instance = (WorkflowProcessInstanceImpl) process;
for (Node node : instance.getNodeContainer().getNodes()) {
if (node.getName().equals(nodeName)) {
if (node.getIncomingConnections().size() != num) {
fail("Expected incomming connections: " + num + " - found " + node.getIncomingConnections().size());
} else {
break;
}
}
}
}
use of org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl in project jbpm by kiegroup.
the class JbpmJUnitBaseTestCase method assertNodeExists.
public void assertNodeExists(ProcessInstance process, String... nodeNames) {
WorkflowProcessInstanceImpl instance = (WorkflowProcessInstanceImpl) process;
List<String> names = new ArrayList<String>();
for (String nodeName : nodeNames) {
names.add(nodeName);
}
for (Node node : instance.getNodeContainer().getNodes()) {
if (names.contains(node.getName())) {
names.remove(node.getName());
}
}
if (!names.isEmpty()) {
String s = names.get(0);
for (int i = 1; i < names.size(); i++) {
s += ", " + names.get(i);
}
fail("Node(s) do not exist: " + s);
}
}
use of org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl in project jbpm by kiegroup.
the class JbpmJUnitBaseTestCase method assertProcessVarExists.
public void assertProcessVarExists(ProcessInstance process, String... processVarNames) {
WorkflowProcessInstanceImpl instance = (WorkflowProcessInstanceImpl) process;
List<String> names = new ArrayList<String>();
for (String nodeName : processVarNames) {
names.add(nodeName);
}
for (String pvar : instance.getVariables().keySet()) {
if (names.contains(pvar)) {
names.remove(pvar);
}
}
if (!names.isEmpty()) {
String s = names.get(0);
for (int i = 1; i < names.size(); i++) {
s += ", " + names.get(i);
}
fail("Process Variable(s) do not exist: " + s);
}
}
use of org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl in project jbpm by kiegroup.
the class JbpmJUnitTestCase method assertNodeExists.
public void assertNodeExists(ProcessInstance process, String... nodeNames) {
WorkflowProcessInstanceImpl instance = (WorkflowProcessInstanceImpl) process;
List<String> names = new ArrayList<String>();
for (String nodeName : nodeNames) {
names.add(nodeName);
}
for (Node node : instance.getNodeContainer().getNodes()) {
if (names.contains(node.getName())) {
names.remove(node.getName());
}
}
if (!names.isEmpty()) {
String s = names.get(0);
for (int i = 1; i < names.size(); i++) {
s += ", " + names.get(i);
}
fail("Node(s) do not exist: " + s);
}
}
use of org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl in project jbpm by kiegroup.
the class JPAProcessInstanceManager method getProcessInstance.
public ProcessInstance getProcessInstance(long id, boolean readOnly) {
InternalRuntimeManager manager = (InternalRuntimeManager) kruntime.getEnvironment().get(EnvironmentName.RUNTIME_MANAGER);
if (manager != null) {
manager.validate((KieSession) kruntime, ProcessInstanceIdContext.get(id));
}
TransactionManager txm = (TransactionManager) this.kruntime.getEnvironment().get(EnvironmentName.TRANSACTION_MANAGER);
org.jbpm.process.instance.ProcessInstance processInstance = null;
processInstance = (org.jbpm.process.instance.ProcessInstance) this.processInstances.get(id);
if (processInstance != null) {
if (((WorkflowProcessInstanceImpl) processInstance).isPersisted() && !readOnly) {
ProcessPersistenceContextManager ppcm = (ProcessPersistenceContextManager) this.kruntime.getEnvironment().get(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER);
ppcm.beginCommandScopedEntityManager();
ProcessPersistenceContext context = ppcm.getProcessPersistenceContext();
ProcessInstanceInfo processInstanceInfo = (ProcessInstanceInfo) context.findProcessInstanceInfo(id);
if (processInstanceInfo == null) {
return null;
}
TransactionManagerHelper.addToUpdatableSet(txm, processInstanceInfo);
processInstanceInfo.updateLastReadDate();
EventManagerProvider.getInstance().get().update(new ProcessInstanceView(processInstance));
}
return processInstance;
}
// Make sure that the cmd scoped entity manager has started
ProcessPersistenceContextManager ppcm = (ProcessPersistenceContextManager) this.kruntime.getEnvironment().get(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER);
ppcm.beginCommandScopedEntityManager();
ProcessPersistenceContext context = ppcm.getProcessPersistenceContext();
ProcessInstanceInfo processInstanceInfo = (ProcessInstanceInfo) context.findProcessInstanceInfo(id);
if (processInstanceInfo == null) {
return null;
}
processInstance = (org.jbpm.process.instance.ProcessInstance) processInstanceInfo.getProcessInstance(kruntime, this.kruntime.getEnvironment(), readOnly);
if (!readOnly) {
processInstanceInfo.updateLastReadDate();
TransactionManagerHelper.addToUpdatableSet(txm, processInstanceInfo);
EventManagerProvider.getInstance().get().update(new ProcessInstanceView(processInstance));
}
if (((ProcessInstanceImpl) processInstance).getProcessXml() == null) {
Process process = kruntime.getKieBase().getProcess(processInstance.getProcessId());
if (process == null) {
throw new IllegalArgumentException("Could not find process " + processInstance.getProcessId());
}
processInstance.setProcess(process);
}
if (processInstance.getKnowledgeRuntime() == null) {
Long parentProcessInstanceId = (Long) ((ProcessInstanceImpl) processInstance).getMetaData().get("ParentProcessInstanceId");
if (parentProcessInstanceId != null) {
kruntime.getProcessInstance(parentProcessInstanceId);
}
processInstance.setKnowledgeRuntime(kruntime);
((ProcessInstanceImpl) processInstance).reconnect();
if (readOnly) {
internalRemoveProcessInstance(processInstance);
}
}
return processInstance;
}
Aggregations