[jbpm-commits] JBoss JBPM SVN: r3379 - in jbpm4/trunk/modules: jpdl/src/main/java/org/jbpm/jpdl/xml and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sun Dec 14 04:31:05 EST 2008
Author: tom.baeyens at jboss.com
Date: 2008-12-14 04:31:04 -0500 (Sun, 14 Dec 2008)
New Revision: 3379
Added:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/EndBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ForkBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JoinBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JpdlActivityBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/StartBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/StateBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/UnresolvedTransition.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/UnresolvedTransitions.java
Removed:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/EndBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ExclusiveBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ForkBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JoinBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlActivityBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StateBinding.java
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java
jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.activities.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
Log:
added hql activity binding and impl
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/EndBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/EndBinding.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/EndBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -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.jpdl.activity;
+
+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;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndBinding extends JpdlActivityBinding {
+
+ public EndBinding() {
+ super("end");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+
+ boolean endProcessInstance = true;
+ String ends = XmlUtil.attribute(element, "ends", false, parse);
+ if ("execution".equalsIgnoreCase(ends)) {
+ endProcessInstance = false;
+ }
+
+ String state = XmlUtil.attribute(element, "state", false, parse);
+
+ return new EndActivity(endProcessInstance, state);
+ }
+}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveBinding.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -0,0 +1,113 @@
+/*
+ * 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.jpdl.activity;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.ExpressionCondition;
+import org.jbpm.pvm.internal.model.NodeImpl;
+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.ExpressionConditionDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveBinding extends JpdlActivityBinding {
+
+ static ObjectBinding objectBinding = new ObjectBinding();
+
+ public ExclusiveBinding() {
+ super("exclusive");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ if (element.hasAttribute("expr")) {
+ ExclusiveExpressionActivity exclusiveExpressionActivity = new ExclusiveExpressionActivity();
+ String expr = element.getAttribute("expr");
+ exclusiveExpressionActivity.setExpr(expr);
+ return exclusiveExpressionActivity;
+ }
+
+ if (element.hasAttribute("handler-ref")) {
+ String exclusiveHandlerName = element.getAttribute("handler-ref");
+ ExclusiveHandlerActivity exclusiveHandlerActivity = new ExclusiveHandlerActivity();
+ exclusiveHandlerActivity.setExclusiveHandlerName(exclusiveHandlerName);
+ return exclusiveHandlerActivity;
+ }
+
+ Element handlerElement = XmlUtil.element(element, "handler");
+ if (handlerElement!=null) {
+ ExclusiveHandlerActivity exclusiveHandlerActivity = new ExclusiveHandlerActivity();
+ ObjectDescriptor exclusiveHandlerDescriptor = (ObjectDescriptor)
+ objectBinding.parse(handlerElement, parse, parser);
+ exclusiveHandlerActivity.setExclusiveHandlerDescriptor(exclusiveHandlerDescriptor);
+ return exclusiveHandlerActivity;
+ }
+
+ boolean hasConditions = false;
+ List<Element> transitionElements = XmlUtil.elements(element, "flow");
+ NodeImpl node = parse.findObject(NodeImpl.class);
+ List<TransitionImpl> transitions = (List) node.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");
+ ExpressionConditionDescriptor expressionConditionDescriptor = new ExpressionConditionDescriptor(expr, lang);
+ transition.setConditionDescriptor(expressionConditionDescriptor);
+
+ } 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 ExclusiveConditionActivity();
+ } else {
+ parse.addProblem("exclusive '"+element.getAttribute("name")+"' must have one of: expr attribute, handler attribute, handler element or condition expressions");
+ }
+
+ return null;
+ }
+}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ForkBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ForkBinding.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ForkBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -0,0 +1,42 @@
+/*
+ * 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.jpdl.activity;
+
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ForkBinding extends JpdlActivityBinding {
+
+ public ForkBinding() {
+ super("fork");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ return new ForkActivity();
+ }
+
+}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlActivity.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlActivity.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -0,0 +1,98 @@
+/*
+ * 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.jpdl.activity;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.env.Environment;
+import org.jbpm.log.Log;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HqlActivity extends JpdlActivity {
+
+ private static final Log log = Log.getLog(HqlActivity.class.getName());
+
+ private static final long serialVersionUID = 1L;
+
+ protected String query;
+ protected ListDescriptor parametersDescriptor;
+ protected String resultVariableName;
+ protected boolean isResultUnique;
+
+ public void execute(ActivityExecution execution) {
+ Environment environment = Environment.getCurrent();
+ if (environment==null) {
+ throw new JbpmException("no environment for jpdl activity "+HqlBinding.TAG);
+ }
+ Session session = environment.get(Session.class);
+
+ Query q = session.createQuery(query);
+
+ if (parametersDescriptor!=null) {
+ for (Descriptor valueDescriptor: parametersDescriptor.getValueDescriptors()) {
+ String parameterName = valueDescriptor.getName();
+ Object value = WireContext.create(valueDescriptor);
+ apply(q, parameterName, value);
+ }
+ }
+
+ Object result = null;
+ if (isResultUnique) {
+ result = q.uniqueResult();
+ } else {
+ result = q.list();
+ }
+
+ execution.setVariable(resultVariableName, result);
+ }
+
+ public void apply(Query q, String parameterName, Object value) {
+ if (value instanceof String) {
+ q.setString(parameterName, (String) value);
+ } else if (value instanceof Long) {
+ q.setLong(parameterName, (Long) value);
+ } else {
+ log.error("unknown hql parameter type: "+value.getClass().getName());
+ }
+ }
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+ public void setParametersDescriptor(ListDescriptor parametersDescriptor) {
+ this.parametersDescriptor = parametersDescriptor;
+ }
+ public void setResultUnique(boolean isResultUnique) {
+ this.isResultUnique = isResultUnique;
+ }
+ public void setResultVariableName(String resultVariableName) {
+ this.resultVariableName = resultVariableName;
+ }
+}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlBinding.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -0,0 +1,79 @@
+/*
+ * 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.jpdl.activity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
+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 HqlBinding extends JpdlActivityBinding {
+
+ public static final String TAG = "hql";
+
+ public HqlBinding() {
+ super(TAG);
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ HqlActivity hqlActivity = new HqlActivity();
+
+ Element queryElement = XmlUtil.element(element, "query", true, parse);
+ if (queryElement==null) {
+ String query = XmlUtil.getContentText(queryElement);
+ hqlActivity.setQuery(query);
+ }
+
+ if (XmlUtil.attributeBoolean(element, "unique", false, parse, Boolean.TRUE)) {
+ hqlActivity.setResultUnique(true);
+ }
+
+ String variableName = XmlUtil.attribute(element, "var", true, parse);
+ hqlActivity.setResultVariableName(variableName);
+
+ List<Element> paramElements = XmlUtil.elements(element, "param");
+ if (!paramElements.isEmpty()) {
+ List<Descriptor> parametersDescriptor = new ArrayList<Descriptor>();
+ for (Element paramElement: paramElements) {
+ WireParser wireParser = WireParser.getInstance();
+ Descriptor paramDescriptor = (Descriptor) wireParser.parseElement(paramElement, parse, WireParser.CATEGORY_DESCRIPTOR);
+ parametersDescriptor.add(paramDescriptor);
+ }
+
+ ListDescriptor parametersListDescriptor = new ListDescriptor();
+ parametersListDescriptor.setValueDescriptors(parametersDescriptor);
+ hqlActivity.setParametersDescriptor(parametersListDescriptor);
+ }
+
+ return hqlActivity;
+ }
+}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JoinBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JoinBinding.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JoinBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -0,0 +1,42 @@
+/*
+ * 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.jpdl.activity;
+
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JoinBinding extends JpdlActivityBinding {
+
+ public JoinBinding() {
+ super("join");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ return new JoinActivity();
+ }
+
+}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JpdlActivityBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JpdlActivityBinding.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JpdlActivityBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -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.jpdl.activity;
+
+import java.util.List;
+
+import org.jbpm.jpdl.xml.UnresolvedTransitions;
+import org.jbpm.pvm.internal.model.NodeImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+import org.jbpm.pvm.internal.util.TagBinding;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class JpdlActivityBinding extends TagBinding {
+
+ public JpdlActivityBinding(String tagName) {
+ super(tagName, "http://jbpm.org/4/jpdl", "activity");
+ }
+
+ public void parseName(Element element, NodeImpl node, 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"));
+ } else if (name.indexOf('/')!=-1) {
+ parse.addProblem(XmlUtil.errorMessageAttribute(element, "name", name, "contains slash (/)"));
+ }
+ node.setName(name);
+ }
+ }
+
+ public boolean isNameRequired() {
+ return true;
+ }
+
+ public void parseFlows(Element element, NodeImpl node, Parse parse) {
+ List<Element> transitionElements = XmlUtil.elements(element, "flow");
+ UnresolvedTransitions unresolvedTransitions = parse.findObject(UnresolvedTransitions.class);
+ for (Element transitionElement: transitionElements) {
+ String transitionName = XmlUtil.attribute(transitionElement, "name", false, parse);
+ TransitionImpl transition = node.createOutgoingTransition(transitionName);
+ unresolvedTransitions.add(transition, transitionElement);
+ }
+ }
+
+}
+
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/StartBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/StartBinding.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/StartBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -0,0 +1,50 @@
+/*
+ * 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.jpdl.activity;
+
+import org.jbpm.jpdl.xml.StartNodes;
+import org.jbpm.pvm.internal.model.NodeImpl;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartBinding extends JpdlActivityBinding {
+
+ public StartBinding() {
+ super("start");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ NodeImpl startNode = parse.findObject(NodeImpl.class);
+ StartNodes startNodes = parse.findObject(StartNodes.class);
+ startNodes.add(startNode);
+ return new StartActivity();
+ }
+
+ public boolean isNameRequired() {
+ return false;
+ }
+}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/StateBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/StateBinding.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/StateBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -0,0 +1,44 @@
+/*
+ * 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.jpdl.activity;
+
+import org.jbpm.pvm.internal.model.NodeImpl;
+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;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StateBinding extends JpdlActivityBinding {
+
+ public StateBinding() {
+ super("state");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ return new StateActivity();
+ }
+
+}
Deleted: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/EndBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/EndBinding.java 2008-12-14 09:06:04 UTC (rev 3378)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/EndBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -1,52 +0,0 @@
-/*
- * 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.jpdl.xml;
-
-import org.jbpm.jpdl.activity.EndActivity;
-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;
-
-
-/**
- * @author Tom Baeyens
- */
-public class EndBinding extends JpdlActivityBinding {
-
- public EndBinding() {
- super("end");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
-
- boolean endProcessInstance = true;
- String ends = XmlUtil.attribute(element, "ends", false, parse);
- if ("execution".equalsIgnoreCase(ends)) {
- endProcessInstance = false;
- }
-
- String state = XmlUtil.attribute(element, "state", false, parse);
-
- return new EndActivity(endProcessInstance, state);
- }
-}
Deleted: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ExclusiveBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ExclusiveBinding.java 2008-12-14 09:06:04 UTC (rev 3378)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ExclusiveBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -1,116 +0,0 @@
-/*
- * 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.jpdl.xml;
-
-import java.util.List;
-
-import org.jbpm.jpdl.activity.ExclusiveConditionActivity;
-import org.jbpm.jpdl.activity.ExclusiveExpressionActivity;
-import org.jbpm.jpdl.activity.ExclusiveHandlerActivity;
-import org.jbpm.pvm.internal.model.ExpressionCondition;
-import org.jbpm.pvm.internal.model.NodeImpl;
-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.ExpressionConditionDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ExclusiveBinding extends JpdlActivityBinding {
-
- static ObjectBinding objectBinding = new ObjectBinding();
-
- public ExclusiveBinding() {
- super("exclusive");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- if (element.hasAttribute("expr")) {
- ExclusiveExpressionActivity exclusiveExpressionActivity = new ExclusiveExpressionActivity();
- String expr = element.getAttribute("expr");
- exclusiveExpressionActivity.setExpr(expr);
- return exclusiveExpressionActivity;
- }
-
- if (element.hasAttribute("handler-ref")) {
- String exclusiveHandlerName = element.getAttribute("handler-ref");
- ExclusiveHandlerActivity exclusiveHandlerActivity = new ExclusiveHandlerActivity();
- exclusiveHandlerActivity.setExclusiveHandlerName(exclusiveHandlerName);
- return exclusiveHandlerActivity;
- }
-
- Element handlerElement = XmlUtil.element(element, "handler");
- if (handlerElement!=null) {
- ExclusiveHandlerActivity exclusiveHandlerActivity = new ExclusiveHandlerActivity();
- ObjectDescriptor exclusiveHandlerDescriptor = (ObjectDescriptor)
- objectBinding.parse(handlerElement, parse, parser);
- exclusiveHandlerActivity.setExclusiveHandlerDescriptor(exclusiveHandlerDescriptor);
- return exclusiveHandlerActivity;
- }
-
- boolean hasConditions = false;
- List<Element> transitionElements = XmlUtil.elements(element, "flow");
- NodeImpl node = parse.findObject(NodeImpl.class);
- List<TransitionImpl> transitions = (List) node.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");
- ExpressionConditionDescriptor expressionConditionDescriptor = new ExpressionConditionDescriptor(expr, lang);
- transition.setConditionDescriptor(expressionConditionDescriptor);
-
- } 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 ExclusiveConditionActivity();
- } else {
- parse.addProblem("exclusive '"+element.getAttribute("name")+"' must have one of: expr attribute, handler attribute, handler element or condition expressions");
- }
-
- return null;
- }
-}
Deleted: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ForkBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ForkBinding.java 2008-12-14 09:06:04 UTC (rev 3378)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ForkBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -1,43 +0,0 @@
-/*
- * 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.jpdl.xml;
-
-import org.jbpm.jpdl.activity.ForkActivity;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ForkBinding extends JpdlActivityBinding {
-
- public ForkBinding() {
- super("fork");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- return new ForkActivity();
- }
-
-}
Deleted: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JoinBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JoinBinding.java 2008-12-14 09:06:04 UTC (rev 3378)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JoinBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -1,43 +0,0 @@
-/*
- * 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.jpdl.xml;
-
-import org.jbpm.jpdl.activity.JoinActivity;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class JoinBinding extends JpdlActivityBinding {
-
- public JoinBinding() {
- super("join");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- return new JoinActivity();
- }
-
-}
Deleted: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlActivityBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlActivityBinding.java 2008-12-14 09:06:04 UTC (rev 3378)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlActivityBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -1,73 +0,0 @@
-/*
- * 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.jpdl.xml;
-
-import java.util.List;
-
-import org.jbpm.jpdl.xml.JpdlParser.UnresolvedTransitions;
-import org.jbpm.pvm.internal.model.NodeImpl;
-import org.jbpm.pvm.internal.model.TransitionImpl;
-import org.jbpm.pvm.internal.util.TagBinding;
-import org.jbpm.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public abstract class JpdlActivityBinding extends TagBinding {
-
- public JpdlActivityBinding(String tagName) {
- super(tagName, "http://jbpm.org/4/jpdl", "activity");
- }
-
- public void parseName(Element element, NodeImpl node, 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"));
- } else if (name.indexOf('/')!=-1) {
- parse.addProblem(XmlUtil.errorMessageAttribute(element, "name", name, "contains slash (/)"));
- }
- node.setName(name);
- }
- }
-
- public boolean isNameRequired() {
- return true;
- }
-
- public void parseFlows(Element element, NodeImpl node, Parse parse) {
- List<Element> transitionElements = XmlUtil.elements(element, "flow");
- UnresolvedTransitions unresolvedTransitions = parse.findObject(UnresolvedTransitions.class);
- for (Element transitionElement: transitionElements) {
- String transitionName = XmlUtil.attribute(transitionElement, "name", false, parse);
- TransitionImpl transition = node.createOutgoingTransition(transitionName);
- unresolvedTransitions.add(transition, transitionElement);
- }
- }
-
-}
-
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java 2008-12-14 09:06:04 UTC (rev 3378)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -22,7 +22,6 @@
package org.jbpm.jpdl.xml;
import java.net.URL;
-import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
@@ -31,10 +30,10 @@
import org.jbpm.activity.Activity;
import org.jbpm.jpdl.JpdlProcessDefinition;
+import org.jbpm.jpdl.activity.JpdlActivityBinding;
import org.jbpm.log.Log;
import org.jbpm.pvm.internal.model.NodeImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.pvm.internal.model.TransitionImpl;
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.DomBuilder;
@@ -175,31 +174,4 @@
return processDefinition;
}
-
- static class UnresolvedTransitions {
- List<UnresolvedTransition> list = new ArrayList<UnresolvedTransition>();
- public void add(TransitionImpl transition, Element transitionElement) {
- list.add(new UnresolvedTransition(transition, transitionElement));
- }
- }
-
- static class UnresolvedTransition {
- TransitionImpl transition;
- Element transitionElement;
- public UnresolvedTransition(TransitionImpl transition, Element transitionElement) {
- this.transition = transition;
- this.transitionElement = transitionElement;
- }
- public void resolve(ProcessDefinitionImpl processDefinition, Parse parse) {
- String to = XmlUtil.attribute(transitionElement, "to", true, parse);
- if (to!=null) {
- NodeImpl destination = (NodeImpl) processDefinition.findNode(to);
- if (destination!=null) {
- destination.addIncomingTransition(transition);
- } else {
- parse.addProblem(XmlUtil.errorMessageAttribute(transitionElement, "to", to, "doesn't reference an existing node name"));
- }
- }
- }
- }
}
Deleted: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartBinding.java 2008-12-14 09:06:04 UTC (rev 3378)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -1,50 +0,0 @@
-/*
- * 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.jpdl.xml;
-
-import org.jbpm.jpdl.activity.StartActivity;
-import org.jbpm.pvm.internal.model.NodeImpl;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class StartBinding extends JpdlActivityBinding {
-
- public StartBinding() {
- super("start");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- NodeImpl startNode = parse.findObject(NodeImpl.class);
- StartNodes startNodes = parse.findObject(StartNodes.class);
- startNodes.add(startNode);
- return new StartActivity();
- }
-
- public boolean isNameRequired() {
- return false;
- }
-}
Deleted: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StateBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StateBinding.java 2008-12-14 09:06:04 UTC (rev 3378)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StateBinding.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -1,45 +0,0 @@
-/*
- * 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.jpdl.xml;
-
-import org.jbpm.jpdl.activity.StateActivity;
-import org.jbpm.pvm.internal.model.NodeImpl;
-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;
-
-
-/**
- * @author Tom Baeyens
- */
-public class StateBinding extends JpdlActivityBinding {
-
- public StateBinding() {
- super("state");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- return new StateActivity();
- }
-
-}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/UnresolvedTransition.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/UnresolvedTransition.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/UnresolvedTransition.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -0,0 +1,49 @@
+/*
+ * 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.jpdl.xml;
+
+import org.jbpm.pvm.internal.model.NodeImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+public class UnresolvedTransition {
+ TransitionImpl transition;
+ Element transitionElement;
+ public UnresolvedTransition(TransitionImpl transition, Element transitionElement) {
+ this.transition = transition;
+ this.transitionElement = transitionElement;
+ }
+ public void resolve(ProcessDefinitionImpl processDefinition, Parse parse) {
+ String to = XmlUtil.attribute(transitionElement, "to", true, parse);
+ if (to!=null) {
+ NodeImpl destination = (NodeImpl) processDefinition.findNode(to);
+ if (destination!=null) {
+ destination.addIncomingTransition(transition);
+ } else {
+ parse.addProblem(XmlUtil.errorMessageAttribute(transitionElement, "to", to, "doesn't reference an existing node name"));
+ }
+ }
+ }
+}
\ No newline at end of file
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/UnresolvedTransitions.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/UnresolvedTransitions.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/UnresolvedTransitions.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -0,0 +1,35 @@
+/*
+ * 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.jpdl.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.TransitionImpl;
+import org.w3c.dom.Element;
+
+public class UnresolvedTransitions {
+ List<UnresolvedTransition> list = new ArrayList<UnresolvedTransition>();
+ public void add(TransitionImpl transition, Element transitionElement) {
+ list.add(new UnresolvedTransition(transition, transitionElement));
+ }
+}
\ No newline at end of file
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.activities.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.activities.xml 2008-12-14 09:06:04 UTC (rev 3378)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.activities.xml 2008-12-14 09:31:04 UTC (rev 3379)
@@ -1,9 +1,9 @@
<activities>
<schema resource="jpdl.xsd" />
- <activity binding="org.jbpm.jpdl.xml.StartBinding" />
- <activity binding="org.jbpm.jpdl.xml.StateBinding" />
- <activity binding="org.jbpm.jpdl.xml.ExclusiveBinding" />
- <activity binding="org.jbpm.jpdl.xml.EndBinding" />
- <activity binding="org.jbpm.jpdl.xml.ForkBinding" />
- <activity binding="org.jbpm.jpdl.xml.JoinBinding" />
+ <activity binding="org.jbpm.jpdl.activity.StartBinding" />
+ <activity binding="org.jbpm.jpdl.activity.StateBinding" />
+ <activity binding="org.jbpm.jpdl.activity.ExclusiveBinding" />
+ <activity binding="org.jbpm.jpdl.activity.EndBinding" />
+ <activity binding="org.jbpm.jpdl.activity.ForkBinding" />
+ <activity binding="org.jbpm.jpdl.activity.JoinBinding" />
</activities>
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java 2008-12-14 09:06:04 UTC (rev 3378)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java 2008-12-14 09:31:04 UTC (rev 3379)
@@ -112,6 +112,10 @@
}
public static Element element(Element element, String tagName) {
+ return element(element, tagName, false, null);
+ }
+
+ public static Element element(Element element, String tagName, boolean required, Parse parse) {
if (element==null) {
return null;
}
@@ -122,9 +126,14 @@
return (Element) child;
}
}
+
+ if (required && (parse!=null)) {
+ parse.addProblem("nested element <"+XmlUtil.getTagLocalName(element)+"><"+tagName+" ... />... is required");
+ }
return null;
}
+
public static List<Element> elements(Element element) {
if (element==null) {
return Collections.EMPTY_LIST;
More information about the jbpm-commits
mailing list