sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-887: Sqoop2: Move string constants from FormDisplayer to resource file
Date Fri, 15 Mar 2013 20:01:45 GMT
Updated Branches:
  refs/heads/sqoop2 0cc834928 -> daccebac5


SQOOP-887: Sqoop2: Move string constants from FormDisplayer to resource file

(Vasanth kumar RJ via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/daccebac
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/daccebac
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/daccebac

Branch: refs/heads/sqoop2
Commit: daccebac519f65d5d8a62e6be421ff1e382ffa06
Parents: 0cc8349
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Fri Mar 15 13:00:49 2013 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Fri Mar 15 13:00:49 2013 -0700

----------------------------------------------------------------------
 .../org/apache/sqoop/client/core/Constants.java    |   31 ++++++++++++
 .../sqoop/client/shell/ShellEnvironment.java       |    4 ++
 .../apache/sqoop/client/utils/FormDisplayer.java   |   37 ++++++++-------
 .../src/main/resources/client-resource.properties  |   17 +++++++
 4 files changed, 71 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/daccebac/client/src/main/java/org/apache/sqoop/client/core/Constants.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/core/Constants.java b/client/src/main/java/org/apache/sqoop/client/core/Constants.java
index ae3f994..cc80df1 100644
--- a/client/src/main/java/org/apache/sqoop/client/core/Constants.java
+++ b/client/src/main/java/org/apache/sqoop/client/core/Constants.java
@@ -316,6 +316,37 @@ public class Constants {
   public static final String RES_TABLE_HEADER_CONNECTOR =
       "table.header.connector";
 
+  public static final String RES_FORMDISPLAYER_SUPPORTED_JOBTYPE =
+      "formdisplayer.supported_job_types";
+  public static final String RES_FORMDISPLAYER_CONNECTION =
+      "formdisplayer.connection";
+  public static final String RES_FORMDISPLAYER_JOB =
+      "formdisplayer.job";
+  public static final String RES_FORMDISPLAYER_FORM_JOBTYPE =
+      "formdisplayer.forms_jobtype";
+  public static final String RES_FORMDISPLAYER_FORM =
+      "formdisplayer.form";
+  public static final String RES_FORMDISPLAYER_NAME =
+      "formdisplayer.name";
+  public static final String RES_FORMDISPLAYER_LABEL =
+      "formdisplayer.label";
+  public static final String RES_FORMDISPLAYER_HELP =
+      "formdisplayer.help";
+  public static final String RES_FORMDISPLAYER_INPUT =
+      "formdisplayer.input";
+  public static final String RES_FORMDISPLAYER_TYPE =
+      "formdisplayer.type";
+  public static final String RES_FORMDISPLAYER_MASK =
+      "formdisplayer.mask";
+  public static final String RES_FORMDISPLAYER_SIZE =
+      "formdisplayer.size";
+  public static final String RES_FORMDISPLAYER_POSSIBLE_VALUES =
+      "formdisplayer.possible_values";
+  public static final String RES_FORMDISPLAYER_UNSUPPORTED_DATATYPE =
+      "formdisplayer.unsupported_datatype";
+  public static final String RES_FORMDISPLAYER_INPUT_SENSITIVE =
+      "formdisplayer.input_sensitive";
+
   private Constants() {
     // Instantiation is prohibited
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/daccebac/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java b/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
index 8c133f2..25ae364 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
@@ -144,4 +144,8 @@ public final class ShellEnvironment {
   public static void print(Object obj) {
     io.out.print(obj);
   }
+
+  public static void print(String format, Object... args) {
+    io.out.printf(format, args);
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/daccebac/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java b/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java
index abd9643..0609ae1 100644
--- a/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java
+++ b/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java
@@ -17,6 +17,7 @@
  */
 package org.apache.sqoop.client.utils;
 
+import org.apache.sqoop.client.core.Constants;
 import org.apache.sqoop.model.MEnumInput;
 import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.model.MFramework;
@@ -42,20 +43,20 @@ public final class FormDisplayer {
 
   public static void displayFormMetadataDetails(MFramework framework,
                                                 ResourceBundle bundle) {
-    print("  Supported job types: ");
+    print("  %s: ", resourceString(Constants.RES_FORMDISPLAYER_SUPPORTED_JOBTYPE));
     println(framework.getAllJobsForms().keySet().toString());
 
     displayFormsMetadata(
       framework.getConnectionForms().getForms(),
-      "Connection",
+      resourceString(Constants.RES_FORMDISPLAYER_CONNECTION),
       bundle);
 
     for (MJobForms jobForms : framework.getAllJobsForms().values()) {
-      print("  Forms for job type ");
+      print("  %s ", resourceString(Constants.RES_FORMDISPLAYER_FORM_JOBTYPE));
       print(jobForms.getType().name());
       println(":");
 
-      displayFormsMetadata(jobForms.getForms(), "Job", bundle);
+      displayFormsMetadata(jobForms.getForms(), resourceString(Constants.RES_FORMDISPLAYER_JOB),
bundle);
     }
   }
 
@@ -67,46 +68,46 @@ public final class FormDisplayer {
     while (fiter.hasNext()) {
       print("    ");
       print(type);
-      print(" form ");
+      print(" %s ", resourceString(Constants.RES_FORMDISPLAYER_FORM));
       print(findx++);
       println(":");
 
       MForm form = fiter.next();
-      print("      Name: ");
+      print("      %s: ", resourceString(Constants.RES_FORMDISPLAYER_NAME));
       println(form.getName());
 
       // Label
-      print("      Label: ");
+      print("      %s: ", resourceString(Constants.RES_FORMDISPLAYER_LABEL));
       println(bundle.getString(form.getLabelKey()));
 
       // Help text
-      print("      Help: ");
+      print("      %s: ", resourceString(Constants.RES_FORMDISPLAYER_HELP));
       println(bundle.getString(form.getHelpKey()));
 
       List<MInput<?>> inputs = form.getInputs();
       Iterator<MInput<?>> iiter = inputs.iterator();
       int iindx = 1;
       while (iiter.hasNext()) {
-        print("      Input ");
+        print("      %s ", resourceString(Constants.RES_FORMDISPLAYER_INPUT));
         print(iindx++);
         println(":");
 
         MInput<?> input = iiter.next();
-        print("        Name: ");
+        print("        %s: ", resourceString(Constants.RES_FORMDISPLAYER_NAME));
         println(input.getName());
-        print("        Label: ");
+        print("        %s: ", resourceString(Constants.RES_FORMDISPLAYER_LABEL));
         println(bundle.getString(input.getLabelKey()));
-        print("        Help: ");
+        print("        %s: ", resourceString(Constants.RES_FORMDISPLAYER_HELP));
         println(bundle.getString(input.getHelpKey()));
-        print("        Type: ");
+        print("        %s: ", resourceString(Constants.RES_FORMDISPLAYER_TYPE));
         println(input.getType());
         if (input.getType() == MInputType.STRING) {
-          print("        Mask: ");
+          print("        %s: ", resourceString(Constants.RES_FORMDISPLAYER_MASK));
           println(((MStringInput)input).isMasked());
-          print("        Size: ");
+          print("        %s: ", resourceString(Constants.RES_FORMDISPLAYER_SIZE));
           println(((MStringInput)input).getMaxLength());
         } else if(input.getType() == MInputType.ENUM) {
-          print("        Possible values: ");
+          print("        %s: ", resourceString(Constants.RES_FORMDISPLAYER_POSSIBLE_VALUES));
           println(StringUtils.join(((MEnumInput)input).getValues(), ","));
         }
       }
@@ -143,7 +144,7 @@ public final class FormDisplayer {
             displayInputEnum((MEnumInput) input);
             break;
           default:
-            println("Unsupported data type " + input.getType());
+            print("\n%s " + input.getType(), resourceString(Constants.RES_FORMDISPLAYER_UNSUPPORTED_DATATYPE));
             return;
         }
       }
@@ -158,7 +159,7 @@ public final class FormDisplayer {
    */
   private static void displayInputString(MStringInput input) {
     if (input.isMasked()) {
-      print("(This input is sensitive)");
+      print("(%s)", resourceString(Constants.RES_FORMDISPLAYER_INPUT_SENSITIVE));
     } else {
       print(input.getValue());
     }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/daccebac/client/src/main/resources/client-resource.properties
----------------------------------------------------------------------
diff --git a/client/src/main/resources/client-resource.properties b/client/src/main/resources/client-resource.properties
index c3a22bb..734333e 100644
--- a/client/src/main/resources/client-resource.properties
+++ b/client/src/main/resources/client-resource.properties
@@ -170,3 +170,20 @@ table.header.version = Version
 table.header.class = Class
 table.header.type = Type
 table.header.connector = Connector
+
+#Form displayer resources
+formdisplayer.supported_job_types = Supported job types
+formdisplayer.connection = Connection
+formdisplayer.job = Job
+formdisplayer.forms_jobtype = Forms for job type
+formdisplayer.form = form
+formdisplayer.name = Name
+formdisplayer.label = Label
+formdisplayer.help = Help
+formdisplayer.input = Input
+formdisplayer.type = Type
+formdisplayer.mask = Mask
+formdisplayer.size = Size
+formdisplayer.possible_values = Possible values
+formdisplayer.unsupported_datatype = Unsupported data type
+formdisplayer.input_sensitive = This input is sensitive


Mime
View raw message