use of org.activityinfo.model.job.ExportFormJob in project activityinfo by bedatadriven.
the class JobResourceTest method startJob.
@Test
public void startJob() {
final org.activityinfo.json.JsonParser parser = new org.activityinfo.json.JsonParser();
final Queue queue = QueueFactory.getDefaultQueue();
final AuthenticatedUser user = new AuthenticatedUser("XYZ", 1, "akbertram@gmail.com");
final JobResource resource = new JobResource(Providers.of(user), queue);
// First request starts the job
final String jobId = ObjectifyService.run(new Work<String>() {
@Override
public String run() {
TableModel tableModel = ImmutableTableModel.builder().formId(ResourceId.valueOf("FORM1")).build();
ExportFormJob exportForm = new ExportFormJob(tableModel);
JobRequest request = new JobRequest(exportForm, "en");
Response response = resource.start(request.toJsonObject().toJson());
JsonValue resultObject = parser.parse((String) response.getEntity());
JobStatus result = JobStatus.fromJson(resultObject);
assertThat(result.getState(), equalTo(JobState.STARTED));
return result.getId();
}
});
// Second request retrieves status
ObjectifyService.run(new VoidWork() {
@Override
public void vrun() {
Response statusResponse = resource.get(jobId);
JsonValue statusObject = parser.parse(((String) statusResponse.getEntity()));
JobStatus status = JobStatus.fromJson(statusObject);
assertThat(status.getState(), equalTo(JobState.STARTED));
}
});
}
use of org.activityinfo.model.job.ExportFormJob in project activityinfo by bedatadriven.
the class ExportOptionsDialog method onOk.
private void onOk(SelectEvent event) {
ExportFormJob exportFormJob = new ExportFormJob(exportModel.get());
dialog.hide();
Observable<JobStatus<ExportFormJob, ExportResult>> jobStatus = formStore.startJob(exportFormJob);
ExportJobDialog statusDialog = new ExportJobDialog(jobStatus);
statusDialog.show();
}
Aggregations