/* ======================================================================================= "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.query; import java.util.Arrays; import java.util.List; import java.util.logging.Logger; import com.ibm.bpc.clientcore.ClientException; import com.ibm.bpc.clientcore.GenericBPCQuery; import com.ibm.bpc.clientcore.exception.QueryException; import com.ibm.bpe.api.ProcessTemplateData; import com.ibm.bpe.clientmodel.BFMConnection; /** * CustomProcessTemplateQuery queries process templates from * the Business Flow Manager API. * *

It is subclassed from GenericBPCQuery and has inherited the properties * to set and get the select, where and order clauses and the threshold. It adds * the connection property to access the Business Flow Manager service.

* *

Through its properties it can be configured externally, e.g. as a managed bean * in a faces-config.xml file:

	<managed-bean>
		<managed-bean-name>ProcessTemplateQuery</managed-bean-name> 
		<managed-bean-class>bpc.samples.CustomProcessTemplateQuery</managed-bean-class> 
		<managed-bean-scope>session</managed-bean-scope>

		<managed-property>
			<property-name>whereClause</property-name>
			<value>PROCESS_TEMPLATE.VALID_FROM < TS('2999-12-31')</value>
		</managed-property>

		<managed-property> 
			<property-name>type</property-name> 
			<value>com.ibm.bpe.api.ProcessTemplateData</value> 
		</managed-property>
		
		<managed-property>
			<property-name>connection</property-name>
			<value>#{bfmConnection}</value>
		</managed-property>

	</managed-bean>
  
* **/ public class CustomProcessTemplateQuery extends GenericBPCQuery { static Logger logger = Logger.getLogger( "CustomClient" ) ; private BFMConnection connection ; // Add setter & getter to manage // property, e.g. in faces-config.xml /** * Returns the BFM connection * @return the BFM connection */ public BFMConnection getConnection() { return connection ; } /** * Set the BFM connection * @param c the BFM connection */ public void setConnection( BFMConnection c ) { connection = c; } /** Query the BusinessFlowmanagerService for ProcessTemplateData objects. * @throws ClientException * @see com.ibm.bpc.clientcore.Query#execute() */ public List execute() throws ClientException { logger.entering(this.getClass().getName(),"execute()"); try { // Connect to the BFM API and query the process templates // BFMConnection bfm = getConnection(); ProcessTemplateData[] apiResult = bfm.getBusinessFlowManagerService().queryProcessTemplates( getWhereClause(), getOrderClause(), getThreshold(), null ) ; // Then transform the array of process templates into a list // List result = Arrays.asList(apiResult); return result ; } catch (Exception e) { e.printStackTrace(); String[] arg = {e.getMessage()}; throw new QueryException(arg, e ); } finally { logger.exiting(this.getClass().getName(),"execute()"); } } }