JBoss JBPM SVN: r5862 - projects/bbq/projects/bbq-core/build.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-30 21:00:54 -0400 (Fri, 30 Oct 2009)
New Revision: 5862
Modified:
projects/bbq/projects/bbq-core/build/
Log:
added gen to svn:ignore
Property changes on: projects/bbq/projects/bbq-core/build
___________________________________________________________________
Name: svn:ignore
+ gen
16 years, 6 months
JBoss JBPM SVN: r5860 - projects/bbq/projects/bbq-test-project/build.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-30 20:58:33 -0400 (Fri, 30 Oct 2009)
New Revision: 5860
Modified:
projects/bbq/projects/bbq-test-project/build/
Log:
added gen to svn:ignore
Property changes on: projects/bbq/projects/bbq-test-project/build
___________________________________________________________________
Name: svn:ignore
+ gen
16 years, 6 months
JBoss JBPM SVN: r5859 - in projects/bbq/projects/bbq-core/src: org and 3 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-30 20:57:56 -0400 (Fri, 30 Oct 2009)
New Revision: 5859
Added:
projects/bbq/projects/bbq-core/src/org/
projects/bbq/projects/bbq-core/src/org/bbq/
projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java
projects/bbq/projects/bbq-core/src/org/bbq/BbqException.java
projects/bbq/projects/bbq-core/src/org/bbq/commands/
projects/bbq/projects/bbq-core/src/org/bbq/commands/Exec.java
projects/bbq/projects/bbq-core/src/org/bbq/commands/Java.java
projects/bbq/projects/bbq-core/src/org/bbq/commands/Javac.java
projects/bbq/projects/bbq-core/src/org/bbq/commands/MkDir.java
projects/bbq/projects/bbq-core/src/org/bbq/system/
projects/bbq/projects/bbq-core/src/org/bbq/system/Console.java
projects/bbq/projects/bbq-core/src/org/bbq/system/FileList.java
projects/bbq/projects/bbq-core/src/org/bbq/system/FileScan.java
projects/bbq/projects/bbq-core/src/org/bbq/system/Os.java
projects/bbq/projects/bbq-core/src/org/bbq/system/Path.java
Log:
uploading bbq second attempt
Added: projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java (rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java 2009-10-31 00:57:56 UTC (rev 5859)
@@ -0,0 +1,63 @@
+/*
+ * 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.bbq;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import org.bbq.commands.Javac;
+import org.bbq.commands.MkDir;
+import org.bbq.system.Console;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Bbq {
+
+ public static void main(String[] args) {
+ String buildClasspath = System.getProperty("java.class.path");
+
+ new Javac()
+ .srcDir("build/src")
+ .destDir("build/gen/build-classes")
+ .classPath(buildClasspath)
+ .execute();
+
+ try {
+ URL[] urls = {new File("build/gen/build-classes").toURL()};
+ ClassLoader classLoader = new URLClassLoader(urls , Bbq.class.getClassLoader());
+ Class<?> buildClass = Class.forName("Build", true, classLoader);
+ for (String operation: args) {
+ Method method = buildClass.getDeclaredMethod(operation);
+ Object result = method.invoke(null, (Object[])null);
+ if (result!=null) {
+ Console.log("result of "+operation+": "+result);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-core/src/org/bbq/BbqException.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/BbqException.java (rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/BbqException.java 2009-10-31 00:57:56 UTC (rev 5859)
@@ -0,0 +1,38 @@
+/*
+ * 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.bbq;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BbqException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public BbqException(String message) {
+ super(message);
+ }
+ public BbqException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/BbqException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-core/src/org/bbq/commands/Exec.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/commands/Exec.java (rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/commands/Exec.java 2009-10-31 00:57:56 UTC (rev 5859)
@@ -0,0 +1,64 @@
+/*
+ * 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.bbq.commands;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.List;
+
+import org.bbq.BbqException;
+import org.bbq.system.Console;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Exec {
+
+ List<String> cmd;
+
+ public Exec(List<String> cmd) {
+ this.cmd = cmd;
+ }
+
+ public void execute() {
+ try {
+ String msg = "exec";
+ for (String cmdPart: cmd) {
+ msg += " "+cmdPart;
+ }
+ Console.log(msg);
+
+ ProcessBuilder processBuilder = new ProcessBuilder(cmd);
+ processBuilder.redirectErrorStream();
+ Process process = processBuilder.start();
+
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
+ for (String line = bufferedReader.readLine(); line!=null; line = bufferedReader.readLine()) {
+ Console.log(" |"+line);
+ }
+
+ } catch (Exception e) {
+ throw new BbqException("couldn't exec "+cmd, e);
+ }
+ }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/commands/Exec.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-core/src/org/bbq/commands/Java.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/commands/Java.java (rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/commands/Java.java 2009-10-31 00:57:56 UTC (rev 5859)
@@ -0,0 +1,74 @@
+/*
+ * 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.bbq.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.bbq.system.Os;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Java {
+
+ static String JAVA_HOME = System.getenv("JAVA_HOME");
+
+ String classPath;
+ String className;
+ String[] args;
+
+ public Java classPath(String classPath) {
+ this.classPath = classPath;
+ return this;
+ }
+
+ public Java className(String className) {
+ this.className = className;
+ return this;
+ }
+
+ public Java args(String[] args) {
+ this.args = args;
+ return this;
+ }
+
+ public void execute() {
+ // build up the command
+ List<String> cmd = new ArrayList<String>();
+ cmd.add(Java.JAVA_HOME+Os.FILE_SEPARATOR+"bin"+Os.FILE_SEPARATOR+"java");
+ cmd.add("-classpath");
+ cmd.add(classPath);
+ cmd.add(className);
+
+ if (args!=null) {
+ for (String arg: args) {
+ cmd.add(arg);
+ }
+ }
+
+ // execute it
+ new Exec(cmd)
+ .execute();
+ }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/commands/Java.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-core/src/org/bbq/commands/Javac.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/commands/Javac.java (rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/commands/Javac.java 2009-10-31 00:57:56 UTC (rev 5859)
@@ -0,0 +1,98 @@
+/*
+ * 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.bbq.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.bbq.system.FileList;
+import org.bbq.system.FileScan;
+import org.bbq.system.Os;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Javac {
+
+ FileList sourceFiles = new FileList();
+ boolean verbose;
+ String destDir;
+ String classPath;
+
+ public Javac srcDir(String srcDir) {
+ FileList sourceFiles = new FileScan(srcDir)
+ .filterEnd(".java")
+ .execute();
+
+ this.sourceFiles.add( sourceFiles );
+
+ return this;
+ }
+
+ public Javac srcFile(String srcFile) {
+ this.sourceFiles.add( srcFile );
+
+ return this;
+ }
+
+ public Javac destDir(String dirPath) {
+ this.destDir = dirPath;
+ return this;
+ }
+
+ public Javac classPath(String classPath) {
+ this.classPath = classPath;
+ return this;
+ }
+
+ public Javac verbose() {
+ this.verbose = true;
+ return this;
+ }
+
+ public void execute() {
+ // create the destination directory
+ new MkDir(destDir)
+ .execute();
+
+ // build up the compile command
+ List<String> cmd = new ArrayList<String>();
+ cmd.add(Java.JAVA_HOME+Os.FILE_SEPARATOR+"bin"+Os.FILE_SEPARATOR+"javac");
+ cmd.add("-d");
+ cmd.add(destDir);
+ if (classPath!=null) {
+ cmd.add("-classpath");
+ cmd.add(classPath);
+ }
+ if (verbose) {
+ cmd.add("-verbose");
+ }
+ for (String fileName: sourceFiles.list()) {
+ cmd.add(fileName);
+ }
+
+ // execute the compile command
+ new Exec(cmd)
+ .execute();
+ }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/commands/Javac.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-core/src/org/bbq/commands/MkDir.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/commands/MkDir.java (rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/commands/MkDir.java 2009-10-31 00:57:56 UTC (rev 5859)
@@ -0,0 +1,44 @@
+/*
+ * 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.bbq.commands;
+
+import java.io.File;
+
+import org.bbq.system.Console;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class MkDir {
+
+ String dirPath;
+
+ public MkDir(String dirPath) {
+ this.dirPath = dirPath;
+ }
+
+ public void execute() {
+ Console.log("mkdir "+dirPath);
+ new File(dirPath).mkdirs();
+ }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/commands/MkDir.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-core/src/org/bbq/system/Console.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/system/Console.java (rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/system/Console.java 2009-10-31 00:57:56 UTC (rev 5859)
@@ -0,0 +1,33 @@
+/*
+ * 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.bbq.system;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Console {
+
+ public static void log(String msg) {
+ System.err.println(msg);
+ }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/system/Console.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-core/src/org/bbq/system/FileList.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/system/FileList.java (rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/system/FileList.java 2009-10-31 00:57:56 UTC (rev 5859)
@@ -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.bbq.system;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FileList {
+
+ List<String> filePaths = new ArrayList<String>();
+
+ public List<String> list() {
+ return filePaths;
+ }
+
+ public void add(String path) {
+ filePaths.add(path);
+ }
+
+ public void add(FileList other) {
+ filePaths.addAll(other.filePaths);
+ }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/system/FileList.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-core/src/org/bbq/system/FileScan.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/system/FileScan.java (rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/system/FileScan.java 2009-10-31 00:57:56 UTC (rev 5859)
@@ -0,0 +1,86 @@
+/*
+ * 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.bbq.system;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FileScan {
+
+ String rootDir;
+ List<ScanFilter> scanFilters = new ArrayList<ScanFilter>();
+
+ public FileScan(String dirPath) {
+ rootDir = dirPath;
+ }
+
+ public FileList execute() {
+ FileList fileList = new FileList();
+ scan(rootDir, fileList);
+ return fileList;
+ }
+
+ private void scan(String dir, FileList fileList) {
+ File dirFile = new File(dir);
+ for (File child: dirFile.listFiles()) {
+ String childPath = ("".equals(dir) ? child.getName() : dir+"/"+child.getName());
+ if (child.isDirectory()) {
+ scan(childPath, fileList);
+ } else if (passesFilters(childPath, child)) {
+ fileList.add(childPath);
+ }
+ }
+ }
+
+ private boolean passesFilters(String relativePath, File file) {
+ for (ScanFilter scanFilter: scanFilters) {
+ if (!scanFilter.passes(relativePath, file)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private interface ScanFilter {
+ boolean passes(String relativePath, File file);
+ }
+
+ private class EndScanFilter implements ScanFilter {
+ String text;
+ public EndScanFilter(String text) {
+ this.text = text;
+ }
+ public boolean passes(String relativePath, File file) {
+ return relativePath.endsWith(text);
+ }
+ }
+
+ public FileScan filterEnd(String text) {
+ scanFilters.add(new EndScanFilter(text));
+ return this;
+ }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/system/FileScan.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-core/src/org/bbq/system/Os.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/system/Os.java (rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/system/Os.java 2009-10-31 00:57:56 UTC (rev 5859)
@@ -0,0 +1,44 @@
+/*
+ * 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.bbq.system;
+
+import org.bbq.BbqException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Os {
+
+ public static final String WINDOWS = "windows";
+
+ public static final String TYPE = getType();
+ public static final String FILE_SEPARATOR = System.getProperty("file.separator");
+
+ private static String getType() {
+ String name = System.getProperty("os.name");
+ if (name.indexOf("Windows")!=-1) {
+ return WINDOWS;
+ }
+ throw new BbqException("unknown os: "+name);
+ }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/system/Os.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-core/src/org/bbq/system/Path.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/system/Path.java (rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/system/Path.java 2009-10-31 00:57:56 UTC (rev 5859)
@@ -0,0 +1,38 @@
+/*
+ * 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.bbq.system;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Path {
+
+// public static String toOsSpecific(String path) {
+// }
+//
+// public static String toGeneric(String path) {
+// }
+//
+// public static String toAbsolute(String path) {
+// }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/system/Path.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 6 months
JBoss JBPM SVN: r5858 - in projects/bbq/projects: bbq-core and 2 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-30 20:56:31 -0400 (Fri, 30 Oct 2009)
New Revision: 5858
Added:
projects/bbq/projects/bbq-core/
projects/bbq/projects/bbq-core/.classpath
projects/bbq/projects/bbq-core/.project
projects/bbq/projects/bbq-core/bin/
projects/bbq/projects/bbq-core/bin/bbq.bat
projects/bbq/projects/bbq-core/build/
projects/bbq/projects/bbq-core/build/gen/
projects/bbq/projects/bbq-core/src/
Log:
uploading bbq second attempt
Added: projects/bbq/projects/bbq-core/.classpath
===================================================================
--- projects/bbq/projects/bbq-core/.classpath (rev 0)
+++ projects/bbq/projects/bbq-core/.classpath 2009-10-31 00:56:31 UTC (rev 5858)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="build/gen/classes"/>
+</classpath>
Property changes on: projects/bbq/projects/bbq-core/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-core/.project
===================================================================
--- projects/bbq/projects/bbq-core/.project (rev 0)
+++ projects/bbq/projects/bbq-core/.project 2009-10-31 00:56:31 UTC (rev 5858)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>bbq-core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: projects/bbq/projects/bbq-core/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-core/bin/bbq.bat
===================================================================
--- projects/bbq/projects/bbq-core/bin/bbq.bat (rev 0)
+++ projects/bbq/projects/bbq-core/bin/bbq.bat 2009-10-31 00:56:31 UTC (rev 5858)
@@ -0,0 +1,2 @@
+echo using java %JAVA_HOME%
+%JAVA_HOME%/bin/java -cp %~dp0..\build\gen\classes org.bbq.Bbq %*
16 years, 6 months
JBoss JBPM SVN: r5857 - in projects/bbq: projects and 6 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-30 20:46:00 -0400 (Fri, 30 Oct 2009)
New Revision: 5857
Added:
projects/bbq/.project
projects/bbq/projects/
projects/bbq/projects/bbq-test-project/
projects/bbq/projects/bbq-test-project/.classpath
projects/bbq/projects/bbq-test-project/.project
projects/bbq/projects/bbq-test-project/build/
projects/bbq/projects/bbq-test-project/build/src/
projects/bbq/projects/bbq-test-project/build/src/Build.java
projects/bbq/projects/bbq-test-project/src/
projects/bbq/projects/bbq-test-project/src/com/
projects/bbq/projects/bbq-test-project/src/com/myproject/
projects/bbq/projects/bbq-test-project/src/com/myproject/Tool.java
Log:
uploading bbq second attempt
Added: projects/bbq/.project
===================================================================
--- projects/bbq/.project (rev 0)
+++ projects/bbq/.project 2009-10-31 00:46:00 UTC (rev 5857)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>bbq</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
Property changes on: projects/bbq/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-test-project/.classpath
===================================================================
--- projects/bbq/projects/bbq-test-project/.classpath (rev 0)
+++ projects/bbq/projects/bbq-test-project/.classpath 2009-10-31 00:46:00 UTC (rev 5857)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" output="build/gen/build-classes" path="build/src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/bbq-core"/>
+ <classpathentry kind="output" path="build/gen/classes"/>
+</classpath>
Property changes on: projects/bbq/projects/bbq-test-project/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-test-project/.project
===================================================================
--- projects/bbq/projects/bbq-test-project/.project (rev 0)
+++ projects/bbq/projects/bbq-test-project/.project 2009-10-31 00:46:00 UTC (rev 5857)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>bbq-test-project</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: projects/bbq/projects/bbq-test-project/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-test-project/build/src/Build.java
===================================================================
--- projects/bbq/projects/bbq-test-project/build/src/Build.java (rev 0)
+++ projects/bbq/projects/bbq-test-project/build/src/Build.java 2009-10-31 00:46:00 UTC (rev 5857)
@@ -0,0 +1,37 @@
+import org.bbq.commands.Javac;
+
+
+/*
+ * 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.
+ */
+
+/**
+ * @author Tom Baeyens
+ */
+public class Build {
+
+ public static void compile() {
+ new Javac()
+ .srcDir("src")
+ .destDir("build/gen/classes")
+ .execute();
+ }
+}
Property changes on: projects/bbq/projects/bbq-test-project/build/src/Build.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/bbq/projects/bbq-test-project/src/com/myproject/Tool.java
===================================================================
--- projects/bbq/projects/bbq-test-project/src/com/myproject/Tool.java (rev 0)
+++ projects/bbq/projects/bbq-test-project/src/com/myproject/Tool.java 2009-10-31 00:46:00 UTC (rev 5857)
@@ -0,0 +1,30 @@
+/*
+ * 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 com.myproject;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Tool {
+
+}
Property changes on: projects/bbq/projects/bbq-test-project/src/com/myproject/Tool.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 6 months
JBoss JBPM SVN: r5855 - in jbpm4/trunk/qa/cleandb: src/org/jboss/qa and 1 other directory.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-30 12:05:54 -0400 (Fri, 30 Oct 2009)
New Revision: 5855
Added:
jbpm4/trunk/qa/cleandb/.classpath
jbpm4/trunk/qa/cleandb/.project
Modified:
jbpm4/trunk/qa/cleandb/build.xml
jbpm4/trunk/qa/cleandb/pom.xml
jbpm4/trunk/qa/cleandb/src/org/jboss/qa/CleanDatabase.java
Log:
cleandb improvements
Added: jbpm4/trunk/qa/cleandb/.classpath
===================================================================
--- jbpm4/trunk/qa/cleandb/.classpath (rev 0)
+++ jbpm4/trunk/qa/cleandb/.classpath 2009-10-30 16:05:54 UTC (rev 5855)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="bin" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/ant.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: jbpm4/trunk/qa/cleandb/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/qa/cleandb/.project
===================================================================
--- jbpm4/trunk/qa/cleandb/.project (rev 0)
+++ jbpm4/trunk/qa/cleandb/.project 2009-10-30 16:05:54 UTC (rev 5855)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jbpm-qa-cleandb</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: jbpm4/trunk/qa/cleandb/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/qa/cleandb/build.xml
===================================================================
--- jbpm4/trunk/qa/cleandb/build.xml 2009-10-30 09:30:01 UTC (rev 5854)
+++ jbpm4/trunk/qa/cleandb/build.xml 2009-10-30 16:05:54 UTC (rev 5855)
@@ -20,7 +20,7 @@
<arg line="dependency:copy" />
</exec>
<path id="classpath.cleandb">
- <fileset dir="lib" includes="*jar"/>
+ <fileset dir="lib" includes="*jar" excludes="ant.jar" />
<pathelement path="bin"/>
</path>
<taskdef name="cleandb" classname="org.jboss.qa.CleanDatabase" classpathref="classpath.cleandb" />
Modified: jbpm4/trunk/qa/cleandb/pom.xml
===================================================================
--- jbpm4/trunk/qa/cleandb/pom.xml 2009-10-30 09:30:01 UTC (rev 5854)
+++ jbpm4/trunk/qa/cleandb/pom.xml 2009-10-30 16:05:54 UTC (rev 5855)
@@ -54,6 +54,13 @@
<outputDirectory>lib</outputDirectory>
<destFileName>mysql-connector-java.jar</destFileName>
</artifactItem>
+ <artifactItem>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.7.0</version>
+ <outputDirectory>lib</outputDirectory>
+ <destFileName>ant.jar</destFileName>
+ </artifactItem>
</artifactItems>
</configuration>
</plugin>
Modified: jbpm4/trunk/qa/cleandb/src/org/jboss/qa/CleanDatabase.java
===================================================================
--- jbpm4/trunk/qa/cleandb/src/org/jboss/qa/CleanDatabase.java 2009-10-30 09:30:01 UTC (rev 5854)
+++ jbpm4/trunk/qa/cleandb/src/org/jboss/qa/CleanDatabase.java 2009-10-30 16:05:54 UTC (rev 5855)
@@ -1,9 +1,12 @@
package org.jboss.qa;
+
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
@@ -11,189 +14,216 @@
import org.apache.tools.ant.Task;
public class CleanDatabase extends Task {
-
- private String url;
- private String driver;
- private String username;
- private String password;
- private String schema;
- private String dropTableString = null;
- private String dropForeignKeyString = null;
- private boolean dropConstraintsFirst = true;
-
- public void execute() throws BuildException {
- Connection con = null;
- // schema is optional, but let's make it null if it is empty
- if ("".equals(getSchema()))
- setSchema(null);
+
+ static String ORACLE = "oracle";
+ static String MYSQL = "mysql";
+ static String POSTGRESQL = "postgtresql";
+ static String DB2 = "db2";
+ static String HSQLDB = "hsqldb";
+ static String OTHER = "other";
- try {
- Class.forName(getDriver());
- } catch (java.lang.ClassNotFoundException e) {
- throw new BuildException("Driver not found: " + e.getMessage(), e);
- }
-
- try {
- String[] types = {"TABLE"};
- con = DriverManager.getConnection(getUrl(), getUsername(), getPassword());
+ private String url;
+ private String driver;
+ private String username;
+ private String password;
+ private String schema;
+
+ private String dbType;
+ private String quote;
+ private String dropTableString = null;
+ private String dropForeignKeyString = null;
+ private boolean dropConstraintsFirst = true;
- adjustStringsForDatabase(con.getMetaData().getIdentifierQuoteString());
+ public void execute() throws BuildException {
- ResultSet tables = con.getMetaData().getTables(null, getSchema(), null, types);
-
- // DROP CONSTRAINTS
- if (isDropConstraintsFirst()) {
-
- while (tables.next()) {
- String table = tables.getString("TABLE_NAME");
+ Connection connection = null;
+ try {
+ connection = getConnection();
+ initialize(connection);
- String schema = getSchema();
- if (null == schema && tables.getString("TABLE_SCHEM") != null)
- schema = tables.getString("TABLE_SCHEM");
-
- ResultSet fksrs = con.getMetaData().getImportedKeys(null, schema, table);
+ List<String> tableNames = getTableNames(connection);
- // we are interested in the FK's only, not in the column they represent...
- // the above method returns one record for each column which is part of a FK
- // eg:
- // FK1 represents CUST_ID and ORDR_NUM from EMBD_KM2O_ORDR table
- // it returns two rows, but we want to drop the constraint (one record).
- // So, we use another list, to get rid of "duplicates"
- Set<String> fks = new HashSet<String>();
- while (fksrs.next()) {
- fks.add(fksrs.getString("FK_NAME"));
- }
-
- for (String fkname : fks) {
- if (fkname != null) {
- try {
- String stmt = getDropForeignKeyString()
- .replaceAll("@SCHEMA@.", schema == null ? "" : Matcher.quoteReplacement(schema)+".")
- .replaceAll("@TABLE@", Matcher.quoteReplacement(table))
- .replaceAll("@FK@", Matcher.quoteReplacement(fkname));
- log("Issuing drop foreign key command:" + stmt);
- con.createStatement().executeUpdate(stmt);
- } catch(Exception e) {
- throw new BuildException("Something went wrong on dropping the FK "+fkname+" from table " + table + ": " + e.getMessage(), e);
- }
- }
- }
- }
- }
+ if (dbType==MYSQL) {
+ for (String tableName : tableNames) {
+ Set<String> foreignKeyNames = getForeignKeyNames(connection, tableName);
+ for (String foreignKeyName : foreignKeyNames) {
+ String stmt = dropForeignKeyString
+ .replaceAll("@TABLE@", Matcher.quoteReplacement(tableName))
+ .replaceAll("@FK@", Matcher.quoteReplacement(foreignKeyName));
+ log("dropping foreign key: " + stmt);
+ connection.createStatement().executeUpdate(stmt);
+ }
+ }
+ }
- // DROP TABLE -- get a fresh result, as some drivers seems to get crazy on .first or .beforeFirst...
- tables = con.getMetaData().getTables(null, getSchema(), null, types);
- while (tables.next()) {
- String table = tables.getString("TABLE_NAME");
- try {
- String stmt = getDropTableString()
- .replaceAll("@SCHEMA@.", schema == null ? "" : Matcher.quoteReplacement(schema)+".")
- .replaceAll("@TABLE@", Matcher.quoteReplacement(table));
- log("Issuing drop table command:" + stmt);
- con.createStatement().executeUpdate(stmt);
- } catch(Exception e) {
- throw new BuildException("Something went wrong on dropping table " + table + ": " + e.getMessage(), e);
- }
- }
+ for (String tableName: tableNames) {
+ String stmt = dropTableString
+ .replaceAll("@TABLE@", Matcher.quoteReplacement(tableName));
+ log("dropping table: " + stmt);
+ connection.createStatement().executeUpdate(stmt);
+ }
- } catch (Exception e) {
- throw new BuildException(e);
- } finally {
- if (con != null) {
- try {
- if (!con.isClosed()) con.close();
- } catch (SQLException e) {}
- }
- }
- }
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new BuildException(e);
- private void adjustStringsForDatabase(String quoteChar) {
- setDropTableString("DROP TABLE "+quoteChar+"@TABLE@"+quoteChar);
- setDropForeignKeyString("ALTER TABLE "+quoteChar+"@TABLE@"+quoteChar+" DROP CONSTRAINT "+quoteChar+"@FK@"+quoteChar);
+ } finally {
+ if (connection != null) {
+ try {
+ if (!connection.isClosed()) {
+ connection.close();
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
- if (getUrl().startsWith("jdbc:mysql")) {
- setDropForeignKeyString("ALTER TABLE "+quoteChar+"@TABLE@"+quoteChar+" DROP FOREIGN KEY "+quoteChar+"@FK@"+quoteChar);
- setDropConstraintsFirst(true);
- }
+ private List<String> getTableNames(Connection connection) throws Exception {
+ List<String> tableNames = new ArrayList<String>();
+
+ String[] types = { "TABLE" };
+ ResultSet resultSet = connection.getMetaData().getTables(null, schema, null, types);
+ while (resultSet.next()) {
+ String tableName = resultSet.getString("TABLE_NAME");
+ if ( tableName.startsWith("JBPM")
+ || tableName.startsWith("jbpm")
+ ) {
+ log("adding table "+tableName);
+ tableNames.add(tableName);
+ } else {
+ log("--- skipping table "+tableName+" ---");
+ }
+ }
+
+ return tableNames;
+ }
- if (getUrl().startsWith("jdbc:postgresql")) {
- setDropTableString(getDropTableString() + " CASCADE");
- setDropConstraintsFirst(false);
- }
+ private Set<String> getForeignKeyNames(Connection connection, String table) throws Exception {
+ ResultSet resultSet = connection.getMetaData().getImportedKeys(null, schema, table);
+ // we are interested in the FK's only, not in the column they
+ // represent...
+ // the above method returns one record for each column which is part
+ // of a FK
+ // eg:
+ // FK1 represents CUST_ID and ORDR_NUM from EMBD_KM2O_ORDR table
+ // it returns two rows, but we want to drop the constraint (one
+ // record).
+ // So, we use another list, to get rid of "duplicates"
+ Set<String> foreignKeyNames = new HashSet<String>();
+ while (resultSet.next()) {
+ String foreignKeyName = resultSet.getString("FK_NAME");
+ if (foreignKeyName != null) {
+ foreignKeyNames.add(foreignKeyName);
+ }
+ }
+ return foreignKeyNames;
+ }
- if (getUrl().startsWith("jdbc:oracle")) {
- setDropTableString(getDropTableString() + " CASCADE CONSTRAINTS");
- setDropConstraintsFirst(false);
- }
+ private Connection getConnection() throws Exception {
+ // initialize the JDBC driver
+ log("initializing JDBC driver "+getDriver());
+ Class.forName(getDriver());
+
+ // create the connection
+ log("creating JDBC connection "+getUrl());
+ return DriverManager.getConnection(getUrl(), getUsername(), getPassword());
+ }
- if (getUrl().startsWith("jdbc:db2")) {
- // db2 drops the constraints by default, when dropping a table
- setDropConstraintsFirst(false);
- }
- }
+ private void initialize(Connection connection) throws Exception {
+ quote = connection.getMetaData().getIdentifierQuoteString();
- public String getUrl() {
- return url;
- }
+ // schema is optional, but let's make it null if it is empty
+ if ("".equals(schema)) {
+ schema = null;
+ }
- public void setUrl(String url) {
- this.url = url;
- }
+ if (getUrl().startsWith("jdbc:mysql")) {
+ dbType = MYSQL;
+ dropForeignKeyString = "ALTER TABLE " + quote + "@TABLE@" + quote + " DROP FOREIGN KEY " + quote + "@FK@" + quote;
+
+ } else if (getUrl().startsWith("jdbc:postgresql")) {
+ dbType = POSTGRESQL;
+ dropTableString = getDropTableString() + " CASCADE";
+
+ } else if (getUrl().startsWith("jdbc:oracle")) {
+ dbType = ORACLE;
+ dropTableString = "DROP TABLE "+(schema!=null ? quote+schema+quote+"." : "")+quote+"@TABLE@"+quote+" CASCADE CONSTRAINTS";
+
+ } else if (getUrl().startsWith("jdbc:db2")) {
+ dbType = DB2;
+ // db2 drops the constraints by default, when dropping a table
+
+ } else {
+ dbType = OTHER;
+ dropTableString = "DROP TABLE " + (schema!=null ? quote+schema+"." : "") + quote + "@TABLE@" + quote;
+ dropForeignKeyString = "ALTER TABLE " + quote + "@TABLE@" + quote + " DROP CONSTRAINT " + quote + "@FK@" + quote;
+ }
+ }
- public String getDriver() {
- return driver;
- }
+ public String getUrl() {
+ return url;
+ }
- public void setDriver(String driver) {
- this.driver = driver;
- }
+ public void setUrl(String url) {
+ this.url = url;
+ }
- public String getUsername() {
- return username;
- }
+ public String getDriver() {
+ return driver;
+ }
- public void setUsername(String username) {
- this.username = username;
- }
+ public void setDriver(String driver) {
+ this.driver = driver;
+ }
- public String getPassword() {
- return password;
- }
+ public String getUsername() {
+ return username;
+ }
- public void setPassword(String password) {
- this.password = password;
- }
+ public void setUsername(String username) {
+ this.username = username;
+ }
- public String getSchema() {
- return schema;
- }
+ public String getPassword() {
+ return password;
+ }
- public void setSchema(String schema) {
- this.schema = schema;
- }
+ public void setPassword(String password) {
+ this.password = password;
+ }
- public String getDropTableString() {
- return dropTableString;
- }
+ public String getSchema() {
+ return schema;
+ }
- public void setDropTableString(String dropTableString) {
- this.dropTableString = dropTableString;
- }
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
- public String getDropForeignKeyString() {
- return dropForeignKeyString;
- }
+ public String getDropTableString() {
+ return dropTableString;
+ }
- public void setDropForeignKeyString(String dropForeignKeyString) {
- this.dropForeignKeyString = dropForeignKeyString;
- }
-
- public boolean isDropConstraintsFirst() {
- return dropConstraintsFirst;
- }
+ public void setDropTableString(String dropTableString) {
+ this.dropTableString = dropTableString;
+ }
- public void setDropConstraintsFirst(boolean dropConstraintsFirst) {
- this.dropConstraintsFirst = dropConstraintsFirst;
- }
+ public String getDropForeignKeyString() {
+ return dropForeignKeyString;
+ }
+ public void setDropForeignKeyString(String dropForeignKeyString) {
+ this.dropForeignKeyString = dropForeignKeyString;
+ }
+
+ public boolean isDropConstraintsFirst() {
+ return dropConstraintsFirst;
+ }
+
+ public void setDropConstraintsFirst(boolean dropConstraintsFirst) {
+ this.dropConstraintsFirst = dropConstraintsFirst;
+ }
+
}
\ No newline at end of file
16 years, 6 months
JBoss JBPM SVN: r5854 - jbpm4/trunk/qa/cleandb.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-30 05:30:01 -0400 (Fri, 30 Oct 2009)
New Revision: 5854
Modified:
jbpm4/trunk/qa/cleandb/
Log:
adding lib and bin dirs to svn:ignore
Property changes on: jbpm4/trunk/qa/cleandb
___________________________________________________________________
Name: svn:ignore
+ bin
lib
16 years, 6 months
JBoss JBPM SVN: r5853 - in jbpm4/trunk/qa: cleandb and 4 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-30 05:29:12 -0400 (Fri, 30 Oct 2009)
New Revision: 5853
Added:
jbpm4/trunk/qa/cleandb/
jbpm4/trunk/qa/cleandb/build.xml
jbpm4/trunk/qa/cleandb/pom.xml
jbpm4/trunk/qa/cleandb/src/
jbpm4/trunk/qa/cleandb/src/org/
jbpm4/trunk/qa/cleandb/src/org/jboss/
jbpm4/trunk/qa/cleandb/src/org/jboss/qa/
jbpm4/trunk/qa/cleandb/src/org/jboss/qa/CleanDatabase.java
Log:
adding cleandb tool
Added: jbpm4/trunk/qa/cleandb/build.xml
===================================================================
--- jbpm4/trunk/qa/cleandb/build.xml (rev 0)
+++ jbpm4/trunk/qa/cleandb/build.xml 2009-10-30 09:29:12 UTC (rev 5853)
@@ -0,0 +1,41 @@
+<project default="clean">
+
+ <!-- checking database property -->
+ <fail message="property database must be specified" unless="database"/>
+
+ <!-- loading jdbc properties -->
+ <echo message="loading properties from ${user.home}/.jbpm4/jdbc/${database}.properties" />
+ <property file="../jdbc/${database}.properties" />
+
+ <!-- default value for jdbc.schema -->
+ <property name="jdbc.schema" value="" />
+
+ <target name="compile">
+ <mkdir dir="bin"/>
+ <javac srcdir="src" destdir="bin"/>
+ </target>
+
+ <target name="clean" depends="compile">
+ <exec executable="mvn.bat" os="Windows Vista, Windows XP,Windows 2000,Windows 98">
+ <arg line="dependency:copy" />
+ </exec>
+ <path id="classpath.cleandb">
+ <fileset dir="lib" includes="*jar"/>
+ <pathelement path="bin"/>
+ </path>
+ <taskdef name="cleandb" classname="org.jboss.qa.CleanDatabase" classpathref="classpath.cleandb" />
+ <echo>
+ url="${jdbc.url}"
+ username="${jdbc.username}"
+ password="${jdbc.password}"
+ schema="${jdbc.schema}"
+ driver="${jdbc.driver}"
+ </echo>
+ <cleandb
+ url="${jdbc.url}"
+ username="${jdbc.username}"
+ password="${jdbc.password}"
+ schema="${jdbc.schema}"
+ driver="${jdbc.driver}" />
+ </target>
+</project>
Property changes on: jbpm4/trunk/qa/cleandb/build.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/qa/cleandb/pom.xml
===================================================================
--- jbpm4/trunk/qa/cleandb/pom.xml (rev 0)
+++ jbpm4/trunk/qa/cleandb/pom.xml 2009-10-30 09:29:12 UTC (rev 5853)
@@ -0,0 +1,78 @@
+<?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.3-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.7</version>
+ <outputDirectory>lib</outputDirectory>
+ <destFileName>hsqldb.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc14</artifactId>
+ <version>10.2.0.4</version>
+ <outputDirectory>lib</outputDirectory>
+ <destFileName>ojdbc14.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.6</version>
+ <outputDirectory>lib</outputDirectory>
+ <destFileName>mysql-connector-java.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>8.3-603.jdbc3</version>
+ <outputDirectory>lib</outputDirectory>
+ <destFileName>mysql-connector-java.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>
+ <repository>
+ <id>qa.jboss.com</id>
+ <url>http://www.qa.jboss.com/jdbc-drivers/maven2</url>
+ </repository>
+ </repositories>
+
+</project>
Property changes on: jbpm4/trunk/qa/cleandb/pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/qa/cleandb/src/org/jboss/qa/CleanDatabase.java
===================================================================
--- jbpm4/trunk/qa/cleandb/src/org/jboss/qa/CleanDatabase.java (rev 0)
+++ jbpm4/trunk/qa/cleandb/src/org/jboss/qa/CleanDatabase.java 2009-10-30 09:29:12 UTC (rev 5853)
@@ -0,0 +1,199 @@
+package org.jboss.qa;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+public class CleanDatabase extends Task {
+
+ private String url;
+ private String driver;
+ private String username;
+ private String password;
+ private String schema;
+ private String dropTableString = null;
+ private String dropForeignKeyString = null;
+ private boolean dropConstraintsFirst = true;
+
+ public void execute() throws BuildException {
+ Connection con = null;
+ // schema is optional, but let's make it null if it is empty
+ if ("".equals(getSchema()))
+ setSchema(null);
+
+ try {
+ Class.forName(getDriver());
+ } catch (java.lang.ClassNotFoundException e) {
+ throw new BuildException("Driver not found: " + e.getMessage(), e);
+ }
+
+ try {
+ String[] types = {"TABLE"};
+ con = DriverManager.getConnection(getUrl(), getUsername(), getPassword());
+
+ adjustStringsForDatabase(con.getMetaData().getIdentifierQuoteString());
+
+ ResultSet tables = con.getMetaData().getTables(null, getSchema(), null, types);
+
+ // DROP CONSTRAINTS
+ if (isDropConstraintsFirst()) {
+
+ while (tables.next()) {
+ String table = tables.getString("TABLE_NAME");
+
+ String schema = getSchema();
+ if (null == schema && tables.getString("TABLE_SCHEM") != null)
+ schema = tables.getString("TABLE_SCHEM");
+
+ ResultSet fksrs = con.getMetaData().getImportedKeys(null, schema, table);
+
+ // we are interested in the FK's only, not in the column they represent...
+ // the above method returns one record for each column which is part of a FK
+ // eg:
+ // FK1 represents CUST_ID and ORDR_NUM from EMBD_KM2O_ORDR table
+ // it returns two rows, but we want to drop the constraint (one record).
+ // So, we use another list, to get rid of "duplicates"
+ Set<String> fks = new HashSet<String>();
+ while (fksrs.next()) {
+ fks.add(fksrs.getString("FK_NAME"));
+ }
+
+ for (String fkname : fks) {
+ if (fkname != null) {
+ try {
+ String stmt = getDropForeignKeyString()
+ .replaceAll("@SCHEMA@.", schema == null ? "" : Matcher.quoteReplacement(schema)+".")
+ .replaceAll("@TABLE@", Matcher.quoteReplacement(table))
+ .replaceAll("@FK@", Matcher.quoteReplacement(fkname));
+ log("Issuing drop foreign key command:" + stmt);
+ con.createStatement().executeUpdate(stmt);
+ } catch(Exception e) {
+ throw new BuildException("Something went wrong on dropping the FK "+fkname+" from table " + table + ": " + e.getMessage(), e);
+ }
+ }
+ }
+ }
+ }
+
+ // DROP TABLE -- get a fresh result, as some drivers seems to get crazy on .first or .beforeFirst...
+ tables = con.getMetaData().getTables(null, getSchema(), null, types);
+ while (tables.next()) {
+ String table = tables.getString("TABLE_NAME");
+ try {
+ String stmt = getDropTableString()
+ .replaceAll("@SCHEMA@.", schema == null ? "" : Matcher.quoteReplacement(schema)+".")
+ .replaceAll("@TABLE@", Matcher.quoteReplacement(table));
+ log("Issuing drop table command:" + stmt);
+ con.createStatement().executeUpdate(stmt);
+ } catch(Exception e) {
+ throw new BuildException("Something went wrong on dropping table " + table + ": " + e.getMessage(), e);
+ }
+ }
+
+ } catch (Exception e) {
+ throw new BuildException(e);
+ } finally {
+ if (con != null) {
+ try {
+ if (!con.isClosed()) con.close();
+ } catch (SQLException e) {}
+ }
+ }
+ }
+
+ private void adjustStringsForDatabase(String quoteChar) {
+ setDropTableString("DROP TABLE "+quoteChar+"@TABLE@"+quoteChar);
+ setDropForeignKeyString("ALTER TABLE "+quoteChar+"@TABLE@"+quoteChar+" DROP CONSTRAINT "+quoteChar+"@FK@"+quoteChar);
+
+ if (getUrl().startsWith("jdbc:mysql")) {
+ setDropForeignKeyString("ALTER TABLE "+quoteChar+"@TABLE@"+quoteChar+" DROP FOREIGN KEY "+quoteChar+"@FK@"+quoteChar);
+ setDropConstraintsFirst(true);
+ }
+
+ if (getUrl().startsWith("jdbc:postgresql")) {
+ setDropTableString(getDropTableString() + " CASCADE");
+ setDropConstraintsFirst(false);
+ }
+
+ if (getUrl().startsWith("jdbc:oracle")) {
+ setDropTableString(getDropTableString() + " CASCADE CONSTRAINTS");
+ setDropConstraintsFirst(false);
+ }
+
+ if (getUrl().startsWith("jdbc:db2")) {
+ // db2 drops the constraints by default, when dropping a table
+ setDropConstraintsFirst(false);
+ }
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getDriver() {
+ return driver;
+ }
+
+ public void setDriver(String driver) {
+ this.driver = driver;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getSchema() {
+ return schema;
+ }
+
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
+
+ public String getDropTableString() {
+ return dropTableString;
+ }
+
+ public void setDropTableString(String dropTableString) {
+ this.dropTableString = dropTableString;
+ }
+
+ public String getDropForeignKeyString() {
+ return dropForeignKeyString;
+ }
+
+ public void setDropForeignKeyString(String dropForeignKeyString) {
+ this.dropForeignKeyString = dropForeignKeyString;
+ }
+
+ public boolean isDropConstraintsFirst() {
+ return dropConstraintsFirst;
+ }
+
+ public void setDropConstraintsFirst(boolean dropConstraintsFirst) {
+ this.dropConstraintsFirst = dropConstraintsFirst;
+ }
+
+}
\ No newline at end of file
Property changes on: jbpm4/trunk/qa/cleandb/src/org/jboss/qa/CleanDatabase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 6 months