Пример #1
0
  private ItemAndBroadcast getFilm(
      ProgData progData, Channel channel, DateTimeZone zone, Timestamp updatedAt) {
    String filmUri = PaHelper.getFilmUri(identifierFor(progData));
    Maybe<Identified> possiblePreviousData =
        contentResolver.findByCanonicalUris(ImmutableList.of(filmUri)).getFirstValue();

    Film film;
    if (possiblePreviousData.hasValue()) {
      Identified previous = possiblePreviousData.requireValue();
      if (previous instanceof Film) {
        film = (Film) previous;
      } else {
        film = new Film();
        Item.copyTo((Episode) previous, film);
      }
    } else {
      film = getBasicFilm(progData);
    }
    film.addAlias(PaHelper.getFilmAlias(identifierFor(progData)));
    Optional<String> rtFilmIdentifier = rtFilmIdentifierFor(progData);
    if (rtFilmIdentifier.isPresent()) {
      film.addAlias(PaHelper.getRtFilmAlias(rtFilmIdentifier.get()));
    }

    film.setAliasUrls(ImmutableSet.of(PaHelper.getAlias(progData.getProgId())));

    Broadcast broadcast = setCommonDetails(progData, channel, zone, film, updatedAt);

    if (progData.getFilmYear() != null
        && MoreStrings.containsOnlyAsciiDigits(progData.getFilmYear())) {
      film.setYear(Integer.parseInt(progData.getFilmYear()));
    }

    return new ItemAndBroadcast(film, Maybe.just(broadcast));
  }
Пример #2
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;
  }
Пример #3
0
  private Film getBasicFilm(ProgData progData) {
    Film film =
        new Film(
            PaHelper.getFilmUri(identifierFor(progData)),
            PaHelper.getEpisodeCurie(identifierFor(progData)),
            Publisher.PA);
    setBasicDetails(progData, film);

    return film;
  }