From: <fg...@us...> - 2007-02-01 17:09:01
|
Revision: 180 http://svn.sourceforge.net/openutils/?rev=180&view=rev Author: fgiust Date: 2007-02-01 09:08:06 -0800 (Thu, 01 Feb 2007) Log Message: ----------- new excel configuration task Modified Paths: -------------- trunk/openutils-dbmigration/pom.xml Added Paths: ----------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java Modified: trunk/openutils-dbmigration/pom.xml =================================================================== --- trunk/openutils-dbmigration/pom.xml 2007-02-01 16:35:22 UTC (rev 179) +++ trunk/openutils-dbmigration/pom.xml 2007-02-01 17:08:06 UTC (rev 180) @@ -43,6 +43,12 @@ <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>3.8.1</version> Added: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java (rev 0) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2007-02-01 17:08:06 UTC (rev 180) @@ -0,0 +1,261 @@ +/* + * 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.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.sql.DataSource; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.io.Resource; +import org.springframework.jdbc.BadSqlGrammarException; +import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; + + +/** + * @author fgiust + * @version $Id$ + */ +public class ExcelConfigurationTask extends BaseDbTask implements DbTask +{ + + /** + * Logger. + */ + private Logger log = LoggerFactory.getLogger(ScriptBasedUnconditionalTask.class); + + private Resource script; + + private Map<String, ExcelConfigurationTask.QueryConfig> config; + + /** + * Sets the script. + * @param script the script to set + */ + public void setScript(Resource script) + { + this.script = script; + } + + /** + * Sets the config. + * @param config the config to set + */ + public void setConfig(Map<String, ExcelConfigurationTask.QueryConfig> config) + { + this.config = config; + } + + /** + * {@inheritDoc} + */ + public void execute(DataSource dataSource) + { + if (script == null || !script.exists()) + { + log.error("Unable to execute db task \"{}\", script \"{}\" not found.", getDescription(), script); + return; + } + + InputStream is = null; + try + { + is = script.getInputStream(); + POIFSFileSystem fs = new POIFSFileSystem(is); + HSSFWorkbook hssfworkbook = new HSSFWorkbook(fs); + int sheetNums = hssfworkbook.getNumberOfSheets(); + for (int j = 0; j < sheetNums; j++) + { + HSSFSheet sheet = hssfworkbook.getSheetAt(j); + String tableName = hssfworkbook.getSheetName(j); + + QueryConfig conf = config.get(tableName); + if (conf == null) + { + log.error("Unable to handle table {}", tableName); + continue; + } + processSheet(sheet, tableName, conf, dataSource); + + } + + } + catch (IOException e) + { + log.error(e.getMessage(), e); + } + finally + { + IOUtils.closeQuietly(is); + } + + } + + /** + * @param sheet + * @param tableName + */ + private void processSheet(HSSFSheet sheet, String tableName, QueryConfig con, DataSource dataSource) + { + List<String> columns = new ArrayList<String>(); + + HSSFRow row = sheet.getRow(0); + for (short k = 0; k < row.getLastCellNum(); k++) + { + String columnName = row.getCell(k).getStringCellValue(); + if (StringUtils.isNotBlank(columnName)) + { + columns.add(columnName); + } + else + { + break; + } + } + + log.debug("Table: {}, Columns: {}", tableName, columns); + + String checkStatement = con.getCheckQuery(); + String insertStatement = con.getInsertQuery(); + + processRecords(sheet, columns, checkStatement, insertStatement, dataSource); + } + + /** + * @param sheet + * @param columns + * @param checkStatement + * @param insertStatement + */ + private void processRecords(HSSFSheet sheet, List<String> columns, String checkStatement, String insertStatement, + DataSource dataSource) + { + SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + int checkNum = StringUtils.countMatches(checkStatement, "?"); + int insertNum = StringUtils.countMatches(insertStatement, "?"); + + HSSFRow row; + for (short u = 1; u <= sheet.getLastRowNum(); u++) + { + row = sheet.getRow(u); + if (row == null) + { + return; + } + + List<String> values = new ArrayList<String>(); + + for (short k = 0; k < columns.size() && k <= row.getLastCellNum(); k++) + { + HSSFCell cell = row.getCell(k); + if (cell == null) + { + return; + } + + String value = null; + if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) + { + value = cell.getStringCellValue(); + } + else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) + { + double valueDouble = cell.getNumericCellValue(); + value = Double.toString(valueDouble); + } + + if (StringUtils.isEmpty(value)) + { + return; + } + values.add(value); + } + + Object[] checkParams = ArrayUtils.subarray(values.toArray(), 0, checkNum); + + int existing; + try + { + existing = jdbcTemplate.queryForInt(checkStatement, checkParams); + } + catch (BadSqlGrammarException bsge) + { + log.error("Error executing check query, current sheet will be skipped. {} Query in error: {}", bsge + .getMessage(), checkStatement); + return; + } + + if (existing == 0) + { + Object[] insertParams = ArrayUtils.subarray(values.toArray(), 0, insertNum); + log.debug("Missing record with key {}; inserting {}", ArrayUtils.toString(checkParams), ArrayUtils + .toString(insertParams)); + jdbcTemplate.update(insertStatement, insertParams); + } + + } + } + + /** + * @author fgiust + * @version $Id$ + */ + public static class QueryConfig + { + + private String checkQuery; + + private String insertQuery; + + /** + * Returns the checkQuery. + * @return the checkQuery + */ + public String getCheckQuery() + { + return checkQuery; + } + + /** + * Sets the checkQuery. + * @param checkQuery the checkQuery to set + */ + public void setCheckQuery(String checkQuery) + { + this.checkQuery = checkQuery; + } + + /** + * Returns the insertQuery. + * @return the insertQuery + */ + public String getInsertQuery() + { + return insertQuery; + } + + /** + * Sets the insertQuery. + * @param insertQuery the insertQuery to set + */ + public void setInsertQuery(String insertQuery) + { + this.insertQuery = insertQuery; + } + } +} Property changes on: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-14 12:00:23
|
Revision: 526 http://openutils.svn.sourceforge.net/openutils/?rev=526&view=rev Author: fgiust Date: 2008-01-14 04:00:28 -0800 (Mon, 14 Jan 2008) Log Message: ----------- new sqlserver update tasks and generic jdbc tasks for tables and columns Modified Paths: -------------- trunk/openutils-dbmigration/pom.xml trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DbSetupManager.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DbSetupManagerImpl.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DbVersionManager.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DefaultDbVersionManagerImpl.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerGenericAlterTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerObjCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerScriptBasedUnconditionalTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerSynonymCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerTableCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerTriggerCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerViewCreateOrUpdateTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerViewCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseDbTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/DbTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericConditionalTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ScriptBasedUnconditionalTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/update/DbUpdate.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/update/ScriptBasedDbUpdate.java Added Paths: ----------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcConditionalTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcIfColumnExistsConditionalTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcObjectCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcTableCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcViewCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreateOrUpdateTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreateOrUpdateTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreationTask.java Modified: trunk/openutils-dbmigration/pom.xml =================================================================== --- trunk/openutils-dbmigration/pom.xml 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/pom.xml 2008-01-14 12:00:28 UTC (rev 526) @@ -9,7 +9,7 @@ </parent> <artifactId>openutils-dbmigration</artifactId> <name>openutils db migration framework</name> - <version>0.7.4-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> <description /> <dependencies> <dependency> @@ -78,13 +78,20 @@ </exclusions> </dependency> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.0</version> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <classifier>jdk15</classifier> + <version>5.1</version> <scope>test</scope> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + </exclusions> </dependency> </dependencies> <properties> - <spring.version>2.5</spring.version> + <spring.version>2.5.1</spring.version> </properties> </project> \ No newline at end of file Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DbSetupManager.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DbSetupManager.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DbSetupManager.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DbSetupManagerImpl.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DbSetupManagerImpl.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DbSetupManagerImpl.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DbVersionManager.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DbVersionManager.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DbVersionManager.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DefaultDbVersionManagerImpl.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DefaultDbVersionManagerImpl.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/DefaultDbVersionManagerImpl.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration; @@ -24,7 +36,7 @@ * </property> * </bean> * </pre> - * + * * @author fgiust * @version $Id$ */ Added: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcConditionalTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcConditionalTask.java (rev 0) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcConditionalTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -0,0 +1,78 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package it.openutils.migration.generic; + +import it.openutils.migration.task.setup.BaseDbTask; +import it.openutils.migration.task.setup.DbTask; + +import javax.sql.DataSource; + +import org.apache.commons.lang.StringUtils; +import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; + + +/** + * @author fgiust + * @version $Id:SqlServerObjCreationTask.java 3143 2007-09-24 19:50:49Z fgiust $ + */ +public abstract class JdbcConditionalTask extends BaseDbTask implements DbTask +{ + + private String ddl; + + private boolean not; + + /** + * {@inheritDoc} + */ + public void setDdl(String ddls) + { + this.ddl = ddls; + } + + /** + * Sets the not. + * @param not the not to set + */ + public void setNot(boolean not) + { + this.not = not; + } + + public abstract boolean check(SimpleJdbcTemplate jdbcTemplate); + + /** + * {@inheritDoc} + */ + public void execute(DataSource dataSource) + { + SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + + if (check(jdbcTemplate) ^ !not) + { + + String[] ddls = StringUtils.split(ddl, ';'); + for (String statement : ddls) + { + if (StringUtils.isNotBlank(statement)) + { + jdbcTemplate.update(statement); + } + } + } + } + +} Property changes on: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcConditionalTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcIfColumnExistsConditionalTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcIfColumnExistsConditionalTask.java (rev 0) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcIfColumnExistsConditionalTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -0,0 +1,61 @@ +package it.openutils.migration.generic; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.apache.commons.lang.StringUtils; +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.ConnectionCallback; +import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; + + +/** + * @author fgiust + * @version $Id: $ + */ +public class JdbcIfColumnExistsConditionalTask extends JdbcConditionalTask +{ + + private String column; + + /** + * Sets the column. + * @param column the column to set + */ + public void setColumn(String column) + { + this.column = column; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean check(SimpleJdbcTemplate jdbcTemplate) + { + final String catalog = null; + final String schema = null; + + String columnTrim = StringUtils.trim(column); + + final String tableName = StringUtils.substringBefore(columnTrim, "."); + final String columnName = StringUtils.substringAfter(columnTrim, "."); + return (Boolean) jdbcTemplate.getJdbcOperations().execute(new ConnectionCallback() + { + + public Object doInConnection(Connection con) throws SQLException, DataAccessException + { + + DatabaseMetaData dbMetadata = con.getMetaData(); + ResultSet rs = dbMetadata.getColumns(catalog, schema, tableName, columnName); + boolean tableExists = rs.first(); + rs.close(); + + return !tableExists; + } + }); + } + +} Property changes on: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcIfColumnExistsConditionalTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcObjectCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcObjectCreationTask.java (rev 0) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcObjectCreationTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -0,0 +1,144 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package it.openutils.migration.generic; + +import it.openutils.migration.task.setup.GenericScriptBasedConditionalTask; + +import java.io.IOException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; + +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.dao.DataAccessException; +import org.springframework.jdbc.core.ConnectionCallback; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; + + +/** + * @author fgiust + * @version $Id:SqlServerObjCreationTask.java 3143 2007-09-24 19:50:49Z fgiust $ + */ +public class JdbcObjectCreationTask extends GenericScriptBasedConditionalTask +{ + + /** + * Logger. + */ + protected Logger log = LoggerFactory.getLogger(getClass()); + + protected String objectType = "TABLE"; + + protected String catalog; + + /** + * {@inheritDoc} + */ + @Override + public void execute(DataSource dataSource) + { + SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + + for (Resource script : scripts) + { + + if (script == null || !script.exists()) + { + log.error("Unable to execute db task \"{}\", script \"{}\" not found.", getDescription(), script); + return; + } + + String fqTableName = this.objectNameFromFileName(script); + String tmptableName = null; + String tmpschema = null; + + if (StringUtils.contains(fqTableName, ".")) + { + String[] tokens = StringUtils.split(fqTableName, "."); + tmptableName = tokens[1]; + tmpschema = tokens[0]; + } + else + { + tmptableName = fqTableName; + } + + final String tableName = tmptableName; + final String schema = tmpschema; + + boolean result = (Boolean) new JdbcTemplate(dataSource).execute(new ConnectionCallback() + { + + public Object doInConnection(Connection con) throws SQLException, DataAccessException + { + + DatabaseMetaData dbMetadata = con.getMetaData(); + ResultSet rs = dbMetadata.getTables(catalog, schema, tableName, new String[]{objectType }); + boolean tableExists = rs.first(); + rs.close(); + + return tableExists; + } + }); + + if (!result) + { + 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, ";"); + + log.info("Creating new {} {}", objectType, tableName); + + for (String ddl : ddls) + { + if (StringUtils.isNotBlank(ddl)) + { + log.debug("Executing:\n{}", ddl); + jdbcTemplate.update(ddl); + } + } + } + } + } +} \ No newline at end of file Property changes on: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcObjectCreationTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcTableCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcTableCreationTask.java (rev 0) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcTableCreationTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -0,0 +1,26 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package it.openutils.migration.generic; + +/** + * @author fgiust + * @version $Id:SqlServerObjCreationTask.java 3143 2007-09-24 19:50:49Z fgiust $ + */ +public class JdbcTableCreationTask extends JdbcObjectCreationTask +{ + + protected String objectType = "TABLE"; +} \ No newline at end of file Property changes on: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcTableCreationTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcViewCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcViewCreationTask.java (rev 0) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcViewCreationTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -0,0 +1,26 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package it.openutils.migration.generic; + +/** + * @author fgiust + * @version $Id:SqlServerObjCreationTask.java 3143 2007-09-24 19:50:49Z fgiust $ + */ +public class JdbcViewCreationTask extends JdbcObjectCreationTask +{ + + protected String objectType = "VIEW"; +} \ No newline at end of file Property changes on: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcViewCreationTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreateOrUpdateTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreateOrUpdateTask.java (rev 0) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreateOrUpdateTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -0,0 +1,160 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package it.openutils.migration.sqlserver; + +import it.openutils.migration.task.setup.GenericScriptBasedConditionalTask; + +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; + + +/** + * Compares the function script with the one stored in the db and drops and recreates it if the scripts differs. Be + * aware that tabs chars are ALWAYS considered different, so remove them from your scripts! This works ONLY for SQL + * Server 2005. + * @author Danilo Ghirardelli + * @version $Id$ + */ +public class SqlServerFunctionCreateOrUpdateTask extends GenericScriptBasedConditionalTask +{ + + /** + * Logger. + */ + private Logger log = LoggerFactory.getLogger(SqlServerObjCreationTask.class); + + /** + * The db with the objects, may differ from the current. + */ + private String sourceDb; + + /** + * Sets the sourceDb. + * @param sourceDb the sourceDb to set + */ + public void setSourceDb(String sourceDb) + { + this.sourceDb = sourceDb; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + @Override + public void execute(DataSource dataSource) + { + String checkQuery = "select count(*) from dbo.sysobjects where id = object_id(?) and xtype in (N'FN', N'IF', N'TF')"; + + SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + for (Resource script : scripts) + { + String functionName = this.objectNameFromFileName(script); + int result = jdbcTemplate.queryForInt(checkQuery, functionName); + String scriptContent = readFully(script); + scriptContent = StringUtils.replace(scriptContent, "\t", " "); + if (StringUtils.isBlank(scriptContent)) + { + continue; + } + if (result == 0) + { + log.info("Function {} not existing. Creating new function", functionName); + createFunction(jdbcTemplate, scriptContent); + } + else + { // If the script is too long a list will be returned, and it must be joined to get the original script. + List<String> previousDDlList = jdbcTemplate.getJdbcOperations().queryForList( + "exec sp_helptext ?", + new Object[]{functionName }, + String.class); + String previousDDl = StringUtils.join(previousDDlList.toArray(new String[previousDDlList.size()])); + if (!StringUtils.equals(previousDDl, scriptContent)) + { + log.info( + "Previous definition of function {} differs from actual. Dropping and recreating function", + new Object[]{functionName }); + jdbcTemplate.update("DROP FUNCTION [" + functionName + "]"); + createFunction(jdbcTemplate, scriptContent); + } + } + } + + } + + /** + * Creates a function executing the given script. + * @param jdbcTemplate Jdbc connection. + * @param script Function script. + * @return + */ + private void createFunction(SimpleJdbcTemplate jdbcTemplate, String script) + { + String[] ddls = StringUtils.split(script, ";"); + for (String ddl : ddls) + { + if (StringUtils.isNotBlank(ddl)) + { + log.debug("Executing:\n{}", ddl); + jdbcTemplate.update(ddl); + } + } + } + + /** + * Reads the script from the given resource and convert it to a string suitable for update query. + * @param script The script file + * @return The script content + */ + private String readFully(Resource script) + { + if (script == null || !script.exists()) + { + log.error("Unable to execute db task \"{}\", script \"{}\" not found.", getDescription(), script); + return null; + } + 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 null; + } + finally + { + IOUtils.closeQuietly(is); + } + return StringUtils.stripEnd( + StringUtils.trim(StringUtils.replace(scriptContent, "${sourceDb}", this.sourceDb)), + ";"); + } +} \ No newline at end of file Property changes on: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreateOrUpdateTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreationTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreationTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.sqlserver; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerGenericAlterTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerGenericAlterTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerGenericAlterTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.sqlserver; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerObjCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerObjCreationTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerObjCreationTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.sqlserver; Added: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreateOrUpdateTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreateOrUpdateTask.java (rev 0) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreateOrUpdateTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -0,0 +1,159 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package it.openutils.migration.sqlserver; + +import it.openutils.migration.task.setup.GenericScriptBasedConditionalTask; + +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; + + +/** + * Compares the procedure script with the one stored in the db and drops and recreates it if the scripts differs. Be + * aware that tabs chars are ALWAYS considered different, so remove them from your scripts! This works ONLY for SQL + * Server 2005. + * @author Danilo Ghirardelli + * @version $Id$ + */ +public class SqlServerProcedureCreateOrUpdateTask extends GenericScriptBasedConditionalTask +{ + + /** + * Logger. + */ + private Logger log = LoggerFactory.getLogger(SqlServerObjCreationTask.class); + + /** + * The db with the objects, may differ from the current. + */ + private String sourceDb; + + /** + * Sets the sourceDb. + * @param sourceDb the sourceDb to set + */ + public void setSourceDb(String sourceDb) + { + this.sourceDb = sourceDb; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + @Override + public void execute(DataSource dataSource) + { + String checkQuery = "select count(*) from dbo.sysobjects where id = object_id(?) and (OBJECTPROPERTY(id, N'IsProcedure') = 1)"; + SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + for (Resource script : scripts) + { + String procedureName = this.objectNameFromFileName(script); + int result = jdbcTemplate.queryForInt(checkQuery, procedureName); + String scriptContent = readFully(script); + scriptContent = StringUtils.replace(scriptContent, "\t", " "); + if (StringUtils.isBlank(scriptContent)) + { + continue; + } + if (result == 0) + { + log.info("Procedure {} not existing. Creating new procedure", procedureName); + createProcedure(jdbcTemplate, scriptContent); + } + else + { // If the script is too long a list will be returned, and it must be joined to get the original script. + List<String> previousDDlList = jdbcTemplate.getJdbcOperations().queryForList( + "exec sp_helptext ?", + new Object[]{procedureName }, + String.class); + String previousDDl = StringUtils.join(previousDDlList.toArray(new String[previousDDlList.size()])); + if (!StringUtils.equals(previousDDl, scriptContent)) + { + log.info( + "Previous definition of procedure {} differs from actual. Dropping and recreating procedure", + new Object[]{procedureName }); + jdbcTemplate.update("DROP PROCEDURE [" + procedureName + "]"); + createProcedure(jdbcTemplate, scriptContent); + } + } + } + + } + + /** + * Creates a stored procedure executing the given script. + * @param jdbcTemplate Jdbc connection. + * @param script Stored procedure script. + * @return + */ + private void createProcedure(SimpleJdbcTemplate jdbcTemplate, String script) + { + String[] ddls = StringUtils.split(script, ";"); + for (String ddl : ddls) + { + if (StringUtils.isNotBlank(ddl)) + { + log.debug("Executing:\n{}", ddl); + jdbcTemplate.update(ddl); + } + } + } + + /** + * Reads the script from the given resource and convert it to a string suitable for update query. + * @param script The script file + * @return The script content + */ + private String readFully(Resource script) + { + if (script == null || !script.exists()) + { + log.error("Unable to execute db task \"{}\", script \"{}\" not found.", getDescription(), script); + return null; + } + 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 null; + } + finally + { + IOUtils.closeQuietly(is); + } + return StringUtils.stripEnd( + StringUtils.trim(StringUtils.replace(scriptContent, "${sourceDb}", this.sourceDb)), + ";"); + } +} \ No newline at end of file Property changes on: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreateOrUpdateTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreationTask.java (rev 0) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreationTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -0,0 +1,38 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package it.openutils.migration.sqlserver; + +import javax.sql.DataSource; + + +/** + * @author Danilo Ghirardelli + * @version $Id:SqlServerProcedureCreationTask.java 3143 2007-09-24 19:50:49Z fgiust $ + */ +public class SqlServerProcedureCreationTask extends SqlServerObjCreationTask +{ + + /** + * {@inheritDoc} + */ + @Override + public void execute(DataSource dataSource) + { + setQualifiedObjQuery("select count(*) from dbo.sysobjects where id = object_id(?) and (OBJECTPROPERTY(id, N'IsProcedure') = 1)"); + setUnqualifiedObjQuery("select count(*) from dbo.sysobjects where id = object_id(?) and (OBJECTPROPERTY(id, N'IsProcedure') = 1)"); + super.execute(dataSource); + } +} \ No newline at end of file Property changes on: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreationTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerScriptBasedUnconditionalTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerScriptBasedUnconditionalTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerScriptBasedUnconditionalTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,3 +1,18 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package it.openutils.migration.sqlserver; import it.openutils.migration.task.setup.BaseDbTask; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerSynonymCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerSynonymCreationTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerSynonymCreationTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.sqlserver; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerTableCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerTableCreationTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerTableCreationTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.sqlserver; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerTriggerCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerTriggerCreationTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerTriggerCreationTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.sqlserver; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerViewCreateOrUpdateTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerViewCreateOrUpdateTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerViewCreateOrUpdateTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.sqlserver; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerViewCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerViewCreationTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerViewCreationTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.sqlserver; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseDbTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseDbTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseDbTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.task.setup; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/DbTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/DbTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/DbTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.task.setup; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.task.setup; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericConditionalTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericConditionalTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericConditionalTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.task.setup; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.task.setup; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ScriptBasedUnconditionalTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ScriptBasedUnconditionalTask.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ScriptBasedUnconditionalTask.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.task.setup; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/update/DbUpdate.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/update/DbUpdate.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/update/DbUpdate.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.task.update; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/update/ScriptBasedDbUpdate.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/update/ScriptBasedDbUpdate.java 2008-01-12 10:46:12 UTC (rev 525) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/update/ScriptBasedDbUpdate.java 2008-01-14 12:00:28 UTC (rev 526) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.migration.task.update; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |