コード例 #1
0
 public void forceUpdatePodcast(Integer id) {
   log.info("Lancement de l'update forcé");
   Podcast podcast = podcastBusiness.findOne(id);
   podcast.setSignature("");
   podcast = podcastBusiness.save(podcast);
   updatePodcast(podcast.getId());
 }
コード例 #2
0
  @Transactional(noRollbackFor = Exception.class)
  private void updatePodcast(List<Podcast> podcasts, Executor selectedExecutor) {
    initUpdate();

    log.info("Lancement de l'update");
    log.info("Traitement de {} podcasts", podcasts.size());

    podcasts
        // Launch every update
        .stream()
        .map(
            podcast ->
                supplyAsync(() -> workerService.updaterOf(podcast))
                    .thenApplyAsync(updater -> updater.update(podcast), selectedExecutor))
        .collect(
            toSet()) // Terminal operation forcing evaluation of each element upper in the stream
        // Get result of each update
        .stream()
        .map(this::wait)
        .filter(tuple -> tuple != Updater.NO_MODIFICATION_TUPLE)
        .peek((tuple) -> changeAndCommunicateUpdate(Boolean.TRUE))
        .forEach(
            tuple ->
                podcastBusiness.save(
                    attachNewItemsToPodcast(tuple.first(), tuple.middle(), tuple.last())));

    log.info("Fin du traitement des {} podcasts", podcasts.size());
    finishUpdate();
  }
コード例 #3
0
 public void updatePodcast(Integer id) {
   updatePodcast(Collections.singletonList(podcastBusiness.findOne(id)), manualExecutor);
 }
コード例 #4
0
 public void updatePodcast() {
   updatePodcast(podcastBusiness.findByUrlIsNotNull(), updateExecutor);
 }