//***************************************************************************** //* * //* "This sample program is provided AS IS and may be used, executed, copied * //* and modified without royalty payment by customer * //* (a) for its own instruction and study, * //* (b) in order to develop applications designed to run with an * //* IBM WebSphere product, either for customer's own internal use or for * //* redistribution by customer, as part of such an application, in * //* customer's own products." * //* * //* Product 5655-FLW, * //* (C) COPYRIGHT International Business Machines Corp., 2006, 2008 * //* All Rights Reserved * Licensed Materials - Property of IBM * //* * //***************************************************************************** //* * //* DISCLAIMER * //* * //* This material contains programming source code for your consideration. * //* These examples have not been thoroughly tested under all conditions. * //* IBM, therefore, cannot guarantee or imply reliability, serviceability, * //* or function of these programs. * //* ALL PROGRAMS CONTAINED HEREIN ARE PROVIDED TO YOU "AS IS", WITHOUT ANY * //* WARRANTIES (EXPRESS OR IMPLIED) OR SUPPORT WHATSOEVER, INCLUDING BUT * //* NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS * //* FOR A PARTICULAR PURPOSE. * //* * //***************************************************************************** /* * This sample shows how to handle workItems: * -- It creates a workitem for a specific user * -- It transfers the workItem to another user * -- It deletes the workItem * * In a first step a staff activity is claimed and the POTENTIAL_OWNER becomes the owner * of the activity. * Then the owner of the staff activity adds Smith as READER and EDITOR. * Then the owner transfers the EDITOR workitem from Smith to Miller * In a last step the system is set to the initial state, i.e., * the two workitems are deleted and the claim is canceled. */ import java.util.TimeZone; import com.ibm.bpe.api.*; public class HandleWorkItems { public static void main(String[] args) { try { // initialize context and access the remote interface for the // BusinessFlowManager bean BusinessFlowManager bfm = ApiHelper.initializeBFM(); String processTemplate = "OrderApprovalProcess"; // get the process instances who's admin is the current user String selectClause = "DISTINCT ACTIVITY.AIID"; String whereClause = "ACTIVITY.STATE = ACTIVITY.STATE.STATE_READY AND " + "ACTIVITY.KIND = ACTIVITY.KIND.KIND_STAFF AND " + "WORK_ITEM.REASON = WORK_ITEM.REASON.REASON_POTENTIAL_OWNER AND " + "PROCESS_INSTANCE.STATE = PROCESS_INSTANCE.STATE.STATE_RUNNING AND " + "PROCESS_TEMPLATE.NAME = '" + processTemplate + "'"; QueryResultSet result = bfm.query( selectClause, whereClause, (String)null, (Integer)null, (TimeZone)null ); System.out.println( "\n > query(), result size: " + result.size()); if ( result.size() == 0 ) { System.exit(0); } result.first(); AIID aiid = (AIID)result.getOID(1); // Claim the activity ClientObjectWrapper input = bfm.claim( aiid ); // add 'Smith' as READER and EDITOR for this activity bfm.createWorkItem( aiid, WorkItemData.REASON_READER, "Smith"); bfm.createWorkItem( aiid, WorkItemData.REASON_EDITOR, "Smith"); System.out.println( " > createWorkItem() "); // transfer this READER-workItem from Smith to Miller bfm.transferWorkItem( aiid, WorkItemData.REASON_EDITOR, "Smith", "Miller"); System.out.println( " > transferWorkItem() "); // delete the workitems created bfm.deleteWorkItem( aiid, WorkItemData.REASON_READER, "Smith"); bfm.deleteWorkItem( aiid, WorkItemData.REASON_EDITOR, "Miller"); bfm.cancelClaim( aiid ); System.out.println( " > deleteWorkItem() "); System.out.println("\n successfully processed \n"); System.exit(0); } catch ( com.ibm.bpe.api.ProcessException xcpt) { System.out.println( xcpt ); } catch (java.rmi.RemoteException xcpt ) { System.out.println( xcpt ); } finally { System.exit(0); } } }