[jboss-svn-commits] JBL Code SVN: r11206 - in labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal: facades and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Apr 22 13:50:22 EDT 2007


Author: estebanschifman
Date: 2007-04-22 13:50:22 -0400 (Sun, 22 Apr 2007)
New Revision: 11206

Added:
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/DeployProcessDefinitionFacade.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/FacadeUtil.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetProcessInstanceFacade.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetTaskInstanceFacade.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetTaskListFacade.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/NewProcessInstanceFacade.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/VariableMapping.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/VariablesFacade.java
Log:


Added: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/DeployProcessDefinitionFacade.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/DeployProcessDefinitionFacade.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/DeployProcessDefinitionFacade.java	2007-04-22 17:50:22 UTC (rev 11206)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.services.jbpm.internal.facades;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
+import org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor;
+import org.jboss.soa.esb.util.Util;
+import org.jbpm.graph.def.ProcessDefinition;
+
+/**
+ *
+ * Implementation of a message preprocessor that obtains the process definition 
+ * from the action configuration XML
+ * 
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a> 
+ */
+public class DeployProcessDefinitionFacade implements SingleCommandProcessor.MessageFacade
+{
+	public OpCode getOpCode() { return Constants.OpCode.DeployProcessDefinition; }
+
+	public DeployProcessDefinitionFacade(ConfigTree config) throws ConfigurationException
+	{
+		ConfigTree[] childs = config.getChildren(Constants.PROCESS_DEFINITION_XML_TAG);
+		if (null==childs || childs.length<1)
+			throw new ConfigurationException("Missing or invalid <"+Constants.PROCESS_DEFINITION_XML_TAG+"> element");
+		if (childs.length>1)
+			throw new ConfigurationException("Only one <"+Constants.PROCESS_DEFINITION_XML_TAG+"> element can be specified");
+
+		String version 	= childs[0].getAttribute("version");
+		String encoding = childs[0].getAttribute("encoding");
+		if (Util.isNullString(version) || Util.isNullString(encoding))
+			throw new ConfigurationException("Wrong 'version' or 'encoding' attribute in <"+Constants.PROCESS_DEFINITION_XML_TAG+">");
+		StringBuilder sb = new StringBuilder("<?xml version='").append(version)
+			.append("' encoding='").append(encoding).append("' ?>\n")
+		;
+
+		ConfigTree[] def = childs[0].getChildren("process-definition");
+		if (null==def || def.length<1)
+			throw new ConfigurationException("Missing or invalid <process-definition> element");
+		if (def.length>1)
+			throw new ConfigurationException("Only one <process-definition> element can be specified");
+
+		final String xmlString = sb.append(def[0].toString()).toString();
+		try
+		{
+			_processDef = ProcessDefinition.parseXmlString(xmlString);
+		}
+		catch (Exception e)
+		{
+			throw new ConfigurationException(e);
+		}
+	} // ________________________________
+	
+	public void preFormat(Message message) 
+	{
+		message.getBody().add(Constants.COMMAND_CODE,getOpCode().toString());
+		message.getBody().add(Constants.PROCESS_DEFINITION, _processDef);
+	} // ________________________________
+    
+	public Message postFormat(Message message) 
+	{
+		return message;
+	} // ________________________________
+    
+	ProcessDefinition _processDef;
+}


Property changes on: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/DeployProcessDefinitionFacade.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/FacadeUtil.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/FacadeUtil.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/FacadeUtil.java	2007-04-22 17:50:22 UTC (rev 11206)
@@ -0,0 +1,142 @@
+package org.jboss.soa.esb.services.jbpm.internal.facades;
+
+import java.util.Map;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor;
+import org.jboss.soa.esb.util.Util;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+
+public class FacadeUtil 
+{
+	static Boolean booleanFromConfig(ConfigTree tree, String tag) 
+		throws ConfigurationException
+	{
+		ConfigTree[] childs = tree.getChildren(tag);
+		if (null==childs || childs.length<1)
+			return null;
+		if (childs.length>1)
+			throw new ConfigurationException("Only one <"+tag
+					+"> element allowed in configuration");
+		try
+		{
+			return Boolean.parseBoolean(childs[0].getAttribute("value"));
+		}
+		catch (Exception e)
+		{
+			throw new ConfigurationException("<"+tag
+					+"> must have a 'value' attribute containing 'true' or 'false'");
+		}
+	} //________________________________
+
+	static VariableMapping variablesFromConfig(ConfigTree tree, boolean acceptValue)
+		throws ConfigurationException
+	{
+		String tag = Constants.VARIABLES_TAG;
+		ConfigTree[] childs = tree.getChildren(tag);
+		if (null==childs || childs.length<1)
+			return null;
+		if (childs.length>1)
+			throw new ConfigurationException("Only one <"+tag
+					+"> element allowed in configuration");
+		
+		tag = Constants.ONE_VARIABLE_TAG;
+		childs	= childs[0].getChildren(tag);
+		if (null==childs || childs.length<1)
+			throw new ConfigurationException("At least one <"+tag
+					+"> child element required for <"+Constants.VARIABLES_TAG+">");
+		VariableMapping ret = new VariableMapping();
+		for (ConfigTree curr: childs)
+		{
+			String name		= curr.getAttribute("name");
+			String esbName	= curr.getAttribute(Constants.ESB_VARNAME_TAG);
+			String jbpmName	= curr.getAttribute(Constants.JBPM_VARNAME_TAG);
+			if (null!=name)
+			{
+				if (null!=esbName || null!=jbpmName)
+					throw new ConfigurationException("When 'name' is specified, neither '"
+							+Constants.JBPM_VARNAME_TAG+"' nor"
+							+Constants.ESB_VARNAME_TAG +"' are accepted");
+				esbName	= jbpmName	= name;
+			}
+			else
+			{
+				if (Util.isNullString(esbName) || Util.isNullString(jbpmName))
+					throw new ConfigurationException("Either 'name' or the pair '"
+							+Constants.JBPM_VARNAME_TAG+"' and"
+							+Constants.ESB_VARNAME_TAG +"' must be specified");
+			}
+			String value = curr.getAttribute("value");
+			if (! acceptValue && (null!=value))
+				throw new ConfigurationException("'value' attribute is incompatible with the '"
+							+tree.getAttribute(SingleCommandProcessor.COMMAND_ATTRIBUTE_TAG)
+							+"' command");
+
+			ret.setVariable(esbName, jbpmName, value);
+		}
+		return ret;
+	} //________________________________
+
+	static String[] actorsFromConfig(ConfigTree tree, boolean acceptValue)
+		throws ConfigurationException
+	{
+		String tag = Constants.ACTORS_TAG;
+		ConfigTree[] childs = tree.getChildren(tag);
+		if (null==childs || childs.length<1)
+			return null;
+		if (childs.length>1)
+			throw new ConfigurationException("Only one <"+tag
+					+"> element allowed in configuration");
+		
+		tag = Constants.ONE_ACTOR_TAG;
+		childs	= childs[0].getChildren(tag);
+		if (null==childs || childs.length<1)
+			throw new ConfigurationException("At least one <"+tag
+					+"> child element required for <"+Constants.VARIABLES_TAG+">");
+		String[] ret = new String[childs.length];
+		int i1=0;
+		for (ConfigTree curr: childs)
+		{
+			String name		= curr.getAttribute("name");
+			if (null==name)
+			{
+				throw new ConfigurationException
+				("You must specifi the 'name' attribute for all <"
+						+tag+"> element");
+			}
+			ret[i1++]	= name;
+		}
+		return ret;
+	} //________________________________
+
+	@SuppressWarnings("unchecked")
+	static void jbpmVarsToMessage(Message message, VariableMapping mapping)
+	{
+		Body body = message.getBody();
+		Object obj = body.get(Constants.JBPM_RETURN_OBJECT);
+		if (null==obj)
+			return;
+
+		Map<String,Object> jbpmVars = null; 
+		if 		(obj instanceof ProcessInstance)
+			jbpmVars	= ((ProcessInstance)obj).getContextInstance().getVariables();
+		else if	(obj instanceof TaskInstance)
+			jbpmVars	= ((TaskInstance)obj).getContextInstance().getVariables();
+		else
+			throw new IllegalArgumentException("Unknown return jbpmObject in message");
+
+		for (Map.Entry<String, Object> curr: jbpmVars.entrySet())
+		{
+			String keyInMsg = (null==mapping) ? curr.getKey()
+					: mapping.getEsbName(curr.getKey());
+			if (null!=curr.getValue())
+				body.add(keyInMsg, curr.getValue());
+		}
+	} // ________________________________ 
+
+}


Property changes on: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/FacadeUtil.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetProcessInstanceFacade.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetProcessInstanceFacade.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetProcessInstanceFacade.java	2007-04-22 17:50:22 UTC (rev 11206)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.services.jbpm.internal.facades;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
+import org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor;
+
+/**
+ *
+ * Implementation of a message preprocessor to obtain data from a process instance 
+ * from the action configuration XML
+ * 
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a> 
+ */
+public class GetProcessInstanceFacade implements SingleCommandProcessor.MessageFacade
+{
+	public OpCode getOpCode() { return Constants.OpCode.GetProcessInstanceCommand; }
+
+	public GetProcessInstanceFacade(ConfigTree config) throws ConfigurationException
+	{
+		_includeAllVars = FacadeUtil.booleanFromConfig(config,Constants.INCLUDE_ALL_VARS_TAG);
+		_includeLogs	= FacadeUtil.booleanFromConfig(config,Constants.INCLUDE_LOGS_TAG);
+		_variables		= FacadeUtil.variablesFromConfig(config, false);
+	} // ________________________________
+	
+	public void preFormat(Message message) 
+	{
+		Body body = message.getBody();
+		if (null!=_includeLogs)
+			body.add(Constants.INCLUDE_LOGS		,_includeLogs);
+		
+		String key = Constants.INCLUDE_ALL_VARS_TAG;
+		// Currently, the jbpm GetProcessInstanceCommand does not accept a list of variables
+		// so, if configuration has a list of variables, we must bring'em all
+		if (null!=_variables)
+			body.add(key, true);
+		else if (null!=_includeAllVars)
+			body.add(key,_includeAllVars);
+	} // _______________________________
+    
+	public Message postFormat(Message response) 
+	{
+		if (null!=_variables)
+			FacadeUtil.jbpmVarsToMessage(response,_variables);
+		else if (null!=_includeAllVars && _includeAllVars)
+			FacadeUtil.jbpmVarsToMessage(response,null);
+		return response;
+	} // ________________________________
+	
+	Boolean 	_includeLogs;
+	Boolean 	_includeAllVars;
+	VariableMapping _variables;
+}


Property changes on: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetProcessInstanceFacade.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetTaskInstanceFacade.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetTaskInstanceFacade.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetTaskInstanceFacade.java	2007-04-22 17:50:22 UTC (rev 11206)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.services.jbpm.internal.facades;
+
+import java.util.Map;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
+import org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor;
+
+/**
+ *
+ * Implementation of a message preprocessor to obtain data from a token instance 
+ * from the action configuration XML
+ * 
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a> 
+ */
+public class GetTaskInstanceFacade implements SingleCommandProcessor.MessageFacade
+{
+	public OpCode getOpCode() { return Constants.OpCode.GetTaskInstanceCommand; }
+
+	public GetTaskInstanceFacade(ConfigTree config) throws ConfigurationException
+	{
+		_includeAllVars = FacadeUtil.booleanFromConfig(config,Constants.INCLUDE_ALL_VARS_TAG);
+		_includeLogs	= FacadeUtil.booleanFromConfig(config,Constants.INCLUDE_LOGS_TAG);
+		_variables		= FacadeUtil.variablesFromConfig(config, false);
+		_actors			= FacadeUtil.actorsFromConfig(config, false);
+	} // ________________________________
+	
+	public void preFormat(Message message) 
+	{
+		Body body = message.getBody();
+		if (null!=_includeLogs)
+			body.add(Constants.INCLUDE_LOGS		,_includeLogs);
+		if (null!=_includeAllVars)
+			body.add(Constants.INCLUDE_ALL_VARS_TAG ,_includeAllVars);
+		if (null!=_variables)
+		{
+			String[] sa = new String[_variables.size()];
+			int i1=0;
+			for(Map.Entry<String,Object> curr:_variables.esbVariables().entrySet())
+				sa[i1++] = _variables.getJbpmName(curr.getKey());
+			body.add(Constants.VARIABLE_NAMES_ARRAY, sa);
+		}
+	} // _______________________________
+    
+	public Message postFormat(Message response) 
+	{
+		if (null!=_variables)
+			FacadeUtil.jbpmVarsToMessage(response,_variables);
+		else if (null!=_includeAllVars && _includeAllVars)
+			FacadeUtil.jbpmVarsToMessage(response,null);
+		return response;
+	} // ________________________________
+
+	Boolean 	_includeLogs;
+	Boolean 	_includeAllVars;
+	VariableMapping _variables;
+	String[]	_actors;
+}


Property changes on: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetTaskInstanceFacade.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetTaskListFacade.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetTaskListFacade.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetTaskListFacade.java	2007-04-22 17:50:22 UTC (rev 11206)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.services.jbpm.internal.facades;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
+import org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+
+/**
+ *
+ * Implementation of a message preprocessor to obtain data from a token instance 
+ * from the action configuration XML
+ * 
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a> 
+ */
+public class GetTaskListFacade implements SingleCommandProcessor.MessageFacade
+{
+	public OpCode getOpCode() { return Constants.OpCode.GetTaskListCommand; }
+
+	public GetTaskListFacade(ConfigTree config) throws ConfigurationException
+	{
+		_includeAllVars = FacadeUtil.booleanFromConfig(config,Constants.INCLUDE_ALL_VARS_TAG);
+		_includeLogs	= FacadeUtil.booleanFromConfig(config,Constants.INCLUDE_LOGS_TAG);
+		_variables		= FacadeUtil.variablesFromConfig(config, false);
+		_actors			= FacadeUtil.actorsFromConfig(config, false);
+	} // ________________________________
+	
+	public void preFormat(Message message) 
+	{
+		Body body = message.getBody();
+		if (null!=_includeLogs)
+			body.add(Constants.INCLUDE_LOGS		,_includeLogs);
+		if (null!=_includeAllVars)
+			body.add(Constants.INCLUDE_ALL_VARS_TAG ,_includeAllVars);
+		if (null!=_variables)
+		{
+			String[] sa = new String[_variables.size()];
+			int i1=0;
+			for(Map.Entry<String,Object> curr:_variables.esbVariables().entrySet())
+				sa[i1++] = _variables.getJbpmName(curr.getKey());
+			body.add(Constants.VARIABLE_NAMES_ARRAY, sa);
+		}
+	} // _______________________________
+    
+	public Message postFormat(Message response) 
+	{
+		Body body = response.getBody();
+		Object obj = body.get(Constants.JBPM_RETURN_OBJECT);
+		if (obj instanceof List)
+		{
+			List<Long>taskIdList = new ArrayList<Long>();	
+			for (Object curr: (List)obj)
+				if (curr instanceof TaskInstance)
+					taskIdList.add(((TaskInstance)curr).getId());
+			if (taskIdList.size() > 0)
+				body.add(Constants.TASK_ID_LIST, taskIdList);
+		}
+		return response;
+	} // ________________________________
+
+	Boolean 	_includeLogs;
+	Boolean 	_includeAllVars;
+	VariableMapping _variables;
+	String[]	_actors;
+}


Property changes on: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/GetTaskListFacade.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/NewProcessInstanceFacade.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/NewProcessInstanceFacade.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/NewProcessInstanceFacade.java	2007-04-22 17:50:22 UTC (rev 11206)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.services.jbpm.internal.facades;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
+import org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor;
+
+/**
+ *
+ * Implementation of a message preprocessor to obtain data from a process instance 
+ * from the action configuration XML
+ * 
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a> 
+ */
+public class NewProcessInstanceFacade implements SingleCommandProcessor.MessageFacade
+{
+	public OpCode getOpCode() 
+	{ 
+		return (_start) 
+				?Constants.OpCode.StartProcessInstanceCommand
+				:Constants.OpCode.NewProcessInstanceCommand; 
+	}
+
+	public NewProcessInstanceFacade(ConfigTree config, boolean start) throws ConfigurationException
+	{
+		_start		= start;
+		_actor		= config.getAttribute(Constants.ONE_ACTOR_TAG);
+		_processName= config.getAttribute(Constants.PROCESS_DEFINITION_NAME_TAG);
+		String aux	= config.getAttribute(Constants.PROCESS_DEFINITION_ID_TAG);
+		if (null!=aux)
+			try {_processId = Long.parseLong(aux); }
+			catch(NumberFormatException e)
+			{
+				throw new ConfigurationException("Invalid value for '"+Constants.PROCESS_DEFINITION_ID_TAG+"'");
+			}
+		_variables	= FacadeUtil.variablesFromConfig(config, false);
+		
+		if (_start)
+			_transitionName	= config.getAttribute(Constants.TRANSITION_NAME_TAG);
+	} // ________________________________
+	
+	public void preFormat(Message message) 
+	{
+		Body body = message.getBody();
+		if (null!=_actor)
+			body.add(Constants.ACTOR_ID	,_actor);
+		if (null!=_processName)
+			body.add(Constants.PROCESS_DEFINITION_NAME	,_processName);
+		if (null!=_processId)
+			body.add(Constants.PROCESS_DEFINITION_ID	,_processId);
+		if (null!=_variables && _variables.size()>0)
+			body.add(Constants.VARIABLE_VALUES, _variables.jbpmVariables());
+		if (null!=_transitionName)
+			body.add(Constants.TRANSITION_NAME, _transitionName);
+	} // _______________________________
+    
+	public Message postFormat(Message response) 
+	{
+		return response;
+	} // ________________________________
+
+	boolean			_start;
+	String			_actor;
+	String			_processName;
+	String			_transitionName;
+	Long			_processId;
+	VariableMapping _variables;
+}


Property changes on: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/NewProcessInstanceFacade.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/VariableMapping.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/VariableMapping.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/VariableMapping.java	2007-04-22 17:50:22 UTC (rev 11206)
@@ -0,0 +1,63 @@
+package org.jboss.soa.esb.services.jbpm.internal.facades;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.soa.esb.util.Util;
+
+/**
+ * A container for variable names and values with access both by esb name and jbpm name.
+ * 
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a> 
+ *
+ */
+public class VariableMapping
+{
+	// internal key is always esb name
+	private Map<String,Object> _values 		= new HashMap<String, Object>();
+	// map jbpm names to esb names
+	private Map<String,String> _jbpmNames 	= new HashMap<String, String>();
+	// map esb names to jbpm names
+	private Map<String,String> _esbNames 	= new HashMap<String, String>();
+
+	public int size()	{ return _values.size(); }
+	
+	public String setMapping(String esbName, String jbpmName)
+	{
+		if (Util.isNullString(esbName) && Util.isNullString(jbpmName))
+			throw new IllegalArgumentException("You must specify at least one valid variable name (esb or jBPM)");
+		if (Util.isNullString(jbpmName))
+			jbpmName = esbName;
+		if (Util.isNullString(esbName))
+			esbName = jbpmName;
+		String oldMapping = _esbNames.get(jbpmName);
+		if (null!=oldMapping && !oldMapping.equals(jbpmName))
+			throw new IllegalArgumentException
+			("Illegal mapping esb=<"+esbName+"> was mapped to jbpm=<"+oldMapping+ "> cannot remap to "+jbpmName);
+			
+		_esbNames	.put(esbName, jbpmName);
+		_jbpmNames	.put(jbpmName, esbName);
+		// Internally, esbName is the key to the variable values
+		return esbName;
+	}
+
+	public void setVariable(String esbName, String jbpmName, Object value)
+	{
+		_values		.put(setMapping(esbName, jbpmName), value);
+	}
+	
+	public String getEsbName	 (String key) { return _jbpmNames.get(key); }
+	public String getJbpmName	 (String key) { return _esbNames.get(key); }
+
+	public Object getEsbVariable (String key) { return _values.get(key); }
+	public Object getJbpmVariable(String key) { return _values.get(_jbpmNames.get(key)); }
+	
+	public Map<String,Object> esbVariables()  { return _values; }
+	public Map<String,Object> jbpmVariables() 
+	{ 
+		HashMap<String,Object> map = new HashMap<String, Object>();
+		for (Map.Entry<String, Object> curr: _values.entrySet())
+			map.put(_jbpmNames.get(curr.getKey()), curr.getValue());
+		return map;
+	}
+}


Property changes on: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/VariableMapping.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/VariablesFacade.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/VariablesFacade.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/VariablesFacade.java	2007-04-22 17:50:22 UTC (rev 11206)
@@ -0,0 +1,5 @@
+package org.jboss.soa.esb.services.jbpm.internal.facades;
+
+public class VariablesFacade {
+
+}


Property changes on: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/internal/facades/VariablesFacade.java
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list