Review Board 1.7.22


SQOOP-648 Moving localizable strings to resources and consolidate all String constants to Constants.java

Review Request #8305 - Created Dec. 1, 2012 and updated

Venkat Ranganathan
Reviewers
Sqoop
jarcec
sqoop-sqoop2
I have moved localizable strings to the client resources (those that are descriptions, messages in general etc).  Also consolidated constants to one place and removed repetitive occurrences.   

4 more files in utils need to be updated, but wanted to get this reviewed and take that after this
Ran the SQOOP2 client tests and manually ran various client commands to make sure that all commands have their localizable strings and constants properly displayed apart from running all the unit tests.   No new tests were added
client/src/main/java/org/apache/sqoop/client/shell/ShowJobFunction.java
Revision ee8c63d New Change
[20] 16 lines
[+20]
17
 */
17
 */
18
package org.apache.sqoop.client.shell;
18
package org.apache.sqoop.client.shell;
19

    
   
19

   
20
import org.apache.commons.cli.CommandLine;
20
import org.apache.commons.cli.CommandLine;
21
import org.apache.commons.cli.OptionBuilder;
21
import org.apache.commons.cli.OptionBuilder;

    
   
22
import org.apache.sqoop.client.core.Constants;
22
import org.apache.sqoop.json.JobBean;
23
import org.apache.sqoop.json.JobBean;
23
import org.apache.sqoop.model.MJob;
24
import org.apache.sqoop.model.MJob;
24
import org.codehaus.groovy.tools.shell.IO;
25
import org.codehaus.groovy.tools.shell.IO;
25

    
   
26

   
26
import java.io.PrintWriter;
27
import java.io.PrintWriter;

    
   
28
import java.text.MessageFormat;
27
import java.util.List;
29
import java.util.List;

    
   
30
import java.util.ResourceBundle;
28

    
   
31

   
29
import static org.apache.sqoop.client.utils.FormDisplayer.*;
32
import static org.apache.sqoop.client.utils.FormDisplayer.*;
30
import static org.apache.sqoop.client.core.RequestCache.*;
33
import static org.apache.sqoop.client.core.RequestCache.*;
31

    
   
34

   
32
/**
35
/**
33
 *
36
 *
34
 */
37
 */
35
public class ShowJobFunction extends SqoopFunction {
38
public class ShowJobFunction extends SqoopFunction {
36

    
   
39
  private static final ResourceBundle clientResource =
37
  public static final String ALL = "all";
40
      ResourceBundle.getBundle(Constants.RESOURCE_NAME);
38
  public static final String JID = "jid";

   
39

    
   

   
40
  private IO io;
41
  private IO io;
41

    
   
42

   
42
  @SuppressWarnings("static-access")
43
  @SuppressWarnings("static-access")
43
  protected ShowJobFunction(IO io) {
44
  protected ShowJobFunction(IO io) {
44
    this.io = io;
45
    this.io = io;
45

    
   
46

   
46
    this.addOption(OptionBuilder
47
    this.addOption(OptionBuilder
47
        .withDescription("Display all jobs")
48
        .withDescription(clientResource.getString(Constants
48
        .withLongOpt(ALL)
49
            .RES_DISPLAY_ALL_JOBS))
49
        .create(ALL.charAt(0)));
50
        .withLongOpt(Constants.OPT_ALL)
50
    this.addOption(OptionBuilder.hasArg().withArgName("jid")
51
        .create(Constants.OPT_ALL.charAt(0)));
51
        .withDescription("Display job with given jid" )
52
    this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
52
        .withLongOpt(JID)
53
        .withDescription(clientResource.getString(Constants
53
        .create('j'));
54
            .RES_DISPLAY_JOB_JID))

    
   
55
        .withLongOpt(Constants.OPT_JID)

    
   
56
        .create(Constants.OPT_JID.charAt(0)));
54
  }
57
  }
55

    
   
58

   
56
  public void printHelp(PrintWriter out) {
59
  public void printHelp(PrintWriter out) {
57
    out.println("Usage: show job");
60
    out.println(clientResource.getString(Constants.RES_SHOW_JOB_USAGE));
58
    super.printHelp(out);
61
    super.printHelp(out);
59
  }
62
  }
60

    
   
63

   
61
  public Object execute(List<String> args) {
64
  public Object execute(List<String> args) {
62
    if (args.size() == 1) {
65
    if (args.size() == 1) {
63
      printHelp(io.out);
66
      printHelp(io.out);
64
      io.out.println();
67
      io.out.println();
65
      return null;
68
      return null;
66
    }
69
    }
67

    
   
70

   
68
    CommandLine line = parseOptions(this, 1, args);
71
    CommandLine line = parseOptions(this, 1, args);
69
    if (line.hasOption(ALL)) {
72
    if (line.hasOption(Constants.OPT_ALL)) {
70
      showJob(null);
73
      showJob(null);
71

    
   
74

   
72
    } else if (line.hasOption(JID)) {
75
    } else if (line.hasOption(Constants.OPT_JID)) {
73
      showJob(line.getOptionValue(JID));
76
      showJob(line.getOptionValue(Constants.OPT_JID));
74
    }
77
    }
75

    
   
78

   
76
    return null;
79
    return null;
77
  }
80
  }
78

    
   
81

   
79
  private void showJob(String jid) {
82
  private void showJob(String jid) {
80
    JobBean jobBean = readJob(jid);
83
    JobBean jobBean = readJob(jid);
81

    
   
84

   
82
    List<MJob> jobs = jobBean.getJobs();
85
    List<MJob> jobs = jobBean.getJobs();

    
   
86
    String s = MessageFormat.format(Constants

    
   
87
        .RES_JOBS_TO_SHOW, jobs.size());

    
   
88
    io.out.println(s);
83

    
   
89

   
84
    io.out.println("@|bold " + jobs.size()

   
85
      + " job(s) to show: |@");

   
86

    
   

   
87
    for (MJob job : jobs) {
90
    for (MJob job : jobs) {
88
      io.out.println("Job with id " + job.getPersistenceId()
91
      s = MessageFormat.format(clientResource.getString
89
        + " and name: " + job.getName());
92
          (Constants.RES_SHOW_CONNR_INFO), job.getPersistenceId(),

    
   
93
          job.getName());

    
   
94
      io.out.println(s);
90

    
   
95

   
91
      long connectorId = job.getConnectorId();
96
      long connectorId = job.getConnectorId();
92

    
   
97

   
93
      // Display connector part
98
      // Display connector part
94
      displayForms(io,
99
      displayForms(io,
95
                   job.getConnectorPart().getForms(),
100
                   job.getConnectorPart().getForms(),
96
                   jobBean.getConnectorBundle(connectorId));
101
                   jobBean.getConnectorBundle(connectorId));
97
      displayForms(io,
102
      displayForms(io,
98
                   job.getFrameworkPart().getForms(),
103
                   job.getFrameworkPart().getForms(),
99
                   jobBean.getFrameworkBundle());
104
                   jobBean.getFrameworkBundle());
100
    }
105
    }
101
  }
106
  }
102
}
107
}
client/src/main/java/org/apache/sqoop/client/shell/ShowServerFunction.java
Revision 039e28b New Change
 
client/src/main/java/org/apache/sqoop/client/shell/ShowVersionFunction.java
Revision 9e8c607 New Change
 
client/src/main/java/org/apache/sqoop/client/shell/SqoopCommand.java
Revision 9ae693e New Change
 
client/src/main/java/org/apache/sqoop/client/shell/SqoopFunction.java
Revision 200b3ee New Change
 
client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java
Revision b2d05f4 New Change
 
client/src/main/java/org/apache/sqoop/client/shell/SubmissionCommand.java
Revision 39a2b31 New Change
 
client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java
Revision 74ce905 New Change
 
client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java
Revision 4d683c0 New Change
 
client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java
Revision 97628f7 New Change
 
client/src/main/java/org/apache/sqoop/client/shell/UpdateCommand.java
Revision 5bac209 New Change
 
client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
Revision 4e55dba New Change
 
client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
Revision f7cdf26 New Change
 
client/src/main/java/org/apache/sqoop/client/utils/ThrowableDisplayer.java
Revision 45c78fb New Change
 
client/src/main/resources/client-resource.properties
Revision 201efe9 New Change
 
  1. client/src/main/java/org/apache/sqoop/client/shell/ShowJobFunction.java: Loading...
  2. client/src/main/java/org/apache/sqoop/client/shell/ShowServerFunction.java: Loading...
  3. client/src/main/java/org/apache/sqoop/client/shell/ShowVersionFunction.java: Loading...
  4. client/src/main/java/org/apache/sqoop/client/shell/SqoopCommand.java: Loading...
  5. client/src/main/java/org/apache/sqoop/client/shell/SqoopFunction.java: Loading...
  6. client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java: Loading...
  7. client/src/main/java/org/apache/sqoop/client/shell/SubmissionCommand.java: Loading...
  8. client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java: Loading...
  9. client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java: Loading...
  10. client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java: Loading...
  11. client/src/main/java/org/apache/sqoop/client/shell/UpdateCommand.java: Loading...
  12. client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java: Loading...
  13. client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java: Loading...
  14. client/src/main/java/org/apache/sqoop/client/utils/ThrowableDisplayer.java: Loading...
  15. client/src/main/resources/client-resource.properties: Loading...
This diff has been split across 2 pages: < 1 2