Exemple #1
0
  private Series getSeriesSummary(ProgData progData, Series series, Timestamp updatedAt) {
    String uri =
        series.getCanonicalUri().replace(Publisher.PA.key(), Publisher.PA_SERIES_SUMMARIES.key());
    Maybe<Identified> maybeSeriesSummary =
        contentResolver.findByCanonicalUris(ImmutableList.of(uri)).getFirstValue();
    Series seriesSummary;

    if (maybeSeriesSummary.isNothing()) {
      seriesSummary = new Series();
      seriesSummary.setCanonicalUri(uri);
      seriesSummary.setPublisher(Publisher.PA_SERIES_SUMMARIES);
      seriesSummary.setEquivalentTo(ImmutableSet.of(LookupRef.from(series)));
    } else {
      seriesSummary = (Series) maybeSeriesSummary.requireValue();
    }

    seriesSummary.setLongDescription(progData.getSeason().getSeasonSummary());
    seriesSummary.setLastUpdated(updatedAt.toDateTimeUTC());

    return seriesSummary;
  }
Exemple #2
0
  private Brand getBrandSummary(ProgData progData, Brand brand, Timestamp updatedAt) {
    String uri =
        brand.getCanonicalUri().replace(Publisher.PA.key(), Publisher.PA_SERIES_SUMMARIES.key());
    Maybe<Identified> maybeBrandSummary =
        contentResolver.findByCanonicalUris(ImmutableList.of(uri)).getFirstValue();
    Brand brandSummary;

    if (maybeBrandSummary.isNothing()) {
      brandSummary = new Brand();
      brandSummary.setCanonicalUri(uri);
      brandSummary.setPublisher(Publisher.PA_SERIES_SUMMARIES);
      brandSummary.setEquivalentTo(ImmutableSet.of(LookupRef.from(brand)));
    } else {
      brandSummary = (Brand) maybeBrandSummary.requireValue();
    }

    brandSummary.setLongDescription(progData.getSeriesSummary());
    brandSummary.setLastUpdated(updatedAt.toDateTimeUTC());

    return brandSummary;
  }
  @Override
  public ContentHierarchyAndSummaries process(
      ProgData progData, Channel channel, DateTimeZone zone, Timestamp updatedAt) {
    try {
      if (!Strings.isNullOrEmpty(progData.getSeriesId())
          && IGNORED_BRANDS.contains(progData.getSeriesId())) {
        return null;
      }

      Brand brandSummary = null;
      Series seriesSummary = null;

      Optional<Brand> possibleBrand = getBrand(progData, channel, updatedAt);
      if (possibleBrand.isPresent()) {
        Brand originalBrand = possibleBrand.get();
        if (hasBrandSummary(progData)) {
          brandSummary = extractSummaryBrand(progData, originalBrand.getCanonicalUri(), updatedAt);
          brandSummary.setEquivalentTo(ImmutableSet.of(LookupRef.from(originalBrand)));
        }
      }

      Optional<Series> possibleSeries = getSeries(progData, channel, updatedAt);
      if (possibleSeries.isPresent()) {
        Series originalSeries = possibleSeries.get();
        if (hasSeriesSummary(progData)) {
          seriesSummary =
              extractSummarySeries(progData, originalSeries.getCanonicalUri(), updatedAt);
          seriesSummary.setEquivalentTo(ImmutableSet.of(LookupRef.from(originalSeries)));
        }
      }

      ItemAndBroadcast itemAndBroadcast =
          isClosedBrand(possibleBrand)
              ? getClosedEpisode(possibleBrand.get(), progData, channel, zone, updatedAt)
              : getFilmOrEpisode(
                  progData,
                  channel,
                  zone,
                  possibleBrand.isPresent() || possibleSeries.isPresent(),
                  updatedAt);

      Item item = itemAndBroadcast.getItem();
      item.setGenericDescription(isGenericDescription(progData));
      item.setLastUpdated(updatedAt.toDateTimeUTC());

      return new ContentHierarchyAndSummaries(
          possibleBrand,
          possibleSeries,
          item,
          itemAndBroadcast.getBroadcast().requireValue(),
          Optional.fromNullable(brandSummary),
          Optional.fromNullable(seriesSummary));
    } catch (Exception e) {
      e.printStackTrace();
      log.record(
          new AdapterLogEntry(Severity.ERROR)
              .withCause(e)
              .withSource(PaProgrammeProcessor.class)
              .withDescription(e.getMessage()));
    }
    return null;
  }
Exemple #4
0
 /**
  * PA People are ingested separately from PA biogs people. Therefore we set a direct equivalence
  * on the PA person if they exist. In the future this will change to an equivalence job so the
  * equivalence will be asserted at a later stage even if the PA person doesn't exist at the time
  * when the PA biog person is ingested.
  *
  * @param person
  */
 private void setDirectEquivalentToPAPerson(Person person, String id) {
   Optional<Person> paPerson = personResolver.person(PA_PERSON_URI_PREFIX + id);
   if (paPerson.isPresent()) {
     person.setEquivalentTo(ImmutableSet.of(LookupRef.from(paPerson.get())));
   }
 }