sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-920: Sqoop2: Print out warnings in client shell for objects created with status ACCEPTABLE
Date Wed, 27 Mar 2013 00:31:06 GMT
Updated Branches:
  refs/heads/sqoop2 3fd8bdffc -> 1a7731796


SQOOP-920: Sqoop2: Print out warnings in client shell for objects created with status ACCEPTABLE

(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/1a773179
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/1a773179
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/1a773179

Branch: refs/heads/sqoop2
Commit: 1a77317969574f68e0066ac7211d7bc20f3b6ab0
Parents: 3fd8bdf
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Tue Mar 26 17:29:53 2013 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Tue Mar 26 17:29:53 2013 -0700

----------------------------------------------------------------------
 .../org/apache/sqoop/client/core/Constants.java    |    3 +
 .../client/shell/CreateConnectionFunction.java     |    3 +-
 .../sqoop/client/shell/CreateJobFunction.java      |    3 +-
 .../client/shell/UpdateConnectionFunction.java     |    3 +-
 .../sqoop/client/shell/UpdateJobFunction.java      |    3 +-
 .../apache/sqoop/client/utils/FormDisplayer.java   |   32 +++++++++++++++
 .../src/main/resources/client-resource.properties  |    2 +
 7 files changed, 45 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a773179/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 b93577c..cc956d0 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
@@ -347,6 +347,9 @@ public class Constants {
   public static final String RES_FORMDISPLAYER_INPUT_SENSITIVE =
       "formdisplayer.input_sensitive";
 
+  public static final String RES_FORMDISPLAYER_FORM_WARNING =
+      "formdisplayer.warning_message";
+
   private Constants() {
     // Instantiation is prohibited
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a773179/client/src/main/java/org/apache/sqoop/client/shell/CreateConnectionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/CreateConnectionFunction.java
b/client/src/main/java/org/apache/sqoop/client/shell/CreateConnectionFunction.java
index 5bf9aaa..04238ee 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/CreateConnectionFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/CreateConnectionFunction.java
@@ -22,6 +22,7 @@ import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.OptionBuilder;
 import org.apache.sqoop.client.core.ClientError;
 import org.apache.sqoop.client.core.Constants;
+import org.apache.sqoop.client.utils.FormDisplayer;
 import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.model.MConnection;
 import org.apache.sqoop.validation.Status;
@@ -86,7 +87,7 @@ public class CreateConnectionFunction extends SqoopFunction {
       // Try to create
       status = client.createConnection(connection);
     } while(!status.canProceed());
-
+    FormDisplayer.displayFormWarning(connection);
     printlnResource(Constants.RES_CREATE_CONN_SUCCESSFUL, status.name(), connection.getPersistenceId());
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a773179/client/src/main/java/org/apache/sqoop/client/shell/CreateJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/CreateJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/CreateJobFunction.java
index f5155d5..cc4d546 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/CreateJobFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/CreateJobFunction.java
@@ -22,6 +22,7 @@ import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.OptionBuilder;
 import org.apache.sqoop.client.core.ClientError;
 import org.apache.sqoop.client.core.Constants;
+import org.apache.sqoop.client.utils.FormDisplayer;
 import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.validation.Status;
@@ -99,7 +100,7 @@ public class CreateJobFunction extends  SqoopFunction {
       // Try to create
       status = client.createJob(job);
     } while(!status.canProceed());
-
+    FormDisplayer.displayFormWarning(job);
     printlnResource(Constants.RES_CREATE_JOB_SUCCESSFUL, status.name(), job.getPersistenceId());
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a773179/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
b/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
index 95ada63..8556e2b 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
@@ -22,6 +22,7 @@ import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.OptionBuilder;
 import org.apache.sqoop.client.core.ClientError;
 import org.apache.sqoop.client.core.Constants;
+import org.apache.sqoop.client.utils.FormDisplayer;
 import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.model.MConnection;
 import org.apache.sqoop.validation.Status;
@@ -88,7 +89,7 @@ public class UpdateConnectionFunction extends SqoopFunction {
       // Try to create
       status = client.updateConnection(connection);
     } while(!status.canProceed());
-
+    FormDisplayer.displayFormWarning(connection);
     printlnResource(Constants.RES_UPDATE_CONN_SUCCESSFUL, status.name());
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a773179/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
index 3f0ac7d..425a53f 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
@@ -22,6 +22,7 @@ import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.OptionBuilder;
 import org.apache.sqoop.client.core.ClientError;
 import org.apache.sqoop.client.core.Constants;
+import org.apache.sqoop.client.utils.FormDisplayer;
 import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.validation.Status;
@@ -88,7 +89,7 @@ public class UpdateJobFunction extends SqoopFunction {
       // Try to create
       status = client.updateJob(job);
     } while(!status.canProceed());
-
+    FormDisplayer.displayFormWarning(job);
     printlnResource(Constants.RES_UPDATE_JOB_SUCCESSFUL, status.name());
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a773179/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 7cce713..36509c4 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
@@ -18,17 +18,22 @@
 package org.apache.sqoop.client.utils;
 
 import org.apache.sqoop.client.core.Constants;
+import org.apache.sqoop.model.MAccountableEntity;
+import org.apache.sqoop.model.MConnection;
 import org.apache.sqoop.model.MEnumInput;
 import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.model.MFramework;
 import org.apache.sqoop.model.MInput;
 import org.apache.sqoop.model.MInputType;
 import org.apache.sqoop.model.MIntegerInput;
+import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MJobForms;
 import org.apache.sqoop.model.MMapInput;
 import org.apache.sqoop.model.MStringInput;
 import org.apache.sqoop.utils.StringUtils;
+import org.apache.sqoop.validation.Status;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -120,6 +125,33 @@ public final class FormDisplayer {
     }
   }
 
+  /**
+   * Method prints the warning message of ACCEPTABLE status
+   * @param entity - connection or job instance
+   */
+  public static void displayFormWarning(MAccountableEntity entity) {
+    List<MForm> formList = new ArrayList<MForm>();
+    boolean showMessage = true;
+    if (entity instanceof MConnection) {
+      MConnection connection = (MConnection) entity;
+      formList.addAll(connection.getConnectorPart().getForms());
+      formList.addAll(connection.getFrameworkPart().getForms());
+    } else if(entity instanceof MJob) {
+      MJob job = (MJob) entity;
+      formList.addAll(job.getConnectorPart().getForms());
+      formList.addAll(job.getFrameworkPart().getForms());
+    }
+    for(MForm form : formList) {
+      if(form.getValidationStatus() == Status.ACCEPTABLE) {
+        if(showMessage) {
+          print("\n@|yellow %s|@\n", resourceString(Constants.RES_FORMDISPLAYER_FORM_WARNING));
+          showMessage = false;
+        }
+        FormFiller.warningMessage(form.getValidationMessage());
+      }
+    }
+  }
+
   private static void displayForm(MForm form, ResourceBundle bundle) {
     print("  ");
     println(bundle.getString(form.getLabelKey()));

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a773179/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 7e68c4f..feb09e0 100644
--- a/client/src/main/resources/client-resource.properties
+++ b/client/src/main/resources/client-resource.properties
@@ -187,3 +187,5 @@ formdisplayer.size = Size
 formdisplayer.possible_values = Possible values
 formdisplayer.unsupported_datatype = Unsupported data type
 formdisplayer.input_sensitive = This input is sensitive
+
+formdisplayer.warning_message = There were warnings while create or update, but saved successfully.
\ No newline at end of file


Mime
View raw message