-
1. Re: No public metadata API?
salaboy21 Feb 8, 2010 6:56 PM (in response to bill.burke)Hi Bill,
At least in jBPM 3.2.6 you can use the Command API to interact with jBPM. In that way you don't need to transport all the jBPM POJOs to the client (you just use primitive types and Strings.).
I suppose that in jBPM 4 it's the same idea.
Greetings.
-
2. Re: No public metadata API?
sebastian.s Feb 9, 2010 2:01 AM (in response to bill.burke)Are you using jBPM 4.3 or jBPM 3.2? In jBPM 4.3 there is the ExecutionService. Using it you can retrieve process instances by their ids:
{code}
ProcessInstance processInstance = executionService.findProcessInstanceById(processInstanceId);
{code}
Afterwards you can use the following methods to retrieve some of the information you wanted:
{code}
processInstance.findActiveActivityNames();
processInstance.getState();
processInstance.getProcessDefinitionId():
..
{code}
HTH. If you could be a bit more specific on the data you want to retrieve we would be able to help more. Maybe it's something which is not possible through the API right now but would make sense and thus be useful to others, too. In this case: why not fill a JIRA issue after discussion?
-
3. Re: No public metadata API?
sebastian.s Feb 9, 2010 2:02 AM (in response to sebastian.s)Why the heck is the wiki markup syntax not working? -
4. Re: No public metadata API?
bill.burke Feb 9, 2010 3:02 PM (in response to sebastian.s)Specific data? I want a pointer to the current state and be able to find out what outgoing transitions are available. -
5. Re: No public metadata API?
bill.burke Feb 9, 2010 3:03 PM (in response to bill.burke)I'm using 4.3 FYI. Also, again, i've been able to get at this information but only through "internal" apis. -
6. Re: No public metadata API?
jbarrez Feb 9, 2010 3:08 PM (in response to bill.burke)Outgoing/Incoming transitions are possible on trunk, so I guess this was added to the API just recentrly.
To know which activities are currently active, you can use the operations on the ProcessInstance (findActiveActivities). Much of that kind of data can be retrieved through the query API (eg executionService.createProcessInstanceQuery).
The XML itself is indeed not queryable through the 'official' API.
-
7. Re: No public metadata API?
bill.burke Feb 9, 2010 3:30 PM (in response to jbarrez)I guess I'm missing how to get an Activity plus how to get the transitions that are available out of the activity. I don't currently see any query api to get this information within JBPM 4.3
Currently I'm getting a "no environment to get org.jbpm.pvm.internal.session.RepositorySession" error when I do this:
engine.getExecutionService().signalExecutionById(pid);
instance = engine.getExecutionService().findProcessInstanceById(pid);
ExecutionImpl execution = (ExecutionImpl)instance;
Activity current = execution.getActivity();getActivity() is throwing it. What I want to get at runtime is the available transitions out of the current wait state.
-
8. Re: No public metadata API?
bill.burke Feb 9, 2010 3:45 PM (in response to bill.burke)Well, I got it to work doing this:
import org.jbpm.pvm.internal.model.Activity;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.model.Transition;{...
if (instance.findActiveActivityNames().size() < 1) return;
String activityName = instance.findActiveActivityNames().iterator().next();ProcessDefinitionImpl pd = (ProcessDefinitionImpl)engine.getRepositoryService().createProcessDefinitionQuery().processDefinitionId(instance.getProcessDefinitionId()).uniqueResult();
Activity current = pd.findActivity(activityName);
for (Transition transition : current.getOutgoingTransitions())
{...}}
-
9. Re: No public metadata API?
kukeltje Feb 9, 2010 7:21 PM (in response to bill.burke)Bill,
If you want access to the internal 'model', cast the Execution to OpenExecution:
OpenExecution e = (OpenExecution)processInstance.findActiveExecutionIn(activityName);
e.getActivity().getOutgoingTransitions();No need to use internal classes then. This still has to be added to the executionService. Getting transitions was only available for the taskService.
Regarding creating xml from the definition, that is not needed:
List<Deployment> dep = repositoryService.createDeploymentQuery().page(0, 10).list();
for (Deployment deployment : dep) {
Set<String> resources = repositoryService.getResourceNames(deployment.getId());
for (String resource : resources) {// e.g. test firstif the resourcename ends with .jpdl.xml
InputStream is = repositoryService.getResourceAsStream(deployment.getId(),resource);
...
}
}
Cheers,
Ronald
-
10. Re: No public metadata API?
kukeltje Feb 9, 2010 7:22 PM (in response to jbarrez)No, but it can be retrieved via the repository service, see my comment below. -
11. Re: No public metadata API?
bill.burke Feb 10, 2010 8:57 AM (in response to kukeltje)Ronald. This API is not in 4.3. Not sure I want to be using trunk... -
12. Re: No public metadata API?
kukeltje Feb 11, 2010 6:03 PM (in response to bill.burke)Sorry, should have indeed mentioned that this was trunk. 4.4 is to be released in 6 weeks I think, following the 3 month release cycle. So it's up to you.
I've been thinking about a rest interface to, more directly on jBPM. My thoughts were to even include in IN the project and just follow the methods of the services by annotating them.
Looking forward to your implementation.
Cheers,
Ronald