[jbpm-commits] JBoss JBPM SVN: r5345 - in jbpm4/trunk/modules/bpmn/src/main/java: org/jbpm/bpmn and 3 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Jul 27 03:30:29 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-07-27 03:30:28 -0400 (Mon, 27 Jul 2009)
New Revision: 5345

Added:
   jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnAutomaticActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnBinding.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnExternalActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/DecisionBinding.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/DecisionConditionActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveBinding.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivityBinding.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/model/
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/model/BpmnProcessDefinition.java
Removed:
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flowobjects/
Modified:
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
Log:
merging bernds bpmn work

Added: jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,8 @@
+<activities>
+  <activity binding="com.camunda.bpmn.activity.StartBinding" />
+  <activity binding="com.camunda.bpmn.activity.TaskBinding" />
+  <activity binding="com.camunda.bpmn.activity.ServiceActivityBinding" />
+  <activity binding="com.camunda.bpmn.activity.ReceiveBinding" />
+  <activity binding="com.camunda.bpmn.activity.EndBinding" />
+  <activity binding="com.camunda.bpmn.activity.DecisionBinding" />
+</activities>


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import org.jbpm.api.activity.ActivityBehaviour;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class BpmnActivity implements ActivityBehaviour {
+  
+  private static final long serialVersionUID = 1L;
+
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnAutomaticActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnAutomaticActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnAutomaticActivity.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,24 @@
+package org.jbpm.bpmn.flownodes;
+
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.listener.EventListenerExecution;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+public abstract class BpmnAutomaticActivity extends BpmnActivity implements EventListener {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) throws Exception {
+    ExecutionImpl executionImpl = (ExecutionImpl)execution;
+    perform(executionImpl);
+    executionImpl.historyAutomatic();
+  }
+    
+  public void notify(EventListenerExecution execution) throws Exception {
+    perform((ExecutionImpl)execution);
+  }    
+    
+  abstract void perform(ExecutionImpl execution) throws Exception;
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnAutomaticActivity.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnBinding.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import org.jbpm.pvm.internal.util.TagBinding;
+
+
+
+public abstract class BpmnBinding extends TagBinding {
+
+//	protected static final WireParser wireParser = BpmnParser.wireParser;
+
+	public BpmnBinding(String tagName) {
+	  super(tagName, "http://schema.omg.org/spec/BPMN/2.0", null);
+	}
+//
+//  public void parseName(Element element, ActivityImpl activity, Parse parse) {
+//    String name = XmlUtil.attribute(element, "name", isNameRequired(), parse);
+//    
+//    if (name!=null) {
+//      // basic name validation
+//      if ("".equals(name)) {
+//        parse.addProblem(XmlUtil.errorMessageAttribute(element, "name", name, "is empty"), element);
+//      } else if (name.indexOf('/')!=-1) {
+//        parse.addProblem(XmlUtil.errorMessageAttribute(element, "name", name, "contains slash (/)"), element);
+//      }
+//      activity.setName(name);
+//    }
+//  }
+//
+//  public boolean isNameRequired() {
+//    return true;
+//  }
+//
+//  public void parseTransitions(Element element, ActivityImpl activity, Parse parse, JpdlParser jpdlParser) {
+//    List<Element> transitionElements = XmlUtil.elements(element, "transition");
+//    UnresolvedTransitions unresolvedTransitions = parse.findObject(UnresolvedTransitions.class);
+//    for (Element transitionElement: transitionElements) {
+//      String transitionName = XmlUtil.attribute(transitionElement, "name", false, parse);
+//
+//      Element timerElement = XmlUtil.element(transitionElement, "timer");
+//      if (timerElement!=null) {
+//        if (transitionName!=null) {
+//          TimerDefinitionImpl timerDefinitionImpl = jpdlParser.parseTimerDefinition(timerElement, parse, activity);
+//          timerDefinitionImpl.setSignalName(transitionName);
+//        } else {
+//          parse.addProblem("a transition name is required when a timer is placed on a transition", element);
+//        }
+//      }
+//
+//      TransitionImpl transition = activity.createOutgoingTransition();
+//      transition.setName(transitionName);
+//
+//      unresolvedTransitions.add(transition, transitionElement);
+//      
+//      jpdlParser.parseOnEvent(transitionElement, parse, transition, Event.TAKE);
+//    }
+//  }
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnExternalActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnExternalActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnExternalActivity.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,9 @@
+package org.jbpm.bpmn.flownodes;
+
+import org.jbpm.api.activity.ExternalActivityBehaviour;
+
+public abstract class BpmnExternalActivity extends BpmnActivity implements ExternalActivityBehaviour {
+
+  private static final long serialVersionUID = 1L;
+
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnExternalActivity.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/DecisionBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/DecisionBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/DecisionBinding.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
+import org.jbpm.pvm.internal.wire.descriptor.ExpressionEvaluatorDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DecisionBinding extends BpmnBinding {
+
+  static ObjectBinding objectBinding = new ObjectBinding();
+  static WireParser wireParser = WireParser.getInstance();
+
+  public DecisionBinding() {
+    super("exclusiveGateway");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {  
+    
+    boolean hasConditions = false;
+    List<Element> transitionElements = XmlUtil.elements(element, "transition");
+    ActivityImpl activity = parse.findObject(ActivityImpl.class);
+    List<TransitionImpl> transitions = (List) activity.getOutgoingTransitions();
+    
+    for (int i=0; i<transitionElements.size(); i++) {
+      TransitionImpl transition = transitions.get(i);
+      Element transitionElement = transitionElements.get(i);
+
+      Element conditionElement = XmlUtil.element(transitionElement, "condition");
+      if (conditionElement!=null) {
+        hasConditions = true;
+        
+        if (conditionElement.hasAttribute("expr")) {
+          String expr = conditionElement.getAttribute("expr");
+          String lang = XmlUtil.attribute(conditionElement, "expr-lang");
+          ExpressionEvaluatorDescriptor expressionDescriptor = new ExpressionEvaluatorDescriptor(expr, lang);
+          transition.setConditionDescriptor(expressionDescriptor);
+          
+        } else if (conditionElement.hasAttribute("ref")) {
+          String expr = conditionElement.getAttribute("ref");
+          ReferenceDescriptor refDescriptor = new ReferenceDescriptor(expr);
+          transition.setConditionDescriptor(refDescriptor);
+          
+        } else if (ObjectBinding.isObjectDescriptor(conditionElement)) {
+          ObjectDescriptor conditionDescriptor = (ObjectDescriptor) objectBinding.parse(conditionElement, parse, parser);
+          transition.setConditionDescriptor(conditionDescriptor);
+        }
+      }
+    }
+    
+    if (hasConditions) {
+      return new DecisionConditionActivity();
+    } else {
+      parse.addProblem("decision '"+element.getAttribute("name")+"' must have one of: expr attribute, handler attribute, handler element or condition expressions", element);
+    }
+    
+    return null;
+  }
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/DecisionBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/DecisionConditionActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/DecisionConditionActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/DecisionConditionActivity.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import java.util.List;
+
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.pvm.internal.model.Activity;
+import org.jbpm.pvm.internal.model.Condition;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.Transition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DecisionConditionActivity extends BpmnActivity {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) {
+    execute((ExecutionImpl)execution);
+  }
+  public void execute(ExecutionImpl execution) {
+    Transition transition = findTransition(execution);
+    if (transition==null) {
+      throw new JbpmException("no outgoing transition condition evaluated to true for decision "+execution.getActivity());
+    }
+    if (transition.getName()!=null) {
+      execution.historyDecision(transition.getName());
+    }
+    execution.take(transition);
+  }
+
+  private Transition findTransition(ExecutionImpl execution) {
+    Activity activity = execution.getActivity();
+    List<Transition> outgoingTransitions = activity.getOutgoingTransitions();
+    for (Transition transition : outgoingTransitions) {
+      Condition condition = transition.getCondition();
+      if  ( (condition==null)
+            || (condition.evaluate(execution))
+          ) {
+        return transition;
+      }
+    }
+    return null;
+  }
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/DecisionConditionActivity.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndActivity.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import java.util.List;
+
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.api.model.OpenExecution;
+import org.jbpm.pvm.internal.model.Activity;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.Transition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndActivity extends BpmnActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected boolean endProcessInstance = true;
+  protected String state = null;
+
+  public void execute(ActivityExecution execution) {
+    execute((ExecutionImpl)execution);
+  }
+  
+  public void execute(ExecutionImpl execution) {
+    Activity activity = execution.getActivity();
+    List<Transition> outgoingTransitions = activity.getOutgoingTransitions();
+    ActivityImpl parentActivity = (ActivityImpl) activity.getParentActivity();
+
+    if ( (parentActivity!=null)
+         && ("group".equals(parentActivity.getType())) 
+       ) {
+      // if the end activity itself has an outgoing transition 
+      // (such end activities should be drawn on the border of the group)
+      if ( (outgoingTransitions!=null)
+              && (outgoingTransitions.size()==1)
+          ) {
+         Transition outgoingTransition = outgoingTransitions.get(0);
+         // taking the transition that goes over the group boundaries will 
+         // destroy the scope automatically (see atomic operation TakeTransition)
+         execution.take(outgoingTransition);
+
+      } else {
+        execution.setActivity(parentActivity);
+        execution.signal();
+      }
+        
+    } else {
+      OpenExecution executionToEnd = null;
+      if (endProcessInstance) {
+        executionToEnd = execution.getProcessInstance();
+      } else {
+        executionToEnd = execution;
+      }
+      
+      if (state==null) {
+        execution.end(executionToEnd);
+      } else {
+        execution.end(executionToEnd, state);
+      }
+    }
+  }
+  
+  public void setEndProcessInstance(boolean endProcessInstance) {
+    this.endProcessInstance = endProcessInstance;
+  }
+  public void setState(String state) {
+    this.state = state;
+  }
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndActivity.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndBinding extends BpmnBinding {
+
+  public EndBinding() {
+    super("endEvent");
+  }
+
+  protected EndBinding(String tag) {
+    super(tag);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    EndActivity endActivity = new EndActivity();
+    return endActivity;
+  }
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveActivity.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import java.util.Map;
+
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.pvm.internal.model.Activity;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.Transition;
+
+public class ReceiveActivity extends BpmnExternalActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  public void execute(ActivityExecution execution) {
+    execute((ExecutionImpl)execution);
+  }
+  public void execute(ExecutionImpl execution) {
+    execution.historyActivityStart();
+
+    execution.waitForSignal();
+  }
+
+  public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+    signal((ExecutionImpl) execution, signalName, parameters);
+  }
+  public void signal(ExecutionImpl execution, String signalName, Map<String, ?> parameters) {
+    Activity activity = execution.getActivity();
+    
+    if (parameters!=null) {
+      execution.setVariables(parameters);
+    }
+    
+    execution.fire(signalName, activity);
+    
+    Transition transition = null;
+    if ( (signalName==null)
+         && (activity.getOutgoingTransitions()!=null)
+         && (activity.getOutgoingTransitions().size()==1)
+       ) {
+      transition = activity.getOutgoingTransitions().get(0);
+    } else {
+      transition = activity.findOutgoingTransition(signalName);
+    }
+    
+    if (transition!=null) {
+      execution.historyActivityEnd(signalName);
+      execution.take(transition);
+    } else {
+      execution.waitForSignal();
+    }
+  }
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveActivity.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveBinding.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+public class ReceiveBinding extends BpmnBinding {
+
+  public ReceiveBinding() {
+    super("receiveTask");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new ReceiveActivity();
+  }
+
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivity.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,208 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.wire.WireException;
+
+public class ServiceActivity extends BpmnAutomaticActivity {
+
+  private static final long serialVersionUID = 1L;
+
+  public static class Data {
+    private String id;
+    private String xmlSchemaType;
+  }
+
+  public static class Assignment {
+    private String fromExpression;
+    private String toExpression;
+  }
+
+  // inputs
+  Data inputData = null; // more than one allowed in BPMN 2
+  List<Assignment> inputAssociation = new ArrayList<Assignment>();
+
+  // outputs
+  Data outputData = null; // more than one allowed in BPMN 2
+  List<Assignment> outputAssociation = new ArrayList<Assignment>();
+
+  // endpoint and binding
+  private String operation;
+  private String endpointAddress;
+  private String portName;
+  private String serviceName;
+
+  public void perform(ExecutionImpl execution) throws Exception {
+    try {
+      callWebservice();
+    } catch (Exception e) {
+      throw new WireException("couldn't invoke WS " + operation + ": " + e.getMessage(), e);
+    }
+  }
+
+  private void callWebservice() {
+    System.out.println("calling ws: " + getOperation());
+    // // Qnames for service as defined in wsdl.
+    // QName serviceName =
+    // new QName(getNamespace(), getServiceName());
+    //
+    // //QName for Port As defined in wsdl.
+    // QName portName =
+    // new QName(getNamespace(), getPort());
+    //
+    // //Endpoint Address
+    // String endpointAddress = getEndpointAdress();
+    //
+    // // Create a dynamic Service instance
+    // Service service = Service.create(serviceName);
+    //
+    // // Add a port to the Service
+    // service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING,
+    // endpointAddress);
+    //
+    // //Create a dispatch instance
+    // Dispatch<SOAPMessage> dispatch =
+    // service.createDispatch(portName, SOAPMessage.class,
+    // Service.Mode.MESSAGE);
+    //
+    // // Use Dispatch as BindingProvider
+    // BindingProvider bp = (BindingProvider) dispatch;
+    //
+    // // Optionally Configure RequestContext to send SOAPAction HTTP Header
+    // Map<String, Object> rc = bp.getRequestContext();
+    // rc.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
+    // rc.put(BindingProvider.SOAPACTION_URI_PROPERTY, "hello");
+    //
+    // // Obtain a preconfigured SAAJ MessageFactory
+    // MessageFactory factory =
+    // ((SOAPBinding) bp.getBinding()).getMessageFactory();
+    //
+    // // Create SOAPMessage Request
+    // SOAPMessage request = factory.createMessage();
+    //
+    // // Request Header
+    // SOAPHeader header = request.getSOAPHeader();
+    //
+    // // Request Body
+    // SOAPBody body = request.getSOAPBody();
+    //
+    // // Compose the soap:Body payload
+    // QName payloadName =
+    // new QName("http://www.example.com/schemas/HelloWorld", "hello",
+    // "ns1");
+    //
+    // SOAPBodyElement payload = body.addBodyElement(payloadName);
+    //
+    // SOAPElement message = payload.addChildElement("message");
+    //
+    // message.addTextNode("Hello World!");
+    //
+    // // Invoke the endpoint synchronously
+    // SOAPMessage reply = null;
+    //
+    // try {
+    // //Invoke Endpoint Operation and read response
+    // reply = dispatch.invoke(request);
+    // } catch (WebServiceException wse){
+    // wse.printStackTrace();
+    // }
+    //
+    // // process the reply
+    // body = reply.getSOAPBody();
+    //
+    // QName responseName =
+    // new QName("http://www.example.com/schemas/HelloWorld",
+    // "helloResponse");
+    //
+    // SOAPBodyElement bodyElement =
+    // body.getChildElements(responseName).next());
+    // String message = bodyElement.getValue();
+  }
+
+  public Data getInputData() {
+    return inputData;
+  }
+
+  public void setInputData(Data inputData) {
+    this.inputData = inputData;
+  }
+
+  public List<Assignment> getInputAssociation() {
+    return inputAssociation;
+  }
+
+  public void setInputAssociation(List<Assignment> inputAssociation) {
+    this.inputAssociation = inputAssociation;
+  }
+
+  public Data getOutputData() {
+    return outputData;
+  }
+
+  public void setOutputData(Data outputData) {
+    this.outputData = outputData;
+  }
+
+  public List<Assignment> getOutputAssociation() {
+    return outputAssociation;
+  }
+
+  public void setOutputAssociation(List<Assignment> outputAssociation) {
+    this.outputAssociation = outputAssociation;
+  }
+
+  public String getOperation() {
+    return operation;
+  }
+
+  public void setOperation(String operation) {
+    this.operation = operation;
+  }
+
+  public String getEndpointAddress() {
+    return endpointAddress;
+  }
+
+  public void setEndpointAddress(String endpointAddress) {
+    this.endpointAddress = endpointAddress;
+  }
+
+  public String getPortName() {
+    return portName;
+  }
+
+  public void setPortName(String portName) {
+    this.portName = portName;
+  }
+
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  public void setServiceName(String serviceName) {
+    this.serviceName = serviceName;
+  }
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivity.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivityBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivityBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivityBinding.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+public class ServiceActivityBinding extends BpmnBinding {
+
+  
+  public ServiceActivityBinding() {
+    super("serviceTask");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ServiceActivity wsActivity = new ServiceActivity();
+
+    String methodName = XmlUtil.attribute(element, "operationRef", true, parse, null);
+//    javaActivity.setMethodName(methodName);
+
+    String variableName = XmlUtil.attribute(element, "var");
+//    javaActivity.setVariableName(variableName);
+
+//    List<Element> argElements = XmlUtil.elements(element, "arg");
+//    if (!argElements.isEmpty()) {
+//      List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse);
+//      InvokeOperation invokeOperation = new InvokeOperation();
+//      invokeOperation.setArgDescriptors(argDescriptors);
+//      javaActivity.setInvokeOperation(invokeOperation);
+//    }
+//
+//    if (element.hasAttribute("class")) {
+//      ObjectDescriptor objectDescriptor = JpdlParser.parseObjectDescriptor(element, parse);
+//      javaActivity.setTargetDescriptor(objectDescriptor);
+//
+//    } else if (element.hasAttribute("expr")) {
+//      String expression = element.getAttribute("expr");
+//      javaActivity.setTargetExpression(expression);
+//      javaActivity.setTargetLanguage(XmlUtil.attribute(element, "lang"));
+//    
+//    } else {
+//      // parse.addProblem("no target specified in "+TAG+": must specify attribute 'class' or 'expr'", element);
+//    }
+     
+    return wsActivity;
+  }
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivityBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartActivity.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import org.jbpm.api.activity.ActivityExecution;
+
+
+public class StartActivity extends BpmnActivity {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) {
+  }
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartActivity.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import org.jbpm.bpmn.model.BpmnProcessDefinition;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+
+public class StartBinding extends BpmnBinding {
+
+  public StartBinding() {
+	  super("startEvent");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ActivityImpl startActivity = parse.findObject(ActivityImpl.class);
+    BpmnProcessDefinition processDefinition = parse.findObject(BpmnProcessDefinition.class);
+    
+    if (processDefinition.getInitial()==null) {
+      processDefinition.setInitial(startActivity);
+      
+    } else if (startActivity.getParentActivity()==null) {
+      parse.addProblem("multiple start events not yet supported", element);
+    }
+    
+    return new StartActivity();
+  }
+
+  public boolean isNameRequired() {
+    return false;
+  }
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.api.task.Task;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.events.TaskActivityStart;
+import org.jbpm.pvm.internal.model.Activity;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.Transition;
+import org.jbpm.pvm.internal.session.DbSession;
+import org.jbpm.pvm.internal.task.ParticipationImpl;
+import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
+import org.jbpm.pvm.internal.task.SwimlaneImpl;
+import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskActivity extends BpmnExternalActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  private static final Log log = Log.getLog(TaskActivity.class.getName());
+
+  protected TaskDefinitionImpl taskDefinition;
+  
+  public void execute(ActivityExecution execution) {
+    execute((ExecutionImpl)execution);
+  }
+
+  public void execute(ExecutionImpl execution) {
+    DbSession dbSession = Environment.getFromCurrent(DbSession.class);
+    TaskImpl task = (TaskImpl) dbSession.createTask();
+    task.setTaskDefinition(taskDefinition);
+    task.setExecution(execution);
+    task.setProcessInstance(execution.getProcessInstance());
+    task.setSignalling(true);
+    
+    // initialize the name
+    if (taskDefinition.getName()!=null) {
+      task.setName(taskDefinition.getName());
+    } else {
+      task.setName(execution.getActivityName());
+    }
+
+    task.setDescription(taskDefinition.getDescription());
+    task.setPriority(taskDefinition.getPriority());
+    task.setFormResourceName(taskDefinition.getFormResourceName());
+    
+    // save task so that TaskDbSession.findTaskByExecution works for assign event listeners
+    dbSession.save(task);
+
+    SwimlaneDefinitionImpl swimlaneDefinition = taskDefinition.getSwimlaneDefinition();
+    if (swimlaneDefinition!=null) {
+      SwimlaneImpl swimlane = execution.getInitializedSwimlane(swimlaneDefinition);
+      task.setSwimlane(swimlane);
+      
+      // copy the swimlane assignments to the task
+      task.setAssignee(swimlane.getAssignee());
+      for (ParticipationImpl participant: swimlane.getParticipations()) {
+        task.addParticipation(participant.getUserId(), participant.getGroupId(), participant.getType());
+      }
+    }
+
+    execution.initializeAssignments(taskDefinition, task);
+    
+    HistoryEvent.fire(new TaskActivityStart(task), execution);
+
+    execution.waitForSignal();
+  }
+  
+  public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
+    signal((ExecutionImpl)execution, signalName, parameters);
+  }
+
+  public void signal(ExecutionImpl execution, String signalName, Map<String, ?> parameters) throws Exception {
+    Activity activity = execution.getActivity();
+    
+    if (parameters!=null) {
+      execution.setVariables(parameters);
+    }
+    
+    execution.fire(signalName, activity);
+
+    DbSession taskDbSession = Environment
+        .getFromCurrent(DbSession.class);
+    TaskImpl task = (TaskImpl) taskDbSession.findTaskByExecution(execution);
+    task.setSignalling(false);
+    
+    Transition transition = null;
+    List<Transition> outgoingTransitions = activity.getOutgoingTransitions();
+    if ( (outgoingTransitions!=null)
+         && (!outgoingTransitions.isEmpty())
+       ) {
+      transition = activity.findOutgoingTransition(signalName);
+      if (transition==null) {
+        if (Task.STATE_COMPLETED.equals(signalName)) {
+          if (outgoingTransitions.size()==1) {
+            transition = outgoingTransitions.get(0);
+          } else {
+            transition = activity.getDefaultOutgoingTransition();
+          }
+        } else {
+          // if a user specified outcome was provided and it doesn't
+          // match with an outgoing transition name, then an exception is
+          // thrown since this is likely a programmatic error.
+          throw new JbpmException("No outcome named '" + signalName + "' was found."); 
+        }
+      }
+      if (transition!=null) {
+        execution.take(transition);
+      }
+    }
+  }
+
+  public TaskDefinitionImpl getTaskDefinition() {
+    return taskDefinition;
+  }
+  public void setTaskDefinition(TaskDefinitionImpl taskDefinition) {
+    this.taskDefinition = taskDefinition;
+  }
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.flownodes;
+
+import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.model.ScopeElementImpl;
+import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskBinding extends BpmnBinding {
+
+  private static final String TAG = "userTask";
+
+  public TaskBinding() {
+    super(TAG);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    TaskActivity taskActivity = new TaskActivity();
+
+    ScopeElementImpl scopeElement = parse.findObject(ScopeElementImpl.class);
+    TaskDefinitionImpl taskDefinition = JpdlParser.parseTaskDefinition(element, parse, scopeElement);
+    taskActivity.setTaskDefinition(taskDefinition);
+    
+    return taskActivity;
+  }
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/model/BpmnProcessDefinition.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/model/BpmnProcessDefinition.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/model/BpmnProcessDefinition.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.jbpm.bpmn.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
+import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
+import org.w3c.dom.Element;
+
+public class BpmnProcessDefinition extends ProcessDefinitionImpl {
+
+	private static final long serialVersionUID = 1L;
+
+	Map<String, TaskDefinitionImpl> taskDefinitions = new HashMap<String, TaskDefinitionImpl>();
+	List<VariableDefinitionImpl> processVariableDefinitions = new ArrayList<VariableDefinitionImpl>();
+	Map<String, Element> messages = new HashMap<String, Element>();
+	Map<String, String> itemDefinitions = new HashMap<String, String>();
+	Map<String, Element> interfaces = new HashMap<String, Element>();
+	Map<String, String> resources = new HashMap<String, String>();
+
+	protected ExecutionImpl newProcessInstance() {
+		return new ExecutionImpl();
+	}
+
+	public TaskDefinitionImpl createTaskDefinition(String name) {
+		TaskDefinitionImpl taskDefinition = new TaskDefinitionImpl();
+		taskDefinitions.put(name, taskDefinition);
+		return taskDefinition;
+	}
+
+	public Map<String, TaskDefinitionImpl> getTaskDefinitions() {
+		return taskDefinitions;
+	}
+
+	public String getType(String typeRef) {
+		return itemDefinitions.get(typeRef);
+	}
+
+	public void setVariableDefinition(List<VariableDefinitionImpl> variableDefinitions) {
+		this.processVariableDefinitions = variableDefinitions;
+	}
+
+	public String getResource(String ref) {
+	    return resources.get(ref);
+	}
+}


Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/model/BpmnProcessDefinition.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java	2009-07-24 06:17:41 UTC (rev 5344)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java	2009-07-27 07:30:28 UTC (rev 5345)
@@ -21,14 +21,28 @@
  */
 package org.jbpm.bpmn.parser;
 
+import java.net.URL;
 import java.util.ArrayList;
+import java.util.Enumeration;
 import java.util.List;
 
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.SAXParserFactory;
-
+import org.jbpm.api.activity.ActivityBehaviour;
+import org.jbpm.bpmn.model.BpmnProcessDefinition;
+import org.jbpm.internal.log.Log;
+import org.jbpm.jpdl.internal.activity.JpdlBinding;
+import org.jbpm.jpdl.internal.xml.BindingsParser;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.CompositeElementImpl;
 import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.ScopeElementImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
+import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.util.TagBinding;
 import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Bindings;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
 import org.w3c.dom.Element;
@@ -39,20 +53,42 @@
  */
 public class BpmnParser extends Parser {
 
+  private static final Log log = Log.getLog(BpmnParser.class.getName());
+  
+  public static final WireParser wireParser = WireParser.getInstance();
+
+  // array elements are mutable, even when final
+  // never make a static array public
+  static final String[] DEFAULT_ACTIVITIES_RESOURCES = { "jbpm.bpmn.activities.xml" };
+  static final String CATEGORY_ACTIVITY = "activity";
+
+  static BindingsParser bindingsParser = new BindingsParser();
+
+  public BpmnParser() {
+    initialize();
+    parseBindings();
+    List<String> schemaResources = new ArrayList<String>();
+    schemaResources.add("BPMN20.xsd");
+    // schemaResources.add("Semantic.xsd");
+    setSchemaResources(schemaResources);
+  }
+
+
   public Object parseDocumentElement(Element documentElement, Parse parse) {
     List<ProcessDefinitionImpl> processDefinitions = new ArrayList<ProcessDefinitionImpl>();
+
+    parseDefinition(documentElement, parse);
+    
     for (Element processElement: XmlUtil.elements(documentElement, "process")) {
       ProcessDefinitionImpl processDefinition = parseProcess(processElement, parse);
       processDefinitions.add(processDefinition);
     }
     
-    // TODO unify document object of JpdlParser with BpmnParser so that ProcessDeployer can be refactored accordingly
-    
     return processDefinitions;
   }
 
   public ProcessDefinitionImpl parseProcess(Element processElement, Parse parse) {
-    ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
+    BpmnProcessDefinition processDefinition = new BpmnProcessDefinition();
     
     parse.pushObject(processDefinition);
     try {
@@ -60,9 +96,25 @@
       // process attribues
       String name = XmlUtil.attribute(processElement, "name", true, parse);
       processDefinition.setName(name);
-      
-      // TODO finish rest of parsing
 
+      String key = XmlUtil.attribute(processElement, "id", false, parse);
+      if (key != null) {
+        processDefinition.setKey(key);
+      }
+
+      Element descriptionElement = XmlUtil.element(processElement, "documentation");
+      if (descriptionElement != null) {
+        String description = XmlUtil.getContentText(descriptionElement);
+        processDefinition.setDescription(description);
+      }
+
+      parseDataObjects(processElement, parse, processDefinition);
+
+      // activities
+      parseActivities(processElement, parse, processDefinition);
+
+      // bind activities to their destinations
+      parseTransitions(processElement, parse, processDefinition);
       
     } finally {
       parse.popObject();
@@ -70,4 +122,192 @@
     
     return processDefinition;
   }
+  
+  
+  ///////////////////////////////////////////////////////////////////////////////////////////
+  
+  
+  
+  protected void parseBindings() {
+    Bindings bindings = new Bindings();
+    setBindings(bindings);
+
+    for (String activityResource : DEFAULT_ACTIVITIES_RESOURCES) {
+      Enumeration<URL> resourceUrls = ReflectUtil.getResources(null, activityResource);
+      if (resourceUrls.hasMoreElements()) {
+        while (resourceUrls.hasMoreElements()) {
+          URL resourceUrl = resourceUrls.nextElement();
+          log.trace("loading bpmn activities from resource: " + resourceUrl);
+          List<JpdlBinding> activityBindings = (List<JpdlBinding>) bindingsParser
+              .createParse()
+              .setUrl(resourceUrl)
+              .execute()
+              .checkErrors("bpmn activities from " + resourceUrl.toString())
+              .getDocumentObject();
+
+          for (TagBinding binding : activityBindings) {
+            binding.setCategory(CATEGORY_ACTIVITY);
+            bindings.addBinding(binding);
+          }
+        }
+      } else {
+        log.trace("skipping unavailable jpdl activities resource: " + activityResource);
+      }
+    }
+  }
+
+  private void parseDataObjects(Element element, Parse parse, BpmnProcessDefinition processDefinition) {
+    List<VariableDefinitionImpl> variableDefinitions = new ArrayList<VariableDefinitionImpl>();
+
+    for (Element dataElement : XmlUtil.elements(element, "dataObject")) {
+      VariableDefinitionImpl variableDefinition = new VariableDefinitionImpl();
+
+      String name = XmlUtil.attribute(dataElement, "id", true, parse);
+      variableDefinition.setName(name);
+
+      String typeRef = XmlUtil.attribute(dataElement, "itemSubjectRef");
+      variableDefinition.setTypeName(processDefinition.getType(typeRef));
+
+      variableDefinitions.add(variableDefinition);
+    }
+
+    processDefinition.setVariableDefinition(variableDefinitions);
+  }
+
+  public void parseActivities(Element element, Parse parse, CompositeElementImpl compositeElement) {
+    List<Element> elements = XmlUtil.elements(element);
+    for (Element nestedElement : elements) {
+      String tagName = XmlUtil.getTagLocalName(nestedElement);
+      String name = XmlUtil.attribute(nestedElement, "name", false, parse);
+      String id = XmlUtil.attribute(nestedElement, "id", true, parse);
+
+      TagBinding activityBinding = (TagBinding) getBinding(nestedElement, CATEGORY_ACTIVITY);
+      if (activityBinding == null) {
+        log.debug("unrecognized activity: " + tagName);
+        continue;
+      }
+
+      ActivityImpl activity = compositeElement.createActivity();
+      parse.pushObject(activity);
+      try {
+        activity.setType(activityBinding.getTagName());
+        activity.setName(id);
+        activity.setDescription(name);
+
+        ActivityBehaviour activityBehaviour = (ActivityBehaviour) activityBinding.parse(nestedElement, parse, this);
+        activity.setBehaviour(activityBehaviour);
+      } finally {
+        parse.popObject();
+      }
+    }
+  }
+
+  public void parseTransitions(Element element, Parse parse, CompositeElementImpl compositeElement) {
+    List<Element> transitionElements = XmlUtil.elements(element, "sequenceFlow");
+    for (Element transitionElement : transitionElements) {
+      String transitionName = XmlUtil.attribute(transitionElement, "name", false, parse);
+      String transitionId = XmlUtil.attribute(transitionElement, "id", true, parse);
+      String sourceRef = XmlUtil.attribute(transitionElement, "sourceRef", true, parse);
+      String targetRef = XmlUtil.attribute(transitionElement, "targetRef", true, parse);
+
+      System.out.println(sourceRef + " -> " + targetRef);
+      TransitionImpl transition = compositeElement.findActivity(sourceRef).createOutgoingTransition();
+      compositeElement.findActivity(targetRef).addIncomingTransition(transition);
+
+      transition.setName(transitionName);
+      transition.setDescription(transitionId);
+    }
+  }
+
+  public void parseDefinition(Element documentElement, Parse parse) {
+    parseImports(documentElement, parse);
+    parseItemDefinitions(documentElement, parse);
+    parseMessages(documentElement, parse);
+    parseInterfaces(documentElement, parse);
+    parseResources(documentElement, parse);
+  }
+
+  // public static void parseAssignmentAttributes(Element element,
+  // AssignableDefinitionImpl assignableDefinition, Parse parse) {
+  // Element descriptionElement = XmlUtil.element(element, "description");
+  // if (descriptionElement!=null) {
+  // String description = XmlUtil.getContentText(descriptionElement);
+  // assignableDefinition.setDescription(description);
+  // }
+  //  
+  // Element assignmentHandlerElement = XmlUtil.element(element,
+  // "assignment-handler");
+  // if (assignmentHandlerElement!=null) {
+  // ObjectDescriptor objectDescriptor =
+  // parseObjectDescriptor(assignmentHandlerElement, parse);
+  // assignableDefinition.setAssignmentHandlerDescriptor(objectDescriptor);
+  // }
+  //  
+  // String assigneeExpression = XmlUtil.attribute(element, "assignee");
+  // assignableDefinition.setAssigneeExpression(assigneeExpression);
+  //    
+  // String assigneeExpressionLanguage = XmlUtil.attribute(element,
+  // "assignee-lang");
+  // assignableDefinition.setAssigneeExpressionLanguage(assigneeExpressionLanguage);
+  //    
+  // String candidateUsersExpression = XmlUtil.attribute(element,
+  // "candidate-users");
+  // assignableDefinition.setCandidateUsersExpression(candidateUsersExpression);
+  //    
+  // String candidateUsersExpressionLanguage = XmlUtil.attribute(element,
+  // "candidate-users-lang");
+  // assignableDefinition.setCandidateUsersExpressionLanguage(candidateUsersExpressionLanguage);
+  //    
+  // String candidateGroupsExpression = XmlUtil.attribute(element,
+  // "candidate-groups");
+  // assignableDefinition.setCandidateGroupsExpression(candidateGroupsExpression);
+  //    
+  // String candidateGroupsExpressionLanguage = XmlUtil.attribute(element,
+  // "candidate-groups-lang");
+  // assignableDefinition.setCandidateGroupsExpressionLanguage(candidateGroupsExpressionLanguage);
+  // }
+
+  public static TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, ScopeElementImpl scopeElement) {
+    TaskDefinitionImpl taskDefinition = new TaskDefinitionImpl();
+
+    String taskName = XmlUtil.attribute(element, "name");
+    taskDefinition.setName(taskName);
+
+    // String form = XmlUtil.attribute(element, "form");
+    // taskDefinition.setForm(form);
+
+    BpmnProcessDefinition processDefinition = parse.findObject(BpmnProcessDefinition.class);
+    if (processDefinition.getTaskDefinition(taskName) != null) {
+      parse.addProblem("duplicate task name " + taskName, element);
+    } else {
+      processDefinition.addTaskDefinitionImpl(taskDefinition);
+    }
+
+    Element potentialOwner = XmlUtil.element(element, "potentialOwner");
+    String potentialOwnerRef = XmlUtil.attribute(potentialOwner, "resourceRef");
+    // set to fixed expression, more evaluation needed for real BPMN 2.0
+    taskDefinition.setCandidateGroupsExpression(processDefinition.getResource(potentialOwnerRef));
+    return taskDefinition;
+  }
+
+  private void parseResources(Element documentElement, Parse parse) {
+
+  }
+
+  private void parseInterfaces(Element documentElement, Parse parse) {
+
+  }
+
+  private void parseMessages(Element documentElement, Parse parse) {
+
+  }
+
+  private void parseItemDefinitions(Element documentElement, Parse parse) {
+
+  }
+
+  private void parseImports(Element documentElement, Parse parse) {
+
+  }
+
 }



More information about the jbpm-commits mailing list