Ejemplo n.º 1
0
  private void setCommonDetails(ProgData progData, Item episode, Optional<Channel> channel) {
    // Currently Welsh channels have Welsh titles/descriptions which flip the English ones,
    // resulting in many writes. We'll only take the Welsh title if we don't
    // already have a title from another channel
    boolean isWelshChannel = channel.isPresent() && channel.get().getUri().contains("wales");

    if (episode.getTitle() == null || !isWelshChannel) {
      if (progData.getEpisodeTitle() != null) {
        episode.setTitle(progData.getEpisodeTitle());
      } else {
        episode.setTitle(progData.getTitle());
      }
    }

    setDescription(progData, episode, isWelshChannel);

    if (channel.isPresent()) {
      episode.setMediaType(channel.get().getMediaType());
      episode.setSpecialization(specialization(progData, channel.get()));
    }

    setGenres(progData, episode);
    setTopicRefs(episode);

    if (progData.getCountry() != null) {
      episode.setCountriesOfOrigin(countryMap.parseCountries(progData.getCountry()));
    }

    if (progData.getAttr() != null) {
      episode.setBlackAndWhite(getBooleanValue(progData.getAttr().getBw()));
    }

    episode.setPeople(people(progData));

    setCertificate(progData, episode);

    // Adding a film alias only used to happen when type was film. Previously this was
    // decided based on the existence of the field rt_filmnumber. That's faulty, though,
    // so we changed it to use the film flag. In order to maintain backward-compatibilty
    // and only set the film alias when a rt_filmnumber value exists, we make that
    // check here.

    Optional<String> rtFilmIdentifier = rtFilmIdentifierFor(progData);
    if (rtFilmIdentifier.isPresent()) {
      episode.addAliasUrl(PaHelper.getLegacyFilmUri(rtFilmIdentifier.get()));
      episode.addAlias(PaHelper.getLegacyFilmAlias(rtFilmIdentifier.get()));
    }
    episode.addAliasUrl(PaHelper.getAlias(progData.getProgId()));
    episode.addAlias(PaHelper.getNewFilmAlias(identifierFor(progData)));
  }
Ejemplo n.º 2
0
  private Broadcast setCommonDetails(
      ProgData progData, Channel channel, DateTimeZone zone, Item episode, Timestamp updatedAt) {

    // currently Welsh channels have Welsh titles/descriptions
    // which flip the English ones, resulting in many writes. We'll only take the Welsh title if we
    // don't
    // already have a title from another channel
    if (episode.getTitle() == null || !channel.getUri().contains("wales")) {
      if (progData.getEpisodeTitle() != null) {
        episode.setTitle(progData.getEpisodeTitle());
      } else {
        episode.setTitle(progData.getTitle());
      }
    }

    if (progData.getBillings() != null) {
      for (Billing billing : progData.getBillings().getBilling()) {
        if ((episode.getDescription() == null || !channel.getUri().contains("wales"))
            && billing.getType().equals("synopsis")) {
          episode.setDescription(billing.getvalue());
        }
        if ((episode.getShortDescription() == null || !channel.getUri().contains("wales"))
            && billing.getType().equals("pa_detail1")) {
          episode.setShortDescription(billing.getvalue());
        }
        if ((episode.getMediumDescription() == null || !channel.getUri().contains("wales"))
            && billing.getType().equals("pa_detail2")) {
          episode.setMediumDescription(billing.getvalue());
        }
        if ((episode.getLongDescription() == null || !channel.getUri().contains("wales"))
            && billing.getType().equals("pa_detail3")) {
          episode.setLongDescription(billing.getvalue());
        }
      }
    }

    episode.setMediaType(channel.getMediaType());
    episode.setSpecialization(specialization(progData, channel));
    setGenres(progData, episode);

    if (progData.getCountry() != null) {
      episode.setCountriesOfOrigin(countryMap.parseCountries(progData.getCountry()));
    }

    if (progData.getAttr() != null) {
      episode.setBlackAndWhite(getBooleanValue(progData.getAttr().getBw()));
    }

    selectImages(
        progData.getPictures(),
        episode,
        PA_PICTURE_TYPE_EPISODE,
        PA_PICTURE_TYPE_SERIES,
        Maybe.just(PA_PICTURE_TYPE_BRAND));

    episode.setPeople(people(progData));

    Version version = findBestVersion(episode.getVersions());
    version.set3d(getBooleanValue(progData.getAttr().getThreeD()));
    Duration duration = Duration.standardMinutes(Long.valueOf(progData.getDuration()));
    version.setDuration(duration);
    setCertificate(progData, episode);

    Broadcast broadcast = broadcast(progData, channel, zone, updatedAt);
    addBroadcast(version, broadcast);
    return broadcast;
  }