Updated Branches: refs/heads/sqoop2 517e171ce -> ebe62d366
SQOOP-1189. Sqoop2: Ensure that clone methods will correctly copy over all values from all parents (Jarek Jarcec Cecho via Hari Shreedharan) Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/ebe62d36 Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/ebe62d36 Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/ebe62d36 Branch: refs/heads/sqoop2 Commit: ebe62d366357ac99a71e5b0e25e97bd514dbd7f0 Parents: 517e171 Author: Hari Shreedharan <[email protected]> Authored: Wed Oct 23 22:09:55 2013 -0700 Committer: Hari Shreedharan <[email protected]> Committed: Wed Oct 23 22:09:55 2013 -0700 ---------------------------------------------------------------------- .../apache/sqoop/model/MAccountableEntity.java | 20 +++ .../org/apache/sqoop/model/MConnection.java | 57 ++++++--- .../main/java/org/apache/sqoop/model/MJob.java | 83 ++++++++----- .../apache/sqoop/model/MPersistableEntity.java | 13 +- .../org/apache/sqoop/model/TestMConnection.java | 86 ++++++++----- .../java/org/apache/sqoop/model/TestMJob.java | 123 ++++++++++++------- .../org/apache/sqoop/repository/Repository.java | 18 +-- 7 files changed, 265 insertions(+), 135 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sqoop/blob/ebe62d36/common/src/main/java/org/apache/sqoop/model/MAccountableEntity.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/sqoop/model/MAccountableEntity.java b/common/src/main/java/org/apache/sqoop/model/MAccountableEntity.java index 8af7c15..781331b 100644 --- a/common/src/main/java/org/apache/sqoop/model/MAccountableEntity.java +++ b/common/src/main/java/org/apache/sqoop/model/MAccountableEntity.java @@ -52,6 +52,12 @@ abstract public class MAccountableEntity extends MPersistableEntity { */ private boolean enabled; + /** + * Default constructor. + * + * Set creation and last update date to now and users as null. By default + * the accountable entity is enabled. + */ public MAccountableEntity() { this.creationUser = null; this.creationDate = new Date(); @@ -60,6 +66,20 @@ abstract public class MAccountableEntity extends MPersistableEntity { this.enabled = DEFAULT_ENABLED; } + /** + * Create new accountable entity as copy of other accountable entity. + * + * @param other Accountable entity to copy + */ + public MAccountableEntity(MAccountableEntity other) { + super(other); + this.creationDate = other.creationDate; + this.creationUser = other.creationUser; + this.lastUpdateDate = other.lastUpdateDate; + this.lastUpdateUser = other.lastUpdateUser; + this.enabled = other.enabled; + } + public void setCreationUser(String name) { this.creationUser = name; } http://git-wip-us.apache.org/repos/asf/sqoop/blob/ebe62d36/common/src/main/java/org/apache/sqoop/model/MConnection.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/sqoop/model/MConnection.java b/common/src/main/java/org/apache/sqoop/model/MConnection.java index 0e4f1a2..da9691f 100644 --- a/common/src/main/java/org/apache/sqoop/model/MConnection.java +++ b/common/src/main/java/org/apache/sqoop/model/MConnection.java @@ -25,9 +25,16 @@ public class MConnection extends MAccountableEntity implements MClonable { private long connectorId; private String name; - private MConnectionForms connectorPart; - private MConnectionForms frameworkPart; - + private final MConnectionForms connectorPart; + private final MConnectionForms frameworkPart; + + /** + * Default constructor to build new MConnection model. + * + * @param connectorId Connector id + * @param connectorPart Connector forms + * @param frameworkPart Framework forms + */ public MConnection(long connectorId, MConnectionForms connectorPart, MConnectionForms frameworkPart) { @@ -36,6 +43,33 @@ public class MConnection extends MAccountableEntity implements MClonable { this.frameworkPart = frameworkPart; } + /** + * Constructor to create deep copy of another MConnection model. + * + * @param other MConnection model to copy + */ + public MConnection(MConnection other) { + this(other, other.connectorPart.clone(true), other.frameworkPart.clone(true)); + } + + /** + * Construct new MConnection model as a copy of another with replaced forms. + * + * This method is suitable only for metadata upgrade path and should not be + * used otherwise. + * + * @param other MConnection model to copy + * @param connectorPart Connector forms + * @param frameworkPart Framework forms + */ + public MConnection(MConnection other, MConnectionForms connectorPart, MConnectionForms frameworkPart) { + super(other); + this.connectorId = other.connectorId; + this.name = other.name; + this.connectorPart = connectorPart; + this.frameworkPart = frameworkPart; + } + @Override public String toString() { StringBuilder sb = new StringBuilder("connection: ").append(name); @@ -57,14 +91,6 @@ public class MConnection extends MAccountableEntity implements MClonable { return connectorId; } - public void setConnectorPart(MConnectionForms connectorPart) { - this.connectorPart = connectorPart; - } - - public void setFrameworkPart(MConnectionForms frameworkPart) { - this.frameworkPart = frameworkPart; - } - public void setConnectorId(long connectorId) { this.connectorId = connectorId; } @@ -87,14 +113,11 @@ public class MConnection extends MAccountableEntity implements MClonable { @Override public MConnection clone(boolean cloneWithValue) { - MConnection copy = new MConnection(this.getConnectorId(), - this.getConnectorPart().clone(cloneWithValue), - this.getFrameworkPart().clone(cloneWithValue)); if(cloneWithValue) { - copy.setPersistenceId(this.getPersistenceId()); - copy.setName(this.getName()); + return new MConnection(this); + } else { + return new MConnection(connectorId, connectorPart.clone(false), frameworkPart.clone(false)); } - return copy; } @Override http://git-wip-us.apache.org/repos/asf/sqoop/blob/ebe62d36/common/src/main/java/org/apache/sqoop/model/MJob.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/sqoop/model/MJob.java b/common/src/main/java/org/apache/sqoop/model/MJob.java index c58d1f0..849168d 100644 --- a/common/src/main/java/org/apache/sqoop/model/MJob.java +++ b/common/src/main/java/org/apache/sqoop/model/MJob.java @@ -37,12 +37,12 @@ public class MJob extends MAccountableEntity implements MClonable { * dependency through connection object, but having this dependency explicitly * carried along helps a lot. */ - private long connectorId; + private final long connectorId; /** * Corresponding connection object. */ - private long connectionId; + private final long connectionId; /** * User name for this object @@ -52,11 +52,20 @@ public class MJob extends MAccountableEntity implements MClonable { /** * Job type */ - private Type type; + private final Type type; - private MJobForms connectorPart; - private MJobForms frameworkPart; + private final MJobForms connectorPart; + private final MJobForms frameworkPart; + /** + * Default constructor to build new MJob model. + * + * @param connectorId Connector id + * @param connectionId Connection id + * @param type Job type + * @param connectorPart Connector forms + * @param frameworkPart Framework forms + */ public MJob(long connectorId, long connectionId, Type type, @@ -67,13 +76,45 @@ public class MJob extends MAccountableEntity implements MClonable { this.type = type; this.connectorPart = connectorPart; this.frameworkPart = frameworkPart; + verifyFormsOfSameType(); + } + + /** + * Constructor to create deep copy of another MJob model. + * + * @param other MConnection model to copy + */ + public MJob(MJob other) { + this(other, other.connectorPart.clone(true), other.frameworkPart.clone(true)); + } + + /** + * Construct new MJob model as a copy of another with replaced forms. + * + * This method is suitable only for metadata upgrade path and should not be + * used otherwise. + * + * @param other MJob model to copy + * @param connectorPart Connector forms + * @param frameworkPart Framework forms + */ + public MJob(MJob other, MJobForms connectorPart, MJobForms frameworkPart) { + super(other); + this.connectionId = other.connectionId; + this.connectorId = other.connectorId; + this.type = other.type; + this.name = other.name; + this.connectorPart = connectorPart; + this.frameworkPart = frameworkPart; + verifyFormsOfSameType(); + } - // Check that we're operating on forms with same type + private void verifyFormsOfSameType() { if (type != connectorPart.getType() || type != frameworkPart.getType()) { throw new SqoopException(ModelError.MODEL_002, "Incompatible types, job: " + type.name() - + ", connector part: " + connectorPart.getType().name() - + ", framework part: " + frameworkPart.getType().name() + + ", connector part: " + connectorPart.getType().name() + + ", framework part: " + frameworkPart.getType().name() ); } } @@ -98,18 +139,10 @@ public class MJob extends MAccountableEntity implements MClonable { return connectionId; } - public void setConnectionId(long connectionId) { - this.connectionId = connectionId; - } - public long getConnectorId() { return connectorId; } - public void setConnectorId(long connectorId) { - this.connectorId = connectorId; - } - public MJobForms getConnectorPart() { return connectorPart; } @@ -118,29 +151,17 @@ public class MJob extends MAccountableEntity implements MClonable { return frameworkPart; } - public void setConnectorPart(MJobForms connectorPart) { - this.connectorPart = connectorPart; - } - - public void setFrameworkPart(MJobForms frameworkPart) { - this.frameworkPart = frameworkPart; - } - - public Type getType() { return type; } @Override public MJob clone(boolean cloneWithValue) { - MJob copy = new MJob(this.connectorId, this.connectionId, this.type, - this.getConnectorPart().clone(cloneWithValue), - this.getFrameworkPart().clone(cloneWithValue)); if(cloneWithValue) { - copy.setPersistenceId(this.getPersistenceId()); - copy.setName(this.getName()); + return new MJob(this); + } else { + return new MJob(connectorId, connectionId, type, connectorPart.clone(false), frameworkPart.clone(false)); } - return copy; } @Override http://git-wip-us.apache.org/repos/asf/sqoop/blob/ebe62d36/common/src/main/java/org/apache/sqoop/model/MPersistableEntity.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/sqoop/model/MPersistableEntity.java b/common/src/main/java/org/apache/sqoop/model/MPersistableEntity.java index 01ecbfb..6507aca 100644 --- a/common/src/main/java/org/apache/sqoop/model/MPersistableEntity.java +++ b/common/src/main/java/org/apache/sqoop/model/MPersistableEntity.java @@ -26,8 +26,19 @@ public abstract class MPersistableEntity { private long persistenceId = PERSISTANCE_ID_DEFAULT; + /** + * Default constructor. + */ protected MPersistableEntity() { - // Default constructor + } + + /** + * Constructor building as a copy of other persistable entity. + * + * @param other Persistable entity to copy + */ + protected MPersistableEntity(MPersistableEntity other) { + this.persistenceId = other.persistenceId; } public void setPersistenceId(long persistenceId) { http://git-wip-us.apache.org/repos/asf/sqoop/blob/ebe62d36/common/src/test/java/org/apache/sqoop/model/TestMConnection.java ---------------------------------------------------------------------- diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConnection.java b/common/src/test/java/org/apache/sqoop/model/TestMConnection.java index 301ef1d..27959fb 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMConnection.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMConnection.java @@ -34,42 +34,68 @@ public class TestMConnection { */ @Test public void testInitialization() { - MConnectionForms connectorPart = connector1(); - MConnectionForms frameworkPart = connector2(); - MConnection connection = new MConnection(123l, connectorPart, frameworkPart); + // Test default constructor + MConnection connection = connection(); assertEquals(123l, connection.getConnectorId()); - assertEquals(connector1(), connection.getConnectorPart()); - assertEquals(connector2(), connection.getFrameworkPart()); - assertFalse(connector1().equals(connection.getFrameworkPart())); - connection.setName("NAME"); - assertEquals("NAME", connection.getName()); - assertEquals(connector1().getForms().get(0), connection.getConnectorForm("FORMNAME")); - assertEquals(connector2().getForms().get(0), connection.getFrameworkForm("form")); + assertEquals("Vampire", connection.getName()); + assertEquals("Buffy", connection.getCreationUser()); + assertEquals(forms1(), connection.getConnectorPart()); + assertEquals(forms2(), connection.getFrameworkPart()); + + // Test copy constructor + MConnection copy = new MConnection(connection); + assertEquals(123l, copy.getConnectorId()); + assertEquals("Vampire", copy.getName()); + assertEquals("Buffy", copy.getCreationUser()); + assertEquals(connection.getCreationDate(), copy.getCreationDate()); + assertEquals(forms1(), copy.getConnectorPart()); + assertEquals(forms2(), copy.getFrameworkPart()); + + // Test constructor for metadata upgrade (the order of forms is different) + MConnection upgradeCopy = new MConnection(connection, forms2(), forms1()); + assertEquals(123l, upgradeCopy.getConnectorId()); + assertEquals("Vampire", upgradeCopy.getName()); + assertEquals("Buffy", upgradeCopy.getCreationUser()); + assertEquals(connection.getCreationDate(), upgradeCopy.getCreationDate()); + assertEquals(forms2(), upgradeCopy.getConnectorPart()); + assertEquals(forms1(), upgradeCopy.getFrameworkPart()); } @Test public void testClone() { - MConnectionForms connectorPart = connector1(); - MConnectionForms frameworkPart = connector2(); - MConnection connection = new MConnection(123l, connectorPart, frameworkPart); - connection.setPersistenceId(12l); - MForm originalForm = connection.getConnectorPart().getForms().get(0); - MConnection clone1 = connection.clone(true); - assertEquals(123l, clone1.getConnectorId()); - MForm clonedForm1 = clone1.getConnectorPart().getForms().get(0); - assertEquals(clonedForm1.getInputs().get(0).getValue(), originalForm.getInputs().get(0).getValue()); - assertEquals(clonedForm1.getInputs().get(1).getValue(), originalForm.getInputs().get(1).getValue()); - assertNotNull(clonedForm1.getInputs().get(0).getValue()); - assertNotNull(clonedForm1.getInputs().get(1).getValue()); - assertEquals(connection, clone1); - MConnection cloneCopy = clone1.clone(true); - assertEquals(clone1, cloneCopy); - //Clone without values - MConnection clone2 = connection.clone(false); - assertNotSame(connection, clone2); + MConnection connection = connection(); + + // Clone without value + MConnection withoutValue = connection.clone(false); + assertEquals(connection, withoutValue); + assertEquals(MPersistableEntity.PERSISTANCE_ID_DEFAULT, withoutValue.getPersistenceId()); + assertNull(withoutValue.getName()); + assertNull(withoutValue.getCreationUser()); + assertEquals(forms1(), withoutValue.getConnectorPart()); + assertEquals(forms2(), withoutValue.getFrameworkPart()); + assertNull(withoutValue.getConnectorPart().getForm("FORMNAME").getInput("INTEGER-INPUT").getValue()); + assertNull(withoutValue.getConnectorPart().getForm("FORMNAME").getInput("STRING-INPUT").getValue()); + + // Clone with value + MConnection withValue = connection.clone(true); + assertEquals(connection, withValue); + assertEquals(connection.getPersistenceId(), withValue.getPersistenceId()); + assertEquals(connection.getName(), withValue.getName()); + assertEquals(connection.getCreationUser(), withValue.getCreationUser()); + assertEquals(forms1(), withValue.getConnectorPart()); + assertEquals(forms2(), withValue.getFrameworkPart()); + assertEquals(100, withValue.getConnectorPart().getForm("FORMNAME").getInput("INTEGER-INPUT").getValue()); + assertEquals("TEST-VALUE", withValue.getConnectorPart().getForm("FORMNAME").getInput("STRING-INPUT").getValue()); + } + + private MConnection connection() { + MConnection connection = new MConnection(123l, forms1(), forms2()); + connection.setName("Vampire"); + connection.setCreationUser("Buffy"); + return connection; } - private MConnectionForms connector1() { + private MConnectionForms forms1() { List<MForm> forms = new ArrayList<MForm>(); MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false); input.setValue(100); @@ -83,7 +109,7 @@ public class TestMConnection { return new MConnectionForms(forms); } - private MConnectionForms connector2() { + private MConnectionForms forms2() { List<MForm> forms = new ArrayList<MForm>(); MMapInput input = new MMapInput("MAP-INPUT", false); List<MInput<?>> list = new ArrayList<MInput<?>>(); http://git-wip-us.apache.org/repos/asf/sqoop/blob/ebe62d36/common/src/test/java/org/apache/sqoop/model/TestMJob.java ---------------------------------------------------------------------- diff --git a/common/src/test/java/org/apache/sqoop/model/TestMJob.java b/common/src/test/java/org/apache/sqoop/model/TestMJob.java index 6cbf7a6..8b6f5dc 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMJob.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMJob.java @@ -22,6 +22,7 @@ import static org.junit.Assert.*; import java.util.ArrayList; import java.util.List; +import org.apache.sqoop.common.SqoopException; import org.junit.Test; /** @@ -33,56 +34,83 @@ public class TestMJob { */ @Test public void testInitialization() { - List<MForm> forms = new ArrayList<MForm>(); - MJobForms jobform1 = new MJobForms(MJob.Type.EXPORT, forms); - List<MForm> forms2 = new ArrayList<MForm>(); - MJobForms jobform2 = new MJobForms(MJob.Type.EXPORT, forms2); - MJob job = new MJob(123l, 456l, MJob.Type.EXPORT, jobform1, jobform2); - + // Test default constructor + MJob job = job(MJob.Type.IMPORT); assertEquals(123l, job.getConnectorId()); - assertEquals(456l, job.getConnectionId()); - assertEquals(MJob.Type.EXPORT, job.getType()); - assertEquals(jobform1, job.getConnectorPart()); - assertEquals(jobform2, job.getFrameworkPart()); + assertEquals(MJob.Type.IMPORT, job.getType()); + assertEquals("Buffy", job.getCreationUser()); + assertEquals("Vampire", job.getName()); + assertEquals(forms1(MJob.Type.IMPORT), job.getConnectorPart()); + assertEquals(forms2(MJob.Type.IMPORT), job.getFrameworkPart()); + + // Test copy constructor + MJob copy = new MJob(job); + assertEquals(123l, copy.getConnectorId()); + assertEquals(MJob.Type.IMPORT, copy.getType()); + assertEquals("Vampire", copy.getName()); + assertEquals("Buffy", copy.getCreationUser()); + assertEquals(job.getCreationDate(), copy.getCreationDate()); + assertEquals(forms1(MJob.Type.IMPORT), copy.getConnectorPart()); + assertEquals(forms2(MJob.Type.IMPORT), copy.getFrameworkPart()); + + // Test constructor for metadata upgrade (the order of forms is different) + MJob upgradeCopy = new MJob(job, forms2(MJob.Type.IMPORT), forms1(MJob.Type.IMPORT)); + assertEquals(123l, upgradeCopy.getConnectorId()); + assertEquals(MJob.Type.IMPORT, upgradeCopy.getType()); + assertEquals("Vampire", upgradeCopy.getName()); + assertEquals("Buffy", upgradeCopy.getCreationUser()); + assertEquals(job.getCreationDate(), upgradeCopy.getCreationDate()); + assertEquals(forms2(MJob.Type.IMPORT), upgradeCopy.getConnectorPart()); + assertEquals(forms1(MJob.Type.IMPORT), upgradeCopy.getFrameworkPart()); + } + + @Test(expected = SqoopException.class) + public void testIncorrectDefaultConstructor() { + new MJob(1l, 1l, MJob.Type.IMPORT, forms1(MJob.Type.IMPORT), forms2(MJob.Type.EXPORT)); + } + + @Test(expected = SqoopException.class) + public void testIncorrectUpgradeConstructor() { + new MJob(job(MJob.Type.EXPORT), forms1(MJob.Type.IMPORT), forms2(MJob.Type.IMPORT)); } @Test public void testClone() { - List<MForm> forms = new ArrayList<MForm>(); - forms.add(getInputValues()); - MJobForms jobform1 = new MJobForms(MJob.Type.EXPORT, forms); - List<MForm> forms2 = new ArrayList<MForm>(); - forms2.add(getInputValues()); - MJobForms jobform2 = new MJobForms(MJob.Type.EXPORT, forms2); - MJob job = new MJob(123l, 456l, MJob.Type.EXPORT, jobform1, jobform2); - job.setPersistenceId(12l); + MJob job = job(MJob.Type.IMPORT); + + // Clone without value + MJob withoutValue = job.clone(false); + assertEquals(job, withoutValue); + assertEquals(MPersistableEntity.PERSISTANCE_ID_DEFAULT, withoutValue.getPersistenceId()); + assertEquals(MJob.Type.IMPORT, withoutValue.getType()); + assertNull(withoutValue.getName()); + assertNull(withoutValue.getCreationUser()); + assertEquals(forms1(MJob.Type.IMPORT), withoutValue.getConnectorPart()); + assertEquals(forms2(MJob.Type.IMPORT), withoutValue.getFrameworkPart()); + assertNull(withoutValue.getConnectorPart().getForm("FORMNAME").getInput("INTEGER-INPUT").getValue()); + assertNull(withoutValue.getConnectorPart().getForm("FORMNAME").getInput("STRING-INPUT").getValue()); - MForm originalForm = job.getConnectorPart().getForms().get(0); - //Clone job - MJob cloneJob = job.clone(true); - assertEquals(12l, cloneJob.getPersistenceId()); - assertEquals(123l, cloneJob.getConnectorId()); - assertEquals(456l, cloneJob.getConnectionId()); - assertEquals(MJob.Type.EXPORT, cloneJob.getType()); - MForm clonedForm = cloneJob.getConnectorPart().getForms().get(0); - assertEquals(clonedForm.getInputs().get(0).getValue(), originalForm.getInputs().get(0).getValue()); - assertEquals(clonedForm.getInputs().get(1).getValue(), originalForm.getInputs().get(1).getValue()); - assertNotNull(clonedForm.getInputs().get(0).getValue()); - assertNotNull(clonedForm.getInputs().get(1).getValue()); - assertEquals(job, cloneJob); + // Clone with value + MJob withValue = job.clone(true); + assertEquals(job, withValue); + assertEquals(job.getPersistenceId(), withValue.getPersistenceId()); + assertEquals(MJob.Type.IMPORT, withValue.getType()); + assertEquals(job.getName(), withValue.getName()); + assertEquals(job.getCreationUser(), withValue.getCreationUser()); + assertEquals(forms1(MJob.Type.IMPORT), withValue.getConnectorPart()); + assertEquals(forms2(MJob.Type.IMPORT), withValue.getFrameworkPart()); + assertEquals(100, withValue.getConnectorPart().getForm("FORMNAME").getInput("INTEGER-INPUT").getValue()); + assertEquals("TEST-VALUE", withValue.getConnectorPart().getForm("FORMNAME").getInput("STRING-INPUT").getValue()); } - //Clone job without value - MJob cloneJob1 = job.clone(false); - assertEquals(123l, cloneJob1.getConnectorId()); - assertEquals(456l, cloneJob1.getConnectionId()); - assertEquals(MJob.Type.EXPORT, cloneJob1.getType()); - clonedForm = cloneJob1.getConnectorPart().getForms().get(0); - assertNull(clonedForm.getInputs().get(0).getValue()); - assertNull(clonedForm.getInputs().get(1).getValue()); - assertNotSame(job, cloneJob1); + private MJob job(MJob.Type type) { + MJob job = new MJob(123l, 456l, type, forms1(type), forms2(type)); + job.setName("Vampire"); + job.setCreationUser("Buffy"); + return job; } - private MForm getInputValues() { + private MJobForms forms1(MJob.Type type) { + List<MForm> forms = new ArrayList<MForm>(); MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false); input.setValue(100); MStringInput strInput = new MStringInput("STRING-INPUT",false,(short)20); @@ -91,6 +119,17 @@ public class TestMJob { list.add(input); list.add(strInput); MForm form = new MForm("FORMNAME", list); - return form; + forms.add(form); + return new MJobForms(type, forms); + } + + private MJobForms forms2(MJob.Type type) { + List<MForm> forms = new ArrayList<MForm>(); + MMapInput input = new MMapInput("MAP-INPUT", false); + List<MInput<?>> list = new ArrayList<MInput<?>>(); + list.add(input); + MForm form = new MForm("form", list); + forms.add(form); + return new MJobForms(type, forms); } } http://git-wip-us.apache.org/repos/asf/sqoop/blob/ebe62d36/core/src/main/java/org/apache/sqoop/repository/Repository.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/sqoop/repository/Repository.java b/core/src/main/java/org/apache/sqoop/repository/Repository.java index 8bf0d40..4c7b866 100644 --- a/core/src/main/java/org/apache/sqoop/repository/Repository.java +++ b/core/src/main/java/org/apache/sqoop/repository/Repository.java @@ -415,16 +415,13 @@ public abstract class Repository { deleteConnectionsAndJobs(connections, jobs, tx); updateConnector(newConnector, tx); for (MConnection connection : connections) { - long connectionID = connection.getPersistenceId(); // Make a new copy of the forms from the connector, // else the values will get set in the forms in the connector for // each connection. List<MForm> forms = newConnector.getConnectionForms().clone(false).getForms(); MConnectionForms newConnectionForms = new MConnectionForms(forms); upgrader.upgrade(connection.getConnectorPart(), newConnectionForms); - MConnection newConnection = new MConnection(connectorID, - newConnectionForms, connection.getFrameworkPart()); - newConnection.setPersistenceId(connectionID); + MConnection newConnection = new MConnection(connection, newConnectionForms, connection.getFrameworkPart()); // Transform form structures to objects for validations Object newConfigurationObject = ClassUtils.instantiate(connector.getConnectionConfigurationClass()); @@ -445,9 +442,7 @@ public abstract class Repository { List<MForm> forms = newConnector.getJobForms(job.getType()).clone(false).getForms(); MJobForms newJobForms = new MJobForms(job.getType(), forms); upgrader.upgrade(job.getConnectorPart(), newJobForms); - MJob newJob = new MJob(connectorID, job.getConnectionId(), - job.getType(), newJobForms, job.getFrameworkPart()); - newJob.setPersistenceId(job.getPersistenceId()); + MJob newJob = new MJob(job, newJobForms, job.getFrameworkPart()); // Transform form structures to objects for validations Object newConfigurationObject = ClassUtils.instantiate(connector.getJobConfigurationClass(job.getType())); @@ -504,16 +499,13 @@ public abstract class Repository { deleteConnectionsAndJobs(connections, jobs, tx); updateFramework(framework, tx); for (MConnection connection : connections) { - long connectionID = connection.getPersistenceId(); // Make a new copy of the forms from the connector, // else the values will get set in the forms in the connector for // each connection. List<MForm> forms = framework.getConnectionForms().clone(false).getForms(); MConnectionForms newConnectionForms = new MConnectionForms(forms); upgrader.upgrade(connection.getFrameworkPart(), newConnectionForms); - MConnection newConnection = new MConnection(connection.getConnectorId(), - connection.getConnectorPart(), newConnectionForms); - newConnection.setPersistenceId(connectionID); + MConnection newConnection = new MConnection(connection, connection.getConnectorPart(), newConnectionForms); // Transform form structures to objects for validations Object newConfigurationObject = ClassUtils.instantiate(FrameworkManager.getInstance().getConnectionConfigurationClass()); @@ -534,9 +526,7 @@ public abstract class Repository { List<MForm> forms = framework.getJobForms(job.getType()).clone(false).getForms(); MJobForms newJobForms = new MJobForms(job.getType(), forms); upgrader.upgrade(job.getFrameworkPart(), newJobForms); - MJob newJob = new MJob(job.getConnectorId(), job.getConnectionId(), - job.getType(), job.getConnectorPart(), newJobForms); - newJob.setPersistenceId(job.getPersistenceId()); + MJob newJob = new MJob(job, job.getConnectorPart(), newJobForms); // Transform form structures to objects for validations Object newConfigurationObject = ClassUtils.instantiate(FrameworkManager.getInstance().getJobConfigurationClass(job.getType()));
