/* ======================================================================================= "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, 2010 All Rights Reserved * Licensed Materials - Property of IBM ======================================================================================= */ package bpc.samples.bean; import java.util.logging.Logger; import com.ibm.bpe.api.ProcessInstanceData; import com.ibm.bpe.api.QueryResultSet; import com.ibm.bpe.clientmodel.BFMConnection; import com.ibm.bpe.clientmodel.bean.ProcessInstanceBean; /** * CustomProcessInstanceBean extends a com.ibm.bpe.clientmodel.bean.ProcessInstanceBean * and adds the following custom properties to the bean's properties: *
    *
  • "department" *
  • "orderNo" *
*/ public class CustomProcessInstanceBean extends ProcessInstanceBean { public static final long serialVersionUID = 1L; Logger logger = Logger.getLogger("CustomClient") ; /* -- Static properties --*/ public static String PROPERTY_NAME_DEPARTMENT = "department" ; public static String PROPERTY_NAME_ORDER_NO = "orderNo" ; private static String DEFAULT_VALUE = "Not set" ; /* -- Instance variables --*/ private String department = DEFAULT_VALUE; private String orderNo = DEFAULT_VALUE; /** Constructs a custom process instance bean from a process instance returned by the API. * * @param processInstance returned by the API * @param bfmConnection the connection to Business Flow Manager */ public CustomProcessInstanceBean( ProcessInstanceData processInstance, BFMConnection bfmConnection) { super(processInstance, bfmConnection); processInstance.getCustomProperty( PROPERTY_NAME_DEPARTMENT ) ; processInstance.getCustomProperty( PROPERTY_NAME_ORDER_NO ) ; } /** Constructs a custom process instance bean from a query result set returned * by the BusinessFlowManager API * * @param resultSet the query result from a query call; represents a row of this result * @param bfmConnection the connection to the Business Flow Manager */ public CustomProcessInstanceBean( QueryResultSet resultSet, BFMConnection bfmConnection) { // Make sure the super class can read the properties from the resultSet // super(resultSet, bfmConnection); // Then read the custom properties from the result set. // Iterate over the columns in the result set and check // if the custom properties were included. // for (int col = 1; col <= resultSet.numberColumns(); col++) { String table = resultSet.getTableDisplayName(col); String column = resultSet.getColumnDisplayName(col); logger.info( "Analyzing: table=" + table + " column=" + column + " value=" + resultSet.getObject(col).toString()) ; // Make sure that the select AND where clause contains the following sequence of attributes: // ... PROCESS_ATTRIBUTE0.NAME="orderNo", PROCESS_ATTRIBUTE1.NAME="department",.... // if (table.equalsIgnoreCase("PROCESS_ATTRIBUTE") && column.equalsIgnoreCase("VALUE")) { if( orderNo.equalsIgnoreCase( DEFAULT_VALUE)) orderNo = resultSet.getString(col) ; else if( department.equalsIgnoreCase( DEFAULT_VALUE )) department = resultSet.getString(col) ; } } } public String getDepartment() { return department ; } public void setDepartment(String department) { this.department = department; } public String getOrderNo() { return orderNo; } public void setOrderNo(String orderNo) { this.orderNo = orderNo; } }