예제 #1
0
  private Item getBasicFilmWithoutBroadcast(ProgData progData) {
    ImmutableList.Builder<String> uris = ImmutableList.builder();

    Optional<String> rtFilmIdentifier = rtFilmIdentifierFor(progData);

    // Previously when constructing the uri we would failover to ProgId if the rtFilmIdentifier
    // was missing but still write to the same namespace. To avoid creating duplicates we have
    // to replicate this old behavior and use the rtFilmIdentifier for resolution when its
    // available

    String legacyFilmUri =
        rtFilmIdentifier.isPresent()
            ? PaHelper.getLegacyFilmUri(rtFilmIdentifier.get())
            : PaHelper.getLegacyFilmUri(progData.getProgId());

    uris.add(legacyFilmUri);
    uris.add(PaHelper.getAlias(progData.getProgId()));
    uris.add(PaHelper.getFilmUri(identifierFor(progData)));
    Map<String, Identified> resolvedContent =
        contentResolver.findByUris(uris.build()).asResolvedMap();

    Film film = getFilmFromResolvedContent(progData, resolvedContent, legacyFilmUri);

    if (progData.getFilmYear() != null
        && MoreStrings.containsOnlyAsciiDigits(progData.getFilmYear())) {
      film.setYear(Integer.parseInt(progData.getFilmYear()));
    }
    return film;
  }
예제 #2
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)));
  }