* 9. Otherwise, Insert the connection inputs followed by job inputs (using
* updateJob and updateConnection)
*/
RepositoryTransaction tx = null;
try {
SqoopConnector connector =
ConnectorManager.getInstance().getConnector(newConnector
.getUniqueName());
Validator validator = connector.getValidator();
boolean upgradeSuccessful = true;
MetadataUpgrader upgrader = connector.getMetadataUpgrader();
List<MConnection> connections = findConnectionsForConnector(
connectorID);
List<MJob> jobs = findJobsForConnector(connectorID);
// -- BEGIN TXN --
tx = getTransaction();
tx.begin();
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);
// Transform form structures to objects for validations
Object newConfigurationObject = ClassUtils.instantiate(connector.getConnectionConfigurationClass());
FormUtils.fromForms(newConnection.getConnectorPart().getForms(), newConfigurationObject);
Validation validation = validator.validateConnection(newConfigurationObject);
if (validation.getStatus().canProceed()) {
updateConnection(newConnection, tx);
} else {
logInvalidModelObject("connection", newConnection, validation);
upgradeSuccessful = false;
}
}
for (MJob job : jobs) {
// 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.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());
// Transform form structures to objects for validations
Object newConfigurationObject = ClassUtils.instantiate(connector.getJobConfigurationClass(job.getType()));
FormUtils.fromForms(newJob.getConnectorPart().getForms(), newConfigurationObject);
Validation validation = validator.validateJob(newJob.getType(), newConfigurationObject);
if (validation.getStatus().canProceed()) {
updateJob(newJob, tx);