//***************************************************************************** //* * //* "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 * //* 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 cancel the claim of a staff activity. * You have to be process administrator to cancel the claim of another user. * * In this sample a user claims a staff activity and then calls cancelClaim() * to cancel the claim. * */ import com.ibm.bpe.api.*; import commonj.sdo.DataObject; public class CancelClaim { public static void main(String[] args) { try { // initialize context and access the remote interface for the // BusinessFlowManager bean BusinessFlowManager bfm = ApiHelper.initializeBFM(); String selectClause = "DISTINCT ACTIVITY.AIID" ; String whereClause = null; String orderClause = null; // List the activities of the OrderApprovalProcess // that are in state ready and for which the current user is a potential owner // in order to work on (claim) it 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 = 'OrderApprovalProcess' "; QueryResultSet result = bfm.query( selectClause, whereClause, orderClause, null, null ); System.out.println( "\n > query(), result size: " + result.size()); if ( result.size() == 0 ) { System.out.println("\n > successfully processed.\n" ); System.exit(0); } AIID aiid = null; result.first(); aiid = (AIID)result.getOID(1); MyTrace.trace( aiid, "activity, retrieved calling query()", bfm ); // in order to work on the activity you have to claim it ClientObjectWrapper input = bfm.claim(aiid); MyTrace.trace( aiid, "activity claimed", bfm ); if (input.getObject() != null && input.getObject() instanceof DataObject) { DataObject inputMessage = (DataObject)input.getObject(); MyTrace.trace(inputMessage, "inputMessage"); } // The process administrator can cancel this claim that another user can // start to work on this activity. bfm.cancelClaim( aiid ); MyTrace.trace( aiid, "activity claim canceled", bfm ); System.out.println(" > successfully processed." ); System.exit(0); } catch ( com.ibm.bpe.api.ProcessException xcpt) { System.out.println( xcpt ); } catch (java.lang.Exception xcpt ) { System.out.println( xcpt ); } catch (Throwable xcpt ) { System.out.println( xcpt ); } finally { System.exit(0); } } }