Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 93CAA200BDE for ; Mon, 7 Nov 2016 21:51:32 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 92A1E160B11; Mon, 7 Nov 2016 20:51:32 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7CD80160B15 for ; Mon, 7 Nov 2016 21:51:30 +0100 (CET) Received: (qmail 59717 invoked by uid 500); 7 Nov 2016 20:51:28 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 57082 invoked by uid 99); 7 Nov 2016 20:51:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2016 20:51:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 14481EEE7B; Mon, 7 Nov 2016 20:51:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ncole@apache.org To: commits@ambari.apache.org Date: Mon, 07 Nov 2016 20:52:09 -0000 Message-Id: <5ef4875e08ae4f5f9011b0775d767a88@git.apache.org> In-Reply-To: <4ebb78072e18430f93a3fac65827b60c@git.apache.org> References: <4ebb78072e18430f93a3fac65827b60c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [46/55] [abbrv] ambari git commit: AMBARI-17943 : removed the linefeed and carriage return and improved UX (nitirajrathore) archived-at: Mon, 07 Nov 2016 20:51:32 -0000 AMBARI-17943 : removed the linefeed and carriage return and improved UX (nitirajrathore) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b5378332 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b5378332 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b5378332 Branch: refs/heads/branch-dev-patch-upgrade Commit: b5378332b5c3e836e9c4e54fe73884d61cd8c1b6 Parents: 02e2c48 Author: Nitiraj Rathore Authored: Mon Nov 7 20:20:07 2016 +0530 Committer: Nitiraj Rathore Committed: Mon Nov 7 20:20:07 2016 +0530 ---------------------------------------------------------------------- .../ui/hive-web/app/controllers/upload-table.js | 10 +++++++--- .../ui/hive-web/app/templates/upload-table.hbs | 5 +++++ .../ui/hive-web/app/controllers/upload-table.js | 11 ++++++++--- .../ui/hive-web/app/templates/upload-table.hbs | 7 ++++++- .../resources/upload/OpenCSVParserTest.java | 20 ++++++++++++++++++++ .../view/hive/resources/upload/OpenCSVTest.java | 17 ++++++++++++++--- 6 files changed, 60 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/b5378332/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/upload-table.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/upload-table.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/upload-table.js index 061a445..cde9503 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/upload-table.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/upload-table.js @@ -35,10 +35,8 @@ export default Ember.Controller.extend({ {"id":"7", "name":"BEL", "description":"(bell)"}, {"id":"8", "name":"BS", "description":"(backspace)"}, {"id":"9", "name":"TAB", "description":"(horizontal tab)"}, - {"id":"10", "name":"LF", "description":"(NL line feed - new line)"}, {"id":"11", "name":"VT", "description":"(vertical tab)"}, {"id":"12", "name":"FF", "description":"(NP form feed - new page)"}, - {"id":"13", "name":"CR", "description":"(carriage return)"}, {"id":"14", "name":"SO", "description":"(shift out)"}, {"id":"15", "name":"SI", "description":"(shift in)"}, {"id":"16", "name":"DLE", "description":"(data link escape)"}, @@ -153,18 +151,24 @@ export default Ember.Controller.extend({ onChangeUploadSource : function(){ this.clearFields(); }.observes("uploadSource"), + asciiFormatter: function( option, escape ){ + if( option.data.id != -1 ) + return "
" + option.data.id + "" + option.data.name + "
"; + else return "
"; + }, fillAsciiList: function(){ var list = this.get('asciiList'); list.push({"id": -1, "name": ""}); var nonPrintable = this.get('NON_PRINTABLE_CHARS'); for( var i = 0 ; i <= 127 ; i++ ){ + if( i == 10 || i == 13 ) continue; var charInfo = nonPrintable.find(function(item){ return item.id == i; }); if(!charInfo){ charInfo = {"id": i, "name": String.fromCodePoint(i), "description":"" }; } - var option = {"id": i, "name": charInfo.id + " " + charInfo.name + charInfo.description}; + var option = {"id": i, "name": charInfo.name + charInfo.description}; list.push(option); if(i === 44){ this.set("csvDelimiter", option); http://git-wip-us.apache.org/repos/asf/ambari/blob/b5378332/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/upload-table.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/upload-table.hbs b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/upload-table.hbs index d84dc4d..b479430 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/upload-table.hbs +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/upload-table.hbs @@ -61,6 +61,7 @@ optionValuePath="id" optionLabelPath="name" selection=csvDelimiter + optionFunction=asciiFormatter }} @@ -72,6 +73,7 @@ optionValuePath="id" optionLabelPath="name" selection=csvEscape + optionFunction=asciiFormatter }} @@ -83,6 +85,7 @@ optionValuePath="id" optionLabelPath="name" selection=csvQuote + optionFunction=asciiFormatter }} @@ -118,6 +121,7 @@ optionValuePath="id" optionLabelPath="name" selection=fieldsTerminatedBy + optionFunction=asciiFormatter }} @@ -129,6 +133,7 @@ optionValuePath="id" optionLabelPath="name" selection=escapedBy + optionFunction=asciiFormatter }} http://git-wip-us.apache.org/repos/asf/ambari/blob/b5378332/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/upload-table.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/upload-table.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/upload-table.js index 061a445..e217e7d 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/upload-table.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/upload-table.js @@ -35,10 +35,8 @@ export default Ember.Controller.extend({ {"id":"7", "name":"BEL", "description":"(bell)"}, {"id":"8", "name":"BS", "description":"(backspace)"}, {"id":"9", "name":"TAB", "description":"(horizontal tab)"}, - {"id":"10", "name":"LF", "description":"(NL line feed - new line)"}, {"id":"11", "name":"VT", "description":"(vertical tab)"}, {"id":"12", "name":"FF", "description":"(NP form feed - new page)"}, - {"id":"13", "name":"CR", "description":"(carriage return)"}, {"id":"14", "name":"SO", "description":"(shift out)"}, {"id":"15", "name":"SI", "description":"(shift in)"}, {"id":"16", "name":"DLE", "description":"(data link escape)"}, @@ -153,18 +151,25 @@ export default Ember.Controller.extend({ onChangeUploadSource : function(){ this.clearFields(); }.observes("uploadSource"), + asciiFormatter: function( option, escape ){ + if( option.data.id != -1 ) + return "
" + option.data.id + "" + option.data.name + "
"; + else + return "
"; + }, fillAsciiList: function(){ var list = this.get('asciiList'); list.push({"id": -1, "name": ""}); var nonPrintable = this.get('NON_PRINTABLE_CHARS'); for( var i = 0 ; i <= 127 ; i++ ){ + if( i == 10 || i == 13 ) continue; var charInfo = nonPrintable.find(function(item){ return item.id == i; }); if(!charInfo){ charInfo = {"id": i, "name": String.fromCodePoint(i), "description":"" }; } - var option = {"id": i, "name": charInfo.id + " " + charInfo.name + charInfo.description}; + var option = {"id": i, "name": charInfo.name + charInfo.description}; list.push(option); if(i === 44){ this.set("csvDelimiter", option); http://git-wip-us.apache.org/repos/asf/ambari/blob/b5378332/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/upload-table.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/upload-table.hbs b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/upload-table.hbs index d84dc4d..1638804 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/upload-table.hbs +++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/upload-table.hbs @@ -61,6 +61,7 @@ optionValuePath="id" optionLabelPath="name" selection=csvDelimiter + optionFunction=asciiFormatter }} @@ -72,7 +73,8 @@ optionValuePath="id" optionLabelPath="name" selection=csvEscape - }} + optionFunction=asciiFormatter + }} @@ -83,6 +85,7 @@ optionValuePath="id" optionLabelPath="name" selection=csvQuote + optionFunction=asciiFormatter }} @@ -118,6 +121,7 @@ optionValuePath="id" optionLabelPath="name" selection=fieldsTerminatedBy + optionFunction=asciiFormatter }} @@ -129,6 +133,7 @@ optionValuePath="id" optionLabelPath="name" selection=escapedBy + optionFunction=asciiFormatter }} http://git-wip-us.apache.org/repos/asf/ambari/blob/b5378332/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/resources/upload/OpenCSVParserTest.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/resources/upload/OpenCSVParserTest.java b/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/resources/upload/OpenCSVParserTest.java index 2c890f5..5256b5a 100644 --- a/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/resources/upload/OpenCSVParserTest.java +++ b/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/resources/upload/OpenCSVParserTest.java @@ -192,6 +192,26 @@ public class OpenCSVParserTest { } @Test + public void testMultipleEscape() throws Exception { + + String csv = "BBAABBKMAABB"; + ParseOptions po = new ParseOptions(); + po.setOption(ParseOptions.OPTIONS_CSV_ESCAPE_CHAR,'B'); + po.setOption(ParseOptions.OPTIONS_CSV_DELIMITER,'M'); + + try( + StringReader sr = new StringReader(csv); + OpenCSVParser jp = new OpenCSVParser(sr, po); + ) { + Iterator iterator = jp.iterator(); + + Row row = new Row(new Object[]{"AABK", "AAB"}); + Assert.assertEquals("Failed to detect 1st row!", true, iterator.hasNext()); + Assert.assertEquals("Failed to match 1st row!", row, iterator.next()); + } + } + + @Test public void testSpecialEscapedEscape() throws Exception { String csv = "aaa,b$$bb,ccc"; http://git-wip-us.apache.org/repos/asf/ambari/blob/b5378332/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/resources/upload/OpenCSVTest.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/resources/upload/OpenCSVTest.java b/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/resources/upload/OpenCSVTest.java index be5733f..0bdf5cf 100644 --- a/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/resources/upload/OpenCSVTest.java +++ b/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/resources/upload/OpenCSVTest.java @@ -21,15 +21,12 @@ package org.apache.ambari.view.hive.resources.upload; import com.opencsv.CSVParser; import com.opencsv.CSVReader; import com.opencsv.CSVWriter; -import org.apache.ambari.view.hive.client.Row; import org.junit.Assert; import org.junit.Test; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; -import java.util.Arrays; -import java.util.Iterator; public class OpenCSVTest { @@ -133,6 +130,20 @@ public class OpenCSVTest { } @Test + public void testMultipleEscape() throws Exception { + + String csv = "BBAABBKMAABB"; + + try( + StringReader sr = new StringReader(csv); + CSVReader csvReader = new CSVReader(sr,'M','"','B'); + ) { + String[] row1 = csvReader.readNext(); + Assert.assertArrayEquals("Failed to match 1st row!",new String[]{"AABK", "AAB"}, row1); + } + } + + @Test public void testParseCustomSeparatorAndCustomQuote() throws Exception { String csv = "\'valu#e1\'#c#10#10.1\n" +