[jbpm-commits] JBoss JBPM SVN: r5769 - in jbpm4/trunk: modules/db/scripts and 5 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Oct 22 04:49:29 EDT 2009


Author: alex.guizar at jboss.com
Date: 2009-10-22 04:49:29 -0400 (Thu, 22 Oct 2009)
New Revision: 5769

Added:
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/JbpmVersion.java
   jbpm4/trunk/qa/reinstall.jbpm.sh
Removed:
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/
   jbpm4/trunk/modules/db/src/main/resources/
   jbpm4/trunk/modules/db/src/test/
Modified:
   jbpm4/trunk/modules/db/.classpath
   jbpm4/trunk/modules/db/pom.xml
   jbpm4/trunk/modules/db/scripts/antrun-schema.xml
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java
Log:
[JBPM-2509] remove old stuff, detect version 4.1, linux reinstall script


Modified: jbpm4/trunk/modules/db/.classpath
===================================================================
--- jbpm4/trunk/modules/db/.classpath	2009-10-21 17:15:41 UTC (rev 5768)
+++ jbpm4/trunk/modules/db/.classpath	2009-10-22 08:49:29 UTC (rev 5769)
@@ -1,9 +1,6 @@
 <?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"/>

Modified: jbpm4/trunk/modules/db/pom.xml
===================================================================
--- jbpm4/trunk/modules/db/pom.xml	2009-10-21 17:15:41 UTC (rev 5768)
+++ jbpm4/trunk/modules/db/pom.xml	2009-10-22 08:49:29 UTC (rev 5769)
@@ -28,14 +28,15 @@
     <relativePath>../../pom.xml</relativePath>
   </parent>
 
-  <properties>
-    <old.version>4.1</old.version>
-  </properties>
-
   <profiles>
     <profile>
       <id>upgrade</id>
 
+      <properties>
+        <old.version>4.1</old.version>
+        <old.scripts.directory>${project.build.directory}/create-drop-${old.version}</old.scripts.directory>
+      </properties>
+
       <dependencies>
         <dependency>
           <groupId>com.oracle</groupId>
@@ -55,6 +56,29 @@
       <build>
         <plugins>
           <plugin>
+            <artifactId>maven-dependency-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>previous-version</id>
+                <phase>generate-resources</phase>
+                <goals>
+                  <goal>unpack</goal>
+                </goals>
+                <configuration>
+                  <artifactItems>
+                    <artifactItem>
+                      <groupId>org.jbpm.jbpm4</groupId>
+                      <artifactId>jbpm-db</artifactId>
+                      <version>${old.version}</version>
+                    </artifactItem>
+                  </artifactItems>
+                  <outputDirectory>${old.scripts.directory}</outputDirectory>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+
+          <plugin>
             <artifactId>maven-antrun-plugin</artifactId>
             <executions>
               <execution>
@@ -65,9 +89,12 @@
                 </goals>
                 <configuration>
                   <tasks>
-                    <property name="upgrade.files.dest.dir"
-                      value="src/main/resources/db/upgrade-${old.version}-to-${version}" />
-                    <property name="database" value="${database}" />
+                    <!-- keep directory properties, explicit paths are bad practice -->
+                    <property name="project.output.dir" value="${project.build.outputDirectory}" />
+                    <property name="old.scripts.dir" value="${old.scripts.directory}"/>
+                    <!-- upgrade scripts could be written to distro directly -->
+                    <property name="upgrade.scripts.dir"
+                      value="${project.build.directory}/upgrade-${old.version}-to-${project.version}" />
                     <!-- for some reason that i don't get, the user.home must be passed explicitly -->
                     <property name="user.home" value="${user.home}" />
                     <ant antfile="scripts/antrun-schema.xml" target="schema-upgrade"
@@ -80,19 +107,6 @@
         </plugins>
       </build>
     </profile>
-
-    <profile>
-      <id>no-database</id>
-      <activation>
-        <property>
-          <name>!database</name>
-        </property>
-      </activation>
-
-      <properties>
-        <database>hsqldb</database>
-      </properties>
-    </profile>
   </profiles>
 
   <!-- Dependencies -->
@@ -115,7 +129,7 @@
     </dependency>
   </dependencies>
 
-  <!-- build>
+  <build>
     <plugins>
       <plugin>
         <artifactId>maven-antrun-plugin</artifactId>
@@ -135,43 +149,7 @@
           </execution>
         </executions>
       </plugin>
-
-      <plugin>
-        <artifactId>maven-dependency-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>previous-version</id>
-            <phase>generate-resources</phase>
-            <goals>
-              <goal>unpack</goal>
-            </goals>
-            <configuration>
-              <artifactItems>
-                <artifactItem>
-                  <groupId>org.jbpm.jbpm4</groupId>
-                  <artifactId>jbpm-db</artifactId>
-                  <version>${old.version}</version>
-                </artifactItem>
-              </artifactItems>
-              <outputDirectory>target/test-classes/old-db</outputDirectory>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-
-      <plugin>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <systemProperties>
-            <property>
-              <name>database</name>
-              <value>${database}</value>
-            </property>
-          </systemProperties>
-        </configuration>
-      </plugin>
-      
     </plugins>
-  </build -->
+  </build>
 
 </project>
\ No newline at end of file

Modified: jbpm4/trunk/modules/db/scripts/antrun-schema.xml
===================================================================
--- jbpm4/trunk/modules/db/scripts/antrun-schema.xml	2009-10-21 17:15:41 UTC (rev 5768)
+++ jbpm4/trunk/modules/db/scripts/antrun-schema.xml	2009-10-22 08:49:29 UTC (rev 5769)
@@ -19,13 +19,13 @@
              classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
              classpathref="maven.compile.classpath" />
 
-    <mkdir dir="target/classes/db" />
+    <mkdir dir="${project.output.dir}" />
 
     <create-ddl db="hsqldb" />
     <create-ddl db="oracle" />
     <create-ddl db="postgresql" />
     <create-ddl db="mysql" />
-    <replace file="target/classes/db/jbpm.mysql.create.sql"
+    <replace file="${project.output.dir}/jbpm.mysql.create.sql"
              token="BLOB_VALUE_ blob"
              value="BLOB_VALUE_ longblob" />
   </target>
@@ -39,7 +39,7 @@
       <echo>Schema Create @{db}</echo>
       <echo>=====================</echo>
 
-      <schemaexport output="target/classes/db/jbpm.@{db}.create.sql"
+      <schemaexport output="${project.output.dir}/jbpm.@{db}.create.sql"
                     create="yes"
                     drop="no"
                     config="../distro/src/main/files/install/src/cfg/hibernate/jdbc/@{db}.hibernate.cfg.xml"
@@ -51,7 +51,7 @@
       <echo>=====================</echo>
       <echo>Schema Drop @{db}</echo>
       <echo>=====================</echo>
-      <schemaexport output="target/classes/db/jbpm.@{db}.drop.sql"
+      <schemaexport output="${project.output.dir}/jbpm.@{db}.drop.sql"
                     create="no"
                     drop="yes"
                     config="../distro/src/main/files/install/src/cfg/hibernate/jdbc/@{db}.hibernate.cfg.xml"
@@ -77,7 +77,7 @@
     <property file="${user.home}/.jbpm4/build.properties" />
     <echo>upgrade.jdbc.properties.dir: ${upgrade.jdbc.properties.dir}</echo>
     <property name="upgrade.jdbc.properties.dir" location="../../qa/jdbc" />
-    <mkdir dir="${upgrade.files.dest.dir}" />
+    <mkdir dir="${upgrade.scripts.dir}" />
 
     <antcall target="start.hsqldb" inheritrefs="true" />
     <upgrade-ddl db="hsqldb" />
@@ -118,14 +118,14 @@
     <sequential>
       <property file="${upgrade.jdbc.properties.dir}/@{db}.properties" prefix="@{db}." />
       <echo />
-      <echo>driver... ${@{db}.jdbc.driver}</echo>
-      <echo>url...... ${@{db}.jdbc.url}</echo>
-      <echo>username. ${@{db}.jdbc.username}</echo>
+      <echo>driver. ${@{db}.jdbc.driver}</echo>
+      <echo>url.... ${@{db}.jdbc.url}</echo>
+      <echo>user... ${@{db}.jdbc.username}</echo>
 
       <echo>=====================</echo>
       <echo>Dropping current schema @{db}</echo>
       <echo>=====================</echo>
-      <sql src="target/classes/db/jbpm.@{db}.drop.sql"
+      <sql src="${project.output.dir}/jbpm.@{db}.drop.sql"
            url="${@{db}.jdbc.url}"
            driver="${@{db}.jdbc.driver}"
            userid="${@{db}.jdbc.username}"
@@ -138,7 +138,7 @@
       <echo>=====================</echo>
       <echo>Creating old schema @{db}</echo>
       <echo>=====================</echo>
-      <sql src="target/test-classes/old-db/jbpm.@{db}.create.sql"
+      <sql src="${old.scripts.dir}/jbpm.@{db}.create.sql"
            url="${@{db}.jdbc.url}"
            driver="${@{db}.jdbc.driver}"
            userid="${@{db}.jdbc.username}"
@@ -158,7 +158,7 @@
       <echo>=====================</echo>
       <echo>Schema Upgrade @{db}</echo>
       <echo>=====================</echo>
-      <schemaupdate outputFile="${upgrade.files.dest.dir}/jbpm.@{db}.upgrade.sql"
+      <schemaupdate outputFile="${upgrade.scripts.dir}/jbpm.@{db}.upgrade.sql"
                     config="target/cfg/@{db}.hibernate.cfg.xml"
                     properties="${upgrade.jdbc.properties.dir}/@{db}.properties"
                     delimiter=";" />
@@ -167,7 +167,7 @@
       <echo>=====================</echo>
       <echo>Dropping old schema @{db}</echo>
       <echo>=====================</echo>
-      <sql src="target/test-classes/old-db/jbpm.@{db}.drop.sql"
+      <sql src="${old.scripts.dir}/jbpm.@{db}.drop.sql"
            url="${@{db}.jdbc.url}"
            driver="${@{db}.jdbc.driver}"
            userid="${@{db}.jdbc.username}"

Copied: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/JbpmVersion.java (from rev 5768, jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/JbpmVersion.java)
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/JbpmVersion.java	                        (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/JbpmVersion.java	2009-10-22 08:49:29 UTC (rev 5769)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.db;
+
+/**
+ * @author Tom Baeyens
+ */
+public enum JbpmVersion {
+
+  V_4_0, V_4_1, V_4_2;
+
+  public String toString() {
+    return "4." + ordinal();
+  }
+
+  public static JbpmVersion getJbpmVersion(String dbVersion) {
+    if (dbVersion.endsWith("-SNAPSHOT")) {
+      dbVersion = dbVersion.substring(0, dbVersion.length() - 9);
+    }
+    return dbVersion.startsWith("4.") && dbVersion.length() > 2 ? valueOf("V_4_"
+        + dbVersion.substring(2)) : null;
+  }
+  
+  public boolean isEarlier(JbpmVersion other) {
+    return ordinal() < other.ordinal();
+  }
+}

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-21 17:15:41 UTC (rev 5768)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java	2009-10-22 08:49:29 UTC (rev 5769)
@@ -23,9 +23,10 @@
 
 import java.util.List;
 
+import org.hibernate.HibernateException;
 import org.hibernate.classic.Session;
+import org.hibernate.criterion.Restrictions;
 import org.jbpm.api.JbpmException;
-import org.jbpm.db.internal.upgrade.JbpmVersion;
 import org.jbpm.jpdl.internal.xml.JpdlParser;
 import org.jbpm.pvm.internal.id.PropertyImpl;
 import org.jbpm.pvm.internal.repository.DeploymentImpl;
@@ -41,45 +42,44 @@
     upgradeOperation.parseArgs(args);
     HibernateOperation.executeInTransaction(upgradeOperation);
   }
-  
+
   public String toString() {
-    return "DB Upgrade to jBPM "+JpdlParser.CURRENT_VERSION_JBPM;
+    return "DB Upgrade to jBPM " + JpdlParser.CURRENT_VERSION_JBPM;
   }
-  
+
   public void execute(Session session) {
     JbpmVersion jbpmVersion = getJbpmVersion(session);
-    
-    if (jbpmVersion==JbpmVersion.V_4_2) {
+
+    if (jbpmVersion == JbpmVersion.V_4_2) {
       throw new JbpmException("jBPM schema is already up to date");
     }
-    
+
     if (jbpmVersion.isEarlier(JbpmVersion.V_4_1)) {
       upgrade40To41(session);
     }
-    
+
     if (jbpmVersion.isEarlier(JbpmVersion.V_4_2)) {
       upgrade41To42(session);
     }
   }
 
   private void upgrade40To41(Session session) {
-    executeSqlResource("upgrade-4.0-to-4.1/jbpm."+database+".upgrade.sql", session);
+    executeSqlResource("upgrade-4.0-to-4.1/jbpm." + database + ".upgrade.sql", session);
   }
 
   private void upgrade41To42(Session session) {
-    executeSqlResource("upgrade-4.1-to-4.2/jbpm."+database+".upgrade.sql", session);
+    executeSqlResource("upgrade-4.1-to-4.2/jbpm." + database + ".upgrade.sql", session);
     addLangId(session);
     PropertyImpl.upgradeProperties(session);
   }
 
   private void addLangId(Session session) {
     // find deployments without a langid property
-    List<DeploymentProperty> deploymentProperties = session.createQuery(
-        "from "+DeploymentProperty.class.getName()+ " deploymentProperty " + 
-        "where deploymentProperty.key = '"+DeploymentImpl.KEY_PROCESS_DEFINITION_ID+"'"
-        ).list();
-    
-    for (DeploymentProperty deploymentProperty: deploymentProperties) {
+    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();
       deploymentProperty.getDeployment().setProcessLanguageId(objectName, "jpdl-4.0");
     }
@@ -87,17 +87,25 @@
 
   private static JbpmVersion getJbpmVersion(Session session) {
     if (!PropertyImpl.propertiesTableExists(session)) {
-      return JbpmVersion.V_4_0;
+      return variableClassNameColumnExists(session) ? JbpmVersion.V_4_1 : JbpmVersion.V_4_0;
     }
 
     String dbVersion = PropertyImpl.getDbVersion(session);
-    if (dbVersion==null) {
-      // property table exists, but no db version property is present
-      // schema must have been updated moments ago
-      return JbpmVersion.V_4_0;
+    if (dbVersion == null) {
+      throw new JbpmException("property table exists, but no db version property is present");
     }
-    
+
     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/qa/reinstall.jbpm.sh
===================================================================
--- jbpm4/trunk/qa/reinstall.jbpm.sh	                        (rev 0)
+++ jbpm4/trunk/qa/reinstall.jbpm.sh	2009-10-22 08:49:29 UTC (rev 5769)
@@ -0,0 +1,9 @@
+#!/bin/sh
+#
+# reinstalls jbpm
+
+echo 'make sure you have jbpm.parent.dir specified in your \${user.home}/.jbpm4/build.properties'
+mvn -U -Pdistro clean install
+ant -f qa/build.xml reinstall.jbpm
+
+echo


Property changes on: jbpm4/trunk/qa/reinstall.jbpm.sh
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF



More information about the jbpm-commits mailing list