sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kathl...@apache.org
Subject git commit: SQOOP-942: Sqoop2: Refactor code repetition in SqoopRequests objects (Jarek Jarcec Cecho via Kate Ting)
Date Tue, 26 Mar 2013 07:41:59 GMT
Updated Branches:
  refs/heads/sqoop2 dd61adf66 -> 27271af13


SQOOP-942: Sqoop2: Refactor code repetition in SqoopRequests objects
(Jarek Jarcec Cecho via Kate Ting)


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

Branch: refs/heads/sqoop2
Commit: 27271af13f16cdfc6b77e5ba8e06adea21558dd4
Parents: dd61adf
Author: Kate Ting <kathleen@apache.org>
Authored: Tue Mar 26 03:40:45 2013 -0400
Committer: Kate Ting <kathleen@apache.org>
Committed: Tue Mar 26 03:40:45 2013 -0400

----------------------------------------------------------------------
 .../java/org/apache/sqoop/client/SqoopClient.java  |   41 ++++++++-
 .../apache/sqoop/client/request/SqoopRequests.java |   68 ---------------
 2 files changed, 37 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/27271af1/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
index 554a8fe..232ef20 100644
--- a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
+++ b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
@@ -18,12 +18,15 @@
 package org.apache.sqoop.client;
 
 import org.apache.sqoop.client.request.SqoopRequests;
+import org.apache.sqoop.json.ValidationBean;
+import org.apache.sqoop.model.FormUtils;
 import org.apache.sqoop.model.MConnection;
 import org.apache.sqoop.model.MConnector;
 import org.apache.sqoop.model.MFramework;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MSubmission;
 import org.apache.sqoop.validation.Status;
+import org.apache.sqoop.validation.Validation;
 
 import java.util.List;
 import java.util.ResourceBundle;
@@ -138,7 +141,7 @@ public class SqoopClient {
    * @return
    */
   public Status createConnection(MConnection connection) {
-    return requests.createConnectionApplyValidations(connection);
+    return applyValidations(requests.createConnection(connection), connection);
   }
 
   /**
@@ -148,7 +151,7 @@ public class SqoopClient {
    * @return
    */
   public Status updateConnection(MConnection connection) {
-    return requests.updateConnectionApplyValidations(connection);
+    return applyValidations(requests.updateConnection(connection), connection);
   }
 
   /**
@@ -205,7 +208,7 @@ public class SqoopClient {
    * @return
    */
   public Status createJob(MJob job) {
-    return requests.createJobApplyValidations(job);
+    return applyValidations(requests.createJob(job), job);
   }
 
   /**
@@ -214,7 +217,7 @@ public class SqoopClient {
    * @return
    */
   public Status updateJob(MJob job) {
-    return requests.updateJobApplyValidations(job);
+    return applyValidations(requests.updateJob(job), job);
   }
 
   /**
@@ -255,4 +258,34 @@ public class SqoopClient {
   public MSubmission getSubmissionStatus(long jid) {
     return requests.readSubmission(jid).getSubmission();
   }
+
+  private Status applyValidations(ValidationBean bean, MConnection connection) {
+    Validation connector = bean.getConnectorValidation();
+    Validation framework = bean.getFrameworkValidation();
+
+    FormUtils.applyValidation(connection.getConnectorPart().getForms(), connector);
+    FormUtils.applyValidation(connection.getFrameworkPart().getForms(), framework);
+
+    Long id = bean.getId();
+    if(id != null) {
+      connection.setPersistenceId(id);
+    }
+
+    return Status.getWorstStatus(connector.getStatus(), framework.getStatus());
+  }
+
+  private Status applyValidations(ValidationBean bean, MJob job) {
+    Validation connector = bean.getConnectorValidation();
+    Validation framework = bean.getFrameworkValidation();
+
+    FormUtils.applyValidation(job.getConnectorPart().getForms(), connector);
+    FormUtils.applyValidation(job.getFrameworkPart().getForms(), framework);
+
+    Long id = bean.getId();
+    if(id != null) {
+      job.setPersistenceId(id);
+    }
+
+    return Status.getWorstStatus(connector.getStatus(), framework.getStatus());
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/27271af1/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java b/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java
index 5ed38b6..32d4ae1 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java
@@ -98,23 +98,6 @@ public class SqoopRequests {
     return getConnectionRequest().create(serverUrl, connection);
   }
 
-  public Status createConnectionApplyValidations(MConnection connection) {
-    ValidationBean bean = createConnection(connection);
-
-    Validation connector = bean.getConnectorValidation();
-    Validation framework = bean.getFrameworkValidation();
-
-    FormUtils.applyValidation(connection.getConnectorPart().getForms(), connector);
-    FormUtils.applyValidation(connection.getFrameworkPart().getForms(), framework);
-
-    Long id = bean.getId();
-    if(id != null) {
-      connection.setPersistenceId(id);
-    }
-
-    return Status.getWorstStatus(connector.getStatus(), framework.getStatus());
-  }
-
   public ConnectionBean readConnection(Long connectionId) {
     return getConnectionRequest().read(serverUrl, connectionId);
   }
@@ -123,23 +106,6 @@ public class SqoopRequests {
     return getConnectionRequest().update(serverUrl, connection);
   }
 
-  public Status updateConnectionApplyValidations(MConnection connection){
-    ValidationBean bean = updateConnection(connection);
-
-    Validation connector = bean.getConnectorValidation();
-    Validation framework = bean.getFrameworkValidation();
-
-    FormUtils.applyValidation(connection.getConnectorPart().getForms(), connector);
-    FormUtils.applyValidation(connection.getFrameworkPart().getForms(), framework);
-
-    Long id = bean.getId();
-    if(id != null) {
-      connection.setPersistenceId(id);
-    }
-
-    return Status.getWorstStatus(connector.getStatus(), framework.getStatus());
-  }
-
   public void deleteConnection(Long xid) {
     getConnectionRequest().delete(serverUrl, xid);
   }
@@ -148,23 +114,6 @@ public class SqoopRequests {
     return getJobRequest().create(serverUrl, job);
   }
 
-  public Status createJobApplyValidations(MJob job) {
-    ValidationBean bean = createJob(job);
-
-    Validation connector = bean.getConnectorValidation();
-    Validation framework = bean.getFrameworkValidation();
-
-    FormUtils.applyValidation(job.getConnectorPart().getForms(), connector);
-    FormUtils.applyValidation(job.getFrameworkPart().getForms(), framework);
-
-    Long id = bean.getId();
-    if(id != null) {
-      job.setPersistenceId(id);
-    }
-
-    return Status.getWorstStatus(connector.getStatus(), framework.getStatus());
-  }
-
   public JobBean readJob(Long jobId) {
     return getJobRequest().read(serverUrl, jobId);
   }
@@ -173,23 +122,6 @@ public class SqoopRequests {
     return getJobRequest().update(serverUrl, job);
   }
 
-  public Status updateJobApplyValidations(MJob job) {
-    ValidationBean bean = updateJob(job);
-
-    Validation connector = bean.getConnectorValidation();
-    Validation framework = bean.getFrameworkValidation();
-
-    FormUtils.applyValidation(job.getConnectorPart().getForms(), connector);
-    FormUtils.applyValidation(job.getFrameworkPart().getForms(), framework);
-
-    Long id = bean.getId();
-    if(id != null) {
-      job.setPersistenceId(id);
-    }
-
-    return Status.getWorstStatus(connector.getStatus(), framework.getStatus());
-  }
-
   public void deleteJob(Long jid) {
     getJobRequest().delete(serverUrl, jid);
   }


Mime
View raw message