use of org.opendatakit.briefcase.model.FormStatus in project briefcase by opendatakit.
the class FormsTableUnitTest method appends_to_a_forms_status_history_when_export_events_are_sent.
@Test
@Ignore
public void appends_to_a_forms_status_history_when_export_events_are_sent() {
FormStatus theForm = buildFormStatus(1);
ExportForms forms = new ExportForms(Collections.singletonList(theForm), ExportConfiguration.empty(), new HashMap<>(), new HashMap<>(), new HashMap<>());
TestFormsTableViewModel viewModel = new TestFormsTableViewModel(forms);
new FormsTable(forms, new TestFormsTableView(viewModel), viewModel);
// TODO Event publishing happens asynchronously. We have to work this test a little more to stop ignoring it
EventBus.publish(new ExportProgressEvent("some progress", (BriefcaseFormDefinition) theForm.getFormDefinition()));
EventBus.publish(new ExportFailedEvent((BriefcaseFormDefinition) theForm.getFormDefinition()));
EventBus.publish(new ExportSucceededEvent((BriefcaseFormDefinition) theForm.getFormDefinition()));
EventBus.publish(new ExportSucceededWithErrorsEvent((BriefcaseFormDefinition) theForm.getFormDefinition()));
assertThat(theForm.getStatusHistory(), Matchers.containsString("some progress"));
assertThat(theForm.getStatusHistory(), Matchers.containsString("Failed."));
assertThat(theForm.getStatusHistory(), Matchers.containsString("Succeeded."));
assertThat(theForm.getStatusHistory(), Matchers.containsString("Succeeded, but with errors."));
}
use of org.opendatakit.briefcase.model.FormStatus in project briefcase by opendatakit.
the class PullFormFromAggregate method pullFormFromAggregate.
public static void pullFormFromAggregate(String storageDir, String formid, String username, String password, String server) {
CliEventsCompanion.attach(log);
bootCache(storageDir);
ServerConnectionInfo transferSettings = new ServerConnectionInfo(server, username, password.toCharArray());
ServerConnectionTest.testPull(transferSettings);
Optional<FormStatus> maybeForm = RetrieveAvailableFormsFromServer.get(transferSettings).stream().filter(f -> f.getFormDefinition().getFormId().equals(formid)).findFirst();
if (!maybeForm.isPresent())
throw new FormNotFoundException(formid);
FormStatus form = maybeForm.get();
EventBus.publish(new StartPullEvent(form));
TransferFromServer.pull(transferSettings, form);
}
use of org.opendatakit.briefcase.model.FormStatus in project briefcase by opendatakit.
the class PushFormToAggregate method pushFormToAggregate.
private static void pushFormToAggregate(String storageDir, String formid, String username, String password, String server) {
CliEventsCompanion.attach(log);
bootCache(storageDir);
Optional<FormStatus> maybeFormStatus = FileSystemUtils.getBriefcaseFormList().stream().filter(form -> form.getFormId().equals(formid)).map(formDef -> new FormStatus(FormStatus.TransferType.UPLOAD, formDef)).findFirst();
FormStatus form = maybeFormStatus.orElseThrow(() -> new FormNotFoundException(formid));
ServerConnectionInfo transferSettings = new ServerConnectionInfo(server, username, password.toCharArray());
ServerConnectionTest.testPush(transferSettings);
TransferToServer.push(transferSettings, form);
}
use of org.opendatakit.briefcase.model.FormStatus in project briefcase by opendatakit.
the class PullTransferPanel method updateFormStatuses.
public void updateFormStatuses() {
List<FormStatus> statuses = new ArrayList<>();
// determine what our origin is...
String strSelection = (String) listOriginDataSource.getSelectedItem();
EndPointType selection = (strSelection != null) ? EndPointType.fromString(strSelection) : null;
if (selection != null) {
if (EndPointType.AGGREGATE_1_0_CHOICE.equals(selection)) {
// clear the list of forms first...
formTransferTable.setFormStatusList(statuses);
terminationFuture.reset();
TransferAction.retrieveAvailableFormsFromServer((Window) getTopLevelAncestor(), originServerInfo, terminationFuture);
// list will be communicated back via the
// RetrieveAvailableFormsSucceededEvent
} else if (EndPointType.CUSTOM_ODK_COLLECT_DIRECTORY.equals(selection)) {
File odk = new File(txtOriginName.getText());
List<OdkCollectFormDefinition> forms = FileSystemUtils.getODKFormList(odk);
for (OdkCollectFormDefinition f : forms) {
statuses.add(new FormStatus(FormStatus.TransferType.GATHER, f));
}
formTransferTable.setFormStatusList(statuses);
} else if (EndPointType.MOUNTED_ODK_COLLECT_DEVICE_CHOICE.equals(selection)) {
File sdcard = new File(txtOriginName.getText());
File odk = new File(sdcard, "odk");
List<OdkCollectFormDefinition> forms = FileSystemUtils.getODKFormList(odk);
for (OdkCollectFormDefinition f : forms) {
statuses.add(new FormStatus(FormStatus.TransferType.GATHER, f));
}
formTransferTable.setFormStatusList(statuses);
} else {
throw new IllegalStateException("unexpected case");
}
}
}
use of org.opendatakit.briefcase.model.FormStatus in project briefcase by opendatakit.
the class ExportPanel method export.
private void export() {
form.disableUI();
terminationFuture.reset();
forms.getSelectedForms().parallelStream().peek(FormStatus::clearStatusHistory).forEach(form -> {
String formId = form.getFormDefinition().getFormId();
ExportConfiguration configuration = forms.getConfiguration(formId);
if (configuration.resolvePullBefore())
forms.getTransferSettings(formId).ifPresent(sci -> NewTransferAction.transferServerToBriefcase(sci, terminationFuture, Collections.singletonList(form)));
ExportAction.export((BriefcaseFormDefinition) form.getFormDefinition(), configuration, terminationFuture);
});
form.enableUI();
}
Aggregations