From: <fc...@us...> - 2007-02-05 17:22:18
|
Revision: 199 http://svn.sourceforge.net/openutils/?rev=199&view=rev Author: fcarone Date: 2007-02-05 09:22:02 -0800 (Mon, 05 Feb 2007) Log Message: ----------- Handle integer values and empty cells correctly Modified Paths: -------------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 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 2007-02-05 17:20:24 UTC (rev 198) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2007-02-05 17:22:02 UTC (rev 199) @@ -3,7 +3,6 @@ */ package it.openutils.migration.task.setup; - import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -163,30 +162,46 @@ for (short k = 0; k < columns.size() && k <= row.getLastCellNum(); k++) { HSSFCell cell = row.getCell(k); + String value = null; + if (cell == null) { - return; + value = StringUtils.EMPTY; } - - String value = null; - if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) + else 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); + // when need to really check if it is a double or an int + double fraction = valueDouble % 1; + if (fraction == 0) + { + value = Integer.toString((int) valueDouble); + } + else + { + value = Double.toString(valueDouble); + } } if (StringUtils.isEmpty(value)) { - return; + value = StringUtils.EMPTY; } values.add(value); } Object[] checkParams = ArrayUtils.subarray(values.toArray(), 0, checkNum); + for (int i = 0; i < checkParams.length; i++) + { + if (StringUtils.isEmpty((String) checkParams[i])) + { + return; + } + } int existing; try This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-02-14 00:06:53
|
Revision: 255 http://svn.sourceforge.net/openutils/?rev=255&view=rev Author: fgiust Date: 2007-02-13 16:06:54 -0800 (Tue, 13 Feb 2007) Log Message: ----------- handle nulls Modified Paths: -------------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 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 2007-02-13 21:39:25 UTC (rev 254) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2007-02-14 00:06:54 UTC (rev 255) @@ -22,6 +22,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.io.Resource; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.jdbc.BadSqlGrammarException; import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; @@ -129,10 +130,10 @@ log.debug("Table: {}, Columns: {}", tableName, columns); - String checkStatement = con.getCheckQuery(); - String insertStatement = con.getInsertQuery(); + String checkStatement = StringUtils.remove(StringUtils.trim(con.getCheckQuery()), "\n"); + String insertStatement = StringUtils.remove(StringUtils.trim(con.getInsertQuery()), "\n"); - processRecords(sheet, columns, checkStatement, insertStatement, dataSource); + processRecords(sheet, columns, checkStatement, insertStatement, dataSource, tableName); } /** @@ -142,16 +143,16 @@ * @param insertStatement */ private void processRecords(HSSFSheet sheet, List<String> columns, String checkStatement, String insertStatement, - DataSource dataSource) + DataSource dataSource, String tableName) { 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++) + for (short rowNum = 1; rowNum <= sheet.getLastRowNum(); rowNum++) { - row = sheet.getRow(u); + row = sheet.getRow(rowNum); if (row == null) { return; @@ -191,6 +192,12 @@ { value = StringUtils.EMPTY; } + + if ("<NULL>".equals(value)) + { + value = null; + } + values.add(value); } @@ -220,7 +227,24 @@ 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); + + try + { + jdbcTemplate.update(insertStatement, insertParams); + } + catch (DataIntegrityViolationException bsge) + { + log + .error( + "Error executing insert, record at {}:{} will be skipped. Query in error: '{}', values: {}. Error message: {}", + new Object[]{ + tableName, + rowNum, + insertStatement, + ArrayUtils.toString(insertParams), + bsge.getMessage() }); + return; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-02-19 21:56:15
|
Revision: 276 http://svn.sourceforge.net/openutils/?rev=276&view=rev Author: fgiust Date: 2007-02-19 13:56:10 -0800 (Mon, 19 Feb 2007) Log Message: ----------- equalsIgnoreCase for NULLs Modified Paths: -------------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 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 2007-02-19 17:13:52 UTC (rev 275) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2007-02-19 21:56:10 UTC (rev 276) @@ -193,7 +193,7 @@ value = StringUtils.EMPTY; } - if ("<NULL>".equals(value)) + if ("<NULL>".equalsIgnoreCase(value)) { value = null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-02-19 23:08:24
|
Revision: 277 http://svn.sourceforge.net/openutils/?rev=277&view=rev Author: fgiust Date: 2007-02-19 15:08:13 -0800 (Mon, 19 Feb 2007) Log Message: ----------- use connectionMetadata to correctly set sql types (worink nulls on derby) Modified Paths: -------------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 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 2007-02-19 21:56:10 UTC (rev 276) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2007-02-19 23:08:13 UTC (rev 277) @@ -5,6 +5,10 @@ import java.io.IOException; import java.io.InputStream; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -22,9 +26,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.io.Resource; +import org.springframework.dao.DataAccessException; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.jdbc.BadSqlGrammarException; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.ConnectionCallback; +import org.springframework.jdbc.core.JdbcTemplate; /** @@ -110,9 +116,9 @@ * @param sheet * @param tableName */ - private void processSheet(HSSFSheet sheet, String tableName, QueryConfig con, DataSource dataSource) + private void processSheet(HSSFSheet sheet, final String tableName, QueryConfig con, DataSource dataSource) { - List<String> columns = new ArrayList<String>(); + final List<String> columns = new ArrayList<String>(); HSSFRow row = sheet.getRow(0); for (short k = 0; k < row.getLastCellNum(); k++) @@ -130,10 +136,37 @@ log.debug("Table: {}, Columns: {}", tableName, columns); + final List<Integer> types = new ArrayList<Integer>(); + + new JdbcTemplate(dataSource).execute(new ConnectionCallback() + { + + public Object doInConnection(Connection con) throws SQLException, DataAccessException + { + for (String column : columns) + { + ResultSet res = con.getMetaData().getColumns(null, null, tableName, column); + if (res.next()) + { + types.add(res.getInt("DATA_TYPE")); + } + res.close(); + } + return null; + } + }); + String checkStatement = StringUtils.remove(StringUtils.trim(con.getCheckQuery()), "\n"); String insertStatement = StringUtils.remove(StringUtils.trim(con.getInsertQuery()), "\n"); - processRecords(sheet, columns, checkStatement, insertStatement, dataSource, tableName); + processRecords( + sheet, + columns, + ArrayUtils.toPrimitive(types.toArray(new Integer[types.size()]), Types.NULL), + checkStatement, + insertStatement, + dataSource, + tableName); } /** @@ -142,10 +175,10 @@ * @param checkStatement * @param insertStatement */ - private void processRecords(HSSFSheet sheet, List<String> columns, String checkStatement, String insertStatement, - DataSource dataSource, String tableName) + private void processRecords(HSSFSheet sheet, List<String> columns, int[] types, String checkStatement, + String insertStatement, DataSource dataSource, String tableName) { - SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); int checkNum = StringUtils.countMatches(checkStatement, "?"); int insertNum = StringUtils.countMatches(insertStatement, "?"); @@ -225,12 +258,15 @@ if (existing == 0) { Object[] insertParams = ArrayUtils.subarray(values.toArray(), 0, insertNum); - log.debug("Missing record with key {}; inserting {}", ArrayUtils.toString(checkParams), ArrayUtils - .toString(insertParams)); + if (log.isDebugEnabled()) + { + log.debug("Missing record with key {}; inserting {}", ArrayUtils.toString(checkParams), ArrayUtils + .toString(insertParams)); + } try { - jdbcTemplate.update(insertStatement, insertParams); + jdbcTemplate.update(insertStatement, insertParams, types); } catch (DataIntegrityViolationException bsge) { @@ -239,11 +275,11 @@ "Error executing insert, record at {}:{} will be skipped. Query in error: '{}', values: {}. Error message: {}", new Object[]{ tableName, - rowNum, + rowNum + 1, insertStatement, ArrayUtils.toString(insertParams), bsge.getMessage() }); - return; + continue; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-02-19 23:28:56
|
Revision: 278 http://svn.sourceforge.net/openutils/?rev=278&view=rev Author: fgiust Date: 2007-02-19 15:28:57 -0800 (Mon, 19 Feb 2007) Log Message: ----------- better handing of types, trim column names Modified Paths: -------------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 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 2007-02-19 23:08:13 UTC (rev 277) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2007-02-19 23:28:57 UTC (rev 278) @@ -126,7 +126,7 @@ String columnName = row.getCell(k).getStringCellValue(); if (StringUtils.isNotBlank(columnName)) { - columns.add(columnName); + columns.add(StringUtils.trim(columnName)); } else { @@ -138,7 +138,7 @@ final List<Integer> types = new ArrayList<Integer>(); - new JdbcTemplate(dataSource).execute(new ConnectionCallback() + boolean result = (Boolean) new JdbcTemplate(dataSource).execute(new ConnectionCallback() { public Object doInConnection(Connection con) throws SQLException, DataAccessException @@ -150,12 +150,22 @@ { types.add(res.getInt("DATA_TYPE")); } + else + { + log.warn("Unable to determine type for column '{}' in table '{}'", column, tableName); + return false; + } res.close(); } - return null; + return true; } }); + if (!result) + { + log.warn("Skipping sheet {} ", tableName); + } + String checkStatement = StringUtils.remove(StringUtils.trim(con.getCheckQuery()), "\n"); String insertStatement = StringUtils.remove(StringUtils.trim(con.getInsertQuery()), "\n"); @@ -258,15 +268,24 @@ if (existing == 0) { Object[] insertParams = ArrayUtils.subarray(values.toArray(), 0, insertNum); + int[] insertTypes = ArrayUtils.subarray(types, 0, insertNum); if (log.isDebugEnabled()) { log.debug("Missing record with key {}; inserting {}", ArrayUtils.toString(checkParams), ArrayUtils .toString(insertParams)); } + if (insertParams.length != insertTypes.length) + { + log.warn("Invalid number of param/type for table {}. Params: {}, types: {}", new Object[]{ + tableName, + insertParams.length, + insertTypes.length }); + } + try { - jdbcTemplate.update(insertStatement, insertParams, types); + jdbcTemplate.update(insertStatement, insertParams, insertTypes); } catch (DataIntegrityViolationException bsge) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-02-26 11:13:53
|
Revision: 308 http://svn.sourceforge.net/openutils/?rev=308&view=rev Author: fgiust Date: 2007-02-26 03:13:54 -0800 (Mon, 26 Feb 2007) Log Message: ----------- fix potential NPE Modified Paths: -------------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 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 2007-02-26 11:12:57 UTC (rev 307) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2007-02-26 11:13:54 UTC (rev 308) @@ -123,15 +123,19 @@ HSSFRow row = sheet.getRow(0); for (short k = 0; k < row.getLastCellNum(); k++) { - String columnName = row.getCell(k).getStringCellValue(); - if (StringUtils.isNotBlank(columnName)) + HSSFCell cell = row.getCell(k); + if (cell != null) { - columns.add(StringUtils.trim(columnName)); + String columnName = cell.getStringCellValue(); + if (StringUtils.isNotBlank(columnName)) + { + columns.add(StringUtils.trim(columnName)); + } + else + { + break; + } } - else - { - break; - } } log.debug("Table: {}, Columns: {}", tableName, columns); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-03-11 17:45:42
|
Revision: 315 http://svn.sourceforge.net/openutils/?rev=315&view=rev Author: fgiust Date: 2007-03-11 10:45:43 -0700 (Sun, 11 Mar 2007) Log Message: ----------- allow updates in ExcelConfigurationTask Modified Paths: -------------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 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 2007-03-05 10:59:55 UTC (rev 314) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2007-03-11 17:45:43 UTC (rev 315) @@ -17,6 +17,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; @@ -29,8 +30,10 @@ import org.springframework.dao.DataAccessException; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.jdbc.BadSqlGrammarException; +import org.springframework.jdbc.core.ColumnMapRowMapper; import org.springframework.jdbc.core.ConnectionCallback; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; /** @@ -172,6 +175,8 @@ String checkStatement = StringUtils.remove(StringUtils.trim(con.getCheckQuery()), "\n"); String insertStatement = StringUtils.remove(StringUtils.trim(con.getInsertQuery()), "\n"); + String selectStatement = StringUtils.remove(StringUtils.trim(con.getSelectQuery()), "\n"); + String updateStatement = StringUtils.remove(StringUtils.trim(con.getUpdateQuery()), "\n"); processRecords( sheet, @@ -179,6 +184,8 @@ ArrayUtils.toPrimitive(types.toArray(new Integer[types.size()]), Types.NULL), checkStatement, insertStatement, + selectStatement, + updateStatement, dataSource, tableName); } @@ -188,13 +195,17 @@ * @param columns * @param checkStatement * @param insertStatement + * @param updateStatement + * @param selectStatement */ private void processRecords(HSSFSheet sheet, List<String> columns, int[] types, String checkStatement, - String insertStatement, DataSource dataSource, String tableName) + String insertStatement, String selectStatement, String updateStatement, DataSource dataSource, String tableName) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); int checkNum = StringUtils.countMatches(checkStatement, "?"); int insertNum = StringUtils.countMatches(insertStatement, "?"); + int selectNum = StringUtils.countMatches(selectStatement, "?"); + int updateNum = StringUtils.countMatches(updateStatement, "?"); HSSFRow row; for (short rowNum = 1; rowNum <= sheet.getLastRowNum(); rowNum++) @@ -289,13 +300,13 @@ try { - jdbcTemplate.update(insertStatement, insertParams, insertTypes); + jdbcTemplate.update(updateStatement, insertParams, insertTypes); } catch (DataIntegrityViolationException bsge) { log .error( - "Error executing insert, record at {}:{} will be skipped. Query in error: '{}', values: {}. Error message: {}", + "Error executing update, record at {}:{} will be skipped. Query in error: '{}', values: {}. Error message: {}", new Object[]{ tableName, rowNum + 1, @@ -305,7 +316,91 @@ continue; } } + else if (StringUtils.isNotBlank(updateStatement) && StringUtils.isNotBlank(selectStatement)) + { + try + { + RowMapper rowMapper = new ColumnMapRowMapper(); + Object[] selectParams = ArrayUtils.subarray(values.toArray(), 0, selectNum); + List selectResult = jdbcTemplate.query(selectStatement, selectParams, rowMapper); + Map<String, Object> fetchedColumns = (Map<String, Object>) selectResult.get(0); + int i = 0; + boolean updateNeeded = false; + for (String columnName : columns) + { + Object columnObject = fetchedColumns.get(columnName); + if (columnObject == null) + { + continue; + } + String columnValue = ObjectUtils.toString(fetchedColumns.get(columnName)); + if (!StringUtils.equals(columnValue, values.get(i))) + { + updateNeeded = true; + break; + } + i++; + } + if (updateNeeded) + { + Object[] updateParams = ArrayUtils.subarray(values.toArray(), 0, updateNum); + int[] insertTypes = ArrayUtils.subarray(types, 0, insertNum); + if (log.isDebugEnabled()) + { + log.debug( + "Missing record with key {}; updating {}", + ArrayUtils.toString(checkParams), + ArrayUtils.toString(updateParams)); + } + if (updateParams.length != insertTypes.length) + { + log.warn("Invalid number of param/type for table {}. Params: {}, types: {}", new Object[]{ + tableName, + updateParams.length, + insertTypes.length }); + } + + try + { + Object[] compoundUpdateParams = new Object[checkParams.length + updateParams.length]; + System.arraycopy(updateParams, 0, compoundUpdateParams, 0, updateParams.length); + System.arraycopy( + checkParams, + 0, + compoundUpdateParams, + compoundUpdateParams.length - 1, + checkParams.length); + jdbcTemplate.update(updateStatement, compoundUpdateParams); + } + catch (DataIntegrityViolationException bsge) + { + log + .error( + "Error executing insert, record at {}:{} will be skipped. Query in error: '{}', values: {}. Error message: {}", + new Object[]{ + tableName, + rowNum + 1, + insertStatement, + ArrayUtils.toString(updateParams), + bsge.getMessage() }); + continue; + } + } + } + catch (BadSqlGrammarException bsge) + { + log + .error( + "Error executing query to load row values, current possible update of row will be skipped. {} Query in error: {}", + bsge.getMessage(), + checkStatement); + return; + } + // 1 check if it is the same + // 2 update only if they differ + } + } } @@ -320,7 +415,29 @@ private String insertQuery; + private String selectQuery; + + private String updateQuery; + /** + * Returns the selectQuery. + * @return the selectQuery + */ + public String getSelectQuery() + { + return selectQuery; + } + + /** + * Sets the selectQuery. + * @param selectQuery the selectQuery to set + */ + public void setSelectQuery(String selectQuery) + { + this.selectQuery = selectQuery; + } + + /** * Returns the checkQuery. * @return the checkQuery */ @@ -355,5 +472,23 @@ { this.insertQuery = insertQuery; } + + /** + * Returns the updateQuery. + * @return the updateQuery + */ + public String getUpdateQuery() + { + return updateQuery; + } + + /** + * Sets the updateQuery. + * @param updateQuery the updateQuery to set + */ + public void setUpdateQuery(String updateQuery) + { + this.updateQuery = updateQuery; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-03-11 21:45:50
|
Revision: 319 http://svn.sourceforge.net/openutils/?rev=319&view=rev Author: fgiust Date: 2007-03-11 14:45:50 -0700 (Sun, 11 Mar 2007) Log Message: ----------- wrong statement used on insert Modified Paths: -------------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 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 2007-03-11 17:46:51 UTC (rev 318) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2007-03-11 21:45:50 UTC (rev 319) @@ -300,7 +300,7 @@ try { - jdbcTemplate.update(updateStatement, insertParams, insertTypes); + jdbcTemplate.update(insertStatement, insertParams, insertTypes); } catch (DataIntegrityViolationException bsge) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2007-05-04 16:56:00
|
Revision: 327 http://svn.sourceforge.net/openutils/?rev=327&view=rev Author: fgiust Date: 2007-05-04 09:49:46 -0700 (Fri, 04 May 2007) Log Message: ----------- updateEnabled property added Modified Paths: -------------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 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 2007-04-04 11:12:36 UTC (rev 326) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2007-05-04 16:49:46 UTC (rev 327) @@ -53,6 +53,12 @@ private Map<String, ExcelConfigurationTask.QueryConfig> config; /** + * If true, when a record already exists and an updated query is defined it will be updated. Set it to false to only + * insert new records. + */ + private boolean updateEnabled = true; + + /** * Sets the script. * @param script the script to set */ @@ -71,6 +77,15 @@ } /** + * Sets the updateEnabled. + * @param updateEnabled the updateEnabled to set + */ + public void setUpdateEnabled(boolean updateEnabled) + { + this.updateEnabled = updateEnabled; + } + + /** * {@inheritDoc} */ public void execute(DataSource dataSource) @@ -316,7 +331,9 @@ continue; } } - else if (StringUtils.isNotBlank(updateStatement) && StringUtils.isNotBlank(selectStatement)) + else if (updateEnabled + && StringUtils.isNotBlank(updateStatement) + && StringUtils.isNotBlank(selectStatement)) { try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |