Search in sources :

Example 1 with RunnerStatus

use of org.opendatakit.briefcase.reused.job.RunnerStatus in project briefcase by opendatakit.

the class PullFromAggregateIntegrationTest method setUp.

@Before
public void setUp() throws IOException {
    Files.createDirectories(briefcaseDir);
    prefs = new BriefcasePreferences(InMemoryPreferences.empty());
    prefs.setStorageDir(tmpDir);
    server = httpServer(serverPort);
    tracker = new PullFromAggregateTracker(form, e -> {
    });
    formMetadataPort = new InMemoryFormMetadataAdapter();
    pullOp = new PullFromAggregate(CommonsHttp.of(1), aggregateServer, briefcaseDir, true, e -> {
    }, formMetadataPort);
    runnerStatus = new TestRunnerStatus(false);
}
Also used : UncheckedFiles.deleteRecursive(org.opendatakit.briefcase.reused.UncheckedFiles.deleteRecursive) RequestBuilder.url(org.opendatakit.briefcase.reused.http.RequestBuilder.url) URL(java.net.URL) JobsRunner.launchSync(org.opendatakit.briefcase.reused.job.JobsRunner.launchSync) Assert.assertThat(org.junit.Assert.assertThat) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) UncheckedFiles.readAllBytes(org.opendatakit.briefcase.reused.UncheckedFiles.readAllBytes) After(org.junit.After) AggregateServer(org.opendatakit.briefcase.reused.transfer.AggregateServer) Pair(org.opendatakit.briefcase.reused.Pair) Path(java.nio.file.Path) FormKey(org.opendatakit.briefcase.model.form.FormKey) CommonsHttp(org.opendatakit.briefcase.reused.http.CommonsHttp) Moco.httpServer(com.github.dreamhead.moco.Moco.httpServer) TransferTestHelpers.buildMediaFiles(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildMediaFiles) FormStatus(org.opendatakit.briefcase.model.FormStatus) FormMetadataQueries.lastCursorOf(org.opendatakit.briefcase.model.form.FormMetadataQueries.lastCursorOf) Moco.method(com.github.dreamhead.moco.Moco.method) TransferTestHelpers.generatePages(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.generatePages) UncheckedFiles.createTempDirectory(org.opendatakit.briefcase.reused.UncheckedFiles.createTempDirectory) GET(com.github.dreamhead.moco.HttpMethod.GET) Collectors.joining(java.util.stream.Collectors.joining) TransferTestHelpers(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers) UncheckedFiles.toURI(org.opendatakit.briefcase.reused.UncheckedFiles.toURI) List(java.util.List) Moco.seq(com.github.dreamhead.moco.Moco.seq) OffsetDateTime(java.time.OffsetDateTime) Runner.running(com.github.dreamhead.moco.Runner.running) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) Matchers.containsString(org.hamcrest.Matchers.containsString) HttpServer(com.github.dreamhead.moco.HttpServer) IntStream(java.util.stream.IntStream) InMemoryFormMetadataAdapter(org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter) Moco.uri(com.github.dreamhead.moco.Moco.uri) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) TransferTestHelpers.buildFormStatus(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildFormStatus) InMemoryPreferences(org.opendatakit.briefcase.model.InMemoryPreferences) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Before(org.junit.Before) TransferTestHelpers.buildManifestXml(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildManifestXml) Files(java.nio.file.Files) RunnerStatus(org.opendatakit.briefcase.reused.job.RunnerStatus) IOException(java.io.IOException) Test(org.junit.Test) Collectors.toList(java.util.stream.Collectors.toList) Paths(java.nio.file.Paths) DateTimeFormatter(java.time.format.DateTimeFormatter) TestRunnerStatus(org.opendatakit.briefcase.reused.job.TestRunnerStatus) Moco.by(com.github.dreamhead.moco.Moco.by) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) InMemoryFormMetadataAdapter(org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter) TestRunnerStatus(org.opendatakit.briefcase.reused.job.TestRunnerStatus) Before(org.junit.Before)

Example 2 with RunnerStatus

use of org.opendatakit.briefcase.reused.job.RunnerStatus in project briefcase by opendatakit.

the class PullFromCentral method pull.

/**
 * Pulls a form completely, writing the form file, form attachments,
 * submission files and their attachments to the local filesystem
 * under the Briefcase Storage directory.
 */
public Job<Void> pull(FormStatus form) {
    FormKey key = FormKey.from(form);
    PullFromCentralTracker tracker = new PullFromCentralTracker(form, onEventCallback);
    return run(rs -> tracker.trackStart()).thenRun(allOf(supply(runnerStatus -> getSubmissionIds(form, token, runnerStatus, tracker)), run(runnerStatus -> {
        downloadForm(form, token, runnerStatus, tracker);
        List<CentralAttachment> attachments = getFormAttachments(form, token, runnerStatus, tracker);
        int totalAttachments = attachments.size();
        AtomicInteger attachmentNumber = new AtomicInteger(1);
        attachments.parallelStream().forEach(attachment -> downloadFormAttachment(form, attachment, token, runnerStatus, tracker, attachmentNumber.getAndIncrement(), totalAttachments));
    }))).thenAccept((runnerStatus, pair) -> withDb(form.getFormDir(briefcaseDir), db -> {
        List<String> submissions = pair.getLeft();
        int totalSubmissions = submissions.size();
        AtomicInteger submissionNumber = new AtomicInteger(1);
        Set<String> submissionVersions = new HashSet<>();
        if (submissions.isEmpty())
            tracker.trackNoSubmissions();
        submissions.stream().map(instanceId -> Pair.of(submissionNumber.getAndIncrement(), instanceId)).forEach(submissionNumberId -> {
            int currentSubmissionNumber = submissionNumberId.getLeft();
            String instanceId = submissionNumberId.getRight();
            boolean inDb = db.hasRecordedInstance(instanceId) != null;
            Path downloadedSubmissionPath = form.getSubmissionFile(briefcaseDir, instanceId);
            if (!inDb || !downloadedSubmissionPath.toFile().exists()) {
                downloadSubmission(form, instanceId, token, runnerStatus, tracker, currentSubmissionNumber, totalSubmissions);
                if (downloadedSubmissionPath.toFile().exists()) {
                    XmlElement root = XmlElement.from(new String(readAllBytes(downloadedSubmissionPath)));
                    SubmissionMetaData metaData = new SubmissionMetaData(root);
                    metaData.getVersion().ifPresent(submissionVersions::add);
                }
            } else {
                tracker.trackSubmissionAlreadyDownloaded(currentSubmissionNumber, totalSubmissions);
            }
            List<CentralAttachment> attachments = getSubmissionAttachmentList(form, instanceId, token, runnerStatus, tracker, currentSubmissionNumber, totalSubmissions);
            int totalAttachments = attachments.size();
            AtomicInteger attachmentNumber = new AtomicInteger(1);
            attachments.stream().filter(attachment -> !inDb || !form.getSubmissionMediaFile(briefcaseDir, instanceId, attachment.getName()).toFile().exists()).forEach(attachment -> downloadSubmissionAttachment(form, instanceId, attachment, token, runnerStatus, tracker, currentSubmissionNumber, totalSubmissions, attachmentNumber.getAndIncrement(), totalAttachments));
            if (!runnerStatus.isCancelled() && !inDb) {
                db.putRecordedInstanceDirectory(instanceId, form.getSubmissionDir(briefcaseDir, instanceId).toFile());
            }
        });
        tracker.trackEnd();
        formMetadataPort.execute(updateAsPulled(key, briefcaseDir, form.getFormDir(briefcaseDir), submissionVersions));
        EventBus.publish(PullEvent.Success.of(form, server));
    }));
}
Also used : Job.run(org.opendatakit.briefcase.reused.job.Job.run) CentralAttachment(org.opendatakit.briefcase.reused.transfer.CentralAttachment) Response(org.opendatakit.briefcase.reused.http.response.Response) Job.supply(org.opendatakit.briefcase.reused.job.Job.supply) SubmissionMetaData(org.opendatakit.briefcase.export.SubmissionMetaData) HashSet(java.util.HashSet) FormMetadataPort(org.opendatakit.briefcase.model.form.FormMetadataPort) PullEvent(org.opendatakit.briefcase.pull.PullEvent) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) UncheckedFiles.readAllBytes(org.opendatakit.briefcase.reused.UncheckedFiles.readAllBytes) EventBus(org.bushe.swing.event.EventBus) Pair(org.opendatakit.briefcase.reused.Pair) DatabaseUtils.withDb(org.opendatakit.briefcase.util.DatabaseUtils.withDb) Path(java.nio.file.Path) FormKey(org.opendatakit.briefcase.model.form.FormKey) FormStatus(org.opendatakit.briefcase.model.FormStatus) FormStatusEvent(org.opendatakit.briefcase.model.FormStatusEvent) CentralServer(org.opendatakit.briefcase.reused.transfer.CentralServer) Job.allOf(org.opendatakit.briefcase.reused.job.Job.allOf) Collections.emptyList(java.util.Collections.emptyList) Set(java.util.Set) RunnerStatus(org.opendatakit.briefcase.reused.job.RunnerStatus) FormMetadataCommands.updateAsPulled(org.opendatakit.briefcase.model.form.FormMetadataCommands.updateAsPulled) Http(org.opendatakit.briefcase.reused.http.Http) UncheckedFiles.createDirectories(org.opendatakit.briefcase.reused.UncheckedFiles.createDirectories) Consumer(java.util.function.Consumer) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Job(org.opendatakit.briefcase.reused.job.Job) XmlElement(org.opendatakit.briefcase.export.XmlElement) Path(java.nio.file.Path) SubmissionMetaData(org.opendatakit.briefcase.export.SubmissionMetaData) HashSet(java.util.HashSet) Set(java.util.Set) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) XmlElement(org.opendatakit.briefcase.export.XmlElement) Collections.emptyList(java.util.Collections.emptyList) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) FormKey(org.opendatakit.briefcase.model.form.FormKey)

Example 3 with RunnerStatus

use of org.opendatakit.briefcase.reused.job.RunnerStatus in project briefcase by opendatakit.

the class PullFromAggregate method getFormAttachments.

List<AggregateAttachment> getFormAttachments(FormStatus form, RunnerStatus runnerStatus, PullFromAggregateTracker tracker) {
    if (runnerStatus.isCancelled()) {
        tracker.trackCancellation("Get form attachments");
        return emptyList();
    }
    if (!form.getManifestUrl().filter(RequestBuilder::isUri).isPresent())
        return emptyList();
    tracker.trackStartGettingFormManifest();
    URL manifestUrl = form.getManifestUrl().map(RequestBuilder::url).get();
    Request<List<AggregateAttachment>> request = get(manifestUrl).asXmlElement().withResponseMapper(PullFromAggregate::parseMediaFiles).build();
    Response<List<AggregateAttachment>> response = http.execute(request);
    if (!response.isSuccess()) {
        tracker.trackErrorGettingFormManifest(response);
        return Collections.emptyList();
    }
    List<AggregateAttachment> attachments = response.get();
    List<AggregateAttachment> attachmentsToDownload = attachments.stream().filter(mediaFile -> mediaFile.needsUpdate(form.getFormMediaDir(briefcaseDir))).collect(toList());
    tracker.trackEndGettingFormManifest();
    tracker.trackIgnoredFormAttachments(attachmentsToDownload.size(), attachments.size());
    return attachmentsToDownload;
}
Also used : Job.run(org.opendatakit.briefcase.reused.job.Job.run) TRUNCATE_EXISTING(java.nio.file.StandardOpenOption.TRUNCATE_EXISTING) URL(java.net.URL) Response(org.opendatakit.briefcase.reused.http.response.Response) RequestBuilder(org.opendatakit.briefcase.reused.http.RequestBuilder) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) FormMetadataPort(org.opendatakit.briefcase.model.form.FormMetadataPort) PullEvent(org.opendatakit.briefcase.pull.PullEvent) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) EventBus(org.bushe.swing.event.EventBus) AggregateServer(org.opendatakit.briefcase.reused.transfer.AggregateServer) Pair(org.opendatakit.briefcase.reused.Pair) DatabaseUtils.withDb(org.opendatakit.briefcase.util.DatabaseUtils.withDb) Path(java.nio.file.Path) FormKey(org.opendatakit.briefcase.model.form.FormKey) RemoteFormDefinition(org.opendatakit.briefcase.model.RemoteFormDefinition) BinaryOperator.maxBy(java.util.function.BinaryOperator.maxBy) OptionalProduct(org.opendatakit.briefcase.reused.OptionalProduct) FormStatus(org.opendatakit.briefcase.model.FormStatus) FormStatusEvent(org.opendatakit.briefcase.model.FormStatusEvent) Request(org.opendatakit.briefcase.reused.http.Request) Collections.emptyList(java.util.Collections.emptyList) Set(java.util.Set) RunnerStatus(org.opendatakit.briefcase.reused.job.RunnerStatus) FormMetadataCommands.updateAsPulled(org.opendatakit.briefcase.model.form.FormMetadataCommands.updateAsPulled) Http(org.opendatakit.briefcase.reused.http.Http) UncheckedFiles.createDirectories(org.opendatakit.briefcase.reused.UncheckedFiles.createDirectories) Consumer(java.util.function.Consumer) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) UncheckedFiles.write(org.opendatakit.briefcase.reused.UncheckedFiles.write) CREATE(java.nio.file.StandardOpenOption.CREATE) Triple(org.opendatakit.briefcase.reused.Triple) Optional(java.util.Optional) Job(org.opendatakit.briefcase.reused.job.Job) Collections(java.util.Collections) RequestBuilder.get(org.opendatakit.briefcase.reused.http.RequestBuilder.get) XmlElement(org.opendatakit.briefcase.export.XmlElement) RequestBuilder(org.opendatakit.briefcase.reused.http.RequestBuilder) ArrayList(java.util.ArrayList) Collections.emptyList(java.util.Collections.emptyList) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) URL(java.net.URL)

Example 4 with RunnerStatus

use of org.opendatakit.briefcase.reused.job.RunnerStatus in project briefcase by opendatakit.

the class PushToCentral method push.

/**
 * Pushes a form completely, sending the form file, form attachments,
 * submission files and their attachments to the Aggregate server.
 * <p>
 * It won't push a form and form attachments if it's already
 * present in the server.
 */
@SuppressWarnings("checkstyle:Indentation")
public Job<Void> push(FormStatus form) {
    PushToCentralTracker tracker = new PushToCentralTracker(form, onEventCallback);
    Job<Void> startTrackingJob = Job.run(runnerStatus -> tracker.trackStart());
    // Verify that the form is not encrypted
    Path formFile = form.getFormFile(briefcaseDir);
    try {
        if (FormDefinition.from(formFile).isFileEncryptedForm())
            return startTrackingJob.thenRun(rs -> {
                tracker.trackEncryptedForm();
                tracker.trackEnd();
            });
    } catch (RuntimeException e) {
        return startTrackingJob.thenRun(rs -> {
            tracker.trackCannotDetermineEncryption(e);
            tracker.trackEnd();
        });
    }
    FormMetadataPort formMetadataPort = FileSystemFormMetadataAdapter.at(briefcaseDir);
    return startTrackingJob.thenSupply(rs -> getMissingFormVersions(form, rs, tracker, formMetadataPort)).thenAccept(((rs, missingFormVersions) -> {
        String localFormVersion = form.getVersion().orElse("");
        boolean sendLocal = missingFormVersions.remove(localFormVersion);
        // First send a request to create the form. It doesn't matter what version is sent because it will be replaced
        // below. Will fail if a published form already exists with this id but then missing versions can still be added.
        createForm(form.getFormFile(briefcaseDir), rs, tracker);
        // Send all of the obsolete versions first so that we can send corresponding submissions. Skip attachments
        // because those versions won't be used by clients.
        missingFormVersions.stream().sorted().forEach(version -> {
            pushFormDraft(form.getFormFile(briefcaseDir), form.getFormId(), version, rs, tracker);
            publishDraft(form.getFormId(), version, rs, tracker);
        });
        if (sendLocal) {
            boolean formSent = pushFormDraft(formFile, form.getFormId(), localFormVersion, rs, tracker);
            if (formSent) {
                List<Path> formAttachments = getFormAttachments(form);
                AtomicInteger attachmentSeq = new AtomicInteger(1);
                int totalAttachments = formAttachments.size();
                formAttachments.forEach(attachment -> pushFormAttachment(form.getFormId(), attachment, rs, tracker, attachmentSeq.getAndIncrement(), totalAttachments));
                publishDraft(form.getFormId(), localFormVersion, rs, tracker);
            }
        }
    })).thenSupply(__ -> getSubmissions(form)).thenAccept((rs, submissions) -> {
        AtomicInteger submissionNumber = new AtomicInteger(1);
        int totalSubmissions = submissions.size();
        if (submissions.isEmpty())
            tracker.trackNoSubmissions();
        // We might not have had access to submission versions because e.g. submissions were manually added to the
        // Briefcase folder or were imported in <=v1.17 when submission versions weren't saved.
        Set<String> seenVersions = new HashSet<>();
        submissions.parallelStream().map(submission -> {
            XmlElement root = XmlElement.from(new String(readAllBytes(submission)));
            SubmissionMetaData metaData = new SubmissionMetaData(root);
            metaData.getVersion().ifPresent(seenVersions::add);
            return Triple.of(submission, submissionNumber.getAndIncrement(), metaData.getInstanceId());
        }).peek(triple -> {
            if (!triple.get3().isPresent())
                tracker.trackNoInstanceId(triple.get2(), totalSubmissions);
        }).filter(triple -> triple.get3().isPresent()).forEach(triple -> {
            Path submission = triple.get1();
            int currentSubmissionNumber = triple.get2();
            String instanceId = triple.get3().get();
            boolean submissionSent = pushSubmission(form.getFormId(), submission, rs, tracker, currentSubmissionNumber, totalSubmissions);
            if (submissionSent) {
                List<Path> submissionAttachments = getSubmissionAttachments(submission);
                AtomicInteger attachmentSeq = new AtomicInteger(1);
                int totalAttachments = submissionAttachments.size();
                submissionAttachments.parallelStream().forEach(attachment -> pushSubmissionAttachment(form.getFormId(), instanceId, attachment, rs, tracker, currentSubmissionNumber, totalSubmissions, attachmentSeq.getAndIncrement(), totalAttachments));
            }
        });
        formMetadataPort.execute(updateSubmissionVersions(FormKey.from(form), briefcaseDir, form.getFormDir(briefcaseDir), seenVersions));
        tracker.trackEnd();
    }).thenRun(rs -> EventBus.publish(new PushEvent.Success(form)));
}
Also used : Path(java.nio.file.Path) FormDefinition(org.opendatakit.briefcase.export.FormDefinition) FileSystemFormMetadataAdapter(org.opendatakit.briefcase.model.form.FileSystemFormMetadataAdapter) UncheckedFiles(org.opendatakit.briefcase.reused.UncheckedFiles) Response(org.opendatakit.briefcase.reused.http.response.Response) SubmissionMetaData(org.opendatakit.briefcase.export.SubmissionMetaData) HashSet(java.util.HashSet) FormMetadataPort(org.opendatakit.briefcase.model.form.FormMetadataPort) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) UncheckedFiles.readAllBytes(org.opendatakit.briefcase.reused.UncheckedFiles.readAllBytes) EventBus(org.bushe.swing.event.EventBus) UncheckedFiles.list(org.opendatakit.briefcase.reused.UncheckedFiles.list) Path(java.nio.file.Path) FormKey(org.opendatakit.briefcase.model.form.FormKey) FormMetadataQueries.submissionVersionsOf(org.opendatakit.briefcase.model.form.FormMetadataQueries.submissionVersionsOf) FormStatus(org.opendatakit.briefcase.model.FormStatus) FormStatusEvent(org.opendatakit.briefcase.model.FormStatusEvent) CentralServer(org.opendatakit.briefcase.reused.transfer.CentralServer) Files(java.nio.file.Files) Collections.emptyList(java.util.Collections.emptyList) Set(java.util.Set) RunnerStatus(org.opendatakit.briefcase.reused.job.RunnerStatus) Http(org.opendatakit.briefcase.reused.http.Http) UncheckedFiles.exists(org.opendatakit.briefcase.reused.UncheckedFiles.exists) FormMetadataCommands.updateSubmissionVersions(org.opendatakit.briefcase.model.form.FormMetadataCommands.updateSubmissionVersions) Consumer(java.util.function.Consumer) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) PushEvent(org.opendatakit.briefcase.push.PushEvent) Triple(org.opendatakit.briefcase.reused.Triple) Job(org.opendatakit.briefcase.reused.job.Job) Collections(java.util.Collections) InputStream(java.io.InputStream) XmlElement(org.opendatakit.briefcase.export.XmlElement) SubmissionMetaData(org.opendatakit.briefcase.export.SubmissionMetaData) HashSet(java.util.HashSet) Set(java.util.Set) FormMetadataPort(org.opendatakit.briefcase.model.form.FormMetadataPort) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) XmlElement(org.opendatakit.briefcase.export.XmlElement) Collections.emptyList(java.util.Collections.emptyList) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List)

Example 5 with RunnerStatus

use of org.opendatakit.briefcase.reused.job.RunnerStatus in project briefcase by opendatakit.

the class PushToAggregate method push.

/**
 * Pushes a form completely, sending the form file, form attachments,
 * submission files and their attachments to the Aggregate server.
 * <p>
 * By default, it won't push a form and form attachments if it's already
 * present in the server, which can be overriden with the {@link #forceSendForm}
 * field.
 */
public Job<Void> push(FormStatus form) {
    PushToAggregateTracker tracker = new PushToAggregateTracker(form, onEventCallback);
    return Job.run(runnerStatus -> {
        tracker.trackStart();
        tracker.trackForceSendForm(forceSendForm);
    }).thenSupply(runnerStatus -> !forceSendForm && checkFormExists(form.getFormId(), runnerStatus, tracker)).thenAccept(((runnerStatus, formExists) -> {
        if (!formExists) {
            Path formFile = form.getFormFile(briefcaseDir);
            List<Path> allAttachments = getFormAttachments(form);
            if (allAttachments.isEmpty()) {
                pushFormAndAttachments(form, emptyList(), runnerStatus, tracker);
            } else {
                AtomicInteger partsSeq = new AtomicInteger(1);
                List<List<Path>> attachmentGroups = createGroupsOfMaxSize(formFile, allAttachments, 10);
                attachmentGroups.forEach(attachments -> pushFormAndAttachments(form, attachments, runnerStatus, tracker, partsSeq.getAndIncrement(), attachmentGroups.size()));
            }
        }
    })).thenSupply(__ -> getSubmissions(form)).thenAccept((runnerStatus, submissions) -> {
        AtomicInteger submissionsSeq = new AtomicInteger(1);
        int totalSubmissions = submissions.size();
        if (submissions.isEmpty())
            tracker.trackNoSubmissions();
        submissions.parallelStream().forEach(submission -> {
            List<Path> allAttachments = getSubmissionAttachments(submission);
            if (allAttachments.isEmpty()) {
                pushSubmissionAndAttachments(submission, emptyList(), runnerStatus, tracker, submissionsSeq.getAndIncrement(), totalSubmissions);
            } else {
                AtomicInteger partsSeq = new AtomicInteger(1);
                List<List<Path>> attachmentGroups = createGroupsOfMaxSize(submission, allAttachments, 10);
                attachmentGroups.forEach(attachment -> pushSubmissionAndAttachments(submission, allAttachments, runnerStatus, tracker, submissionsSeq.getAndIncrement(), totalSubmissions, partsSeq.getAndIncrement(), attachmentGroups.size()));
            }
        });
        tracker.trackEnd();
    }).thenRun(rs -> EventBus.publish(new PushEvent.Success(form)));
}
Also used : FormStatus(org.opendatakit.briefcase.model.FormStatus) FormStatusEvent(org.opendatakit.briefcase.model.FormStatusEvent) UncheckedFiles.size(org.opendatakit.briefcase.reused.UncheckedFiles.size) Files(java.nio.file.Files) Collections.emptyList(java.util.Collections.emptyList) UncheckedFiles(org.opendatakit.briefcase.reused.UncheckedFiles) Response(org.opendatakit.briefcase.reused.http.response.Response) RunnerStatus(org.opendatakit.briefcase.reused.job.RunnerStatus) Http(org.opendatakit.briefcase.reused.http.Http) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PushEvent(org.opendatakit.briefcase.push.PushEvent) EventBus(org.bushe.swing.event.EventBus) AggregateServer(org.opendatakit.briefcase.reused.transfer.AggregateServer) Job(org.opendatakit.briefcase.reused.job.Job) UncheckedFiles.list(org.opendatakit.briefcase.reused.UncheckedFiles.list) Path(java.nio.file.Path) XmlElement(org.opendatakit.briefcase.export.XmlElement) Path(java.nio.file.Path) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Collections.emptyList(java.util.Collections.emptyList) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List)

Aggregations

Path (java.nio.file.Path)5 List (java.util.List)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 Collectors.toList (java.util.stream.Collectors.toList)5 FormStatus (org.opendatakit.briefcase.model.FormStatus)5 RunnerStatus (org.opendatakit.briefcase.reused.job.RunnerStatus)5 Collections.emptyList (java.util.Collections.emptyList)4 Consumer (java.util.function.Consumer)4 EventBus (org.bushe.swing.event.EventBus)4 XmlElement (org.opendatakit.briefcase.export.XmlElement)4 FormKey (org.opendatakit.briefcase.model.form.FormKey)4 Files (java.nio.file.Files)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 FormStatusEvent (org.opendatakit.briefcase.model.FormStatusEvent)3 Http (org.opendatakit.briefcase.reused.http.Http)3 Response (org.opendatakit.briefcase.reused.http.response.Response)3 Job (org.opendatakit.briefcase.reused.job.Job)3 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2