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 ae3f994a..cc80df10 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 } 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 8c133f22..25ae3646 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 static void print(String str) { public static void print(Object obj) { io.out.print(obj); } + + public static void print(String format, Object... args) { + io.out.printf(format, args); + } } 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 abd96431..0609ae10 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 static void displayFormsMetadata(List forms, 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> inputs = form.getInputs(); Iterator> 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 @@ private static void displayForm(MForm form, ResourceBundle bundle) { 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 @@ private static void displayForm(MForm form, ResourceBundle bundle) { */ 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()); } diff --git a/client/src/main/resources/client-resource.properties b/client/src/main/resources/client-resource.properties index c3a22bb2..734333ee 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