[jbpm-commits] JBoss JBPM SVN: r5753 - in jbpm4/trunk/modules/db/src/main/java/org/jbpm/db: internal and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Oct 18 04:03:52 EDT 2009


Author: alex.guizar at jboss.com
Date: 2009-10-18 04:03:52 -0400 (Sun, 18 Oct 2009)
New Revision: 5753

Added:
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/UpgradeTask.java
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/InitDbidGeneratorCmd.java
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java
Removed:
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbUpgrade.java
Log:
[JBPM-2509] provide upgrade tool and related ant task


Deleted: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbUpgrade.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbUpgrade.java	2009-10-18 06:30:10 UTC (rev 5752)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbUpgrade.java	2009-10-18 08:03:52 UTC (rev 5753)
@@ -1,49 +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 org.jbpm.api.JbpmException;
-
-
-/**
- * @author Tom Baeyens
- */
-public class DbUpgrade {
-
-  public static void main(String[] args) {
-    System.out.println("jBPM DB upgrade tool");
-    if (args!=null) {
-      for (int i=0; i<args.length; i++) {
-        System.out.println("  args["+i+"]="+args[i]);
-      }
-    }
-    
-    throw new JbpmException("TODO initialize langid deployproperties for existing processes");
-    
-//    String dbVersion = getDbVersion();
-//    String distroVersion = "4.2";
-//    
-//    if (upgrade41to40Necessary(dbVersion)) {
-//      upgrade41to40();
-//    }
-  }
-}

Added: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/UpgradeTask.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/UpgradeTask.java	                        (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/UpgradeTask.java	2009-10-18 08:03:52 UTC (rev 5753)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.db.internal.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.jbpm.db.internal.upgrade.UpgradeTool;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class UpgradeTask extends Task {
+
+  private String jbpmCfg;
+
+  @Override
+  public void execute() throws BuildException {
+    UpgradeTool upgradeTool = jbpmCfg == null ? new UpgradeTool() : new UpgradeTool(jbpmCfg);
+    try {
+      upgradeTool.upgrade();
+    }
+    catch (Exception e) {
+      e.printStackTrace();
+      throw new BuildException("failed to upgrade jbpm database");
+    }
+  }
+
+  public void setJbpmCfg(String jbpmCfg) {
+    this.jbpmCfg = jbpmCfg;
+  }
+
+}


Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/UpgradeTask.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java	2009-10-18 08:03:52 UTC (rev 5753)
@@ -0,0 +1,52 @@
+/*
+ * 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.internal.upgrade;
+
+import java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
+
+/**
+ * Adds the "langid" property to each deployed process.
+ * 
+ * @author Alejandro Guizar
+ */
+public class AddLangIdCmd implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+
+  public Void execute(Environment environment) throws Exception {
+    Session session = environment.get(Session.class);
+    // find process definitions without a langid property
+    List processDefinitions = session.createCriteria(JpdlProcessDefinition.class).list();
+    // initialize missing langid property to "jpdl-4.0"
+    for (Object element : processDefinitions) {
+      JpdlProcessDefinition processDefinition = (JpdlProcessDefinition) element;
+      // TODO how?
+    }
+    return null;
+  }
+
+}


Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/InitDbidGeneratorCmd.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/InitDbidGeneratorCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/InitDbidGeneratorCmd.java	2009-10-18 08:03:52 UTC (rev 5753)
@@ -0,0 +1,41 @@
+/*
+ * 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.internal.upgrade;
+
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.pvm.internal.id.DatabaseDbidGenerator;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class InitDbidGeneratorCmd implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+
+  public Void execute(Environment environment) throws Exception {
+    DatabaseDbidGenerator dbidGenerator = environment.get(DatabaseDbidGenerator.class);
+    dbidGenerator.initialize();
+    return null;
+  }
+
+}


Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/InitDbidGeneratorCmd.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java	2009-10-18 08:03:52 UTC (rev 5753)
@@ -0,0 +1,47 @@
+/*
+ * 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.internal.upgrade;
+
+import java.util.List;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.tool.hbm2ddl.SchemaUpdate;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+
+/**
+ * Executes the Hibernate schema update tool.
+ * 
+ * @author Alejandro Guizar
+ */
+public class UpdateSchemaCmd implements Command<List<Exception>> {
+
+  private static final long serialVersionUID = 1L;
+
+  @SuppressWarnings("unchecked")
+  public List<Exception> execute(Environment environment) throws Exception {
+    SchemaUpdate schemaUpdate = new SchemaUpdate(environment.get(Configuration.class));
+    schemaUpdate.execute(false, true);
+    return schemaUpdate.getExceptions();
+  }
+
+}


Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java (from rev 5748, jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbUpgrade.java)
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java	                        (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java	2009-10-18 08:03:52 UTC (rev 5753)
@@ -0,0 +1,61 @@
+/*
+ * 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.internal.upgrade;
+
+import java.util.List;
+
+import org.jbpm.api.Configuration;
+import org.jbpm.api.ProcessEngine;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class UpgradeTool {
+
+  private final ProcessEngine processEngine;
+
+  public UpgradeTool() {
+    processEngine = Configuration.getProcessEngine();
+  }
+
+  public UpgradeTool(String configResource) {
+    processEngine = new Configuration().setResource(configResource).buildProcessEngine();
+  }
+
+  public void upgrade() throws Exception {
+    // update database schema
+    List<Exception> exceptions = processEngine.execute(new UpdateSchemaCmd());
+    if (!exceptions.isEmpty())
+      throw exceptions.get(0);
+
+    // add property "langid" to each deployed process
+    processEngine.execute(new AddLangIdCmd());
+
+    // initialize database id generator
+    processEngine.execute(new InitDbidGeneratorCmd());
+  }
+
+  public static void main(String[] args) throws Exception {
+    UpgradeTool upgradeTool = args.length == 0 ? new UpgradeTool() : new UpgradeTool(args[0]);
+    upgradeTool.upgrade();
+  }
+}


Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:mergeinfo
   + 



More information about the jbpm-commits mailing list