Search in sources :

Example 1 with EndPointType

use of org.opendatakit.briefcase.model.EndPointType 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)

Aggregations

File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 EndPointType (org.opendatakit.briefcase.model.EndPointType)1 FormStatus (org.opendatakit.briefcase.model.FormStatus)1 OdkCollectFormDefinition (org.opendatakit.briefcase.model.OdkCollectFormDefinition)1