mirror of
https://github.com/apache/sqoop.git
synced 2025-05-09 00:42:44 +08:00
SQOOP-619 Display user persistent id of newly created connection and job objects
(Jarek Cecho)
This commit is contained in:
parent
31d6f72761
commit
202ae0630b
@ -119,8 +119,8 @@ private void cloneConnection(String connectionId) throws IOException {
|
||||
status = createConnection(connection);
|
||||
} while(!status.canProceed());
|
||||
|
||||
io.out.println("Connection was successfully updated with status "
|
||||
+ status.name());
|
||||
io.out.println("Connection was successfully created with validation status "
|
||||
+ status.name() + " and persistent id " + connection.getPersistenceId());
|
||||
}
|
||||
|
||||
private Status createConnection(MConnection connection) {
|
||||
|
@ -118,8 +118,8 @@ private void cloneJob(String jobId) throws IOException {
|
||||
status = createJob(job);
|
||||
} while(!status.canProceed());
|
||||
|
||||
io.out.println("Job was successfully updated with status "
|
||||
+ status.name());
|
||||
io.out.println("Job was successfully created with validation status "
|
||||
+ status.name() + " and persistent id " + job.getPersistenceId());
|
||||
}
|
||||
|
||||
private Status createJob(MJob job) {
|
||||
|
@ -127,7 +127,8 @@ private void createConnection(String connectorId) throws IOException {
|
||||
} while(!status.canProceed());
|
||||
|
||||
io.out.println("New connection was successfully created with validation "
|
||||
+ "status " + status.name());
|
||||
+ "status " + status.name() + " and persistent id "
|
||||
+ connection.getPersistenceId());
|
||||
}
|
||||
|
||||
private FrameworkBean getFrameworkBean() {
|
||||
|
@ -153,7 +153,8 @@ private void createJob(String connectionId, String type) throws IOException {
|
||||
} while(!status.canProceed());
|
||||
|
||||
io.out.println("New job was successfully created with validation "
|
||||
+ "status " + status.name());
|
||||
+ "status " + status.name() + " and persistent id "
|
||||
+ job.getPersistenceId());
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
import org.apache.sqoop.model.MForm;
|
||||
import org.apache.sqoop.model.MInput;
|
||||
import org.apache.sqoop.model.MJob;
|
||||
import org.apache.sqoop.model.MPersistableEntity;
|
||||
import org.apache.sqoop.model.MValidatedElement;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.json.simple.JSONObject;
|
||||
@ -36,6 +37,7 @@ public class ValidationBean implements JsonBean {
|
||||
|
||||
private static final String STATUS = "status";
|
||||
private static final String TYPE = "type";
|
||||
private static final String ID = "id";
|
||||
private static final String CONNECTOR_PART = "connector";
|
||||
private static final String FRAMEWORK_PART = "framework";
|
||||
|
||||
@ -97,6 +99,17 @@ public JSONObject extract() {
|
||||
object.put(CONNECTOR_PART, extractForms(connectorPart));
|
||||
object.put(FRAMEWORK_PART, extractForms(frameworkPart));
|
||||
|
||||
// If we do have ID available, let's send it across network
|
||||
long id = MPersistableEntity.PERSISTANCE_ID_DEFAULT;
|
||||
if(connection != null) {
|
||||
id = connection.getPersistenceId();
|
||||
} else if(job != null) {
|
||||
id = job.getPersistenceId();
|
||||
}
|
||||
if( id != MPersistableEntity.PERSISTANCE_ID_DEFAULT) {
|
||||
object.put(ID, id);
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
@ -141,6 +154,16 @@ public void restore(JSONObject jsonObject) {
|
||||
restoreForms(connectorPart, job.getConnectorPart().getForms());
|
||||
restoreForms(frameworkPart, job.getFrameworkPart().getForms());
|
||||
}
|
||||
|
||||
// Restore persistent id if available
|
||||
if(jsonObject.containsKey(ID)) {
|
||||
long id = (Long)jsonObject.get(ID);
|
||||
if(connection != null) {
|
||||
connection.setPersistenceId(id);
|
||||
} else if(job != null) {
|
||||
job.setPersistenceId(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreForms(JSONObject json, List<MForm> forms) {
|
||||
|
Loading…
Reference in New Issue
Block a user