Search in sources :

Example 1 with GenericCompositeFuture

use of org.folio.okapi.common.GenericCompositeFuture in project mod-source-record-manager by folio-org.

the class JobExecutionServiceImpl method saveJobExecutions.

/**
 * Performs save for received JobExecution entities using {@link JobExecutionDao}
 *
 * @param jobExecutions list on JobExecution entities
 * @return future
 */
private Future<List<String>> saveJobExecutions(List<JobExecution> jobExecutions, String tenantId) {
    List<Future<String>> savedJobExecutionFutures = new ArrayList<>();
    for (JobExecution jobExecution : jobExecutions) {
        Future<String> savedJobExecutionFuture = jobExecutionDao.save(jobExecution, tenantId);
        savedJobExecutionFutures.add(savedJobExecutionFuture);
    }
    return GenericCompositeFuture.all(savedJobExecutionFutures).map(genericCompositeFuture -> genericCompositeFuture.result().list());
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) ArrayList(java.util.ArrayList) GenericCompositeFuture(org.folio.okapi.common.GenericCompositeFuture) Future(io.vertx.core.Future)

Example 2 with GenericCompositeFuture

use of org.folio.okapi.common.GenericCompositeFuture in project mod-source-record-manager by folio-org.

the class JobExecutionServiceImpl method saveSnapshots.

/**
 * Performs save for received Snapshot entities.
 * For each Snapshot posts the request to mod-source-record-manager.
 *
 * @param snapshots list of Snapshot entities
 * @param params    object-wrapper with params necessary to connect to OKAPI
 * @return future
 */
private Future<List<String>> saveSnapshots(List<Snapshot> snapshots, OkapiConnectionParams params) {
    List<Future<String>> postedSnapshotFutures = new ArrayList<>();
    for (Snapshot snapshot : snapshots) {
        Future<String> postedSnapshotFuture = postSnapshot(snapshot, params);
        postedSnapshotFutures.add(postedSnapshotFuture);
    }
    return GenericCompositeFuture.all(postedSnapshotFutures).map(genericCompositeFuture -> genericCompositeFuture.result().list());
}
Also used : Snapshot(org.folio.rest.jaxrs.model.Snapshot) ArrayList(java.util.ArrayList) GenericCompositeFuture(org.folio.okapi.common.GenericCompositeFuture) Future(io.vertx.core.Future)

Aggregations

Future (io.vertx.core.Future)2 ArrayList (java.util.ArrayList)2 GenericCompositeFuture (org.folio.okapi.common.GenericCompositeFuture)2 JobExecution (org.folio.rest.jaxrs.model.JobExecution)1 Snapshot (org.folio.rest.jaxrs.model.Snapshot)1