Search in sources :

Example 1 with FormStatus

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."));
}
Also used : ExportForms(org.opendatakit.briefcase.export.ExportForms) FormStatus(org.opendatakit.briefcase.model.FormStatus) FormStatusBuilder.buildFormStatus(org.opendatakit.briefcase.model.FormStatusBuilder.buildFormStatus) BriefcaseFormDefinition(org.opendatakit.briefcase.model.BriefcaseFormDefinition) ExportSucceededWithErrorsEvent(org.opendatakit.briefcase.model.ExportSucceededWithErrorsEvent) ExportProgressEvent(org.opendatakit.briefcase.model.ExportProgressEvent) ExportFailedEvent(org.opendatakit.briefcase.model.ExportFailedEvent) ExportSucceededEvent(org.opendatakit.briefcase.model.ExportSucceededEvent) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with FormStatus

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);
}
Also used : Common.bootCache(org.opendatakit.briefcase.operations.Common.bootCache) Arrays(java.util.Arrays) ServerConnectionTest(org.opendatakit.briefcase.util.ServerConnectionTest) FormStatus(org.opendatakit.briefcase.model.FormStatus) Logger(org.slf4j.Logger) ODK_USERNAME(org.opendatakit.briefcase.operations.Common.ODK_USERNAME) Param(org.opendatakit.common.cli.Param) STORAGE_DIR(org.opendatakit.briefcase.operations.Common.STORAGE_DIR) LoggerFactory(org.slf4j.LoggerFactory) ServerConnectionInfo(org.opendatakit.briefcase.model.ServerConnectionInfo) RetrieveAvailableFormsFromServer(org.opendatakit.briefcase.util.RetrieveAvailableFormsFromServer) AGGREGATE_SERVER(org.opendatakit.briefcase.operations.Common.AGGREGATE_SERVER) FORM_ID(org.opendatakit.briefcase.operations.Common.FORM_ID) Operation(org.opendatakit.common.cli.Operation) TransferFromServer(org.opendatakit.briefcase.util.TransferFromServer) EventBus(org.bushe.swing.event.EventBus) Optional(java.util.Optional) ODK_PASSWORD(org.opendatakit.briefcase.operations.Common.ODK_PASSWORD) ServerConnectionInfo(org.opendatakit.briefcase.model.ServerConnectionInfo) FormStatus(org.opendatakit.briefcase.model.FormStatus)

Example 3 with FormStatus

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);
}
Also used : Common.bootCache(org.opendatakit.briefcase.operations.Common.bootCache) Arrays(java.util.Arrays) ServerConnectionTest(org.opendatakit.briefcase.util.ServerConnectionTest) FormStatus(org.opendatakit.briefcase.model.FormStatus) Logger(org.slf4j.Logger) ODK_USERNAME(org.opendatakit.briefcase.operations.Common.ODK_USERNAME) Param(org.opendatakit.common.cli.Param) STORAGE_DIR(org.opendatakit.briefcase.operations.Common.STORAGE_DIR) LoggerFactory(org.slf4j.LoggerFactory) ServerConnectionInfo(org.opendatakit.briefcase.model.ServerConnectionInfo) TransferToServer(org.opendatakit.briefcase.util.TransferToServer) AGGREGATE_SERVER(org.opendatakit.briefcase.operations.Common.AGGREGATE_SERVER) FORM_ID(org.opendatakit.briefcase.operations.Common.FORM_ID) Operation(org.opendatakit.common.cli.Operation) Optional(java.util.Optional) ODK_PASSWORD(org.opendatakit.briefcase.operations.Common.ODK_PASSWORD) FileSystemUtils(org.opendatakit.briefcase.util.FileSystemUtils) ServerConnectionInfo(org.opendatakit.briefcase.model.ServerConnectionInfo) FormStatus(org.opendatakit.briefcase.model.FormStatus)

Example 4 with FormStatus

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");
        }
    }
}
Also used : EndPointType(org.opendatakit.briefcase.model.EndPointType) FormStatus(org.opendatakit.briefcase.model.FormStatus) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) File(java.io.File) OdkCollectFormDefinition(org.opendatakit.briefcase.model.OdkCollectFormDefinition)

Example 5 with FormStatus

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();
}
Also used : ConfigurationPanel(org.opendatakit.briefcase.ui.export.components.ConfigurationPanel) TransferSucceededEvent(org.opendatakit.briefcase.model.TransferSucceededEvent) ExportProgressEvent(org.opendatakit.briefcase.model.ExportProgressEvent) LocalDateTime(java.time.LocalDateTime) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) EXPORT(org.opendatakit.briefcase.model.FormStatus.TransferType.EXPORT) ExportFailedEvent(org.opendatakit.briefcase.model.ExportFailedEvent) BriefcaseFormDefinition(org.opendatakit.briefcase.model.BriefcaseFormDefinition) AnnotationProcessor(org.bushe.swing.event.annotation.AnnotationProcessor) ExportConfiguration(org.opendatakit.briefcase.export.ExportConfiguration) ISO_DATE_TIME(java.time.format.DateTimeFormatter.ISO_DATE_TIME) SavePasswordsConsentRevoked(org.opendatakit.briefcase.model.SavePasswordsConsentRevoked) ExportForms(org.opendatakit.briefcase.export.ExportForms) ExportSucceededWithErrorsEvent(org.opendatakit.briefcase.model.ExportSucceededWithErrorsEvent) FileSystemUtils(org.opendatakit.briefcase.util.FileSystemUtils) ExportSucceededEvent(org.opendatakit.briefcase.model.ExportSucceededEvent) ExportForms.buildCustomConfPrefix(org.opendatakit.briefcase.export.ExportForms.buildCustomConfPrefix) FormStatus(org.opendatakit.briefcase.model.FormStatus) FormStatusEvent(org.opendatakit.briefcase.model.FormStatusEvent) Executor(java.util.concurrent.Executor) ExportAction(org.opendatakit.briefcase.export.ExportAction) SavePasswordsConsentGiven(org.opendatakit.briefcase.model.SavePasswordsConsentGiven) Collectors.joining(java.util.stream.Collectors.joining) NewTransferAction(org.opendatakit.briefcase.transfer.NewTransferAction) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture) Collectors.toList(java.util.stream.Collectors.toList) ODKOptionPane.showErrorDialog(org.opendatakit.briefcase.ui.ODKOptionPane.showErrorDialog) List(java.util.List) Stream(java.util.stream.Stream) EventSubscriber(org.bushe.swing.event.annotation.EventSubscriber) Analytics(org.opendatakit.briefcase.ui.reused.Analytics) Collections(java.util.Collections) ExportConfiguration(org.opendatakit.briefcase.export.ExportConfiguration)

Aggregations

FormStatus (org.opendatakit.briefcase.model.FormStatus)22 Test (org.junit.Test)9 FormStatusBuilder.buildFormStatus (org.opendatakit.briefcase.model.FormStatusBuilder.buildFormStatus)7 BriefcaseFormDefinition (org.opendatakit.briefcase.model.BriefcaseFormDefinition)6 File (java.io.File)4 ExportForms (org.opendatakit.briefcase.export.ExportForms)4 BriefcasePreferences (org.opendatakit.briefcase.model.BriefcasePreferences)4 TerminationFuture (org.opendatakit.briefcase.model.TerminationFuture)4 SQLException (java.sql.SQLException)3 LocalDateTime (java.time.LocalDateTime)3 FileSystemException (org.opendatakit.briefcase.model.FileSystemException)3 FormStatusEvent (org.opendatakit.briefcase.model.FormStatusEvent)3 ServerConnectionInfo (org.opendatakit.briefcase.model.ServerConnectionInfo)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors.toList (java.util.stream.Collectors.toList)2 ExportConfiguration (org.opendatakit.briefcase.export.ExportConfiguration)2