ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [01/22] ambari git commit: AMBARI-17943 : removed the linefeed and carriage return and improved UX (nitirajrathore)
Date Tue, 08 Nov 2016 20:25:09 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-18634 4024e1389 -> 3ce19737c


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-feature-AMBARI-18634
Commit: b5378332b5c3e836e9c4e54fe73884d61cd8c1b6
Parents: 02e2c48
Author: Nitiraj Rathore <nitiraj.rathore@gmail.com>
Authored: Mon Nov 7 20:20:07 2016 +0530
Committer: Nitiraj Rathore <nitiraj.rathore@gmail.com>
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 "<div><span style='font-weight: bold;margin: 5px'>" + option.data.id
+ "</span><span style='font-style: italic; color: grey; margin: 5px'>" + option.data.name
+ "</span></div>";
+    else return "<div></div>";
+  },
   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
               }}
             </td>
           </tr>
@@ -72,6 +73,7 @@
               optionValuePath="id"
               optionLabelPath="name"
               selection=csvEscape
+              optionFunction=asciiFormatter
               }}
             </td>
           </tr>
@@ -83,6 +85,7 @@
               optionValuePath="id"
               optionLabelPath="name"
               selection=csvQuote
+              optionFunction=asciiFormatter
               }}
             </td>
           </tr>
@@ -118,6 +121,7 @@
               optionValuePath="id"
               optionLabelPath="name"
               selection=fieldsTerminatedBy
+              optionFunction=asciiFormatter
               }}
             </td>
           </tr>
@@ -129,6 +133,7 @@
               optionValuePath="id"
               optionLabelPath="name"
               selection=escapedBy
+              optionFunction=asciiFormatter
               }}
             </td>
           </tr>

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 "<div><span style='font-weight: bold;margin: 5px'>" + option.data.id
+ "</span><span style='font-style: italic; color: grey; margin: 5px'>" + option.data.name
+ "</span></div>";
+    else
+      return "<div></div>";
+  },
   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
               }}
             </td>
           </tr>
@@ -72,7 +73,8 @@
               optionValuePath="id"
               optionLabelPath="name"
               selection=csvEscape
-              }}
+              optionFunction=asciiFormatter
+            }}
             </td>
           </tr>
           <tr>
@@ -83,6 +85,7 @@
               optionValuePath="id"
               optionLabelPath="name"
               selection=csvQuote
+              optionFunction=asciiFormatter
               }}
             </td>
           </tr>
@@ -118,6 +121,7 @@
               optionValuePath="id"
               optionLabelPath="name"
               selection=fieldsTerminatedBy
+              optionFunction=asciiFormatter
               }}
             </td>
           </tr>
@@ -129,6 +133,7 @@
               optionValuePath="id"
               optionLabelPath="name"
               selection=escapedBy
+              optionFunction=asciiFormatter
               }}
             </td>
           </tr>

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<Row> 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" +


Mime
View raw message