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));
  }
Beispiel #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;
  }
  private Film createNitroFilm(boolean subtitled) {
    Film film = new Film();

    film.setCanonicalUri("http://nitro.bbc.co.uk/programmes/b020tm1g");
    film.setPublisher(Publisher.BBC_NITRO);
    film.setCountriesOfOrigin(ImmutableSet.of(Countries.GB));
    film.setYear(1963);
    film.addVersion(createVersion(subtitled));

    return film;
  }
Beispiel #4
0
 private Alias generateAliasFor(Film content) {
   return PaHelper.getFilmAlias(content.getId().toString());
 }
  private Film createAlbaNitroFilm() {
    Film film = createNitroFilm(true);
    film.setPresentationChannel("http://ref.atlasapi.org/channels/bbcalba");

    return film;
  }