[jbpm-commits] JBoss JBPM SVN: r3404 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/hql and 5 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Dec 16 14:56:46 EST 2008
Author: tom.baeyens at jboss.com
Date: 2008-12-16 14:56:45 -0500 (Tue, 16 Dec 2008)
New Revision: 3404
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/sql/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/sql/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/sql/process.jpdl.xml
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/SqlActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/SqlBinding.java
Modified:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.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/resources/jbpm.jpdl.activities.xml
jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml
Log:
added sql node
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java 2008-12-16 17:50:21 UTC (rev 3403)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java 2008-12-16 19:56:45 UTC (rev 3404)
@@ -36,7 +36,7 @@
*/
public class HqlTest extends DbTestCase {
- public void testStateChoiceAccept() {
+ public void testHql() {
deployJpdlResource("org/jbpm/examples/hql/process.jpdl.xml");
Execution execution = executionService.startExecutionByKey("Hql");
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java 2008-12-16 19:56:45 UTC (rev 3404)
@@ -0,0 +1,59 @@
+/*
+ * 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.examples.sql;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SqlTest extends DbTestCase {
+
+ public void testSql() {
+ deployJpdlResource("org/jbpm/examples/sql/process.jpdl.xml");
+
+ Execution execution = executionService.startExecutionByKey("Sql");
+ String executionId = execution.getId();
+
+ Set<String> variableNames = executionService.getVariableNames(executionId);
+ Map<String, Object> variables = executionService.getVariables(executionId, variableNames);
+
+ Map<String, Object> expectedVariables = new HashMap<String, Object>();
+ List<String> nodeNames = new ArrayList<String>();
+ nodeNames.add("get process names");
+ nodeNames.add("count nodes");
+ expectedVariables.put("nodes with o", nodeNames);
+
+ expectedVariables.put("nodes", new Integer(4));
+
+ assertEquals(expectedVariables, variables);
+ }
+
+}
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/sql/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/sql/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/sql/process.jpdl.xml 2008-12-16 19:56:45 UTC (rev 3404)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Sql">
+
+ <start>
+ <flow to="get process names" />
+ </start>
+
+ <sql name="get process names"
+ var="nodes with o">
+ <query>
+ select NAME_
+ from JBPM_NODE
+ where NAME_ like :nodeName
+ </query>
+ <parameters>
+ <string name="nodeName" value="%o%" />
+ </parameters>
+ <flow to="count nodes" />
+ </sql>
+
+ <sql name="count nodes"
+ var="nodes"
+ unique="true">
+ <query>
+ select count(*)
+ from JBPM_NODE
+ </query>
+ <flow to="wait" />
+ </sql>
+
+ <state name="wait" />
+
+</process>
Modified: 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 2008-12-16 17:50:21 UTC (rev 3403)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlActivity.java 2008-12-16 19:56:45 UTC (rev 3404)
@@ -53,13 +53,13 @@
}
Session session = environment.get(Session.class);
- Query q = session.createQuery(query);
+ Query q = createQuery(session);
if (parametersDescriptor!=null) {
for (Descriptor valueDescriptor: parametersDescriptor.getValueDescriptors()) {
String parameterName = valueDescriptor.getName();
Object value = WireContext.create(valueDescriptor);
- apply(q, parameterName, value);
+ applyParameter(q, parameterName, value);
}
}
@@ -73,7 +73,11 @@
execution.setVariable(resultVariableName, result);
}
- public void apply(Query q, String parameterName, Object value) {
+ protected Query createQuery(Session session) {
+ return session.createQuery(query);
+ }
+
+ public void applyParameter(Query q, String parameterName, Object value) {
if (value instanceof String) {
q.setString(parameterName, (String) value);
} else if (value instanceof Long) {
Modified: 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 2008-12-16 17:50:21 UTC (rev 3403)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlBinding.java 2008-12-16 19:56:45 UTC (rev 3404)
@@ -43,9 +43,13 @@
public HqlBinding() {
super(TAG);
}
+
+ protected HqlBinding(String tagName) {
+ super(tagName);
+ }
public Object parse(Element element, Parse parse, Parser parser) {
- HqlActivity hqlActivity = new HqlActivity();
+ HqlActivity hqlActivity = createHqlActivity();
Element queryElement = XmlUtil.element(element, "query", true, parse);
if (queryElement!=null) {
@@ -77,4 +81,8 @@
return hqlActivity;
}
+
+ protected HqlActivity createHqlActivity() {
+ return new HqlActivity();
+ }
}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/SqlActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/SqlActivity.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/SqlActivity.java 2008-12-16 19:56:45 UTC (rev 3404)
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+/**
+ * @author Tom Baeyens
+ */
+public class SqlActivity extends HqlActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Query createQuery(Session session) {
+ return session.createSQLQuery(query);
+ }
+}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/SqlBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/SqlBinding.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/SqlBinding.java 2008-12-16 19:56:45 UTC (rev 3404)
@@ -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.jpdl.activity;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SqlBinding extends HqlBinding {
+
+ public static final String TAG = "sql";
+
+ public SqlBinding() {
+ super(TAG);
+ }
+
+ protected HqlActivity createHqlActivity() {
+ return new SqlActivity();
+ }
+}
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-16 17:50:21 UTC (rev 3403)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.activities.xml 2008-12-16 19:56:45 UTC (rev 3404)
@@ -7,4 +7,5 @@
<activity binding="org.jbpm.jpdl.activity.ForkBinding" />
<activity binding="org.jbpm.jpdl.activity.JoinBinding" />
<activity binding="org.jbpm.jpdl.activity.HqlBinding" />
+ <activity binding="org.jbpm.jpdl.activity.SqlBinding" />
</activities>
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml 2008-12-16 17:50:21 UTC (rev 3403)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml 2008-12-16 19:56:45 UTC (rev 3404)
@@ -48,6 +48,8 @@
class="org.jbpm.pvm.internal.wire.descriptor.ListDescriptor"
foreign-key="FK_ACT_PARAMDESCR"
index="IDX_ACT_PARAMDESCR" />
+
+ <subclass name="org.jbpm.jpdl.activity.SqlActivity" discriminator-value="sql" />
</subclass>
</class>
More information about the jbpm-commits
mailing list