sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-2740: Sqoop2: Use name instead of id for ValidationResultBean
Date Wed, 16 Dec 2015 19:22:58 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 3f8765837 -> 060be9049


SQOOP-2740: Sqoop2: Use name instead of id for ValidationResultBean

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

Branch: refs/heads/sqoop2
Commit: 060be9049cabc1c42536cd0e6883ce40392546d6
Parents: 3f87658
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Wed Dec 16 20:22:16 2015 +0100
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Wed Dec 16 20:22:16 2015 +0100

----------------------------------------------------------------------
 .../org/apache/sqoop/client/SqoopClient.java     | 12 ++++++------
 .../apache/sqoop/json/ValidationResultBean.java  | 19 +++++++++----------
 .../sqoop/json/TestValidationResultBean.java     | 14 +++++++-------
 .../apache/sqoop/handler/JobRequestHandler.java  |  2 +-
 .../apache/sqoop/handler/LinkRequestHandler.java |  2 +-
 5 files changed, 24 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/060be904/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 e71d3ef..bac7fe8 100644
--- a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
+++ b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
@@ -806,9 +806,9 @@ public class SqoopClient {
     ConfigValidationResult linkConfig = bean.getValidationResults()[0];
     // Apply validation results
     ConfigUtils.applyValidation(link.getConnectorLinkConfig(), linkConfig);
-    Long id = bean.getId();
-    if (id != null) {
-      link.setPersistenceId(id);
+    String linkName = bean.getName();
+    if (linkName != null) {
+      link.setName(linkName);
     }
     return Status.getWorstStatus(linkConfig.getStatus());
   }
@@ -830,9 +830,9 @@ public class SqoopClient {
       driver
     );
 
-    Long id = bean.getId();
-    if(id != null) {
-      job.setPersistenceId(id);
+    String jobName = bean.getName();
+    if(jobName != null) {
+      job.setName(jobName);
     }
 
     return Status.getWorstStatus(fromConfig.getStatus(), toConfig.getStatus(), driver.getStatus());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/060be904/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java b/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java
index b328a25..09ea847 100644
--- a/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java
@@ -38,12 +38,11 @@ import java.util.Set;
 public class ValidationResultBean implements JsonBean {
 
   private static final String VALIDATION_RESULT = "validation-result";
-  private static final String ID = "id";
   private static final String STATUS = "status";
   private static final String MESSAGE = "message";
 
   private ConfigValidationResult[] results;
-  private Long id;
+  private String name;
 
   public ValidationResultBean() {
     // Empty, for restore
@@ -60,12 +59,12 @@ public class ValidationResultBean implements JsonBean {
     return results.clone();
   }
 
-  public void setId(Long id) {
-    this.id = id;
+  public String getName() {
+    return name;
   }
 
-  public Long getId() {
-    return id;
+  public void setName(String name) {
+    this.name = name;
   }
 
   @SuppressWarnings("unchecked")
@@ -80,8 +79,8 @@ public class ValidationResultBean implements JsonBean {
 
     JSONObject object = new JSONObject();
     object.put(VALIDATION_RESULT, array);
-    if(id != null) {
-      object.put(ID, id);
+    if(name != null) {
+      object.put(NAME, name);
     }
     return object;
   }
@@ -124,8 +123,8 @@ public class ValidationResultBean implements JsonBean {
     for(Object item : array) {
       results[i++] = restoreValidationResult((JSONObject) item);
     }
-    if(jsonObject.containsKey(ID)) {
-      id = JSONUtils.getLong(jsonObject, ID);
+    if(jsonObject.containsKey(NAME)) {
+      name = JSONUtils.getString(jsonObject, NAME);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/060be904/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java b/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
index 0381c7d..8b50797 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
@@ -71,11 +71,11 @@ public class TestValidationResultBean {
 
   @Test
   public void testId() {
-    long id = transfer(10L);
-    assertEquals(10L, id);
+    String name = transfer("testName");
+    assertEquals("testName", name);
 
-    Long idNull = transfer((Long)null);
-    assertNull(idNull);
+    String nameNull = transfer((String)null);
+    assertNull(nameNull);
   }
 
   public void verifyResultA(ConfigValidationResult result) {
@@ -107,9 +107,9 @@ public class TestValidationResultBean {
   }
 
 
-  private Long transfer(Long id) {
+  private String transfer(String name) {
     ValidationResultBean bean = new ValidationResultBean(new ConfigValidationResult[0]);
-    bean.setId(id);
+    bean.setName(name);
     JSONObject json = bean.extract(false);
 
     String string = json.toString();
@@ -118,7 +118,7 @@ public class TestValidationResultBean {
     ValidationResultBean retrievedBean = new ValidationResultBean();
     retrievedBean.restore(retrievedJson);
 
-    return retrievedBean.getId();
+    return retrievedBean.getName();
   }
 
   private ConfigValidationResult[] transfer(ConfigValidationResult [] results) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/060be904/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
index c70f457..01516ed 100644
--- a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
@@ -250,7 +250,7 @@ public class JobRequestHandler implements RequestHandler {
         postedJob.setCreationUser(username);
         postedJob.setLastUpdateUser(username);
         repository.createJob(postedJob);
-        validationResultBean.setId(postedJob.getPersistenceId());
+        validationResultBean.setName(postedJob.getName());
       } else {
         AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
             ctx.getRequest().getRemoteAddr(), "update", "job",

http://git-wip-us.apache.org/repos/asf/sqoop/blob/060be904/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
index cc07fc8..189293a 100644
--- a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
@@ -174,7 +174,7 @@ public class LinkRequestHandler implements RequestHandler {
         postedLink.setCreationUser(username);
         postedLink.setLastUpdateUser(username);
         repository.createLink(postedLink);
-        linkValidationBean.setId(postedLink.getPersistenceId());
+        linkValidationBean.setName(postedLink.getName());
       } else {
         AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
             ctx.getRequest().getRemoteAddr(), "update", "link",


Mime
View raw message