JBoss Community

Re: Get Activity Coordinates

created by Marcelo Zabalet in jBPM - View the full discussion

Ah, ok, I understand, I thought you was interested on the active nodes of an instance, and I see now you are interested on all nodes of a process definition.

I IMHO I suggest two ways.

 

One is expose the bpmn file to the front end because this file is a standard and has a lot of sense to use it directly for a RIA. It is relative simple to extract diagram information and parsing it with javascript.

 

The other way is using the api, this has sense too because this way you have only one authorithy of information in your system and some more control. Moreover, if you need another runtime information, you must go this way.

 

Here some sample code. I'm not yet using it... take it with care

 

Somewhere in your code you have surely something like this...

 

org.drools.builder.KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();

org.drools.KnowledgeBase knowledgeBase = builder.newKnowledgeBase();

// add some process definitions

// builder.add(resource, ResourceType.BPMN2);

 

org.drools.runtime.StatefulKnowledgeSession knowledgeSession = JPAKnowledgeService.newStatefulKnowledgeSession(knowledgeBase, null, env);

 

Then, you can do something like this:

 

// import org.drools.definition.process.Process

Process process = knowledgeBase.getProcess("the.process.definition.id.you.are.interested.in");

 

You could find a lot of info inside process object, ie:

 

// import org.jbpm.workflow.core.impl.NodeImpl

// import org.jbpm.workflow.core.impl.WorkflowProcessImpl

for (NodeImpl nodeImpl : (NodeImpl[]) ((WorkflowProcessImpl) process).getNodes()) {

    node.getMetaData().get("height");

    node.getName();

}

Reply to this message by going to Community

Start a new discussion in jBPM at Community