JBoss JBPM SVN: r5782 - jbpm4/trunk/modules/devguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: koen.aers(a)jboss.com
Date: 2009-10-23 17:21:22 -0400 (Fri, 23 Oct 2009)
New Revision: 5782
Modified:
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml
Log:
added more migration handler documentation
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml 2009-10-23 21:20:45 UTC (rev 5781)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml 2009-10-23 21:21:22 UTC (rev 5782)
@@ -703,7 +703,9 @@
to the newly deployed definition. jBPM contains a tool that exactly supports these use cases.</para>
<para>Before delving into the details of the instance migration tool, we have to warn the reader. Though we did a
reasonable attempt at trying to understand the different use cases, there are certainly a number of situations that
- are not yet covered. We welcome any feedback around these use cases very eagerly.</para>
+ are not yet covered. For now we have concentrated on the limited case where the nodes that are involved in the
+ migration are states. The goal is to expand this support to other nodes (e.g. human tasks) in the future.
+ We welcome any feedback around these use cases very eagerly.</para>
<para>For all the examples that follow, we will start from the same original process definition:
<programlisting>
<process name="foobar">
@@ -729,7 +731,7 @@
<para>The first obvious use case that we wanted to cover is where a new version of a process is deployed for
which one of the following statements is true:
<itemizedlist>
- <listitem>the structure of the process is completely the same</listitem>
+ <listitem>the structure of the process is completely the same and all the nodes have the same name</listitem>
<listitem>only new nodes have been added but all the nodes from the previous definition still exist</listitem>
</itemizedlist>
This use case might be useful if for instance event handler names change between versions, if new processing
@@ -878,10 +880,101 @@
<section>
<title>Activity Mappings</title>
+ <para>In some cases users will want to map nodes from the previously deployed process definition to
+ nodes of the newly deployed process definition. This could be the case when in the newly deployed process
+ definition some nodes are deleted or have been replaced by nodes with a different name. To support
+ this use case it is possible to specify so-called activity-mapping elements. These elements have
+ two attributes: the activity name in the old process definition and the activity name in the new
+ process definition. Consider the following process definition:
+ <programlisting>
+<process name="foobar">
+ <start>
+ <transition to="a"/>
+ </start>
+ <state name="a">
+ <transition to="b">
+ </state>
+ <state name="b">
+ <transition to="c"/>
+ </state>
+ <state name="c">
+ <transition to="d"/>
+ </state>
+ <state name="d">
+ <transition to="end"/>
+ </state>
+ <end name="end"/>
+ <migrate-instances>
+ <activity-mapping old-name="b" new-name="a"/>
+ <activity-mapping old-name="c" new-name="d"/>
+ </migrate-instances>
+</process>
+ </programlisting>
+ Deploying this process will put all the instances of the previously deployed process that are waiting
+ in the state "b" into the state "a" of the newly deployed process. Likewise all
+ instances of the previously deployed process definition that are waiting in state "c" will be
+ placed in the state "d". The following piece of code illustrates this:
+ <programlisting>
+ ProcessDefinition pd1 = deployProcessDefinition("foobar", originalVersion);
+ ProcessInstance pi1 = startAndSignal(pd1, "a");
+ ProcessInstance pi2 = startAndSignal(pd1, "b");
+ ProcessInstance pi3 = startAndSignal(pd1, "c");
+ ProcessDefinition pd2 = deployProcessDefinition("foobar", versionWithCorrectMappings);
+ pi1 = executionService.findProcessInstanceById(pi1.getId());
+ pi2 = executionService.findProcessInstanceById(pi2.getId());
+ pi3 = executionService.findProcessInstanceById(pi3.getId());
+ assertEquals(pd2.getId(), pi1.getProcessDefinitionId());
+ assertEquals(pd2.getId(), pi2.getProcessDefinitionId());
+ assertEquals(pd2.getId(), pi3.getProcessDefinitionId());
+ assertEquals(pi1, pi1.findActiveExecutionIn("a"));
+ assertEquals(pi2, pi2.findActiveExecutionIn("a"));
+ assertEquals(pi3, pi3.findActiveExecutionIn("d"));
+ pi1 = executionService.signalExecutionById(pi1.getId());
+ pi2 = executionService.signalExecutionById(pi2.getId());
+ pi2 = executionService.signalExecutionById(pi2.getId());
+ pi3 = executionService.signalExecutionById(pi3.getId());
+ assertEquals(pi1, pi1.findActiveExecutionIn("b"));
+ assertEquals(pi2, pi2.findActiveExecutionIn("c"));
+ assertTrue(pi3.isEnded());
+ </programlisting>
+ </para>
</section>
<section>
<title>Migration Handlers</title>
+ <para>We already mentioned that there are a lot of use cases that we probably didn't think of or for
+ which there was not enough time to build support. Exactly for this reason we provide the concept of
+ a migration handler. This is a user defined piece of code that implements the interface
+ "org.jbpm.pvm.internal.migration.MigrationHandler":
+ <programlisting>
+public interface MigrationHandler {
+
+ void migrateInstance(
+ ProcessDefinition newProcessDefinition,
+ ProcessInstance processInstance,
+ MigrationDescriptor migrationDescriptor);
+
+}
+ </programlisting>
+ This migration handler can be specified in the process definition xml and will be executed for each
+ process instance that has to be migrated. Experienced users can use this to do all kinds of bookkeeping
+ they need to do when migrating (or ending) process instances. To perform this bookkeeping, it gets
+ of course a handle to the process instance that needs to be migrated, but also to the new process
+ definition and to a so called migration descriptor that contains among others the migration mapping.
+ Take e.g. the following example:
+ <programlisting>
+<process name="foobar">
+ ...
+ <migrate-instances>
+ <migration-handler class="org.jbpm.test.migration.TestHandler"/>
+ </migrate-instances>
+</process>
+ </programlisting>
+ In this case the specified migration handler will be executed for each process instance that needs to
+ be migrated AFTER the default migration has been done. If the attribute action is set to "end"
+ the migration handler will be called BEFORE the process instance is ended. If more than one migration
+ handler is specified, they will be executed one after another.
+ </para>
</section>
</section>
16 years, 6 months
JBoss JBPM SVN: r5781 - in jbpm4/trunk/modules: test-db/src/test/java/org/jbpm/test/migration and 1 other directory.
by do-not-reply@jboss.org
Author: koen.aers(a)jboss.com
Date: 2009-10-23 17:20:45 -0400 (Fri, 23 Oct 2009)
New Revision: 5781
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/MigrationHelper.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/migration/InstanceMigratorTest.java
Log:
migration handlers are called after default migration and before ending process instances
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/MigrationHelper.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/MigrationHelper.java 2009-10-23 19:27:31 UTC (rev 5780)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/MigrationHelper.java 2009-10-23 21:20:45 UTC (rev 5781)
@@ -25,11 +25,11 @@
}
MigrationDescriptor migrationDescriptor = new MigrationDescriptor();
String action = migrationElement.getAttribute("action");
- if ("abort".equals(action)) {
+ if ("end".equals(action)) {
migrationDescriptor.addMigrationHandlerClassName(AbortMigrationHandler.class.getName());
- } else if ("custom".equals(action)) {
- parseMigrationHandlers(migrationElement, migrationDescriptor);
- } else {
+ }
+ parseMigrationHandlers(migrationElement, migrationDescriptor);
+ if (!"end".equals(action)) {
migrationDescriptor.addMigrationHandlerClassName(DefaultMigrationHandler.class.getName());
parseActivityMappings(migrationElement, migrationDescriptor);
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/migration/InstanceMigratorTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/migration/InstanceMigratorTest.java 2009-10-23 19:27:31 UTC (rev 5780)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/migration/InstanceMigratorTest.java 2009-10-23 21:20:45 UTC (rev 5781)
@@ -44,12 +44,12 @@
" <transition to='end'/>" +
" </state>" +
" <end name='end'/>" +
- " <migrate-instances action='custom'>" +
+ " <migrate-instances>" +
" <migration-handler class='org.jbpm.test.migration.InstanceMigratorTest$TestHandler'/>" +
" </migrate-instances>" +
"</process>";
- private String versionWithSimpleAbortion =
+ private String versionWithAbortion =
"<process name='foobar'>" +
" <start>" +
" <transition to='a'/>" +
@@ -64,7 +64,9 @@
" <transition to='end'/>" +
" </state>" +
" <end name='end'/>" +
- " <migrate-instances action='abort'/>" +
+ " <migrate-instances action='end'>" +
+ " <migration-handler class='org.jbpm.test.migration.InstanceMigratorTest$TestHandler'/>" +
+ " </migrate-instances>" +
"</process>";
private String versionWithSimpleMigration =
@@ -262,6 +264,12 @@
ProcessDefinition pd2 = deployProcessDefinition("foobar", versionWithMigrationHandler);
assertTrue(PROCESS_INSTANCES_SET.contains(pi1.getId()));
assertTrue(PROCESS_INSTANCES_SET.contains(pi2.getId()));
+ pi1 = executionService.findProcessInstanceById(pi1.getId());
+ pi2 = executionService.findProcessInstanceById(pi2.getId());
+ assertEquals(pd2.getId(), pi1.getProcessDefinitionId());
+ assertEquals(pd2.getId(), pi2.getProcessDefinitionId());
+ assertEquals(pi1, pi1.findActiveExecutionIn("a"));
+ assertEquals(pi2, pi2.findActiveExecutionIn("b"));
repositoryService.deleteDeploymentCascade(pd1.getDeploymentId());
repositoryService.deleteDeploymentCascade(pd2.getDeploymentId());
}
@@ -270,7 +278,9 @@
ProcessDefinition pd1 = deployProcessDefinition("foobar", originalVersion);
ProcessInstance pi1 = startAndSignal(pd1, "a");
ProcessInstance pi2 = startAndSignal(pd1, "b");
- ProcessDefinition pd2 = deployProcessDefinition("foobar", versionWithSimpleAbortion);
+ ProcessDefinition pd2 = deployProcessDefinition("foobar", versionWithAbortion);
+ assertTrue(PROCESS_INSTANCES_SET.contains(pi1.getId()));
+ assertTrue(PROCESS_INSTANCES_SET.contains(pi2.getId()));
pi1 = executionService.findProcessInstanceById(pi1.getId());
pi2 = executionService.findProcessInstanceById(pi2.getId());
assertNull(pi1);
16 years, 6 months
JBoss JBPM SVN: r5780 - in jbpm4/trunk: modules/db/src and 11 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-23 15:27:31 -0400 (Fri, 23 Oct 2009)
New Revision: 5780
Added:
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbHelper.java
jbpm4/trunk/modules/db/src/test/
jbpm4/trunk/modules/db/src/test/resources/
jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml
jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml
jbpm4/trunk/modules/db/src/test/resources/logging.properties
jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/logging/debug/
jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/logging/debug/logging.properties
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/QueryTest.java
Removed:
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbOperation.java
Modified:
jbpm4/trunk/modules/db/.classpath
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Create.java
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DbidGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/idgenerator/DeploymentIdGenerationTest.java
jbpm4/trunk/qa/build.xml
Log:
JBPM-2509 database upgrade ci scripts
Modified: jbpm4/trunk/modules/db/.classpath
===================================================================
--- jbpm4/trunk/modules/db/.classpath 2009-10-23 15:45:19 UTC (rev 5779)
+++ jbpm4/trunk/modules/db/.classpath 2009-10-23 19:27:31 UTC (rev 5780)
@@ -1,7 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" output="target/classes" path="src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Modified: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Create.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Create.java 2009-10-23 15:45:19 UTC (rev 5779)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Create.java 2009-10-23 19:27:31 UTC (rev 5780)
@@ -22,32 +22,56 @@
package org.jbpm.db;
import org.hibernate.classic.Session;
+import org.jbpm.api.ProcessEngine;
import org.jbpm.api.cmd.Command;
import org.jbpm.api.cmd.Environment;
-import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.id.PropertyImpl;
/**
* @author Alejandro Guizar
*/
-public class Create extends DbOperation implements Command<Object> {
+public class Create {
private static final long serialVersionUID = 1L;
+ private static Log log = Log.getLog(Upgrade.class.getName());
+
+ static String database;
+
public static void main(String[] args) {
- Create createOperation = new Create();
- createOperation.parseArgs(args);
- executeInTransaction(createOperation);
- }
+ if ( (args==null)
+ || (args.length!=1)
+ ) {
+ DbHelper.printSyntax(Upgrade.class);
+ return;
+ }
+
+ database = args[0];
+
+ ProcessEngine processEngine = new ProcessEngineImpl()
+ .skipDbCheck()
+ .buildProcessEngine();
+
+ try {
+ processEngine.execute(new Command<Object>(){
+ private static final long serialVersionUID = 1L;
+ public Object execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ DbHelper.executeSqlResource("create/jbpm."+database+".create.sql", session);
+ PropertyImpl.createProperties(session);
+ return null;
+ }
+ });
- public Object execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
- executeSqlResource("create/jbpm."+database+".create.sql", session);
- PropertyImpl.createProperties(session);
- return null;
+ log.info("jBPM DB create completed successfully.");
+
+ } catch (Exception e) {
+ log.error("ERROR: jBPM DB create FAILED", e);
+
+ } finally {
+ processEngine.close();
+ }
}
-
- public String toString() {
- return "jBPM "+JpdlParser.CURRENT_VERSION_JBPM+" DB Create";
- }
}
Copied: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbHelper.java (from rev 5779, jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbOperation.java)
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbHelper.java (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbHelper.java 2009-10-23 19:27:31 UTC (rev 5780)
@@ -0,0 +1,90 @@
+/*
+ * 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.db;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.classic.Session;
+import org.jbpm.api.JbpmException;
+import org.jbpm.internal.log.Jdk14LogFactory;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.util.IoUtil;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class DbHelper {
+
+ private static Log log = Log.getLog(DbHelper.class.getName());
+
+ public static void initializeLogging() {
+ Jdk14LogFactory.initializeJdk14Logging();
+ }
+
+ public static void printSyntax(Class<?> clazz) {
+ log.info("Syntax: java -cp ... "+clazz.getName()+" database [delimiter]");
+ log.info("where database is one of {oracle, postgresql, mysql, hsqldb}");
+ log.info("and delimiter is the db sql delimiter. default delimiter is ;");
+ }
+
+ public static void executeSqlResource(String resource, Session session) {
+ InputStream stream = Upgrade.class.getClassLoader().getResourceAsStream(resource);
+ if (stream == null) {
+ throw new JbpmException("resource "+resource+" does not exist");
+ }
+
+ byte[] bytes = IoUtil.readBytes(stream);
+ String fileContents = new String(bytes);
+ List<String> commands = extractCommands(fileContents);
+
+ log.info("--- Executing DB Commands -------------------------");
+ for (String command: commands) {
+ log.info(command);
+ try {
+ int result = session.createSQLQuery(command).executeUpdate();
+ log.info("--- Result: "+result+" --------------------------");
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.info("-----------------------------------------------");
+ }
+ }
+ }
+
+ public static List<String> extractCommands(String fileContents) {
+ List<String> commands = new ArrayList<String>();
+ int i = 0;
+ while (i<fileContents.length()) {
+ int j = fileContents.indexOf(";", i);
+ if (j==-1) {
+ j = fileContents.length();
+ }
+ String command = fileContents.substring(i, j).trim();
+ if (command.length()>0) {
+ commands.add(command);
+ }
+ i = j+1;
+ }
+ return commands;
+ }
+}
Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbOperation.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbOperation.java 2009-10-23 15:45:19 UTC (rev 5779)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbOperation.java 2009-10-23 19:27:31 UTC (rev 5780)
@@ -1,134 +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.db;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hibernate.classic.Session;
-import org.jbpm.api.JbpmException;
-import org.jbpm.api.ProcessEngine;
-import org.jbpm.api.cmd.Command;
-import org.jbpm.internal.log.Jdk14LogFactory;
-import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
-import org.jbpm.pvm.internal.util.IoUtil;
-
-/**
- * @author Tom Baeyens
- */
-public abstract class DbOperation {
-
- static{
- Jdk14LogFactory.initializeJdk14Logging();
- }
-
- String database;
- String delimiter;
-
- public void parseArgs(String[] args) {
- if (args==null || args.length==0) {
- log("Syntax: java -cp ... "+getClass().getName()+" database [delimiter]");
- log("where database is one of {oracle, postgresql, mysql, hsqldb}");
- log("and delimiter is the db sql delimiter. default delimiter is ;");
- return;
- }
-
- database = args[0];
-
- delimiter = ";";
- if (args.length>1) {
- delimiter = args[1];
- }
- }
-
- public static void executeInTransaction(Command<Object> command) {
- log("Starting "+command);
-
- ProcessEngine processEngine = new ProcessEngineImpl()
- .skipDbCheck()
- .buildProcessEngine();
-
- try {
- processEngine.execute(command);
- log(command+" completed successfully.");
-
- } catch (Exception e) {
- log("ERROR: "+command+" FAILED:");
- e.printStackTrace();
-
- } finally {
- processEngine.close();
- }
- }
-
- public void executeSqlResource(String resource, Session session) {
- InputStream stream = Upgrade.class.getClassLoader().getResourceAsStream(resource);
- if (stream == null) {
- throw new JbpmException("resource "+resource+" does not exist");
- }
-
- byte[] bytes = IoUtil.readBytes(stream);
- String fileContents = new String(bytes);
- List<String> commands = extractCommands(fileContents);
-
- log("--- Executing DB Commands -------------------------");
- for (String command: commands) {
- log(command);
- try {
- int result = session.createSQLQuery(command).executeUpdate();
- log("--- Result: "+result+" --------------------------");
- } catch (Exception e) {
- e.printStackTrace();
- log("-----------------------------------------------");
- }
- }
- }
-
- public List<String> extractCommands(String fileContents) {
- List<String> commands = new ArrayList<String>();
- int i = 0;
- while (i<fileContents.length()) {
- int j = fileContents.indexOf(delimiter, i);
- if (j==-1) {
- j = fileContents.length();
- } else {
- j += delimiter.length();
- }
- String command = fileContents.substring(i, j).trim();
- if ( "oracle".equals(database)
- && command.endsWith(";")
- ) {
- command = command.substring(0, command.length()-1);
- }
- if (command.length()>0) {
- commands.add(command);
- }
- i = j;
- }
- return commands;
- }
-
- public static void log(String msg) {
- System.out.println(msg);
- }
-}
Modified: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java 2009-10-23 15:45:19 UTC (rev 5779)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java 2009-10-23 19:27:31 UTC (rev 5780)
@@ -27,9 +27,11 @@
import org.hibernate.classic.Session;
import org.hibernate.criterion.Restrictions;
import org.jbpm.api.JbpmException;
+import org.jbpm.api.ProcessEngine;
import org.jbpm.api.cmd.Command;
import org.jbpm.api.cmd.Environment;
-import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.id.PropertyImpl;
import org.jbpm.pvm.internal.repository.DeploymentImpl;
import org.jbpm.pvm.internal.repository.DeploymentProperty;
@@ -37,82 +39,103 @@
/**
* @author Alejandro Guizar
*/
-public class Upgrade extends DbOperation implements Command<Object> {
+public class Upgrade {
private static final long serialVersionUID = 1L;
+
+ private static Log log = Log.getLog(Upgrade.class.getName());
+
+ static String database;
public static void main(String[] args) {
- Upgrade upgradeOperation = new Upgrade();
- upgradeOperation.parseArgs(args);
- DbOperation.executeInTransaction(upgradeOperation);
- }
-
- public String toString() {
- return "DB Upgrade to jBPM " + JpdlParser.CURRENT_VERSION_JBPM;
- }
-
- public Object execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
- JbpmVersion jbpmVersion = getJbpmVersion(session);
-
- if (jbpmVersion == JbpmVersion.V_4_2) {
- throw new JbpmException("jBPM schema is already up to date");
+ if ( (args==null)
+ || (args.length!=1)
+ ) {
+ DbHelper.printSyntax(Upgrade.class);
+ return;
}
+
+ database = args[0];
+
+ ProcessEngine processEngine = new ProcessEngineImpl()
+ .skipDbCheck()
+ .buildProcessEngine();
+
+ try {
+ JbpmVersion jbpmVersion = (JbpmVersion) processEngine.execute(new Command<Object>(){
+ private static final long serialVersionUID = 1L;
+ public Object execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ if (!PropertyImpl.propertiesTableExists(session)) {
+ try {
+ session.createSQLQuery("select CLASSNAME_ from JBPM4_VARIABLE").list();
+ return JbpmVersion.V_4_1;
- if (jbpmVersion.isEarlier(JbpmVersion.V_4_1)) {
- upgrade40To41(session);
- }
+ } catch (HibernateException e) {
+ return JbpmVersion.V_4_0;
+ }
+ }
+
+ String dbVersion = PropertyImpl.getDbVersion(session);
+ if (dbVersion == null) {
+ throw new JbpmException("property table exists, but no db version property is present");
+ }
+
+ return JbpmVersion.getJbpmVersion(dbVersion);
+ }
+ });
- if (jbpmVersion.isEarlier(JbpmVersion.V_4_2)) {
- upgrade41To42(session);
- }
- return null;
- }
+ if (jbpmVersion == JbpmVersion.V_4_2) {
+ throw new JbpmException("jBPM schema is already up to date");
+ }
- private void upgrade40To41(Session session) {
- executeSqlResource("upgrade-4.0-to-4.1/jbpm." + database + ".upgrade.sql", session);
- }
+ if (jbpmVersion.isEarlier(JbpmVersion.V_4_1)) {
+ processEngine.execute(new Command<Object>(){
+ private static final long serialVersionUID = 1L;
+ public Object execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ DbHelper.executeSqlResource("upgrade-4.0-to-4.1/jbpm." + database + ".upgrade.sql", session);
+ return null;
+ }
+ });
+ }
- private void upgrade41To42(Session session) {
- executeSqlResource("upgrade-4.1-to-4.2/jbpm." + database + ".upgrade.sql", session);
- PropertyImpl.upgradeProperties(session);
- addLangId(session);
- }
+ if (jbpmVersion.isEarlier(JbpmVersion.V_4_2)) {
+ processEngine.execute(new Command<Object>(){
+ private static final long serialVersionUID = 1L;
+ public Object execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ DbHelper.executeSqlResource("upgrade-4.1-to-4.2/jbpm." + database + ".upgrade.sql", session);
+ PropertyImpl.upgradeProperties(session);
+ return null;
+ }
+ });
+ processEngine.execute(new Command<Object>(){
+ private static final long serialVersionUID = 1L;
+ public Object execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ // find deployments without a langid property
+ List<DeploymentProperty> deploymentProperties = session.createCriteria(DeploymentProperty.class)
+ .add(Restrictions.eq("key", DeploymentImpl.KEY_PROCESS_DEFINITION_ID))
+ .list();
- private void addLangId(Session session) {
- // find deployments without a langid property
- List<DeploymentProperty> deploymentProperties = session.createCriteria(DeploymentProperty.class)
- .add(Restrictions.eq("key", DeploymentImpl.KEY_PROCESS_DEFINITION_ID))
- .list();
+ for (DeploymentProperty deploymentProperty : deploymentProperties) {
+ String objectName = deploymentProperty.getObjectName();
+ DeploymentImpl deployment = deploymentProperty.getDeployment();
+ deployment.setProcessLanguageId(objectName, "jpdl-4.0");
+ }
+ return null;
+ }
+ });
+ }
- for (DeploymentProperty deploymentProperty : deploymentProperties) {
- String objectName = deploymentProperty.getObjectName();
- DeploymentImpl deployment = deploymentProperty.getDeployment();
- deployment.setProcessLanguageId(objectName, "jpdl-4.0");
- }
- }
+ log.info("jBPM DB upgrade completed successfully.");
- private static JbpmVersion getJbpmVersion(Session session) {
- if (!PropertyImpl.propertiesTableExists(session)) {
- return variableClassNameColumnExists(session) ? JbpmVersion.V_4_1 : JbpmVersion.V_4_0;
- }
+ } catch (Exception e) {
+ log.error("ERROR: jBPM DB upgrade FAILED", e);
- String dbVersion = PropertyImpl.getDbVersion(session);
- if (dbVersion == null) {
- throw new JbpmException("property table exists, but no db version property is present");
+ } finally {
+ processEngine.close();
}
-
- return JbpmVersion.getJbpmVersion(dbVersion);
}
-
- private static boolean variableClassNameColumnExists(Session session) {
- try {
- session.createSQLQuery("select CLASSNAME_ from JBPM4_VARIABLE").list();
- return true;
- }
- catch (HibernateException e) {
- return false;
- }
- }
-
}
Added: jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml 2009-10-23 19:27:31 UTC (rev 5780)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.default.cfg.xml" />
+
+ <import resource="jbpm.tx.hibernate.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+
+</jbpm-configuration>
Property changes on: jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml 2009-10-23 19:27:31 UTC (rev 5780)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+ <property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost:1701</property>
+ <property name="hibernate.connection.username">sa</property>
+ <property name="hibernate.connection.password"></property>
+ <property name="hibernate.format_sql">true</property>
+
+ <mapping resource="jbpm.repository.hbm.xml" />
+ <mapping resource="jbpm.execution.hbm.xml" />
+ <mapping resource="jbpm.history.hbm.xml" />
+ <mapping resource="jbpm.task.hbm.xml" />
+ <mapping resource="jbpm.identity.hbm.xml" />
+
+ </session-factory>
+</hibernate-configuration>
Property changes on: jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/db/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/db/src/test/resources/logging.properties (rev 0)
+++ jbpm4/trunk/modules/db/src/test/resources/logging.properties 2009-10-23 19:27:31 UTC (rev 5780)
@@ -0,0 +1,18 @@
+handlers= java.util.logging.ConsoleHandler
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
+
+org.jbpm.level=FINE
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=INFO
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+org.hibernate.cfg.HbmBinder.level=SEVERE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/db/src/test/resources/logging.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/logging/debug/logging.properties
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/logging/debug/logging.properties (rev 0)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/logging/debug/logging.properties 2009-10-23 19:27:31 UTC (rev 5780)
@@ -0,0 +1,18 @@
+handlers= java.util.logging.ConsoleHandler
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
+
+org.jbpm.level=FINEST
+org.jbpm.pvm.internal.tx.level=FINE
+org.jbpm.pvm.internal.wire.level=FINE
+org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=FINE
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+org.hibernate.cfg.HbmBinder.level=SEVERE
+org.hibernate.SQL.level=FINEST
+org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/logging/debug/logging.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DbidGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DbidGenerator.java 2009-10-23 15:45:19 UTC (rev 5779)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DbidGenerator.java 2009-10-23 19:27:31 UTC (rev 5780)
@@ -44,7 +44,4 @@
}
public abstract long getNextId();
-
- public abstract void reset();
-
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java 2009-10-23 15:45:19 UTC (rev 5779)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java 2009-10-23 19:27:31 UTC (rev 5780)
@@ -105,8 +105,8 @@
public static void upgradeProperties(Session session) {
setDbVersionToLibraryVersion(session);
long nextDbid = getMaxDbid(session)+1;
+ setNextDbid(session, nextDbid);
log.info("nextDbid is initialized to "+nextDbid);
- setNextDbid(session, nextDbid);
}
public static boolean propertiesTableExists(Session session) {
@@ -159,7 +159,7 @@
e.printStackTrace();
}
}
-
+
return maxDbid;
}
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml 2009-10-23 15:45:19 UTC (rev 5779)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml 2009-10-23 19:27:31 UTC (rev 5780)
@@ -20,7 +20,6 @@
<object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator">
<field name="commandService"><ref object="newTxRequiredCommandService" /></field>
- <invoke method="initialize" />
</object>
<object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java 2009-10-23 15:45:19 UTC (rev 5779)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java 2009-10-23 19:27:31 UTC (rev 5780)
@@ -44,6 +44,8 @@
DbidGenerator dbidGenerator = processEngine.get(DbidGenerator.class);
+ assertEquals(1, dbidGenerator.getNextId());
+
processEngine.execute(new Command<Void>() {
private static final long serialVersionUID = 1L;
public Void execute(Environment environment) throws Exception {
@@ -56,7 +58,7 @@
}
});
- for (int i=1; i<10020; i++) {
+ for (int i=2; i<10020; i++) {
assertEquals(i, dbidGenerator.getNextId());
if ((i%1000) == 0) {
log.debug("just got dbid "+i+"...");
Modified: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/idgenerator/DeploymentIdGenerationTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/idgenerator/DeploymentIdGenerationTest.java 2009-10-23 15:45:19 UTC (rev 5779)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/idgenerator/DeploymentIdGenerationTest.java 2009-10-23 19:27:31 UTC (rev 5780)
@@ -104,7 +104,8 @@
assertNotSame(oldProcessEngine, processEngine);
// Reset the in memory generator and redeploy the process
- DbidGenerator.getDefaultIdGenerator().reset();
+ MemoryDbidGenerator memoryDbidGenerator = (MemoryDbidGenerator) DbidGenerator.getDefaultIdGenerator();
+ memoryDbidGenerator.reset();
}
}
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/QueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/QueryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/QueryTest.java 2009-10-23 19:27:31 UTC (rev 5780)
@@ -0,0 +1,116 @@
+/*
+ * 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.test.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
+import org.jbpm.pvm.internal.history.model.HistoryVariableImpl;
+import org.jbpm.pvm.internal.identity.impl.GroupImpl;
+import org.jbpm.pvm.internal.identity.impl.MembershipImpl;
+import org.jbpm.pvm.internal.identity.impl.UserImpl;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.lob.Lob;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.repository.DeploymentImpl;
+import org.jbpm.pvm.internal.repository.DeploymentProperty;
+import org.jbpm.pvm.internal.task.ParticipationImpl;
+import org.jbpm.pvm.internal.task.SwimlaneImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.type.Variable;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class QueryTest extends JbpmTestCase {
+
+ private static Log log = Log.getLog(QueryTest.class.getName());
+
+ public void testQueries() {
+
+ deployJpdlXmlString(
+ "<process name='TaskCommentDetail'>" +
+ " <start>" +
+ " <transition to='t' />" +
+ " </start>" +
+ " <task name='t' assignee='johndoe'/>" +
+ "</process>"
+ );
+
+ executionService.startProcessInstanceByKey("TaskCommentDetail");
+ executionService.startProcessInstanceByKey("TaskCommentDetail");
+ executionService.startProcessInstanceByKey("TaskCommentDetail");
+ executionService.startProcessInstanceByKey("TaskCommentDetail");
+
+
+ processEngine.execute(new Command<Object>() {
+ private static final long serialVersionUID = 1L;
+ public Object execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+
+ List<String> persistedTypes = new ArrayList<String>();
+ persistedTypes.add(DeploymentImpl.class.getName());
+ persistedTypes.add(DeploymentProperty.class.getName());
+ persistedTypes.add(ExecutionImpl.class.getName());
+ persistedTypes.add(GroupImpl.class.getName());
+ persistedTypes.add(HistoryActivityInstanceImpl.class.getName());
+ persistedTypes.add(HistoryDetailImpl.class.getName());
+ persistedTypes.add(HistoryTaskImpl.class.getName());
+ persistedTypes.add(HistoryVariableImpl.class.getName());
+ persistedTypes.add(JobImpl.class.getName());
+ persistedTypes.add(Lob.class.getName());
+ persistedTypes.add(MembershipImpl.class.getName());
+ persistedTypes.add(ParticipationImpl.class.getName());
+ persistedTypes.add(SwimlaneImpl.class.getName());
+ persistedTypes.add(TaskImpl.class.getName());
+ persistedTypes.add(UserImpl.class.getName());
+ persistedTypes.add(Variable.class.getName());
+
+ for (String persistedType: persistedTypes) {
+ try {
+ Long typeMaxDbid = (Long) session.createQuery(
+ "select max(o.dbid) " +
+ "from "+persistedType+" as o"
+ ).uniqueResult();
+
+ log.info(persistedType+": "+typeMaxDbid);
+
+ } catch (Exception e) {
+ log.info("couldn't get max dbid for "+persistedType, e);
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+ });
+
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/QueryTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/qa/build.xml
===================================================================
--- jbpm4/trunk/qa/build.xml 2009-10-23 15:45:19 UTC (rev 5779)
+++ jbpm4/trunk/qa/build.xml 2009-10-23 19:27:31 UTC (rev 5780)
@@ -207,6 +207,7 @@
<ant antfile="${jbpm.home}/install/build.xml" target="upgrade.jbpm.schema" inheritall="false">
<property name="database" value="${database}" />
<property name="tx" value="standalone.testsuite" />
+ <!--property name="logging" value="debug" /-->
</ant>
</target>
16 years, 6 months
JBoss JBPM SVN: r5779 - in jbpm4/trunk: modules/distro and 9 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-23 11:45:19 -0400 (Fri, 23 Oct 2009)
New Revision: 5779
Added:
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbOperation.java
jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/
jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/hsqldb.properties
jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/mysql.properties
jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/oracle.properties
jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/postgresql.properties
Removed:
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/HibernateOperation.java
Modified:
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Create.java
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java
jbpm4/trunk/modules/distro/pom.xml
jbpm4/trunk/modules/distro/src/main/files/install/build.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentProperty.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
jbpm4/trunk/modules/test-upgrade/pom.xml
jbpm4/trunk/qa/build.xml
Log:
JBPM-2509 database upgrade ci scripts
Modified: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Create.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Create.java 2009-10-23 11:36:57 UTC (rev 5778)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Create.java 2009-10-23 15:45:19 UTC (rev 5779)
@@ -22,23 +22,29 @@
package org.jbpm.db;
import org.hibernate.classic.Session;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
import org.jbpm.jpdl.internal.xml.JpdlParser;
import org.jbpm.pvm.internal.id.PropertyImpl;
/**
* @author Alejandro Guizar
*/
-public class Create extends HibernateOperation {
+public class Create extends DbOperation implements Command<Object> {
+ private static final long serialVersionUID = 1L;
+
public static void main(String[] args) {
Create createOperation = new Create();
createOperation.parseArgs(args);
executeInTransaction(createOperation);
}
- public void execute(Session session) {
+ public Object execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
executeSqlResource("create/jbpm."+database+".create.sql", session);
PropertyImpl.createProperties(session);
+ return null;
}
public String toString() {
Copied: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbOperation.java (from rev 5778, jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/HibernateOperation.java)
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbOperation.java (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbOperation.java 2009-10-23 15:45:19 UTC (rev 5779)
@@ -0,0 +1,134 @@
+/*
+ * 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.db;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.classic.Session;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.internal.log.Jdk14LogFactory;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
+import org.jbpm.pvm.internal.util.IoUtil;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class DbOperation {
+
+ static{
+ Jdk14LogFactory.initializeJdk14Logging();
+ }
+
+ String database;
+ String delimiter;
+
+ public void parseArgs(String[] args) {
+ if (args==null || args.length==0) {
+ log("Syntax: java -cp ... "+getClass().getName()+" database [delimiter]");
+ log("where database is one of {oracle, postgresql, mysql, hsqldb}");
+ log("and delimiter is the db sql delimiter. default delimiter is ;");
+ return;
+ }
+
+ database = args[0];
+
+ delimiter = ";";
+ if (args.length>1) {
+ delimiter = args[1];
+ }
+ }
+
+ public static void executeInTransaction(Command<Object> command) {
+ log("Starting "+command);
+
+ ProcessEngine processEngine = new ProcessEngineImpl()
+ .skipDbCheck()
+ .buildProcessEngine();
+
+ try {
+ processEngine.execute(command);
+ log(command+" completed successfully.");
+
+ } catch (Exception e) {
+ log("ERROR: "+command+" FAILED:");
+ e.printStackTrace();
+
+ } finally {
+ processEngine.close();
+ }
+ }
+
+ public void executeSqlResource(String resource, Session session) {
+ InputStream stream = Upgrade.class.getClassLoader().getResourceAsStream(resource);
+ if (stream == null) {
+ throw new JbpmException("resource "+resource+" does not exist");
+ }
+
+ byte[] bytes = IoUtil.readBytes(stream);
+ String fileContents = new String(bytes);
+ List<String> commands = extractCommands(fileContents);
+
+ log("--- Executing DB Commands -------------------------");
+ for (String command: commands) {
+ log(command);
+ try {
+ int result = session.createSQLQuery(command).executeUpdate();
+ log("--- Result: "+result+" --------------------------");
+ } catch (Exception e) {
+ e.printStackTrace();
+ log("-----------------------------------------------");
+ }
+ }
+ }
+
+ public List<String> extractCommands(String fileContents) {
+ List<String> commands = new ArrayList<String>();
+ int i = 0;
+ while (i<fileContents.length()) {
+ int j = fileContents.indexOf(delimiter, i);
+ if (j==-1) {
+ j = fileContents.length();
+ } else {
+ j += delimiter.length();
+ }
+ String command = fileContents.substring(i, j).trim();
+ if ( "oracle".equals(database)
+ && command.endsWith(";")
+ ) {
+ command = command.substring(0, command.length()-1);
+ }
+ if (command.length()>0) {
+ commands.add(command);
+ }
+ i = j;
+ }
+ return commands;
+ }
+
+ public static void log(String msg) {
+ System.out.println(msg);
+ }
+}
Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbOperation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/HibernateOperation.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/HibernateOperation.java 2009-10-23 11:36:57 UTC (rev 5778)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/HibernateOperation.java 2009-10-23 15:45:19 UTC (rev 5779)
@@ -1,148 +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.db;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.classic.Session;
-import org.jbpm.api.JbpmException;
-import org.jbpm.internal.log.Jdk14LogFactory;
-import org.jbpm.pvm.internal.util.IoUtil;
-
-/**
- * @author Tom Baeyens
- */
-public abstract class HibernateOperation {
-
- static{
- Jdk14LogFactory.initializeJdk14Logging();
- }
-
- String database;
- String delimiter;
-
- public abstract void execute(Session session);
-
- public void parseArgs(String[] args) {
- if (args==null || args.length==0) {
- log("Syntax: java -cp ... "+getClass().getName()+" database [delimiter]");
- log("where database is one of {oracle, postgresql, mysql, hsqldb}");
- log("and delimiter is the db sql delimiter. default delimiter is ;");
- return;
- }
-
- database = args[0];
-
- delimiter = ";";
- if (args.length>1) {
- delimiter = args[1];
- }
- }
-
- public static void executeInTransaction(HibernateOperation hibernateOperation) {
- log("Starting "+hibernateOperation);
- log(" database : "+hibernateOperation.database);
- log(" delimiter: "+hibernateOperation.delimiter);
-
- SessionFactory sessionFactory = new Configuration()
- .configure("jbpm.hibernate.cfg.xml")
- .buildSessionFactory();
-
- Session session = sessionFactory.openSession();
- Transaction transaction = null;
- try {
- transaction = session.beginTransaction();
-
- hibernateOperation.execute(session);
-
- transaction.commit();
-
- log(hibernateOperation+" completed successfully.");
-
- } catch (Exception e) {
- if (transaction!=null){
- transaction.rollback();
- }
- log("ERROR: "+hibernateOperation+" FAILED:");
- e.printStackTrace();
-
- } finally {
- session.close();
- }
- }
-
- public void executeSqlResource(String resource, Session session) {
- InputStream stream = Upgrade.class.getClassLoader().getResourceAsStream(resource);
- if (stream == null) {
- throw new JbpmException("resource "+resource+" does not exist");
- }
-
- byte[] bytes = IoUtil.readBytes(stream);
- String fileContents = new String(bytes);
- List<String> commands = extractCommands(fileContents);
-
- log("--- Executing DB Commands -------------------------");
- for (String command: commands) {
- log(command);
- try {
- int result = session.createSQLQuery(command).executeUpdate();
- log("--- Result: "+result+" --------------------------");
- } catch (Exception e) {
- e.printStackTrace();
- log("-----------------------------------------------");
- }
- }
- }
-
- public List<String> extractCommands(String fileContents) {
- List<String> commands = new ArrayList<String>();
- int i = 0;
- while (i<fileContents.length()) {
- int j = fileContents.indexOf(delimiter, i);
- if (j==-1) {
- j = fileContents.length();
- } else {
- j += delimiter.length();
- }
- String command = fileContents.substring(i, j).trim();
- if ( "oracle".equals(database)
- && command.endsWith(";")
- ) {
- command = command.substring(0, command.length()-1);
- }
- if (command.length()>0) {
- commands.add(command);
- }
- i = j;
- }
- return commands;
- }
-
- public static void log(String msg) {
- System.out.println(msg);
- }
-}
Modified: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java 2009-10-23 11:36:57 UTC (rev 5778)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java 2009-10-23 15:45:19 UTC (rev 5779)
@@ -27,6 +27,8 @@
import org.hibernate.classic.Session;
import org.hibernate.criterion.Restrictions;
import org.jbpm.api.JbpmException;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
import org.jbpm.jpdl.internal.xml.JpdlParser;
import org.jbpm.pvm.internal.id.PropertyImpl;
import org.jbpm.pvm.internal.repository.DeploymentImpl;
@@ -35,19 +37,22 @@
/**
* @author Alejandro Guizar
*/
-public class Upgrade extends HibernateOperation {
+public class Upgrade extends DbOperation implements Command<Object> {
+ private static final long serialVersionUID = 1L;
+
public static void main(String[] args) {
Upgrade upgradeOperation = new Upgrade();
upgradeOperation.parseArgs(args);
- HibernateOperation.executeInTransaction(upgradeOperation);
+ DbOperation.executeInTransaction(upgradeOperation);
}
public String toString() {
return "DB Upgrade to jBPM " + JpdlParser.CURRENT_VERSION_JBPM;
}
- public void execute(Session session) {
+ public Object execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
JbpmVersion jbpmVersion = getJbpmVersion(session);
if (jbpmVersion == JbpmVersion.V_4_2) {
@@ -61,6 +66,7 @@
if (jbpmVersion.isEarlier(JbpmVersion.V_4_2)) {
upgrade41To42(session);
}
+ return null;
}
private void upgrade40To41(Session session) {
@@ -69,8 +75,8 @@
private void upgrade41To42(Session session) {
executeSqlResource("upgrade-4.1-to-4.2/jbpm." + database + ".upgrade.sql", session);
+ PropertyImpl.upgradeProperties(session);
addLangId(session);
- PropertyImpl.upgradeProperties(session);
}
private void addLangId(Session session) {
@@ -81,7 +87,8 @@
for (DeploymentProperty deploymentProperty : deploymentProperties) {
String objectName = deploymentProperty.getObjectName();
- deploymentProperty.getDeployment().setProcessLanguageId(objectName, "jpdl-4.0");
+ DeploymentImpl deployment = deploymentProperty.getDeployment();
+ deployment.setProcessLanguageId(objectName, "jpdl-4.0");
}
}
Modified: jbpm4/trunk/modules/distro/pom.xml
===================================================================
--- jbpm4/trunk/modules/distro/pom.xml 2009-10-23 11:36:57 UTC (rev 5778)
+++ jbpm4/trunk/modules/distro/pom.xml 2009-10-23 15:45:19 UTC (rev 5779)
@@ -159,11 +159,6 @@
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- <version>2.9.1</version>
- </dependency>
<!-- Database Drivers -->
<dependency>
Modified: jbpm4/trunk/modules/distro/src/main/files/install/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-10-23 11:36:57 UTC (rev 5778)
+++ jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-10-23 15:45:19 UTC (rev 5779)
@@ -585,7 +585,10 @@
depends="create.cfg"
description="creates the jbpm tables in the database">
<echo message="creating jbpm schema..." />
- <java classname="org.jbpm.db.Create">
+ <copy tofile="${cfg.dest.dir}/jbpm.cfg.xml"
+ file="${install.src.dir}/cfg/jbpm/standalone.testsuite.jbpm.cfg.xml"
+ overwrite="true" />
+ <java classname="org.jbpm.db.Create" fork="true">
<arg line="${database}" />
<classpath>
<pathelement location="${jbpm.home}/install/generated/cfg" />
@@ -605,7 +608,10 @@
depends="create.cfg"
description="Upgrades the jBPM tables in the database to the current version">
<echo message="upgrading jbpm schema..." />
- <java classname="org.jbpm.db.Upgrade">
+ <copy tofile="${cfg.dest.dir}/jbpm.cfg.xml"
+ file="${install.src.dir}/cfg/jbpm/standalone.testsuite.jbpm.cfg.xml"
+ overwrite="true" />
+ <java classname="org.jbpm.db.Upgrade" fork="true">
<arg line="${database}" />
<classpath>
<pathelement location="${jbpm.home}/install/generated/cfg" />
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java 2009-10-23 11:36:57 UTC (rev 5778)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java 2009-10-23 15:45:19 UTC (rev 5779)
@@ -105,6 +105,7 @@
public static void upgradeProperties(Session session) {
setDbVersionToLibraryVersion(session);
long nextDbid = getMaxDbid(session)+1;
+ log.info("nextDbid is initialized to "+nextDbid);
setNextDbid(session, nextDbid);
}
@@ -144,8 +145,8 @@
for (String persistedType: persistedTypes) {
try {
Long typeMaxDbid = (Long) session.createQuery(
- "select max(id) " +
- "from "+persistedType
+ "select max(o.dbid) " +
+ "from "+persistedType+" as o"
).uniqueResult();
if ( (typeMaxDbid!=null)
@@ -154,10 +155,11 @@
maxDbid = typeMaxDbid.longValue();
}
} catch (Exception e) {
- log.info("couldn't get max dbid for "+persistedType);
+ log.info("couldn't get max dbid for "+persistedType, e);
+ e.printStackTrace();
}
}
-
+
return maxDbid;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java 2009-10-23 11:36:57 UTC (rev 5778)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java 2009-10-23 15:45:19 UTC (rev 5779)
@@ -226,7 +226,6 @@
setObjectProperty(processDefinitionName, KEY_PROCESS_LANGUAGE_ID, processLanguageId);
}
-
public void setObjectProperty(String objectName, String key, Object value) {
if (objectProperties==null) {
objectProperties = new HashSet<DeploymentProperty>();
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentProperty.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentProperty.java 2009-10-23 11:36:57 UTC (rev 5778)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentProperty.java 2009-10-23 15:45:19 UTC (rev 5779)
@@ -23,7 +23,9 @@
import java.io.Serializable;
+import org.hibernate.Session;
import org.jbpm.api.JbpmException;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.id.DbidGenerator;
@@ -46,6 +48,7 @@
public DeploymentProperty(DeploymentImpl deployment, String objectName, String key) {
this.dbid = DbidGenerator.getDbidGenerator().getNextId();
+ EnvironmentImpl.getFromCurrent(Session.class).save(this);
this.deployment = deployment;
this.objectName = objectName;
this.key = key;
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml 2009-10-23 11:36:57 UTC (rev 5778)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml 2009-10-23 15:45:19 UTC (rev 5779)
@@ -18,7 +18,7 @@
<hibernate-session-factory />
- <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator" init="eager">
+ <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator">
<field name="commandService"><ref object="newTxRequiredCommandService" /></field>
<invoke method="initialize" />
</object>
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java 2009-10-23 11:36:57 UTC (rev 5778)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java 2009-10-23 15:45:19 UTC (rev 5779)
@@ -42,6 +42,8 @@
public void testDbidGenerator() {
ProcessEngine processEngine = new Configuration().buildProcessEngine();
+ DbidGenerator dbidGenerator = processEngine.get(DbidGenerator.class);
+
processEngine.execute(new Command<Void>() {
private static final long serialVersionUID = 1L;
public Void execute(Environment environment) throws Exception {
@@ -54,7 +56,6 @@
}
});
- DbidGenerator dbidGenerator = processEngine.get(DbidGenerator.class);
for (int i=1; i<10020; i++) {
assertEquals(i, dbidGenerator.getNextId());
if ((i%1000) == 0) {
Modified: jbpm4/trunk/modules/test-upgrade/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/pom.xml 2009-10-23 11:36:57 UTC (rev 5778)
+++ jbpm4/trunk/modules/test-upgrade/pom.xml 2009-10-23 15:45:19 UTC (rev 5779)
@@ -32,7 +32,6 @@
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
<artifactId>jbpm-jpdl</artifactId>
- <version>4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>hsqldb</groupId>
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/hsqldb.properties
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/hsqldb.properties (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/hsqldb.properties 2009-10-23 15:45:19 UTC (rev 5779)
@@ -0,0 +1 @@
+hibernate.dialect=org.hibernate.dialect.HSQLDialect
Property changes on: jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/hsqldb.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/mysql.properties
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/mysql.properties (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/mysql.properties 2009-10-23 15:45:19 UTC (rev 5779)
@@ -0,0 +1 @@
+hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
Property changes on: jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/mysql.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/oracle.properties
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/oracle.properties (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/oracle.properties 2009-10-23 15:45:19 UTC (rev 5779)
@@ -0,0 +1 @@
+hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
Property changes on: jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/oracle.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/postgresql.properties
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/postgresql.properties (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/postgresql.properties 2009-10-23 15:45:19 UTC (rev 5779)
@@ -0,0 +1 @@
+hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
Property changes on: jbpm4/trunk/modules/test-upgrade/src/main/resources/dialect/postgresql.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/qa/build.xml
===================================================================
--- jbpm4/trunk/qa/build.xml 2009-10-23 11:36:57 UTC (rev 5778)
+++ jbpm4/trunk/qa/build.xml 2009-10-23 15:45:19 UTC (rev 5779)
@@ -177,6 +177,11 @@
<replacefilter token="PVM1" value="PVM2" />
<replacefilter token="pvm1" value="pvm2" />
</replace>
+ <!-- install the jbpm-test-upgrade lib -->
+ <delete dir="upgrade/target/jbpm-test-upgrade" />
+ <mkdir dir="upgrade/target/jbpm-test-upgrade" />
+ <unzip dest="upgrade/target/jbpm-test-upgrade" src="upgrade/target/jbpm-test-upgrade.jar" />
+ <delete file="upgrade/target/jbpm-test-upgrade/hibernate.properties" />
<!-- create jbpm schema using the old jbpm distro -->
<condition property="is.old.jbpm.40">
<equals arg1="${old.jbpm.version}" arg2="4.0" />
@@ -184,11 +189,7 @@
<antcall target="create.jbpm.schema.in.jbpm.40" />
<antcall target="create.jbpm.schema.in.jbpm.41plus" />
<!-- start couple of processes using the old jbpm version -->
- <delete dir="upgrade/target/jbpm-test-upgrade" />
- <mkdir dir="upgrade/target/jbpm-test-upgrade" />
- <unzip dest="upgrade/target/jbpm-test-upgrade" src="upgrade/target/jbpm-test-upgrade.jar" />
- <copy file="upgrade/target/jdbc/${database}.properties" tofile="upgrade/target/jbpm-test-upgrade/hibernate.properties" overwrite="true" />
- <java classname="org.jbpm.upgrade.BeforeUpgrade">
+ <java classname="org.jbpm.upgrade.BeforeUpgrade" fork="true">
<classpath>
<pathelement location="upgrade/target/jbpm-test-upgrade" />
<fileset dir="${old.jbpm.home}">
@@ -203,7 +204,10 @@
<copy todir="${jbpm.home}/install/jdbc" overwrite="true">
<fileset dir="upgrade/target/jdbc" />
</copy>
- <ant antfile="${jbpm.home}/install/build.xml" target="upgrade.jbpm.schema" inheritall="false" />
+ <ant antfile="${jbpm.home}/install/build.xml" target="upgrade.jbpm.schema" inheritall="false">
+ <property name="database" value="${database}" />
+ <property name="tx" value="standalone.testsuite" />
+ </ant>
</target>
<condition property="is.hsqldb">
@@ -240,16 +244,27 @@
</target>
<target name="create.jbpm.schema.in.jbpm.40" if="is.old.jbpm.40">
+ <echo message="creating schema in jbpm 4.0" />
<!-- copy the PVM2 jdbc properties files in the old jbpm distro -->
<copy todir="${old.jbpm.home}/db/jdbc">
<fileset dir="upgrade/target/jdbc" />
</copy>
+ <replace file="upgrade/target/jbpm-test-upgrade/jbpm.cfg.xml">
+ <replacetoken><![CDATA[<import resource="jbpm.businesscalendar.cfg.xml" />]]></replacetoken>
+ <replacevalue></replacevalue>
+ </replace>
<ant antfile="${old.jbpm.home}/db/build.xml" target="create.jbpm.schema" inheritall="false">
<property name="database" value="${database}" />
</ant>
+ <copy file="${old.jbpm.home}/db/hibernate.cfg/${database}.hibernate.cfg.xml"
+ tofile="upgrade/target/jbpm-test-upgrade/jbpm.hibernate.cfg.xml"
+ overwrite="true">
+ <filterset filtersfile="upgrade/target/jdbc/${database}.properties" />
+ </copy>
</target>
<target name="create.jbpm.schema.in.jbpm.41plus" unless="is.old.jbpm.40">
+ <echo message="creating schema in jbpm 4.1+" />
<!-- copy the PVM2 jdbc properties files in the old jbpm distro -->
<copy todir="${old.jbpm.home}/install/jdbc">
<fileset dir="upgrade/target/jdbc" />
@@ -257,6 +272,11 @@
<ant antfile="${old.jbpm.home}/install/build.xml" target="create.jbpm.schema" inheritall="false">
<property name="database" value="${database}" />
</ant>
+ <copy file="${old.jbpm.home}/install/src/cfg/hibernate/jdbc/${database}.hibernate.cfg.xml"
+ tofile="upgrade/target/jbpm-test-upgrade/jbpm.hibernate.cfg.xml"
+ overwrite="true">
+ <filterset filtersfile="upgrade/target/jdbc/${database}.properties" />
+ </copy>
</target>
<target name="testsuite.upgrade.teardown">
16 years, 6 months
JBoss JBPM SVN: r5778 - in jbpm4/trunk/modules: distro/src/main/files/install/src/db/create and 1 other directory.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-23 07:36:57 -0400 (Fri, 23 Oct 2009)
New Revision: 5778
Modified:
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/HibernateOperation.java
jbpm4/trunk/modules/distro/src/main/files/install/src/db/create/jbpm.oracle.create.sql
Log:
for oracle, remove delimiters when executing a script of sql commands
Modified: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/HibernateOperation.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/HibernateOperation.java 2009-10-23 11:30:25 UTC (rev 5777)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/HibernateOperation.java 2009-10-23 11:36:57 UTC (rev 5778)
@@ -129,6 +129,11 @@
j += delimiter.length();
}
String command = fileContents.substring(i, j).trim();
+ if ( "oracle".equals(database)
+ && command.endsWith(";")
+ ) {
+ command = command.substring(0, command.length()-1);
+ }
if (command.length()>0) {
commands.add(command);
}
Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/db/create/jbpm.oracle.create.sql
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/db/create/jbpm.oracle.create.sql 2009-10-23 11:30:25 UTC (rev 5777)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/db/create/jbpm.oracle.create.sql 2009-10-23 11:36:57 UTC (rev 5778)
@@ -1,6 +1,22 @@
-create table JBPM4_DEPLOYMENT (DBID_ number(19,0) not null,NAME_ clob,TIMESTAMP_ number(19,0),STATE_ varchar2(255 char),primary key (DBID_));
-create table JBPM4_DEPLOYPROP (DBID_ number(19,0) not null,DEPLOYMENT_ number(19,0),OBJNAME_ varchar2(255 char),KEY_ varchar2(255 char),STRINGVAL_ varchar2(255 char),LONGVAL_ number(19,0),primary key (DBID_));
+ create table JBPM4_DEPLOYMENT (
+ DBID_ number(19,0) not null,
+ NAME_ clob,
+ TIMESTAMP_ number(19,0),
+ STATE_ varchar2(255 char),
+ primary key (DBID_)
+ );
+
+ create table JBPM4_DEPLOYPROP (
+ DBID_ number(19,0) not null,
+ DEPLOYMENT_ number(19,0),
+ OBJNAME_ varchar2(255 char),
+ KEY_ varchar2(255 char),
+ STRINGVAL_ varchar2(255 char),
+ LONGVAL_ number(19,0),
+ primary key (DBID_)
+ );
+
create table JBPM4_EXECUTION (
DBID_ number(19,0) not null,
CLASS_ varchar2(255 char) not null,
16 years, 6 months
JBoss JBPM SVN: r5777 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/api and 18 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-10-23 07:30:25 -0400 (Fri, 23 Oct 2009)
New Revision: 5777
Added:
jbpm4/trunk/modules/test-upgrade/
jbpm4/trunk/modules/test-upgrade/.classpath
jbpm4/trunk/modules/test-upgrade/.project
jbpm4/trunk/modules/test-upgrade/.settings/
jbpm4/trunk/modules/test-upgrade/.settings/org.eclipse.jdt.core.prefs
jbpm4/trunk/modules/test-upgrade/.settings/org.maven.ide.eclipse.prefs
jbpm4/trunk/modules/test-upgrade/pom.xml
jbpm4/trunk/modules/test-upgrade/src/
jbpm4/trunk/modules/test-upgrade/src/main/
jbpm4/trunk/modules/test-upgrade/src/main/java/
jbpm4/trunk/modules/test-upgrade/src/main/java/org/
jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/
jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/upgrade/
jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java
jbpm4/trunk/modules/test-upgrade/src/main/resources/
jbpm4/trunk/modules/test-upgrade/src/main/resources/hibernate.properties
jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.cfg.xml
jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.hibernate.cfg.xml
jbpm4/trunk/modules/test-upgrade/src/main/resources/logging.properties
jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess1.jpdl.xml
jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess2.jpdl.xml
jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess3.jpdl.xml
jbpm4/trunk/modules/test-upgrade/src/test/
jbpm4/trunk/modules/test-upgrade/src/test/java/
jbpm4/trunk/modules/test-upgrade/src/test/java/org/
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/AfterUpgradeJbpmTestCase.java
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process1AfterUpgradeTest.java
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process2AfterUpgradeTest.java
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process3AfterUpgradeTest.java
jbpm4/trunk/modules/test-upgrade/src/test/resources/
jbpm4/trunk/modules/test-upgrade/target/
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
Log:
initial commit test-upgrade
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java 2009-10-23 09:47:10 UTC (rev 5776)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -36,8 +36,11 @@
/** select only process instances for the given process definition */
ProcessInstanceQuery processDefinitionId(String processDefinitionId);
- /** select only a specific process instances */
+ /** select only a specific process instances using the process instance id */
ProcessInstanceQuery processInstanceId(String processInstanceId);
+
+ /** select only specific process instances using a business key */
+ ProcessInstanceQuery processInstanceKey(String processInstanceKey);
/** select only suspended process definitions */
ProcessInstanceQuery suspended();
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java 2009-10-23 09:47:10 UTC (rev 5776)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -40,12 +40,17 @@
String PROPERTY_STATE = "state";
/** duration property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
String PROPERTY_DURATION = "duration";
+ /** Key propertu to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
+ String PROPERTY_KEY = "key";
/** select only the process instances with the given id */
HistoryProcessInstanceQuery processInstanceId(String processInstanceId);
- /** select only process instances within the given process definition */
+ /** select only process instances with the given process definition */
HistoryProcessInstanceQuery processDefinitionId(String processDefinitionId);
+
+ /** select only process instances with the given business key */
+ HistoryProcessInstanceQuery processInstanceKey(String processInstanceKey);
/** select only process instances in the given state */
HistoryProcessInstanceQuery state(String state);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java 2009-10-23 09:47:10 UTC (rev 5776)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -38,6 +38,7 @@
protected String processDefinitionId;
protected String state;
protected String processInstanceId;
+ protected String processInstanceKey;
public String hql() {
StringBuilder hql = new StringBuilder();
@@ -58,6 +59,10 @@
appendWhereClause(" hpi.state = '"+state+"' ", hql);
}
+ if (processInstanceKey!=null) {
+ appendWhereClause(" hpi.key = '" + processInstanceKey + "'", hql);
+ }
+
appendOrderByClause(hql);
return hql.toString();
@@ -98,6 +103,11 @@
this.processDefinitionId = processDefinitionId;
return this;
}
+
+ public HistoryProcessInstanceQuery processInstanceKey(String processInstanceKey) {
+ this.processInstanceKey = processInstanceKey;
+ return this;
+ }
public HistoryProcessInstanceQuery state(String state) {
this.state = state;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java 2009-10-23 09:47:10 UTC (rev 5776)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -37,6 +37,7 @@
protected String processDefinitionId;
protected String processInstanceId;
+ protected String processInstanceKey;
protected Boolean suspended;
public ProcessInstance uniqueResult() {
@@ -64,13 +65,17 @@
}
}
- if (processInstanceId!=null) {
- appendWhereClause("processInstance.processInstance.id = '"+processInstanceId+"' ", hql);
+ if (processInstanceId != null) {
+ appendWhereClause("processInstance.processInstance.id = '" + processInstanceId+"' ", hql);
}
- if (processDefinitionId!=null) {
- appendWhereClause("processInstance.processDefinitionId = '"+processDefinitionId+"' ", hql);
+ if (processDefinitionId != null) {
+ appendWhereClause("processInstance.processDefinitionId = '" + processDefinitionId+"' ", hql);
}
+
+ if (processInstanceKey != null) {
+ appendWhereClause("processInstance.key = '" + processInstanceKey + "'", hql);
+ }
appendOrderByClause(hql);
@@ -110,8 +115,14 @@
return this;
}
+ public ProcessInstanceQuery processInstanceKey(String processInstanceKey) {
+ this.processInstanceKey = processInstanceKey;
+ return this;
+ }
+
public ProcessInstanceQuery notSuspended() {
this.suspended = false;
return this;
}
+
}
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-10-23 09:47:10 UTC (rev 5776)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -220,7 +220,8 @@
column="PROCESSINSTANCE_"
cascade="none"
foreign-key="none"
- index="IDX_JOB_PRINST"/>
+ index="IDX_JOB_PRINST"
+ lazy="false"/>
<many-to-one name="execution"
class="org.jbpm.pvm.internal.model.ExecutionImpl"
Added: jbpm4/trunk/modules/test-upgrade/.classpath
===================================================================
--- jbpm4/trunk/modules/test-upgrade/.classpath (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/.classpath 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: jbpm4/trunk/modules/test-upgrade/.project
===================================================================
--- jbpm4/trunk/modules/test-upgrade/.project (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/.project 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,23 @@
+<projectDescription>
+ <name>jbpm-test-upgrade</name>
+ <comment/>
+ <projects>
+ <project>api</project>
+ <project>jpdl</project>
+ <project>log</project>
+ <project>pvm</project>
+ <project>test-base</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Added: jbpm4/trunk/modules/test-upgrade/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- jbpm4/trunk/modules/test-upgrade/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/.settings/org.eclipse.jdt.core.prefs 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,5 @@
+#Wed Oct 21 23:47:50 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
Added: jbpm4/trunk/modules/test-upgrade/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- jbpm4/trunk/modules/test-upgrade/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/.settings/org.maven.ide.eclipse.prefs 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,9 @@
+#Wed Oct 21 23:32:38 CEST 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
Added: jbpm4/trunk/modules/test-upgrade/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/pom.xml (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/pom.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!-- -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 3010 2008-11-20 08:30:16Z tom.baeyens(a)jboss.com $ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!-- Module Info -->
+ <modelVersion>4.0.0</modelVersion>
+ <name>jBPM 4 - TEST-UPGRADE</name>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-test-upgrade</artifactId>
+ <packaging>jar</packaging>
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm</artifactId>
+ <version>4.2-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-jpdl</artifactId>
+ <version>4.2-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>${hsqldb.version}</version>
+ </dependency>
+ </dependencies>
+
+
+</project>
Added: jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,163 @@
+/*
+ * 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.upgrade;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.Configuration;
+import org.jbpm.api.Execution;
+import org.jbpm.api.ExecutionService;
+import org.jbpm.api.ManagementService;
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.RepositoryService;
+import org.jbpm.api.job.Job;
+
+/**
+ * Class to be executed during the upgrade test, before the actual schema
+ * upgrade is applied. This class will populate the 'old' DB schema with
+ * process, variables, history, ... data, that will be verified by the
+ * {@link AfterUpgrade} class.
+ *
+ * @author jbarrez
+ */
+public class BeforeUpgrade {
+
+ private ProcessEngine processEngine;
+
+ private RepositoryService repositoryService;
+
+ private ExecutionService executionService;
+
+ private ManagementService managementService;
+
+ private static final String TEST_PROCESS_1 = "testprocess1.jpdl.xml";
+
+ private static final String TEST_PROCESS_2 = "testprocess2.jpdl.xml";
+
+ private static final String TEST_PROCESS_3 = "testprocess3.jpdl.xml";
+
+ public static void main(String[] args) {
+ BeforeUpgrade beforeUpgrade = new BeforeUpgrade();
+ beforeUpgrade.generateProcess1Data();
+ beforeUpgrade.generateProcess2Data();
+ beforeUpgrade.generateProcess3Data();
+ }
+
+ public BeforeUpgrade() {
+ this.processEngine = new Configuration().buildProcessEngine();
+ this.repositoryService = processEngine.getRepositoryService();
+ this.executionService = processEngine.getExecutionService();
+ this.managementService = processEngine.getManagementService();
+ }
+
+
+ private void deploy(String processFile) {
+ NewDeployment deployment = repositoryService.createDeployment();
+ deployment.addResourceFromClasspath(processFile);
+ deployment.deploy();
+ }
+
+ /**
+ * Process 1 is a simple process using fork/join and states
+ */
+ private void generateProcess1Data() {
+
+ // Deploy test processes
+ deploy(TEST_PROCESS_1);
+
+ // Start 5 instances of process1
+ List<String> ids = new ArrayList<String>();
+ for (int i = 0; i < 5; i++) {
+ String procDefKey = TEST_PROCESS_1.replace(".jpdl.xml", "");
+ String procInstKey = procDefKey + "-" + i;
+ ids.add(executionService.startProcessInstanceByKey(procDefKey, procInstKey).getId());
+ }
+
+ // Put these instances in various states
+
+ // First one: only in state 'print documents'
+ String execId = executionService.findProcessInstanceById(ids.get(0)).findActiveExecutionIn("send invoice").getId();
+ executionService.signalExecutionById(execId);
+
+ execId = executionService.findProcessInstanceById(ids.get(0)).findActiveExecutionIn("load truck").getId();
+ executionService.signalExecutionById(execId);
+
+ // Second one: put in state 'load truck' and 'send invoice'
+ execId = executionService.findProcessInstanceById(ids.get(1)).findActiveExecutionIn("print documents").getId();
+ executionService.signalExecutionById(execId);
+
+ // third one: finished
+ executionService.endProcessInstance(ids.get(2), Execution.STATE_ENDED);
+
+ }
+
+ /**
+ * Process 2 is a process using variables and a decision
+ */
+ private void generateProcess2Data() {
+
+ // Deploy test process
+ deploy(TEST_PROCESS_2);
+
+ // Start 6 instances, of which 3 will be ended
+ List<String> ids = new ArrayList<String>();
+ for (int i = 0; i < 7; i++) {
+
+ String procDefKey = TEST_PROCESS_2.replace(".jpdl.xml", "");
+ String procInstKey = procDefKey + "-" + i;
+
+ Map<String, Object> vars = new HashMap<String, Object>();
+ vars.put("var", i * 2); // we store as var: 0, 2, 4, 6, 8, 10, 12
+ ids.add(executionService.startProcessInstanceByKey(procDefKey, vars, procInstKey).getId());
+ }
+
+
+ }
+
+ /**
+ * Process 3 is a basic process containing a human task and a timer
+ */
+ private void generateProcess3Data() {
+
+ // Deploy test process
+ deploy(TEST_PROCESS_3);
+
+ // Start 2 instances, 1 will have timer fired
+ List<String> ids = new ArrayList<String>();
+ for (int i = 0; i < 2; i++) {
+
+ String procDefKey = TEST_PROCESS_3.replace(".jpdl.xml", "");
+ String procInstKey = procDefKey + "-" + i;
+ ids.add(executionService.startProcessInstanceByKey(procDefKey, procInstKey).getId());
+ }
+
+ Job timer = managementService.createJobQuery()
+ .processInstanceId(ids.get(0)).uniqueResult();
+ managementService.executeJob(timer.getId());
+
+ }
+
+}
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/hibernate.properties
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/hibernate.properties (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/hibernate.properties 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,10 @@
+# Using a property file here, since property values are easier to
+# replace than in the XML counterpart
+
+hibernate.dialect=org.hibernate.dialect.HSQLDialect
+hibernate.connection.driver_class=org.hsqldb.jdbcDriver
+hibernate.connection.url=jdbc:hsqldb:hsql://localhost:1701
+hibernate.connection.username=sa
+hibernate.connection.password=
+hibernate.hbm2ddl.auto=create-drop
+hibernate.format_sql=true
\ No newline at end of file
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.cfg.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.default.cfg.xml" />
+ <import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.tx.hibernate.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+
+</jbpm-configuration>
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.hibernate.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.hibernate.cfg.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <!-- Connection properties will be taken from hibernate.properties -->
+
+ <mapping resource="jbpm.repository.hbm.xml" />
+ <mapping resource="jbpm.execution.hbm.xml" />
+ <mapping resource="jbpm.history.hbm.xml" />
+ <mapping resource="jbpm.task.hbm.xml" />
+ <mapping resource="jbpm.identity.hbm.xml" />
+
+ </session-factory>
+</hibernate-configuration>
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/logging.properties (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/logging.properties 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,18 @@
+handlers= java.util.logging.ConsoleHandler
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
+
+org.jbpm.level=FINE
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=INFO
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+org.hibernate.cfg.HbmBinder.level=SEVERE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST
\ No newline at end of file
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess1.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess1.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess1.jpdl.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+ <process name="testprocess1" xmlns="http://jbpm.org/4.2/jpdl">
+
+ <start>
+ <transition to="theFork"/>
+ </start>
+
+ <fork name="theFork">
+ <transition to="send invoice"/>
+ <transition to="load truck"/>
+ <transition to="print documents"/>
+ </fork>
+
+ <state name="send invoice">
+ <transition to="theJoin"/>
+ </state>
+
+ <state name="load truck">
+ <transition to="shipping join"/>
+ </state>
+
+ <state name="print documents">
+ <transition to="shipping join"/>
+ </state>
+
+ <join name="shipping join">
+ <transition to="drive truck"/>
+ </join>
+
+ <state name="drive truck">
+ <transition to="theJoin"/>
+ </state>
+
+ <join name="theJoin">
+ <transition to="end"/>
+ </join>
+
+ <end name="end"/>
+
+ </process>
\ No newline at end of file
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess2.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess2.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess2.jpdl.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="testprocess2" xmlns="http://jbpm.org/4.2/jpdl">
+
+ <start>
+ <transition to="testVariable" />
+ </start>
+
+ <decision name="testVariable">
+ <transition to="end">
+ <condition expr="#{var < 6}" />
+ </transition>
+ <transition to="more than 5">
+ <condition expr="#{var > 5}" />
+ </transition>
+ </decision>
+
+ <state name="more than 5">
+ <transition to="testVariable" />
+ </state>
+
+ <end name="end" />
+
+</process>
\ No newline at end of file
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess3.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess3.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess3.jpdl.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="testprocess3" xmlns="http://jbpm.org/4.2/jpdl">
+
+ <start>
+ <transition to="do something important" />
+ </start>
+
+ <task name="do something important" assignee="johnDoe">
+ <transition name="timeout" to="timed out">
+ <timer duedate="3 days" />
+ </transition>
+ <transition name="done" to="end" />
+ </task>
+
+ <state name="timed out">
+ <transition to="end" />
+ </state>
+
+ <end name="end" />
+
+</process>
\ No newline at end of file
Added: jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/AfterUpgradeJbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/AfterUpgradeJbpmTestCase.java (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/AfterUpgradeJbpmTestCase.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,68 @@
+package org.jbpm.test.upgrade;
+
+import java.util.List;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+import org.jbpm.upgrade.BeforeUpgrade;
+
+/**
+ * We cannot use the {@link JbpmTestCase} directly, since it will check if the
+ * database is clean. However, in the upgrade test, we expect to have data in
+ * the database that was put there before the upgrade. So this class adapts the
+ * {@link JbpmTestCase} where needed, so that the database is not checked to be
+ * clean.
+ *
+ * @author jbarrez
+ */
+public abstract class AfterUpgradeJbpmTestCase extends JbpmTestCase {
+
+ protected void tearDown() throws Exception {
+ // Do nothing -> the super.tearDown() will check the database to be
+ // clean, which now isn't happening due to the override.
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ //BeforeUpgrade.main(new String[] {}); // For testing locally
+ }
+
+ public abstract void testDataValid();
+
+ /*
+ * -------------- HELPER METHODS --------------
+ */
+
+ protected ProcessInstance findProcessInstanceByKey(String key) {
+ return executionService.createProcessInstanceQuery()
+ .processInstanceKey(key).uniqueResult();
+ }
+
+ protected HistoryProcessInstance findHistoryProcessInstanceByKey(String key) {
+ return historyService.createHistoryProcessInstanceQuery()
+ .processInstanceKey(key).uniqueResult();
+ }
+
+ protected List<HistoryProcessInstance> findEndedProcessInstancesByProcDef(String processDefinitionId){
+ return historyService.createHistoryProcessInstanceQuery()
+ .state(Execution.STATE_ENDED)
+ .processDefinitionId(processDefinitionId).list();
+ }
+
+ protected List<ProcessDefinition> findProcessDefinitionsByKey(String key) {
+ return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).list();
+ }
+
+ protected ProcessDefinition findProcessDefinitionByKey(String key) {
+ return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).uniqueResult();
+ }
+
+ protected List<ProcessInstance> findProcessInstancesByProcessDefinition(String procDefId) {
+ return executionService.createProcessInstanceQuery().processDefinitionId(procDefId).list();
+ }
+
+}
Added: jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process1AfterUpgradeTest.java
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process1AfterUpgradeTest.java (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process1AfterUpgradeTest.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,43 @@
+package org.jbpm.test.upgrade;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryProcessInstance;
+
+public class Process1AfterUpgradeTest extends AfterUpgradeJbpmTestCase {
+
+ private static final String PROCESS_1_KEY = "testprocess1";
+
+ public void testDataValid() {
+
+ // Check process1 deployment
+ List<ProcessDefinition> procDefs = findProcessDefinitionsByKey(PROCESS_1_KEY);
+ assertEquals(1, procDefs.size());
+
+ List<ProcessInstance> procInstances = findProcessInstancesByProcessDefinition(procDefs.get(0).getId());
+ assertEquals(4, procInstances.size());
+
+ // process instance 1 is in the 'print documents' state
+ ProcessInstance processInstance1 = findProcessInstanceByKey(PROCESS_1_KEY + "-0");
+ Set<String> activeActivities = processInstance1.findActiveActivityNames();
+ assertEquals(1, activeActivities.size());
+ assertActivityActive(processInstance1.getId(), "print documents");
+
+ // process instance 2 is in the 'load truck' and 'send invoice' state
+ ProcessInstance processInstance2 = findProcessInstanceByKey(PROCESS_1_KEY + "-1");
+ activeActivities = processInstance2.findActiveActivityNames();
+ assertActivitiesActive(processInstance2.getId(), "load truck", "send invoice");
+
+ // process instance 3 is finished
+ ProcessInstance processInstance3 = findProcessInstanceByKey(PROCESS_1_KEY + "-2");
+ assertNull(processInstance3);
+ HistoryProcessInstance histProcInst3 = findHistoryProcessInstanceByKey(PROCESS_1_KEY + "-2");
+ assertNotNull(histProcInst3);
+
+ }
+
+}
Added: jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process2AfterUpgradeTest.java
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process2AfterUpgradeTest.java (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process2AfterUpgradeTest.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,34 @@
+package org.jbpm.test.upgrade;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryProcessInstance;
+
+public class Process2AfterUpgradeTest extends AfterUpgradeJbpmTestCase {
+
+ private static final String PROCESS_2_KEY = "testprocess2";
+
+ public void testDataValid() {
+
+ // 4 process instances should be active
+ ProcessDefinition procDef = findProcessDefinitionByKey(PROCESS_2_KEY);
+ List<ProcessInstance> procInstances = findProcessInstancesByProcessDefinition(procDef.getId());
+ assertEquals(4, procInstances.size()); // 3 processes are already finished: 7-3=4 left
+
+ // These processes should be in the 'more than 5' state
+ for (ProcessInstance processInstance : procInstances) {
+ Set<String> activeActivities = processInstance.findActiveActivityNames();
+ assertEquals(1, activeActivities.size());
+ assertActivityActive(processInstance.getId(), "more than 5");
+ }
+
+ // 4 process instances should have ended
+ List<HistoryProcessInstance> histProcInsts = findEndedProcessInstancesByProcDef(procDef.getId());
+ assertEquals(3, histProcInsts.size());
+
+ }
+
+}
Added: jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process3AfterUpgradeTest.java
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process3AfterUpgradeTest.java (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process3AfterUpgradeTest.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,36 @@
+package org.jbpm.test.upgrade;
+
+import java.util.List;
+
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.api.task.Task;
+
+public class Process3AfterUpgradeTest extends AfterUpgradeJbpmTestCase {
+
+ private static final String PROCESS_3_KEY = "testprocess3";
+
+ public void testDataValid() {
+
+ // 2 process instances should be active
+ ProcessDefinition procDef = findProcessDefinitionByKey(PROCESS_3_KEY);
+ List<ProcessInstance> procInstances = findProcessInstancesByProcessDefinition(procDef.getId());
+ assertEquals(2, procInstances.size());
+
+ // process instance 1 should be in the 'timed out' state
+ ProcessInstance processInstance = findProcessInstanceByKey(PROCESS_3_KEY + "-0");
+ assertActivityActive(processInstance.getId(), "timed out");
+
+ // process instance 2 should have an uncompleted task
+ List<Task> tasks = taskService.createTaskQuery().assignee("johnDoe").list();
+ assertEquals(2, tasks.size());
+
+ // There should be one job unfinished
+ List<Job> jobs = managementService.createJobQuery().list();
+ assertEquals(1, jobs.size());
+ assertEquals(PROCESS_3_KEY + "-1", jobs.get(0).getProcessInstance().getKey());
+
+ }
+
+}
16 years, 6 months
JBoss JBPM SVN: r5776 - jbpm4/trunk/modules/distro/src/main/files/install/src/db/create.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-23 05:47:10 -0400 (Fri, 23 Oct 2009)
New Revision: 5776
Modified:
jbpm4/trunk/modules/distro/src/main/files/install/src/db/create/jbpm.oracle.create.sql
Log:
test oracle create script without newlines in command
Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/db/create/jbpm.oracle.create.sql
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/db/create/jbpm.oracle.create.sql 2009-10-23 09:45:21 UTC (rev 5775)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/db/create/jbpm.oracle.create.sql 2009-10-23 09:47:10 UTC (rev 5776)
@@ -1,22 +1,6 @@
+create table JBPM4_DEPLOYMENT (DBID_ number(19,0) not null,NAME_ clob,TIMESTAMP_ number(19,0),STATE_ varchar2(255 char),primary key (DBID_));
+create table JBPM4_DEPLOYPROP (DBID_ number(19,0) not null,DEPLOYMENT_ number(19,0),OBJNAME_ varchar2(255 char),KEY_ varchar2(255 char),STRINGVAL_ varchar2(255 char),LONGVAL_ number(19,0),primary key (DBID_));
- create table JBPM4_DEPLOYMENT (
- DBID_ number(19,0) not null,
- NAME_ clob,
- TIMESTAMP_ number(19,0),
- STATE_ varchar2(255 char),
- primary key (DBID_)
- );
-
- create table JBPM4_DEPLOYPROP (
- DBID_ number(19,0) not null,
- DEPLOYMENT_ number(19,0),
- OBJNAME_ varchar2(255 char),
- KEY_ varchar2(255 char),
- STRINGVAL_ varchar2(255 char),
- LONGVAL_ number(19,0),
- primary key (DBID_)
- );
-
create table JBPM4_EXECUTION (
DBID_ number(19,0) not null,
CLASS_ varchar2(255 char) not null,
16 years, 6 months
JBoss JBPM SVN: r5775 - jbpm4/trunk/qa/upgrade.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-23 05:45:21 -0400 (Fri, 23 Oct 2009)
New Revision: 5775
Modified:
jbpm4/trunk/qa/upgrade/
Log:
added target to svn:ignore
Property changes on: jbpm4/trunk/qa/upgrade
___________________________________________________________________
Name: svn:ignore
+ target
16 years, 6 months
JBoss JBPM SVN: r5774 - in jbpm4/trunk/qa: upgrade and 1 other directory.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-23 05:42:53 -0400 (Fri, 23 Oct 2009)
New Revision: 5774
Added:
jbpm4/trunk/qa/hudson-jbpm4-upgrade.bat
jbpm4/trunk/qa/hudson-jbpm4-upgrade.sh
jbpm4/trunk/qa/upgrade/
jbpm4/trunk/qa/upgrade/pom.xml
Modified:
jbpm4/trunk/qa/build.xml
Log:
JBPM-2509 database upgrade ci scripts
Modified: jbpm4/trunk/qa/build.xml
===================================================================
--- jbpm4/trunk/qa/build.xml 2009-10-23 08:24:09 UTC (rev 5773)
+++ jbpm4/trunk/qa/build.xml 2009-10-23 09:42:53 UTC (rev 5774)
@@ -157,6 +157,113 @@
<ant antfile="${jbpm.home}/install/build.xml" target="internal.stop.hsqldb.server.if.needed" />
</target>
+ <!-- ################ -->
+ <!-- ### UPGRADE ### -->
+ <!-- ################ -->
+ <property name="old.jbpm.home" value="${jbpm.parent.dir}/jbpm-${old.jbpm.version}" />
+ <target name="testsuite.upgrade.setup" depends="reinstall.jbpm">
+ <fail message="old.jbpm.version is a mandatory property" unless="old.jbpm.version" />
+ <!-- install old jbpm version -->
+ <delete dir="${old.jbpm.home}" />
+ <unzip src="upgrade/target/jbpm-distro-${old.jbpm.version}.jar" dest="${jbpm.parent.dir}" />
+ <!-- create jdbc properties files for PVM2 based on the originals -->
+ <delete dir="upgrade/target/jdbc" />
+ <mkdir dir="upgrade/target/jdbc" />
+ <copy todir="upgrade/target/jdbc">
+ <fileset dir="jdbc" />
+ </copy>
+ <replace dir="upgrade/target/jdbc">
+ <include name="*.properties" />
+ <replacefilter token="PVM1" value="PVM2" />
+ <replacefilter token="pvm1" value="pvm2" />
+ </replace>
+ <!-- create jbpm schema using the old jbpm distro -->
+ <condition property="is.old.jbpm.40">
+ <equals arg1="${old.jbpm.version}" arg2="4.0" />
+ </condition>
+ <antcall target="create.jbpm.schema.in.jbpm.40" />
+ <antcall target="create.jbpm.schema.in.jbpm.41plus" />
+ <!-- start couple of processes using the old jbpm version -->
+ <delete dir="upgrade/target/jbpm-test-upgrade" />
+ <mkdir dir="upgrade/target/jbpm-test-upgrade" />
+ <unzip dest="upgrade/target/jbpm-test-upgrade" src="upgrade/target/jbpm-test-upgrade.jar" />
+ <copy file="upgrade/target/jdbc/${database}.properties" tofile="upgrade/target/jbpm-test-upgrade/hibernate.properties" overwrite="true" />
+ <java classname="org.jbpm.upgrade.BeforeUpgrade">
+ <classpath>
+ <pathelement location="upgrade/target/jbpm-test-upgrade" />
+ <fileset dir="${old.jbpm.home}">
+ <include name="jbpm.jar"/>
+ </fileset>
+ <fileset dir="${old.jbpm.home}/lib">
+ <include name="*.jar"/>
+ </fileset>
+ </classpath>
+ </java>
+ <!-- upgrade -->
+ <copy todir="${jbpm.home}/install/jdbc" overwrite="true">
+ <fileset dir="upgrade/target/jdbc" />
+ </copy>
+ <ant antfile="${jbpm.home}/install/build.xml" target="upgrade.jbpm.schema" inheritall="false" />
+ </target>
+
+ <condition property="is.hsqldb">
+ <equals arg1="${database}" arg2="hsqldb" />
+ </condition>
+
+ <target name="start.hsqldb" if="is.hsqldb">
+ <delete dir="upgrade/target/hsqldb" />
+ <mkdir dir="upgrade/target/hsqldb" />
+ <java classname="org.hsqldb.Server" dir="upgrade/target/hsqldb" fork="true">
+ <arg line="-address localhost -port 1701 -dbname.0 jbpmDatabase" />
+ <classpath>
+ <fileset dir="upgrade/target">
+ <include name="hsqldb.jar"/>
+ </fileset>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="stop.hsqldb" if="is.hsqldb">
+ <property file="upgrade/target/jdbc/${database}.properties" />
+ <path id="hsqldb.classpath">
+ <fileset dir="upgrade/target">
+ <include name="hsqldb.jar"/>
+ </fileset>
+ </path>
+ <sql driver="${jdbc.driver}"
+ password="${jdbc.password}"
+ url="${jdbc.url}"
+ userid="${jdbc.username}"
+ onerror="continue"
+ autocommit="true"
+ classpathref="hsqldb.classpath">SHUTDOWN</sql>
+ </target>
+
+ <target name="create.jbpm.schema.in.jbpm.40" if="is.old.jbpm.40">
+ <!-- copy the PVM2 jdbc properties files in the old jbpm distro -->
+ <copy todir="${old.jbpm.home}/db/jdbc">
+ <fileset dir="upgrade/target/jdbc" />
+ </copy>
+ <ant antfile="${old.jbpm.home}/db/build.xml" target="create.jbpm.schema" inheritall="false">
+ <property name="database" value="${database}" />
+ </ant>
+ </target>
+
+ <target name="create.jbpm.schema.in.jbpm.41plus" unless="is.old.jbpm.40">
+ <!-- copy the PVM2 jdbc properties files in the old jbpm distro -->
+ <copy todir="${old.jbpm.home}/install/jdbc">
+ <fileset dir="upgrade/target/jdbc" />
+ </copy>
+ <ant antfile="${old.jbpm.home}/install/build.xml" target="create.jbpm.schema" inheritall="false">
+ <property name="database" value="${database}" />
+ </ant>
+ </target>
+
+ <target name="testsuite.upgrade.teardown">
+ <ant antfile="${jbpm.home}/install/build.xml" target="drop.jbpm.schema" inheritall="false" />
+ <antcall target="stop.hsqldb" />
+ </target>
+
<!-- ############################################ -->
<!-- ### REUSABLE TARGETS ### -->
<!-- ### These targets can be called directly ### -->
@@ -183,36 +290,4 @@
todir="${jbpm.home}/lib"/>
</target>
- <!-- ############################ -->
- <!-- ### OLD IDENTITY TARGETS ### -->
- <!-- ############################
-
- <target name="internal.install.idm.into.jboss.integrationtestspecifics" if="jbpm.identity.idm">
- <copy todir="${jboss.server.config.dir}/deploy/jbpm/jbpm-service.sar" overwrite="true">
- <fileset dir="jbpm.cfg.jboss.testsuite/jboss.idm" />
- </copy>
- </target>
-
- <condition property="identity.component.idm">
- <equals arg1="${identity.component}" arg2="jboss.idm"/>
- </condition>
-
- <target name="copy.jbossidm.jdbc.configuration" if="identity.component.idm">
- <copy file="../modules/distro/target/libs/ojdbc14.jar"
- todir="${jbossidm.home}/lib" />
- <copy file="jdbc/${database}.properties"
- todir="${jbossidm.home}/db/jdbc"
- overwrite="true"
- failonerror="false" />
- </target>
-
- <target name="drop.jbossidm.schema" if="identity.component.idm">
- <ant antfile="${jbossidm.home}/db/build.xml" target="drop.jbossidm.schema" />
- </target>
-
- <target name="create.jbossidm.schema" if="identity.component.idm">
- <ant antfile="${jbossidm.home}/db/build.xml" target="create.jbossidm.schema" />
- </target>
- -->
-
</project>
Added: jbpm4/trunk/qa/hudson-jbpm4-upgrade.bat
===================================================================
--- jbpm4/trunk/qa/hudson-jbpm4-upgrade.bat (rev 0)
+++ jbpm4/trunk/qa/hudson-jbpm4-upgrade.bat 2009-10-23 09:42:53 UTC (rev 5774)
@@ -0,0 +1,16 @@
+set MAVEN_OPTS=-Xms1024M -Xmx1024M
+set ANT_PROPERTIES=-Dold.jbpm.version=%1 -Ddatabase=%2
+
+cd qa\upgrade
+cmd /C mvn %ANT_PROPERTIES% dependency:copy
+cd ..\..
+
+cmd /C mvn -U -Pdistro,integration clean install
+start ant -f qa/build.xml %ANT_PROPERTIES% start.hsqldb
+cmd /C ant -f qa/build.xml %ANT_PROPERTIES% testsuite.upgrade.setup
+
+cd modules\test-upgrade
+cmd /C mvn %ANT_PROPERTIES% clean test
+cd ..\..
+
+cmd /C ant -f qa/build.xml %ANT_PROPERTIES% testsuite.upgrade.teardown
Added: jbpm4/trunk/qa/hudson-jbpm4-upgrade.sh
===================================================================
--- jbpm4/trunk/qa/hudson-jbpm4-upgrade.sh (rev 0)
+++ jbpm4/trunk/qa/hudson-jbpm4-upgrade.sh 2009-10-23 09:42:53 UTC (rev 5774)
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# runs the upgrade tests
+
+MAVEN_OPTS="-Xms1024M -Xmx1024M"
+ANT_PROPERTIES="-Dold.jbpm.version=$OLD_JBPM_VERSION -Ddatabase=$DATABASE -Djbpm.parent.dir=$WORKSPACE"
+echo ANT_PROPERTIES=${ANT_PROPERTIES}
+
+cd qa/upgrade
+mvn $ANT_PROPERTIES dependency:copy
+cd ../..
+
+mvn -U -Pdistro,integration clean install
+ant -f qa/build.xml $ANT_PROPERTIES start.hsqldb &
+ant -f qa/build.xml $ANT_PROPERTIES testsuite.upgrade.setup
+
+cd modules/test-upgrade
+mvn $ANT_PROPERTIES clean test
+cd ../..
+
+ant -f qa/build.xml $ANT_PROPERTIES testsuite.upgrade.teardown
Added: jbpm4/trunk/qa/upgrade/pom.xml
===================================================================
--- jbpm4/trunk/qa/upgrade/pom.xml (rev 0)
+++ jbpm4/trunk/qa/upgrade/pom.xml 2009-10-23 09:42:53 UTC (rev 5774)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!-- -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 5246 2009-07-06 11:07:48Z tom.baeyens(a)jboss.com $ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <name>jBPM 4 - Fetch old distro</name>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-fetch-old-distro</artifactId>
+ <packaging>jar</packaging>
+ <version>4.2-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-distro</artifactId>
+ <version>${old.jbpm.version}</version>
+ <outputDirectory>target</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-test-upgrade</artifactId>
+ <version>${old.jbpm.version}</version>
+ <outputDirectory>target</outputDirectory>
+ <destFileName>jbpm-test-upgrade.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.7</version>
+ <outputDirectory>target</outputDirectory>
+ <destFileName>hsqldb.jar</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- Repositories -->
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <url>http://repository.jboss.com/maven2</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+</project>
Property changes on: jbpm4/trunk/qa/upgrade/pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 6 months
JBoss JBPM SVN: r5773 - jbpm4/trunk/modules/userguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-10-23 04:24:09 -0400 (Fri, 23 Oct 2009)
New Revision: 5773
Modified:
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
Log:
[JBPM-2509] insert upgrade database section into user guide
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml 2009-10-23 01:59:01 UTC (rev 5772)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml 2009-10-23 08:24:09 UTC (rev 5773)
@@ -127,7 +127,7 @@
<para>To customize the values for these properties, just use <literal>-D</literal> like this
</para>
<programlisting>ant -Ddatabase=postgresql demo.setup.jboss</programlisting>
- <para>Alternativelym you can specify the customized values in
+ <para>Alternatively you can specify the customized values in
<literal>${user.home}/.jbpm4/build.properties</literal>
</para>
</section>
@@ -189,53 +189,59 @@
<section id="database">
<title>Database</title>
- <para>The install script also contains scripts for
- DB operations like creating and dropping the schema.
+ <para>The install script is also capable of performing database operations
+ such as creating the schema, if you are installing jBPM for the first time,
+ or upgrading the database used with a previous version to the current schema.
+ Dropping the schema is an option as well.
</para>
- <para>To create the schema in your database:</para>
- <itemizedlist>
- <listitem>First, update the properties file of your database in <literal>${jbpm.home}/install/jdbc</literal></listitem>
- <listitem>Then run target <literal>ant create.jbpm.schema</literal> in the <literal>${jbpm.home}/install</literal> directory</listitem>
- </itemizedlist>
- </section>
+ <para>The prerrequisite for any database operation is to specify your
+ database connection parameters in <literal>${jbpm.home}/install/jdbc</literal>.
+ </para>
- <!--
- <section id="databasemigration">
- <title>Database migration</title>
-
- <para>jBPM is able to generate SQL DDL scripts to upgrade the database schema from any past version
- starting from 4.0. To enact this capability, first check out the project from our SVN repository as
- described in the Wiki page <ulink url="http://www.jboss.org/community/wiki/jbpm4buildingfromsource">
- Building from Source</ulink>. Make sure you specify the appropriate database properties for your
- target database.</para>
- <para>Afterwards, change to the <literal>modules/db</literal> directory and run:</para>
- <synopsis>mvn -Djbpm.previous.version=<version.number>
- -Ddatabase={hsqldb|mysql|postgresql|oracle} package</synopsis>
- <para>The valid previous versions are those available from the JBoss <ulink
- url="http://repository.jboss.org/maven2/org/jbpm/jbpm4/jbpm-db/">Maven repo</ulink> starting
- from 4.0.</para>
- <para>Let us walk over an example. Assume you want to generate an update script from version 4.0
- for PostgreSQL. You have checked out <ulink url="http://anonsvn.jboss.org/repos/jbpm/jbpm4/trunk/">trunk</ulink>.
- You have a local PostgreSQL server listening on port 5432 (default). You have created a database and login
- both called <literal>jbpm4</literal>. File <literal><user.home>/.jbpm4/jdbc/postgresql.properties</literal>
- contains your JDBC connection properties.</para>
- <programlisting>hibernate.connection.driver_class=org.postgresql.Driver
-hibernate.connection.url=jdbc:postgresql://localhost:5432/jbpm4
-hibernate.connection.username=jbpm4
-hibernate.connection.password=</programlisting>
- <para>Given the environment described above, you change to the <literal>modules/db</literal> directory
- and run maven there.</para>
- <synopsis>mvn -Djbpm.previous.version=4.0 -Ddatabase=postgresql package</synopsis>
- <para>This command creates directory <literal>target/4.0</literal> and writes the following artifacts
- there:</para>
- <itemizedlist>
- <listitem>Scripts to create and drop the jBPM 4.0 database schema, retrieved from the Maven repo.</listitem>
- <listitem>PostgreSQL script to upgrade from the jBPM 4.0 schema to the version in your working copy.</listitem>
- <listitem>Diff file between the previous and the current schema creation scripts. Only appears if your OS
- belongs to the Unix family (including Linux and Mac OS X) and provides the diff command.</listitem>
- </itemizedlist>
+ <section id="createdropdb">
+ <title>Creating or dropping the database schema</title>
+ <para>To create the schema, run target <literal>create.jbpm.schema</literal>
+ in the <literal>${jbpm.home}/install</literal> directory. Apart from
+ creating tables and constraints, the mentioned target will initialize
+ table <literal>JBPM4_PROPERTY</literal> with the current engine version
+ (key <literal>db.version</literal>) and the ID generator base value
+ (key <literal>next.dbid</literal>.</para>
+ <para>To drop the schema, simply run target <literal>drop.jbpm.schema</literal>.
+ Be aware that this operation will destroy any data present in the jBPM
+ tables.</para>
+ </section>
+
+ <section id="upgradedb">
+ <title>Upgrading an existing database</title>
+ <para>To upgrade, run target <literal>upgrade.jbpm.schema</literal>
+ in the <literal>${jbpm.home}/install</literal> directory.</para>
+ <para>Upgrading is a two-fold operation. The foremost step is to add
+ any extra tables, columns or constraints that were introduced in newer
+ versions. Afterwards, seed data is inserted.</para>
+ <para>Between 4.0 and 4.1, table <literal>JBPM4_VARIABLE</literal> got
+ a new column <literal>CLASSNAME_</literal> used to support setting
+ process variables to values of custom types mapped with Hibernate.
+ This column is nullable and left uninitialized since the feature was
+ not operational in 4.0.</para>
+ <para>From 4.1 to 4.2 the upgrade procedure got more interesting.</para>
+ <itemizedlist>
+ <listitem>A new table <literal>JBPM4_PROPERTY</literal>
+ was introduced for storing engine-wide values.</listitem>
+ <listitem>The jBPM version is saved in table <literal>JBPM4_PROPERTY</literal>
+ under key <literal>db.version</literal> to allow for precise
+ identification in future releases.</listitem>
+ <listitem>The ID generation strategy is consistent across databases.
+ The next available ID is calculated by querying all tables having
+ an identifier column, and stored under key <literal>next.dbid</literal>
+ in the <literal>JBPM4_PROPERTY</literal> table.</listitem>
+ <listitem>The process language is set to <literal>jpdl-4.0</literal>
+ for all existing process definitions under key <literal>langid</literal>
+ in table <literal>JBPM4_DEPLOYPROP</literal>. The jPDL parser employs the
+ <literal>langid</literal> property to read process documents in a
+ backwards-compatible manner.</listitem>
+ </itemizedlist>
+ </section>
</section>
- -->
<section id="graphicalprocessdesigner">
<title>Graphical Process Designer (GPD)</title>
16 years, 6 months