From 5aec75696d5d6b8f7bb9e255ce8f6eb997a497a0 Mon Sep 17 00:00:00 2001 From: David Huynh Date: Sun, 6 Nov 2011 20:13:05 +0000 Subject: [PATCH] Fixed Issue 477 in google-refine: Implement or remove the line separator option. Also, fixed displaying bug in the fixed-width parser UI: previously, tab characters forced columns to be wider. git-svn-id: http://google-refine.googlecode.com/svn/trunk@2364 7d457c2a-affb-35e4-300a-418c747d4874 --- .../refine/importers/FixedWidthImporter.java | 3 --- .../google/refine/importers/LineBasedImporter.java | 1 - .../refine/importers/SeparatorBasedImporter.java | 4 ---- .../parser-interfaces/fixed-width-parser-ui.html | 14 ++------------ .../parser-interfaces/fixed-width-parser-ui.js | 13 +------------ .../parser-interfaces/line-based-parser-ui.html | 14 ++------------ .../parser-interfaces/line-based-parser-ui.js | 11 ----------- .../separator-based-parser-ui.html | 10 +--------- .../parser-interfaces/separator-based-parser-ui.js | 11 ----------- 9 files changed, 6 insertions(+), 75 deletions(-) diff --git a/main/src/com/google/refine/importers/FixedWidthImporter.java b/main/src/com/google/refine/importers/FixedWidthImporter.java index 7a476db17..cc1312202 100644 --- a/main/src/com/google/refine/importers/FixedWidthImporter.java +++ b/main/src/com/google/refine/importers/FixedWidthImporter.java @@ -44,7 +44,6 @@ public class FixedWidthImporter extends TabularImportingParserBase { } } - JSONUtilities.safePut(options, "lineSeparator", "\\n"); JSONUtilities.safePut(options, "headerLines", 0); JSONUtilities.safePut(options, "columnWidths", columnWidths); JSONUtilities.safePut(options, "guessCellValueTypes", true); @@ -63,8 +62,6 @@ public class FixedWidthImporter extends TabularImportingParserBase { JSONObject options, List exceptions ) { -// String lineSeparator = JSONUtilities.getString(options, "lineSeparator", "\\n"); -// lineSeparator = StringEscapeUtils.unescapeJava(lineSeparator); final int[] columnWidths = JSONUtilities.getIntArray(options, "columnWidths"); List retrievedColumnNames = null; diff --git a/main/src/com/google/refine/importers/LineBasedImporter.java b/main/src/com/google/refine/importers/LineBasedImporter.java index 5d623bfd0..3fa0c16fb 100644 --- a/main/src/com/google/refine/importers/LineBasedImporter.java +++ b/main/src/com/google/refine/importers/LineBasedImporter.java @@ -27,7 +27,6 @@ public class LineBasedImporter extends TabularImportingParserBase { ImportingJob job, List fileRecords, String format) { JSONObject options = super.createParserUIInitializationData(job, fileRecords, format); - JSONUtilities.safePut(options, "lineSeparator", "\\n"); JSONUtilities.safePut(options, "linesPerRow", 1); JSONUtilities.safePut(options, "headerLines", 0); JSONUtilities.safePut(options, "guessCellValueTypes", true); diff --git a/main/src/com/google/refine/importers/SeparatorBasedImporter.java b/main/src/com/google/refine/importers/SeparatorBasedImporter.java index 943794a78..9e994b2b5 100644 --- a/main/src/com/google/refine/importers/SeparatorBasedImporter.java +++ b/main/src/com/google/refine/importers/SeparatorBasedImporter.java @@ -69,8 +69,6 @@ public class SeparatorBasedImporter extends TabularImportingParserBase { List fileRecords, String format) { JSONObject options = super.createParserUIInitializationData(job, fileRecords, format); - JSONUtilities.safePut(options, "lineSeparator", "\\n"); - String separator = guessSeparator(job, fileRecords); JSONUtilities.safePut(options, "separator", separator != null ? separator : "\\t"); @@ -91,8 +89,6 @@ public class SeparatorBasedImporter extends TabularImportingParserBase { JSONObject options, List exceptions ) { -// String lineSeparator = JSONUtilities.getString(options, "lineSeparator", "\\n"); -// lineSeparator = StringEscapeUtils.unescapeJava(lineSeparator); String sep = JSONUtilities.getString(options, "separator", "\\t"); if (sep == null || "".equals(sep)) { sep = "\\t"; diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/fixed-width-parser-ui.html b/main/webapp/modules/core/scripts/index/parser-interfaces/fixed-width-parser-ui.html index 2c91641d2..560bd7c2c 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/fixed-width-parser-ui.html +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/fixed-width-parser-ui.html @@ -6,7 +6,7 @@ -
+ -
@@ -14,22 +14,12 @@
 
+ - - -
Column widths:comma separated numbers
Column names:optional, comma separated
- - - - - - -
Rows are separated by
-
Escape special characters with \
diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/fixed-width-parser-ui.js b/main/webapp/modules/core/scripts/index/parser-interfaces/fixed-width-parser-ui.js index 035efcbab..f53376959 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/fixed-width-parser-ui.js +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/fixed-width-parser-ui.js @@ -72,12 +72,6 @@ Refine.FixedWidthParserUI.prototype.getOptions = function() { options.columnNames = columnNames; } - if (this._optionContainer.find("input[name='row-separator']:checked")[0].value === "new-line") { - options.lineSeparator = "\\n"; - } else { - options.lineSeparator = this._optionContainerElmts.rowSeparatorInput[0].value; - } - var parseIntDefault = function(s, def) { try { var n = parseInt(s,10); @@ -140,11 +134,6 @@ Refine.FixedWidthParserUI.prototype._initialize = function() { this._optionContainerElmts.columnNamesInput[0].value = this._config.columnNames.join(','); } - var rowSeparatorValue = (this._config.lineSeparator == "\\n") ? 'new-line' : 'custom'; - this._optionContainer.find( - "input[name='row-separator'][value='" + rowSeparatorValue + "']").attr("checked", "checked"); - this._optionContainerElmts.rowSeparatorInput[0].value = this._config.lineSeparator; - if (this._config.ignoreLines > 0) { this._optionContainerElmts.ignoreCheckbox.attr("checked", "checked"); this._optionContainerElmts.ignoreInput[0].value = this._config.ignoreLines.toString(); @@ -326,7 +315,7 @@ Refine.FixedWidthPreviewTable.prototype._render = function() { .attr("target", "_blank") .appendTo(divContent); } else { - $('').text(cell.v).appendTo(divContent); + $('').text(cell.v.replace(/\s/g, ' ')).appendTo(divContent); } } } diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/line-based-parser-ui.html b/main/webapp/modules/core/scripts/index/parser-interfaces/line-based-parser-ui.html index dcc49e384..a83e49b39 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/line-based-parser-ui.html +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/line-based-parser-ui.html @@ -6,7 +6,7 @@
+ - - -
@@ -19,16 +19,6 @@ lines into one row - - - - - - -
 
Lines are separated by
-
Escape special characters with \
@@ -37,7 +27,7 @@
+ - +
diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/line-based-parser-ui.js b/main/webapp/modules/core/scripts/index/parser-interfaces/line-based-parser-ui.js index 8a38ac693..17aba7504 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/line-based-parser-ui.js +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/line-based-parser-ui.js @@ -80,12 +80,6 @@ Refine.LineBasedParserUI.prototype.getOptions = function() { }; options.linesPerRow = parseIntDefault(this._optionContainerElmts.linesPerRowInput[0].value, 1); - if (this._optionContainer.find("input[name='row-separator']:checked")[0].value === "new-line") { - options.lineSeparator = "\\n"; - } else { - options.lineSeparator = this._optionContainerElmts.rowSeparatorInput[0].value; - } - if (this._optionContainerElmts.ignoreCheckbox[0].checked) { options.ignoreLines = parseIntDefault(this._optionContainerElmts.ignoreInput[0].value, -1); } else { @@ -127,11 +121,6 @@ Refine.LineBasedParserUI.prototype._initialize = function() { this._optionContainerElmts.linesPerRowInput[0].value = this._config.linesPerRow.toString(); - var rowSeparatorValue = (this._config.lineSeparator == "\\n") ? 'new-line' : 'custom'; - this._optionContainer.find( - "input[name='row-separator'][value='" + rowSeparatorValue + "']").attr("checked", "checked"); - this._optionContainerElmts.rowSeparatorInput[0].value = this._config.lineSeparator; - if (this._config.ignoreLines > 0) { this._optionContainerElmts.ignoreCheckbox.attr("checked", "checked"); this._optionContainerElmts.ignoreInput[0].value = this._config.ignoreLines.toString(); diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/separator-based-parser-ui.html b/main/webapp/modules/core/scripts/index/parser-interfaces/separator-based-parser-ui.html index 1b3fa7ef1..30455d16a 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/separator-based-parser-ui.html +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/separator-based-parser-ui.html @@ -49,15 +49,7 @@
- - - - - - -
Rows are separated by
-
Escape special characters with \
 
diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/separator-based-parser-ui.js b/main/webapp/modules/core/scripts/index/parser-interfaces/separator-based-parser-ui.js index eb5be8889..03b3e0425 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/separator-based-parser-ui.js +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/separator-based-parser-ui.js @@ -65,12 +65,6 @@ Refine.SeparatorBasedParserUI.prototype.getOptions = function() { encoding: $.trim(this._optionContainerElmts.encodingInput[0].value) }; - if (this._optionContainer.find("input[name='row-separator']:checked")[0].value === "new-line") { - options.lineSeparator = "\\n"; - } else { - options.lineSeparator = this._optionContainerElmts.rowSeparatorInput[0].value; - } - switch (this._optionContainer.find("input[name='column-separator']:checked")[0].value) { case 'comma': options.separator = ","; @@ -140,11 +134,6 @@ Refine.SeparatorBasedParserUI.prototype._initialize = function() { }); }); - var rowSeparatorValue = (this._config.lineSeparator == "\\n") ? 'new-line' : 'custom'; - this._optionContainer.find( - "input[name='row-separator'][value='" + rowSeparatorValue + "']").attr("checked", "checked"); - this._optionContainerElmts.rowSeparatorInput[0].value = this._config.lineSeparator; - var columnSeparatorValue = (this._config.separator == ",") ? 'comma' : ((this._config.separator == "\\t") ? 'tab' : 'custom'); this._optionContainer.find(