Querying Oracle BPM Process Instances
来源:互联网 发布:访客网络会影响网速么 编辑:程序博客网 时间:2024/05/29 13:25
THURSDAY, JULY 14, 2011
Querying Oracle BPM Process Instances
This is the first in a series of posts related to the BPM 11g Java API. As far as I know, as of this writing, there is no official Oracle BPM 11g Java API documentation that is being release yet, but the corresponding jars are already present on a standard JDeveloper installation (probably after installing BPM Extension).
The purpose of this post is to show simple runnable classes so readers can easily have an acquintance with the BPM 11g APIs, without needing to setup a complex web project.
We can manipulate BPM processes through a BPMServiceClient that we can acquire from a BPMServiceClientFactory. Below is a utility class that I set to easily acquire a client instance for my testing. This class need the following jars in the classpath: Oracle.bpm.client.jar, Oracle.bpm.project.model.jar, and Oracle.bpm.runtime.jar which are present inside the BPM folders in "MIDDLEWARE_HOME\jdeveloper\soa\modules" directory.
Below is a sample class that demonstrate querying of BPM process instances. It shows how to compose Predicate, Ordering, and IInstanceQueryInput objects.
Below is a sample result when I run it on my machine:
You can access the sample application on this link.
Cheers!
The purpose of this post is to show simple runnable classes so readers can easily have an acquintance with the BPM 11g APIs, without needing to setup a complex web project.
We can manipulate BPM processes through a BPMServiceClient that we can acquire from a BPMServiceClientFactory. Below is a utility class that I set to easily acquire a client instance for my testing. This class need the following jars in the classpath: Oracle.bpm.client.jar, Oracle.bpm.project.model.jar, and Oracle.bpm.runtime.jar which are present inside the BPM folders in "MIDDLEWARE_HOME\jdeveloper\soa\modules" directory.
package soadev.bpmclient;import java.util.HashMap;import java.util.Map;import oracle.bpel.services.bpm.common.IBPMContext;import oracle.bpel.services.workflow.client.IWorkflowServiceClient;import oracle.bpel.services.workflow.client.IWorkflowServiceClientConstants;import oracle.bpel.services.workflow.client.WorkflowServiceClientFactory;import oracle.bpm.client.BPMServiceClientFactory;import oracle.bpm.services.client.IBPMServiceClient;public class Fixture { private static String url = "t3://localhost:8001"; public static BPMServiceClientFactory getBPMServiceClientFactory() { Map<IWorkflowServiceClientConstants.CONNECTION_PROPERTY, String> properties = new HashMap<IWorkflowServiceClientConstants.CONNECTION_PROPERTY, String>(); properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.CLIENT_TYPE, WorkflowServiceClientFactory.REMOTE_CLIENT); properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY .EJB_PROVIDER_URL,url); properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY .EJB_INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); return BPMServiceClientFactory.getInstance(properties, null, null); } public static IBPMContext getIBPMContext(String username, String password) throws Exception{ return getBPMServiceClientFactory().getBPMUserAuthenticationService() .authenticate(username, password.toCharArray(), null); } public static IWorkflowServiceClient getIWorkflowServiceClient() { return getBPMServiceClientFactory().getWorkflowServiceClient(); } public static IBPMServiceClient getBPMServiceClient(){ return getBPMServiceClientFactory().getBPMServiceClient(); }}
Below is a sample class that demonstrate querying of BPM process instances. It shows how to compose Predicate, Ordering, and IInstanceQueryInput objects.
package soadev.bpmclient;import java.util.ArrayList;import java.util.List;import oracle.bpel.services.bpm.common.IBPMContext;import oracle.bpel.services.workflow.repos.Column;import oracle.bpel.services.workflow.repos.Ordering;import oracle.bpel.services.workflow.repos.Predicate;import oracle.bpm.services.instancemanagement.model.IProcessInstance;import oracle.bpm.services.instancequery.IColumnConstants;import oracle.bpm.services.instancequery.IInstanceQueryInput;import oracle.bpm.services.instancequery.IInstanceQueryService;import oracle.bpm.services.instancequery.impl.InstanceQueryInput;public class GetProcessInstances { public static void main(String[] args) { GetProcessInstances client = new GetProcessInstances(); client.testGetProcessInstances(); } public void testGetProcessInstances(){ try { IInstanceQueryService queryService = Fixture.getBPMServiceClient().getInstanceQueryService(); IBPMContext bpmContext = Fixture.getIBPMContext("pino", "password1"); List<Column> columns = new ArrayList<Column>(); columns.add(IColumnConstants.PROCESS_ID_COLUMN); columns.add(IColumnConstants.PROCESS_NUMBER_COLUMN); columns.add(IColumnConstants.PROCESS_STATE_COLUMN); columns.add(IColumnConstants.PROCESS_TITLE_COLUMN); columns.add(IColumnConstants.PROCESS_CREATOR_COLUMN); columns.add(IColumnConstants.PROCESS_CREATEDDATE_COLUMN); Ordering ordering = new Ordering(IColumnConstants.PROCESS_NUMBER_COLUMN, true,true); Predicate pred = new Predicate(IColumnConstants.PROCESS_STATE_COLUMN, Predicate.OP_EQ, "OPEN"); IInstanceQueryInput input = new InstanceQueryInput(); input.setAssignmentFilter(IInstanceQueryInput.AssignmentFilter.MY_AND_GROUP); List<IProcessInstance> processInstances = queryService.queryInstances(bpmContext, columns, pred, ordering, input); System.out.println("ProcessId\tProcess#\tState\tTitle\t\t\t\t\tCreator\tCreadedDate"); for (IProcessInstance instance : processInstances) { System.out.println(instance.getSystemAttributes().getProcessInstanceId() + "\t" + instance.getSystemAttributes() .getProcessNumber() + "\t" + instance.getSystemAttributes().getState() + "\t" + instance.getTitle() + "\t" + instance.getCreator() + "\t" + instance.getSystemAttributes() .getCreatedDate().getTime()); } if (processInstances.isEmpty()){ System.out.println("no result"); } } catch (Exception e) { // TODO: Add catch code e.printStackTrace(); } }}
Below is a sample result when I run it on my machine:
You can access the sample application on this link.
Kudus
Kudus to the following blogs and OTN forum posts:- RedStack-Process Instance List and Detail added to Worklist -for showing the right source of Column constants (IColumnConstants instead of the TableConstants constants).
- Matt Wang - Find something interesting today - for I guess starting it up.
Cheers!
0 0
- Querying Oracle BPM Process Instances
- BPM Process Instances – Faults, Rollback & Recovery – Part 1
- BPM Process Instances – Faults, Rollback & Recovery – Part 2
- BPM Process Instances – Faults, Rollback & Recovery – Part 3
- BPM Process Instances – Faults, Rollback & Recovery – Part 4
- 图解oracle BPM入门 asynchronous/Manual Process
- Building Your First Process with Oracle BPM 11g
- Building Your First Process with Oracle BPM 11g
- Building Your First Process with Oracle BPM 11g
- PDW中的Split Querying Process
- BPM- Business Process Management
- ANT: deploy BPM Process
- BPM process map
- Business Process Modeling ,BPM小结
- instances
- Oracle-BPM(一)
- Oracle-BPM(二)
- Oracle-BPM(三)
- EasyUI 日期格式中文化
- iOS的三维透视投影
- iOS上生成圆角图片
- interceptor-stack跟interceptor-ref的区别
- 互联网思维:3个段子,9大分类,19条法则
- Querying Oracle BPM Process Instances
- 软件测试工具MonkeyTalk使用方法
- Qt下编译警告unused parameter ,参数未使用
- ATL学习笔记(2): ATL对象多线程访问临界锁的实现
- MiniProfiler用法(转)
- Hive学习之Hive数据库DDL
- 去掉多余的tableview line
- DSPLINK DEMO解析之SCALE【转】
- Postel ActiveX Control支持Postel的ActiveX控件