|
From: <fg...@us...> - 2007-07-03 22:04:06
|
Revision: 352
http://svn.sourceforge.net/openutils/?rev=352&view=rev
Author: fgiust
Date: 2007-07-03 15:04:07 -0700 (Tue, 03 Jul 2007)
Log Message:
-----------
[maven-release-plugin] copy for tag openutils-dbmigration-0.7
Added Paths:
-----------
tags/openutils-dbmigration-0.7/
tags/openutils-dbmigration-0.7/pom.xml
tags/openutils-dbmigration-0.7/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java
Removed Paths:
-------------
tags/openutils-dbmigration-0.7/pom.xml
tags/openutils-dbmigration-0.7/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java
Copied: tags/openutils-dbmigration-0.7 (from rev 342, trunk/openutils-dbmigration)
Deleted: tags/openutils-dbmigration-0.7/pom.xml
===================================================================
--- trunk/openutils-dbmigration/pom.xml 2007-06-30 15:21:31 UTC (rev 342)
+++ tags/openutils-dbmigration-0.7/pom.xml 2007-07-03 22:04:07 UTC (rev 352)
@@ -1,87 +0,0 @@
-<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>
- <parent>
- <groupId>net.sourceforge.openutils</groupId>
- <artifactId>openutils</artifactId>
- <version>3</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>openutils-dbmigration</artifactId>
- <name>openutils db migration framework</name>
- <version>0.7-SNAPSHOT</version>
- <description />
- <dependencies>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.3</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.3</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- <version>2.0.1</version>
- <exclusions>
- <exclusion>
- <groupId>avalon-framework</groupId>
- <artifactId>avalon-framework</artifactId>
- </exclusion>
- <exclusion>
- <groupId>logkit</groupId>
- <artifactId>logkit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>2.0.1</version>
- <exclusions>
- <exclusion>
- <groupId>avalon-framework</groupId>
- <artifactId>avalon-framework</artifactId>
- </exclusion>
- <exclusion>
- <groupId>logkit</groupId>
- <artifactId>logkit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>2.0.1</version>
- <exclusions>
- <exclusion>
- <groupId>avalon-framework</groupId>
- <artifactId>avalon-framework</artifactId>
- </exclusion>
- <exclusion>
- <groupId>logkit</groupId>
- <artifactId>logkit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>poi</groupId>
- <artifactId>poi</artifactId>
- <version>2.5.1-final-20040804</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Copied: tags/openutils-dbmigration-0.7/pom.xml (from rev 351, trunk/openutils-dbmigration/pom.xml)
===================================================================
--- tags/openutils-dbmigration-0.7/pom.xml (rev 0)
+++ tags/openutils-dbmigration-0.7/pom.xml 2007-07-03 22:04:07 UTC (rev 352)
@@ -0,0 +1,93 @@
+<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>
+ <parent>
+ <groupId>net.sourceforge.openutils</groupId>
+ <artifactId>openutils</artifactId>
+ <version>3</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>openutils-dbmigration</artifactId>
+ <name>openutils db migration framework</name>
+ <version>0.7</version>
+ <description />
+ <dependencies>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ <version>2.0.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>2.0.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>2.0.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>poi</groupId>
+ <artifactId>poi</artifactId>
+ <version>2.5.1-final-20040804</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <scm>
+ <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-dbmigration-0.7</connection>
+ <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-dbmigration-0.7</developerConnection>
+ <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-dbmigration-0.7</url>
+ </scm>
+</project>
\ No newline at end of file
Deleted: tags/openutils-dbmigration-0.7/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java
===================================================================
--- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java 2007-06-30 15:21:31 UTC (rev 342)
+++ tags/openutils-dbmigration-0.7/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java 2007-07-03 22:04:07 UTC (rev 352)
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it
- */
-package it.openutils.migration.task.setup;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-import javax.sql.DataSource;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.io.Resource;
-import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
-
-
-/**
- * @author fgiust
- * @version $Id$
- */
-public class GenericScriptBasedConditionalTask implements DbTask
-{
-
- /**
- * Logger.
- */
- private static Logger log = LoggerFactory.getLogger(GenericScriptBasedConditionalTask.class);
-
- /**
- * Script list to execute
- */
- protected List<Resource> scripts;
-
- private String check;
-
- /**
- * Sets the scripts.
- * @param scripts the scripts to set
- */
- public void setScripts(List<Resource> scripts)
- {
- this.scripts = scripts;
- }
-
- /**
- * Sets the check.
- * @param check the check to set
- */
- public void setCheck(String check)
- {
- this.check = check;
- }
-
- /**
- * @param script The script resource
- * @return The script name
- */
- protected String objectNameFromFileName(Resource script)
- {
- return StringUtils.substringBeforeLast(script.getFilename(), ".");
- }
-
- /**
- * {@inheritDoc}
- */
- public String getDescription()
- {
- // @todo add better description and avoid NPEs
- return "Checking " + objectNameFromFileName(scripts.get(0));
- }
-
- /**
- * {@inheritDoc}
- */
- public void execute(DataSource dataSource)
- {
-
- SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
-
- for (Resource script : scripts)
- {
- int result = jdbcTemplate.queryForInt(check, this.objectNameFromFileName(script));
- if (result == 0)
- {
- if (script == null || !script.exists())
- {
- log.error("Unable to execute db task \"{}\", script \"{}\" not found.", getDescription(), script);
- return;
- }
-
- String scriptContent;
- InputStream is = null;
-
- try
- {
- is = script.getInputStream();
- scriptContent = IOUtils.toString(is, "UTF8");
- }
- catch (IOException e)
- {
- log.error(
- "Unable to execute db task \"{}\", script \"{}\" can't be read.",
- getDescription(),
- script);
- return;
- }
- finally
- {
- IOUtils.closeQuietly(is);
- }
-
- String[] ddls = StringUtils.split(scriptContent, ";");
-
- for (String ddl : ddls)
- {
- if (StringUtils.isNotBlank(ddl))
- {
- log.debug("Executing:\n{}", ddl);
- jdbcTemplate.update(ddl);
- }
- }
- }
- }
-
- }
-}
Copied: tags/openutils-dbmigration-0.7/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java (from rev 350, trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java)
===================================================================
--- tags/openutils-dbmigration-0.7/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java (rev 0)
+++ tags/openutils-dbmigration-0.7/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java 2007-07-03 22:04:07 UTC (rev 352)
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it
+ */
+package it.openutils.migration.task.setup;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.Resource;
+import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
+
+
+/**
+ * @author fgiust
+ * @version $Id$
+ */
+public class GenericScriptBasedConditionalTask implements DbTask
+{
+
+ /**
+ * Logger.
+ */
+ private static Logger log = LoggerFactory.getLogger(GenericScriptBasedConditionalTask.class);
+
+ /**
+ * Script list to execute
+ */
+ protected List<Resource> scripts;
+
+ private String check;
+
+ /**
+ * Sets the scripts.
+ * @param scripts the scripts to set
+ */
+ public void setScripts(List<Resource> scripts)
+ {
+ this.scripts = scripts;
+ }
+
+ /**
+ * Sets the check.
+ * @param check the check to set
+ */
+ public void setCheck(String check)
+ {
+ this.check = check;
+ }
+
+ /**
+ * @param script The script resource
+ * @return The script name
+ */
+ protected String objectNameFromFileName(Resource script)
+ {
+ return StringUtils.substringBeforeLast(script.getFilename(), ".");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getDescription()
+ {
+ if (scripts == null)
+ {
+ return "Nothing to do, no scripts configured";
+ }
+
+ StringBuffer result = new StringBuffer();
+ if (!scripts.isEmpty())
+ {
+ result.append("Checking :\n");
+ for (Resource script : scripts)
+ {
+ result.append(" - " + objectNameFromFileName(script) + "\n");
+ }
+
+ }
+ return result.toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void execute(DataSource dataSource)
+ {
+
+ SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
+
+ for (Resource script : scripts)
+ {
+ int result = jdbcTemplate.queryForInt(check, this.objectNameFromFileName(script));
+ if (result == 0)
+ {
+ if (script == null || !script.exists())
+ {
+ log.error("Unable to execute db task \"{}\", script \"{}\" not found.", getDescription(), script);
+ return;
+ }
+
+ String scriptContent;
+ InputStream is = null;
+
+ try
+ {
+ is = script.getInputStream();
+ scriptContent = IOUtils.toString(is, "UTF8");
+ }
+ catch (IOException e)
+ {
+ log.error(
+ "Unable to execute db task \"{}\", script \"{}\" can't be read.",
+ getDescription(),
+ script);
+ return;
+ }
+ finally
+ {
+ IOUtils.closeQuietly(is);
+ }
+
+ String[] ddls = StringUtils.split(scriptContent, ";");
+
+ for (String ddl : ddls)
+ {
+ if (StringUtils.isNotBlank(ddl))
+ {
+ log.debug("Executing:\n{}", ddl);
+ jdbcTemplate.update(ddl);
+ }
+ }
+ }
+ }
+
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|