[jbpm-commits] JBoss JBPM SVN: r5743 - in jbpm3/branches/jbpm-3.2-soa/modules: core/src/main/java/org/jbpm/db and 4 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Oct 15 03:43:15 EDT 2009
Author: alex.guizar at jboss.com
Date: 2009-10-15 03:43:15 -0400 (Thu, 15 Oct 2009)
New Revision: 5743
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/ant/JbpmSchemaTask.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/ant/StartJBossTask.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlWriter.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/util/IoUtil.java
jbpm3/branches/jbpm-3.2-soa/modules/db/pom.xml
jbpm3/branches/jbpm-3.2-soa/modules/db/scripts/antrun-jbpmschema.xml
Log:
[JBPM-2582] put correct delimiters in sql scripts;
switch to jconnect as jtds does not inform correctly about foreign keys
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/ant/JbpmSchemaTask.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/ant/JbpmSchemaTask.java 2009-10-15 00:04:47 UTC (rev 5742)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/ant/JbpmSchemaTask.java 2009-10-15 07:43:15 UTC (rev 5743)
@@ -30,9 +30,11 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.SQLExec.DelimiterType;
import org.hibernate.cfg.Configuration;
import org.jbpm.db.JbpmSchema;
+import org.jbpm.util.IoUtil;
public class JbpmSchemaTask extends Task {
@@ -40,7 +42,8 @@
String properties;
String action = "create";
String output;
- String delimiter;
+ String delimiter = ";";
+ String delimiterType = DelimiterType.NORMAL;
public void execute() throws BuildException {
// Create schema tool
@@ -93,7 +96,8 @@
Configuration configuration = AntHelper.getConfiguration(config, properties);
JbpmSchema jbpmSchema = new JbpmSchema(configuration);
- jbpmSchema.setDelimiter(delimiter);
+ jbpmSchema.setDelimiter(DelimiterType.ROW.equals(delimiterType) ? IoUtil.lineSeparator
+ + delimiter : delimiter);
return jbpmSchema;
}
@@ -123,6 +127,10 @@
this.delimiter = delimiter;
}
+ public void setDelimiterType(DelimiterType delimiterType) {
+ this.delimiterType = delimiterType.getValue();
+ }
+
public void setOutput(String output) {
this.output = output;
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/ant/StartJBossTask.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/ant/StartJBossTask.java 2009-10-15 00:04:47 UTC (rev 5742)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/ant/StartJBossTask.java 2009-10-15 07:43:15 UTC (rev 5743)
@@ -21,45 +21,45 @@
*/
package org.jbpm.ant;
+import java.io.File;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
public class StartJBossTask extends Task {
-
+
private static final String END_MESSAGE = " Started in ";
-
+
String configuration = null;
public void execute() throws BuildException {
try {
// get some environment variableInstances
- String fileSeparator = System.getProperty( "file.separator" );
- String jbossHome = getProject().getProperty( "jboss.home" );
- String os = getProject().getProperty( "os.name" ).toLowerCase();
-
+ char fileSeparator = File.separatorChar;
+ boolean isWindows = System.getProperty("os.name").startsWith("Windows");
+
// build the command string
- String command = null;
- if ( os.indexOf( "windows" ) != -1 ) {
- command = jbossHome + fileSeparator + "bin" + fileSeparator + "run.bat " + getConfigParameter();
- } else if ( os.indexOf( "linux" ) != -1 ) {
- command = jbossHome + fileSeparator + "bin" + fileSeparator + "run.sh " + getConfigParameter();
- } else {
- throw new BuildException( "os '" + os + "' not supported in the startjboss task." );
- }
+ String command = getProject().getProperty("jboss.home")
+ + fileSeparator
+ + "bin"
+ + fileSeparator
+ + (isWindows ? "run.bat" : "run.sh")
+ + getConfigParameter();
// launch the command and wait till the END_MESSAGE appears
Thread launcher = new Launcher(this, command, END_MESSAGE);
launcher.start();
launcher.join();
-
- } catch (Exception e) {
+
+ }
+ catch (Exception e) {
e.printStackTrace();
}
}
-
+
String getConfigParameter() {
- if (configuration==null) return "";
- return "-c "+configuration;
+ if (configuration == null) return "";
+ return "-c " + configuration;
}
public void setConfiguration(String configuration) {
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2009-10-15 00:04:47 UTC (rev 5742)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2009-10-15 07:43:15 UTC (rev 5743)
@@ -58,6 +58,7 @@
import org.hibernate.util.JDBCExceptionReporter;
import org.jbpm.JbpmException;
+import org.jbpm.util.IoUtil;
/**
* utilities for the jBPM database schema.
@@ -244,11 +245,10 @@
}
public void writeSql(Writer writer, String[] script) throws IOException {
- String lineSeparator = System.getProperty("line.separator");
for (int i = 0; i < script.length; i++) {
writer.write(script[i]);
if (delimiter != null) writer.write(delimiter);
- writer.write(lineSeparator);
+ writer.write(IoUtil.lineSeparator);
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlWriter.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlWriter.java 2009-10-15 00:04:47 UTC (rev 5742)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlWriter.java 2009-10-15 07:43:15 UTC (rev 5743)
@@ -47,6 +47,7 @@
import org.jbpm.graph.node.ProcessFactory;
import org.jbpm.graph.node.StartState;
import org.jbpm.jpdl.JpdlException;
+import org.jbpm.util.IoUtil;
/**
* Class for writing process definitions to character streams.
@@ -115,8 +116,8 @@
private Document createDomTree(ProcessDefinition processDefinition) {
Document document = DocumentHelper.createDocument();
- Element root = null;
+ Element root;
if (useNamespace)
root = document.addElement("process-definition", jbpmNamespace.getURI());
else
@@ -144,7 +145,7 @@
writeActions(root, namedProcessActions);
}
- root.addText(System.getProperty("line.separator"));
+ root.addText(IoUtil.lineSeparator);
return document;
}
@@ -253,7 +254,7 @@
}
private void writeComment(Element element, String comment) {
- element.addText(System.getProperty("line.separator"));
+ element.addText(IoUtil.lineSeparator);
element.addComment(" " + comment + " ");
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/util/IoUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/util/IoUtil.java 2009-10-15 00:04:47 UTC (rev 5742)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/util/IoUtil.java 2009-10-15 07:43:15 UTC (rev 5743)
@@ -25,11 +25,20 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
public class IoUtil {
- private static final int BUFFERSIZE = 4096;
+ private static final int BUFFER_SIZE = 4096;
+ public static final String lineSeparator = (String) AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty("line.separator");
+ }
+ });
+
// hide default constructor
private IoUtil() {
}
@@ -42,7 +51,7 @@
public static int transfer(InputStream in, OutputStream out) throws IOException {
int total = 0;
- byte[] buffer = new byte[BUFFERSIZE];
+ byte[] buffer = new byte[BUFFER_SIZE];
for (int bytesRead; (bytesRead = in.read(buffer)) != -1; total += bytesRead) {
out.write(buffer, 0, bytesRead);
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/db/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/db/pom.xml 2009-10-15 00:04:47 UTC (rev 5742)
+++ jbpm3/branches/jbpm-3.2-soa/modules/db/pom.xml 2009-10-15 07:43:15 UTC (rev 5743)
@@ -64,7 +64,7 @@
<executions>
<execution>
<id>update-schema</id>
- <phase>process-resources</phase>
+ <phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
@@ -98,6 +98,11 @@
<scope>runtime</scope>
</dependency>
<dependency>
+ <groupId>com.sybase</groupId>
+ <artifactId>jconnect</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<scope>runtime</scope>
@@ -181,7 +186,7 @@
<executions>
<execution>
<id>create-drop-schema</id>
- <phase>generate-resources</phase>
+ <phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
Modified: jbpm3/branches/jbpm-3.2-soa/modules/db/scripts/antrun-jbpmschema.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/db/scripts/antrun-jbpmschema.xml 2009-10-15 00:04:47 UTC (rev 5742)
+++ jbpm3/branches/jbpm-3.2-soa/modules/db/scripts/antrun-jbpmschema.xml 2009-10-15 07:43:15 UTC (rev 5743)
@@ -45,23 +45,21 @@
action="create" />
<jbpmschema output="${project.output.dir}/jbpm.jpdl.mysql.sql"
config="hibernate.cfg.mysql.xml"
- action="create"
- delimiter=";" />
+ action="create" />
<jbpmschema output="${project.output.dir}/jbpm.jpdl.oracle.sql"
config="hibernate.cfg.oracle.xml"
- action="create"
- delimiter=";" />
+ action="create" />
<jbpmschema output="${project.output.dir}/jbpm.jpdl.postgresql.sql"
config="hibernate.cfg.postgresql.xml"
- action="create"
- delimiter=";" />
+ action="create" />
<jbpmschema output="${project.output.dir}/jbpm.jpdl.sapdb.sql"
config="hibernate.cfg.sapdb.xml"
action="create" />
<jbpmschema output="${project.output.dir}/jbpm.jpdl.sybase.sql"
config="hibernate.cfg.sybase.xml"
- action="create" />
- <concat destfile="${project.output.dir}/jbpm.jpdl.sybase.sql" append="yes">go</concat>
+ action="create"
+ delimiter="go"
+ delimiterType="row" />
</target>
<target name="drop-schema" depends="init" description="Generate schema drop scripts">
@@ -76,40 +74,39 @@
action="drop" />
<jbpmschema output="${project.output.dir}/jbpm.jpdl.mysql.drop.sql"
config="hibernate.cfg.mysql.xml"
- action="drop"
- delimiter=";" />
+ action="drop" />
<jbpmschema output="${project.output.dir}/jbpm.jpdl.oracle.drop.sql"
config="hibernate.cfg.oracle.xml"
- action="drop"
- delimiter=";" />
+ action="drop" />
<jbpmschema output="${project.output.dir}/jbpm.jpdl.postgresql.drop.sql"
config="hibernate.cfg.postgresql.xml"
- action="drop"
- delimiter=";" />
+ action="drop" />
<jbpmschema output="${project.output.dir}/jbpm.jpdl.sybase.drop.sql"
config="hibernate.cfg.sybase.xml"
- action="drop" />
- <concat destfile="${project.output.dir}/jbpm.jpdl.sybase.drop.sql" append="yes">go</concat>
+ action="drop"
+ delimiter="go"
+ delimiterType="row" />
</target>
<target name="update-schema" depends="init" description="Generate schema update scripts">
- <generate-update-script db="db2" delimiter=";" />
- <generate-update-script db="mssql" delimiter=";" />
- <generate-update-script db="mysql" delimiter=";" />
- <generate-update-script db="oracle" delimiter=";" />
- <generate-update-script db="postgresql" delimiter=";" />
- <generate-update-script db="sybase" />
+ <!--generate-update-script db="db2" /-->
+ <!--generate-update-script db="mssql" /-->
+ <generate-update-script db="mysql" />
+ <!--generate-update-script db="oracle" /-->
+ <generate-update-script db="postgresql" />
+ <generate-update-script db="sybase" delimiter="go" delimitertype="row" />
</target>
<macrodef name="generate-update-script">
<attribute name="db" />
- <attribute name="delimiter" />
+ <attribute name="delimiter" default=";" />
+ <attribute name="delimitertype" default="normal" />
+
<sequential>
<hbproperties config="hibernate.cfg.@{db}.xml"
prefix="@{db}."
includes="hibernate\.connection\..*" />
- <echo>Dropping current schema @{db}</echo>
<sql src="${project.output.dir}/jbpm.jpdl.@{db}.drop.sql"
url="${@{db}.hibernate.connection.url}"
driver="${@{db}.hibernate.connection.driver_class}"
@@ -117,9 +114,10 @@
password="${@{db}.hibernate.connection.password}"
classpathref="maven.runtime.classpath"
autocommit="yes"
- onerror="continue" />
+ onerror="continue"
+ delimiter="@{delimiter}"
+ delimitertype="@{delimitertype}" />
- <echo>Creating previous schema @{db}</echo>
<sql src="${previous.version.dir}/jbpm.jpdl.@{db}.sql"
url="${@{db}.hibernate.connection.url}"
driver="${@{db}.hibernate.connection.driver_class}"
@@ -127,33 +125,27 @@
password="${@{db}.hibernate.connection.password}"
classpathref="maven.runtime.classpath"
autocommit="yes"
- onerror="continue" />
+ onerror="continue"
+ delimiter="@{delimiter}"
+ delimitertype="@{delimitertype}" />
- <echo>Generating update script @{db}</echo>
+ <echo>Generating @{db} update schema</echo>
<jbpmschema output="${project.output.dir}/jbpm.jpdl.@{db}.update.sql"
config="hibernate.cfg.@{db}.xml"
action="update"
- delimiter="@{delimiter}" />
+ delimiter="@{delimiter}"
+ delimitertype="@{delimitertype}" />
- <echo>Dropping previous schema @{db}</echo>
- <sql src="${project.output.dir}/jbpm.jpdl.@{db}.drop.sql"
+ <sql src="${project.output.dir}/jbpm.jpdl.@{db}.update.sql"
url="${@{db}.hibernate.connection.url}"
driver="${@{db}.hibernate.connection.driver_class}"
userid="${@{db}.hibernate.connection.username}"
password="${@{db}.hibernate.connection.password}"
- classpathref="maven.compile.classpath"
- autocommit="yes"
- onerror="continue" />
-
- <echo>Creating current schema @{db}</echo>
- <sql src="${project.output.dir}/jbpm.jpdl.@{db}.sql"
- url="${@{db}.hibernate.connection.url}"
- driver="${@{db}.hibernate.connection.driver_class}"
- userid="${@{db}.hibernate.connection.username}"
- password="${@{db}.hibernate.connection.password}"
classpathref="maven.runtime.classpath"
autocommit="yes"
- onerror="continue" />
+ onerror="continue"
+ delimiter="@{delimiter}"
+ delimitertype="@{delimitertype}" />
</sequential>
</macrodef>
</project>
More information about the jbpm-commits
mailing list