sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r1376202 - in /sqoop/branches/sqoop2: client/src/main/java/org/apache/sqoop/client/shell/ common/src/main/java/org/apache/sqoop/json/ common/src/main/java/org/apache/sqoop/model/ common/src/test/java/org/apache/sqoop/json/ common/src/test/j...
Date Wed, 22 Aug 2012 19:25:52 GMT
Author: blee
Date: Wed Aug 22 19:25:51 2012
New Revision: 1376202

URL: http://svn.apache.org/viewvc?rev=1376202&view=rev
Log:
SQOOP-497: Enhance repository interface to support Connection CRUD

Added:
    sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java
    sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MJobForms.java
Modified:
    sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
    sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java
    sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnection.java
    sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnector.java
    sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MFramework.java
    sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MJob.java
    sqoop/branches/sqoop2/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
    sqoop/branches/sqoop2/common/src/test/java/org/apache/sqoop/model/TestMFramework.java
    sqoop/branches/sqoop2/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
    sqoop/branches/sqoop2/connector/connector-mysql-jdbc/src/main/java/org/apache/sqoop/connector/mysqljdbc/MySqlJdbcConnector.java
    sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java
    sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
    sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
    sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/repository/Repository.java
    sqoop/branches/sqoop2/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
    sqoop/branches/sqoop2/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java

Modified: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
(original)
+++ sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
Wed Aug 22 19:25:51 2012
@@ -30,7 +30,7 @@ import org.apache.sqoop.model.MConnector
 import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.model.MInput;
 import org.apache.sqoop.model.MInputType;
-import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MJobForms;
 import org.apache.sqoop.model.MStringInput;
 import org.codehaus.groovy.tools.shell.IO;
 
@@ -101,16 +101,16 @@ public class ShowConnectorFunction exten
       io.out.print("  Class: ");
       io.out.println(connector.getClassName());
       io.out.print("  Supported job types: ");
-      io.out.println(connector.getJobs().keySet().toString());
+      io.out.println(connector.getAllJobsForms().keySet().toString());
 
-      displayForms(connector.getConnection().getForms(), "Connection");
+      displayForms(connector.getConnectionForms().getForms(), "Connection");
 
-      for (MJob job : connector.getJobs().values()) {
-        io.out.print("  Forms for job type ");
-        io.out.print(job.getType().name());
+      for (MJobForms jobForms : connector.getAllJobsForms().values()) {
+        io.out.print("  Forms for jobForms type ");
+        io.out.print(jobForms.getType().name());
         io.out.println(":");
 
-        displayForms(job.getForms(), "Job");
+        displayForms(jobForms.getForms(), "Job");
       }
     }
 

Modified: sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java (original)
+++ sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java Wed
Aug 22 19:25:51 2012
@@ -22,13 +22,14 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.sqoop.model.MConnection;
+import org.apache.sqoop.model.MConnectionForms;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MJobForms;
 import org.apache.sqoop.model.MConnector;
 import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.model.MFormType;
 import org.apache.sqoop.model.MInput;
 import org.apache.sqoop.model.MInputType;
-import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MMapInput;
 import org.apache.sqoop.model.MStringInput;
 import org.json.simple.JSONArray;
@@ -79,10 +80,10 @@ public class ConnectorBean implements Js
       idArray.add(connector.getPersistenceId());
       nameArray.add(connector.getUniqueName());
       classArray.add(connector.getClassName());
-      conFormsArray.add(extractForms(connector.getConnection().getForms()));
+      conFormsArray.add(extractForms(connector.getConnectionForms().getForms()));
 
       JSONObject jobForms = new JSONObject();
-      for (MJob job : connector.getJobs().values()) {
+      for (MJobForms job : connector.getAllJobsForms().values()) {
         jobForms.put(job.getType().name(), extractForms(job.getForms()));
       }
       jobFormsArray.add(jobForms);
@@ -153,7 +154,7 @@ public class ConnectorBean implements Js
       List<MForm> connForms = restoreForms((JSONArray) conFormsArray.get(i));
 
       JSONObject jobJson = (JSONObject) jobFormsArray.get(i);
-      List<MJob> jobs = new ArrayList<MJob>();
+      List<MJobForms> jobs = new ArrayList<MJobForms>();
       for( Map.Entry entry : (Set<Map.Entry>) jobJson.entrySet()) {
         //TODO(jarcec): Handle situation when server is supporting operation
         // that client do not know (server do have newer version than client)
@@ -162,11 +163,11 @@ public class ConnectorBean implements Js
         List<MForm> jobForms =
           restoreForms((JSONArray) jobJson.get(entry.getKey()));
 
-        jobs.add(new MJob(type, jobForms));
+        jobs.add(new MJobForms(type, jobForms));
       }
 
       MConnector connector = new MConnector(uniqueName, className,
-        new MConnection(connForms), jobs);
+        new MConnectionForms(connForms), jobs);
       connector.setPersistenceId(persistenceId);
       connectors[i] = connector;
     }

Modified: sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnection.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnection.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnection.java (original)
+++ sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnection.java Wed
Aug 22 19:25:51 2012
@@ -17,53 +17,24 @@
  */
 package org.apache.sqoop.model;
 
-import java.util.List;
-
 /**
- * Metadata describing all required information to build up an connection
- * object. Both connector and framework will have it's own MConnection part of
- * metadata.
+ * Model describing entire connection object including both connector and
+ * framework part.
  */
-public class MConnection extends MPersistableEntity {
-
-  private final List<MForm> forms;
-
-  public MConnection(List<MForm> forms) {
-    this.forms = forms;
-  }
+public class MConnection extends MNamedElement {
+  // TODO(jarcec): We probably need reference to connector object here
+  MConnectionForms connectorPart;
+  MConnectionForms frameworkPart;
 
-  public List<MForm> getForms() {
-    return forms;
+  public MConnection(String name) {
+    super(name);
   }
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder("connection, forms:");
-    sb.append(forms);
-    return sb.toString();
-  }
-
-  @Override
-  public boolean equals(Object other) {
-    if (other == this) {
-      return true;
-    }
-
-    if (!(other instanceof MConnection)) {
-      return false;
-    }
-
-    MConnection mc = (MConnection) other;
-    return forms.equals(mc.forms);
-  }
+    StringBuilder sb = new StringBuilder("connection connector-part: ");
+    sb.append(connectorPart).append(", framework-part: ").append(frameworkPart);
 
-  @Override
-  public int hashCode() {
-    int result = super.hashCode();
-    for(MForm form : forms) {
-      result = 31 * result + form.hashCode();
-    }
-
-    return result;
+    return sb.toString();
   }
 }

Added: sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java?rev=1376202&view=auto
==============================================================================
--- sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java
(added)
+++ sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java
Wed Aug 22 19:25:51 2012
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import java.util.List;
+
+/**
+ * Metadata describing all required information to build up an connection
+ * object for one part. Both connector and framework need to supply this object
+ * to build up entire connection.
+ */
+public class MConnectionForms {
+
+  private final List<MForm> forms;
+
+  public MConnectionForms(List<MForm> forms) {
+    this.forms = forms;
+  }
+
+  public List<MForm> getForms() {
+    return forms;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("connection, forms:");
+    sb.append(forms);
+    return sb.toString();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == this) {
+      return true;
+    }
+
+    if (!(other instanceof MConnectionForms)) {
+      return false;
+    }
+
+    MConnectionForms mc = (MConnectionForms) other;
+    return forms.equals(mc.forms);
+  }
+
+  @Override
+  public int hashCode() {
+    int result = super.hashCode();
+    for(MForm form : forms) {
+      result = 31 * result + form.hashCode();
+    }
+
+    return result;
+  }
+}

Modified: sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnector.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnector.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnector.java (original)
+++ sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MConnector.java Wed
Aug 22 19:25:51 2012
@@ -31,8 +31,8 @@ public final class MConnector extends MF
   private final String className;
 
   public MConnector(String uniqueName, String className,
-      MConnection connection, List<MJob> jobs) {
-    super(connection, jobs);
+      MConnectionForms connectionForms, List<MJobForms> jobForms) {
+    super(connectionForms, jobForms);
 
     if (uniqueName == null || className == null) {
       throw new NullPointerException();
@@ -55,8 +55,8 @@ public final class MConnector extends MF
     StringBuilder sb = new StringBuilder("connector-");
     sb.append(uniqueName).append(":").append(getPersistenceId()).append(":");
     sb.append(className);
-    sb.append(", ").append(getConnection().toString());
-    for(MJob entry: getJobs().values()) {
+    sb.append(", ").append(getConnectionForms().toString());
+    for(MJobForms entry: getAllJobsForms().values()) {
       sb.append(entry.toString());
     }
 

Modified: sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MFramework.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MFramework.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MFramework.java (original)
+++ sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MFramework.java Wed
Aug 22 19:25:51 2012
@@ -25,23 +25,23 @@ import java.util.Map;
 
 /**
  * Metadata describing framework options for connection and job for each
- * supported operation.
+ * supported job type.
  */
 public class MFramework extends MPersistableEntity {
 
-  private final MConnection connection;
-  private final Map<MJob.Type, MJob> jobs;
+  private final MConnectionForms connectionForms;
+  private final Map<MJob.Type, MJobForms> jobs;
 
-  public MFramework(MConnection connection, List<MJob> jobs) {
-    this.connection = connection;
-    this.jobs = new HashMap<MJob.Type, MJob>();
+  public MFramework(MConnectionForms connectionForms, List<MJobForms> jobForms) {
+    this.connectionForms = connectionForms;
+    this.jobs = new HashMap<MJob.Type, MJobForms>();
 
-    for (MJob job : jobs) {
+    for (MJobForms job : jobForms) {
       MJob.Type type = job.getType();
 
       if(this.jobs.containsKey(type)) {
         throw new SqoopException(ModelError.MODEL_001, "Duplicate entry for"
-          + " job type " + job.getType().name());
+          + " jobForms type " + job.getType().name());
       }
       this.jobs.put(type, job);
     }
@@ -51,8 +51,8 @@ public class MFramework extends MPersist
   public String toString() {
     StringBuilder sb = new StringBuilder("framework-");
     sb.append(getPersistenceId()).append(":");
-    sb.append(", ").append(connection.toString());
-    for(MJob entry: jobs.values()) {
+    sb.append(", ").append(connectionForms.toString());
+    for(MJobForms entry: jobs.values()) {
       sb.append(entry.toString());
     }
 
@@ -70,29 +70,29 @@ public class MFramework extends MPersist
     }
 
     MFramework mo = (MFramework) other;
-    return connection.equals(mo.connection) && jobs.equals(mo.jobs);
+    return connectionForms.equals(mo.connectionForms) && jobs.equals(mo.jobs);
   }
 
   @Override
   public int hashCode() {
-    int result = connection.hashCode();
+    int result = connectionForms.hashCode();
 
-    for(MJob entry: jobs.values()) {
+    for(MJobForms entry: jobs.values()) {
       result = 31 * result + entry.hashCode();
     }
 
     return result;
   }
 
-  public MConnection getConnection() {
-    return connection;
+  public MConnectionForms getConnectionForms() {
+    return connectionForms;
   }
 
-  public Map<MJob.Type, MJob> getJobs() {
+  public Map<MJob.Type, MJobForms> getAllJobsForms() {
     return jobs;
   }
 
-  public MJob getJob(MJob.Type type) {
+  public MJobForms getJobForms(MJob.Type type) {
     return jobs.get(type);
   }
 }

Modified: sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MJob.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MJob.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MJob.java (original)
+++ sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MJob.java Wed Aug 22
19:25:51 2012
@@ -17,65 +17,30 @@
  */
 package org.apache.sqoop.model;
 
-import java.util.List;
-
 /**
- * Metadata for specific job type. Internally Sqoop have two different job
- * metadata for each job type. One for connector and second for framework.
+ * Model describing entire job object including both connector and
+ * framework part.
  */
-public class MJob extends MPersistableEntity {
-
+public class MJob extends MNamedElement {
 
   static public enum Type {
     IMPORT,
     EXPORT,
   }
 
-  private final Type type;
-  private final List<MForm> forms;
+  // TODO(jarcec): We probably need reference to connection object here
+  MJobForms connectorPart;
+  MJobForms frameworkPart;
 
-  public MJob(Type type, List<MForm> forms) {
-    this.type = type;
-    this.forms = forms;
+  public MJob(String name) {
+    super(name);
   }
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder("job type:").append(type.name());
-    sb.append(", forms: ").append(forms);
-    return sb.toString();
-  }
-
-  public Type getType() {
-    return type;
-  }
-
-  public List<MForm> getForms() {
-    return forms;
-  }
+    StringBuilder sb = new StringBuilder("job connector-part: ");
+    sb.append(connectorPart).append(", framework-part: ").append(frameworkPart);
 
-  @Override
-  public boolean equals(Object other) {
-    if (other == this) {
-      return true;
-    }
-
-    if (!(other instanceof MJob)) {
-      return false;
-    }
-
-    MJob mj = (MJob) other;
-    return type.equals(mj.type) && forms.equals(mj.forms);
-  }
-
-  @Override
-  public int hashCode() {
-    int result = super.hashCode();
-    result = 31 * result + type.hashCode();
-    for(MForm form : forms) {
-      result = 31 * result + form.hashCode();
-    }
-
-    return result;
+    return sb.toString();
   }
 }

Added: sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MJobForms.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MJobForms.java?rev=1376202&view=auto
==============================================================================
--- sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MJobForms.java (added)
+++ sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/model/MJobForms.java Wed Aug
22 19:25:51 2012
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import java.util.List;
+
+/**
+ * Metadata describing all required information to build up an job
+ * object for one part. Both connector and framework need to supply this object
+ * to build up entire job.
+ */
+public class MJobForms {
+
+  private final MJob.Type type;
+  private final List<MForm> forms;
+
+  public MJobForms(MJob.Type type, List<MForm> forms) {
+    this.type = type;
+    this.forms = forms;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("job type:").append(type.name());
+    sb.append(", forms: ").append(forms);
+    return sb.toString();
+  }
+
+  public MJob.Type getType() {
+    return type;
+  }
+
+  public List<MForm> getForms() {
+    return forms;
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == this) {
+      return true;
+    }
+
+    if (!(other instanceof MJobForms)) {
+      return false;
+    }
+
+    MJobForms mj = (MJobForms) other;
+    return type.equals(mj.type) && forms.equals(mj.forms);
+  }
+
+  @Override
+  public int hashCode() {
+    int result = super.hashCode();
+    result = 31 * result + type.hashCode();
+    for(MForm form : forms) {
+      result = 31 * result + form.hashCode();
+    }
+
+    return result;
+  }
+}

Modified: sqoop/branches/sqoop2/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
(original)
+++ sqoop/branches/sqoop2/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
Wed Aug 22 19:25:51 2012
@@ -19,11 +19,12 @@ package org.apache.sqoop.json;
 
 import static org.junit.Assert.*;
 
-import org.apache.sqoop.model.MConnection;
+import org.apache.sqoop.model.MConnectionForms;
+import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MConnector;
 import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.model.MInput;
-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.json.simple.JSONObject;
@@ -31,9 +32,7 @@ import org.json.simple.JSONValue;
 import org.junit.Test;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
  *
@@ -80,7 +79,7 @@ public class TestConnectorBean {
     inputs = new ArrayList<MInput<?>>();
     inputs.add(new MMapInput("properties"));
     connectionForms.add(new MForm("properties", inputs));
-    MConnection connection = new MConnection(connectionForms);
+    MConnectionForms connection = new MConnectionForms(connectionForms);
 
     List<MForm> jobForms = new ArrayList<MForm>();
     inputs = new ArrayList<MInput<?>>();
@@ -95,8 +94,8 @@ public class TestConnectorBean {
     inputs.add(new MStringInput("Y", false, (short) 10));
     jobForms.add(new MForm("D", inputs));
 
-    List<MJob> jobs = new ArrayList<MJob>();
-    jobs.add(new MJob(MJob.Type.IMPORT, jobForms));
+    List<MJobForms> jobs = new ArrayList<MJobForms>();
+    jobs.add(new MJobForms(MJob.Type.IMPORT, jobForms));
 
     return new MConnector(name, name + ".class", connection, jobs);
   }

Modified: sqoop/branches/sqoop2/common/src/test/java/org/apache/sqoop/model/TestMFramework.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/common/src/test/java/org/apache/sqoop/model/TestMFramework.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/common/src/test/java/org/apache/sqoop/model/TestMFramework.java
(original)
+++ sqoop/branches/sqoop2/common/src/test/java/org/apache/sqoop/model/TestMFramework.java
Wed Aug 22 19:25:51 2012
@@ -31,13 +31,13 @@ public class TestMFramework {
 
   @Test
   public void testFailureOnDuplicateJobTypes() {
-    MConnection connection = new MConnection(new ArrayList<MForm>());
-    List<MJob> jobs = new ArrayList<MJob>();
-    jobs.add(new MJob(MJob.Type.IMPORT, new ArrayList<MForm>()));
-    jobs.add(new MJob(MJob.Type.IMPORT, new ArrayList<MForm>()));
+    MConnectionForms connectionForms = new MConnectionForms(new ArrayList<MForm>());
+    List<MJobForms> jobForms = new ArrayList<MJobForms>();
+    jobForms.add(new MJobForms(MJob.Type.IMPORT, new ArrayList<MForm>()));
+    jobForms.add(new MJobForms(MJob.Type.IMPORT, new ArrayList<MForm>()));
 
     try {
-      new MFramework(connection, jobs);
+      new MFramework(connectionForms, jobForms);
       fail("We we're expecting exception for invalid usage");
     } catch(Exception ex) {
       // Expected case

Modified: sqoop/branches/sqoop2/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
(original)
+++ sqoop/branches/sqoop2/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
Wed Aug 22 19:25:51 2012
@@ -24,10 +24,11 @@ import java.util.ResourceBundle;
 
 import org.apache.sqoop.job.etl.Exporter;
 import org.apache.sqoop.job.etl.Importer;
-import org.apache.sqoop.model.MConnection;
+import org.apache.sqoop.model.MConnectionForms;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MJobForms;
 import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MMapInput;
 import org.apache.sqoop.model.MStringInput;
 import org.apache.sqoop.connector.spi.SqoopConnector;
@@ -36,8 +37,8 @@ import static org.apache.sqoop.connector
 
 public class GenericJdbcConnector implements SqoopConnector {
 
-  private static final MConnection connection;
-  private static final List<MJob> jobs;
+  private static final MConnectionForms CONNECTION_FORMS;
+  private static final List<MJobForms> JOB_FORMS;
 
   private Importer IMPORTER = new Importer(
       GenericJdbcImportInitializer.class,
@@ -77,7 +78,7 @@ public class GenericJdbcConnector implem
     MForm connForm = new MForm(FORM_CONNECTION, inputs);
     forms.add(connForm);
 
-    connection = new MConnection(forms);
+    CONNECTION_FORMS = new MConnectionForms(forms);
 
     // Job forms
     forms = new ArrayList<MForm>();
@@ -86,9 +87,9 @@ public class GenericJdbcConnector implem
     inputs.add(new MStringInput(INPUT_TBL_TABLE, false, (short) 50));
     forms.add(new MForm(FORM_TABLE, inputs));
 
-    jobs = new ArrayList<MJob>();
-    jobs.add(new MJob(MJob.Type.IMPORT, forms));
-    jobs.add(new MJob(MJob.Type.EXPORT, forms));
+    JOB_FORMS = new ArrayList<MJobForms>();
+    JOB_FORMS.add(new MJobForms(MJob.Type.IMPORT, forms));
+    JOB_FORMS.add(new MJobForms(MJob.Type.EXPORT, forms));
   }
 
   @Override
@@ -98,13 +99,13 @@ public class GenericJdbcConnector implem
   }
 
   @Override
-  public MConnection getConnection() {
-    return connection;
+  public MConnectionForms getConnectionForms() {
+    return CONNECTION_FORMS;
   }
 
   @Override
-  public List<MJob> getJobs() {
-    return jobs;
+  public List<MJobForms> getJobsForms() {
+    return JOB_FORMS;
   }
 
   @Override

Modified: sqoop/branches/sqoop2/connector/connector-mysql-jdbc/src/main/java/org/apache/sqoop/connector/mysqljdbc/MySqlJdbcConnector.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/connector/connector-mysql-jdbc/src/main/java/org/apache/sqoop/connector/mysqljdbc/MySqlJdbcConnector.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/connector/connector-mysql-jdbc/src/main/java/org/apache/sqoop/connector/mysqljdbc/MySqlJdbcConnector.java
(original)
+++ sqoop/branches/sqoop2/connector/connector-mysql-jdbc/src/main/java/org/apache/sqoop/connector/mysqljdbc/MySqlJdbcConnector.java
Wed Aug 22 19:25:51 2012
@@ -24,15 +24,15 @@ import java.util.ResourceBundle;
 
 import org.apache.sqoop.job.etl.Exporter;
 import org.apache.sqoop.job.etl.Importer;
-import org.apache.sqoop.model.MConnection;
+import org.apache.sqoop.model.MConnectionForms;
 import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.connector.spi.SqoopConnector;
-import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MJobForms;
 
 public class MySqlJdbcConnector implements SqoopConnector {
 
   private static final List<MForm> CONNECTION_FORMS = new ArrayList<MForm>();
-  private static final List<MJob> JOBS = new ArrayList<MJob>();
+  private static final List<MJobForms> JOB_FORMS = new ArrayList<MJobForms>();
 
   @Override
   public ResourceBundle getBundle(Locale locale) {
@@ -41,13 +41,13 @@ public class MySqlJdbcConnector implemen
   }
 
   @Override
-  public MConnection getConnection() {
-    return new MConnection(CONNECTION_FORMS);
+  public MConnectionForms getConnectionForms() {
+    return new MConnectionForms(CONNECTION_FORMS);
   }
 
   @Override
-  public List<MJob> getJobs() {
-    return JOBS;
+  public List<MJobForms> getJobsForms() {
+    return JOB_FORMS;
   }
 
   @Override

Modified: sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java
(original)
+++ sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java
Wed Aug 22 19:25:51 2012
@@ -88,7 +88,7 @@ public final class ConnectorHandler {
 
     // Initialize Metadata
     mConnector = new MConnector(connectorUniqueName, connectorClassName,
-        connector.getConnection(), connector.getJobs());
+        connector.getConnectionForms(), connector.getJobsForms());
 
     if (LOG.isInfoEnabled()) {
       LOG.info("Connector [" + connectorClassName + "] initialized.");

Modified: sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
(original)
+++ sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
Wed Aug 22 19:25:51 2012
@@ -19,11 +19,12 @@ package org.apache.sqoop.framework;
 
 import org.apache.log4j.Logger;
 import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.model.MConnection;
+import org.apache.sqoop.model.MConnectionForms;
+import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.model.MFramework;
 import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MJobForms;
 import org.apache.sqoop.model.MStringInput;
 import org.apache.sqoop.repository.RepositoryManager;
 
@@ -43,9 +44,9 @@ public class FrameworkManager {
 
   private static final Logger LOG = Logger.getLogger(FrameworkManager.class);
 
-  private static final MConnection connection;
+  private static final MConnectionForms CONNECTION_FORMS;
 
-  private static final List<MJob> jobs;
+  private static final List<MJobForms> JOB_FORMS;
 
   private static final MFramework mFramework;
 
@@ -53,7 +54,7 @@ public class FrameworkManager {
 
     List<MForm> conForms = new ArrayList<MForm>();
 
-    // Build the connection forms for import
+    // Build the CONNECTION_FORMS forms for import
     List<MInput<?>> connFormInputs = new ArrayList<MInput<?>>();
 
     MStringInput maxConnections = new MStringInput(
@@ -63,7 +64,7 @@ public class FrameworkManager {
     MForm connForm = new MForm(FORM_SECURITY, connFormInputs);
 
     conForms.add(connForm);
-    connection = new MConnection(conForms);
+    CONNECTION_FORMS = new MConnectionForms(conForms);
 
     // Build job forms for import
     List<MInput<?>> jobFormInputs = new ArrayList<MInput<?>>();
@@ -76,11 +77,11 @@ public class FrameworkManager {
     List<MForm> jobForms = new ArrayList<MForm>();
     jobForms.add(jobForm);
 
-    jobs = new ArrayList<MJob>();
-    jobs.add(new MJob(MJob.Type.IMPORT, jobForms));
-    jobs.add(new MJob(MJob.Type.EXPORT, jobForms));
+    JOB_FORMS = new ArrayList<MJobForms>();
+    JOB_FORMS.add(new MJobForms(MJob.Type.IMPORT, jobForms));
+    JOB_FORMS.add(new MJobForms(MJob.Type.EXPORT, jobForms));
 
-    mFramework = new MFramework(connection, jobs);
+    mFramework = new MFramework(CONNECTION_FORMS, JOB_FORMS);
   }
 
   public static synchronized void initialize() {

Modified: sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
(original)
+++ sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
Wed Aug 22 19:25:51 2012
@@ -18,9 +18,11 @@
 package org.apache.sqoop.repository;
 
 import java.sql.Connection;
+import java.util.List;
 
 import org.apache.log4j.Logger;
 import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.model.MConnection;
 import org.apache.sqoop.model.MConnector;
 import org.apache.sqoop.model.MFramework;
 
@@ -125,4 +127,46 @@ public class JdbcRepository implements R
       }
     }
   }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public void createConnection(MConnection connection) {
+    // TODO(jarcec): Implement
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public void updateConnection(MConnection connection) {
+    // TODO(jarcec): Implement
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public void deleteConnection(MConnection connection) {
+    // TODO(jarcec): Implement
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public MConnection findConnection(String name) {
+    // TODO(jarcec): Implement
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public List<MConnection> findConnections(MConnector connector) {
+    // TODO(jarcec): Implement
+    return null;
+  }
 }

Modified: sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/repository/Repository.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/repository/Repository.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/repository/Repository.java (original)
+++ sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/repository/Repository.java Wed
Aug 22 19:25:51 2012
@@ -17,9 +17,12 @@
  */
 package org.apache.sqoop.repository;
 
+import org.apache.sqoop.model.MConnection;
 import org.apache.sqoop.model.MConnector;
 import org.apache.sqoop.model.MFramework;
 
+import java.util.List;
+
 
 /**
  * Defines the contract of a Repository used by Sqoop. A Repository allows
@@ -55,4 +58,45 @@ public interface Repository {
    * @param mFramework Framework data that should be registered.
    */
   public void registerFramework(MFramework mFramework);
+
+  /**
+   * Save given connection to repository. This connection must not be already
+   * present in the repository otherwise exception will be thrown.
+   *
+   * @param connection Connection object to serialize into repository.
+   */
+  public void createConnection(MConnection connection);
+
+  /**
+   * Update given connection representation in repository. This connection
+   * object must already exists in the repository otherwise exception will be
+   * thrown.
+   *
+   * @param connection Connection object that should be updated in repository.
+   */
+  public void updateConnection(MConnection connection);
+
+  /**
+   * Delete given connection from repository. This connection object must
+   * exists in repository otherwise exception will be thrown.
+   *
+   * @param connection Connection object that should be removed from repository
+   */
+  public void deleteConnection(MConnection connection);
+
+  /**
+   * Find connection with given name in repository.
+   *
+   * @param name Connection name
+   * @return Deserialized form of the connection that is saved in repository
+   */
+  public MConnection findConnection(String name);
+
+  /**
+   * Get all connection objects for given connector.
+   *
+   * @param connector Connector object
+   * @return Array will all saved connection objects
+   */
+  public List<MConnection> findConnections(MConnector connector);
 }

Modified: sqoop/branches/sqoop2/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
(original)
+++ sqoop/branches/sqoop2/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
Wed Aug 22 19:25:51 2012
@@ -35,14 +35,15 @@ import javax.sql.DataSource;
 
 import org.apache.log4j.Logger;
 import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.model.MConnection;
+import org.apache.sqoop.model.MConnectionForms;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MJobForms;
 import org.apache.sqoop.model.MConnector;
 import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.model.MFormType;
 import org.apache.sqoop.model.MFramework;
 import org.apache.sqoop.model.MInput;
 import org.apache.sqoop.model.MInputType;
-import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MMapInput;
 import org.apache.sqoop.model.MStringInput;
 import org.apache.sqoop.repository.JdbcRepositoryContext;
@@ -113,12 +114,12 @@ public class DerbyRepositoryHandler impl
           Statement.RETURN_GENERATED_KEYS);
 
       // Register connector forms
-      registerForms(connectorId, null, mc.getConnection().getForms(),
+      registerForms(connectorId, null, mc.getConnectionForms().getForms(),
         MFormType.CONNECTION.name(), baseFormStmt, baseInputStmt);
 
       // Register all jobs
-      for (MJob job : mc.getJobs().values()) {
-        registerForms(connectorId, job.getType(), job.getForms(),
+      for (MJobForms jobForms : mc.getAllJobsForms().values()) {
+        registerForms(connectorId, jobForms.getType(), jobForms.getForms(),
           MFormType.JOB.name(), baseFormStmt, baseInputStmt);
       }
 
@@ -305,7 +306,7 @@ public class DerbyRepositoryHandler impl
         formFetchStmt, inputFetchStmt);
 
       mc = new MConnector(connectorName, connectorClassName,
-        new MConnection(connectionForms),
+        new MConnectionForms(connectionForms),
         convertToJobList(jobForms));
       mc.setPersistenceId(connectorId);
 
@@ -361,12 +362,12 @@ public class DerbyRepositoryHandler impl
           Statement.RETURN_GENERATED_KEYS);
 
       // Register connector forms
-      registerForms(null, null, mf.getConnection().getForms(),
+      registerForms(null, null, mf.getConnectionForms().getForms(),
         MFormType.CONNECTION.name(), baseFormStmt, baseInputStmt);
 
       // Register all jobs
-      for (MJob job : mf.getJobs().values()) {
-        registerForms(null, job.getType(), job.getForms(),
+      for (MJobForms jobForms : mf.getAllJobsForms().values()) {
+        registerForms(null, jobForms.getType(), jobForms.getForms(),
           MFormType.JOB.name(), baseFormStmt, baseInputStmt);
       }
 
@@ -419,7 +420,7 @@ public class DerbyRepositoryHandler impl
         return null;
       }
 
-      mf = new MFramework(new MConnection(connectionForms),
+      mf = new MFramework(new MConnectionForms(connectionForms),
         convertToJobList(jobForms));
 
       // We're using hardcoded value for framework metadata as they are
@@ -705,14 +706,14 @@ public class DerbyRepositoryHandler impl
     }
   }
 
-  public List<MJob> convertToJobList(Map<MJob.Type, List<MForm>> l) {
-    List<MJob> ret = new ArrayList<MJob>();
+  public List<MJobForms> convertToJobList(Map<MJob.Type, List<MForm>> l)
{
+    List<MJobForms> ret = new ArrayList<MJobForms>();
 
     for (Map.Entry<MJob.Type, List<MForm>> entry : l.entrySet()) {
       MJob.Type type = entry.getKey();
       List<MForm> forms = entry.getValue();
 
-      ret.add(new MJob(type, forms));
+      ret.add(new MJobForms(type, forms));
     }
 
     return ret;

Modified: sqoop/branches/sqoop2/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java?rev=1376202&r1=1376201&r2=1376202&view=diff
==============================================================================
--- sqoop/branches/sqoop2/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
(original)
+++ sqoop/branches/sqoop2/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
Wed Aug 22 19:25:51 2012
@@ -23,8 +23,8 @@ import java.util.ResourceBundle;
 
 import org.apache.sqoop.job.etl.Exporter;
 import org.apache.sqoop.job.etl.Importer;
-import org.apache.sqoop.model.MConnection;
-import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MJobForms;
+import org.apache.sqoop.model.MConnectionForms;
 
 /**
  * Service provider interface for Sqoop Connectors.
@@ -40,12 +40,12 @@ public interface SqoopConnector {
   /**
    * @return Get connection structure
    */
-  public MConnection getConnection();
+  public MConnectionForms getConnectionForms();
 
   /**
    * @return Get supported jobs and their associated data structures
    */
-  public List<MJob> getJobs();
+  public List<MJobForms> getJobsForms();
 
   /**
    * @return an <tt>Importer</tt> that provides classes for performing import.



Mime
View raw message