示例#1
0
  private Optional<Brand> getBrandWithoutChannel(ProgData progData, Timestamp updatedAt) {

    String brandId = progData.getSeriesId();
    if (Strings.isNullOrEmpty(brandId) || Strings.isNullOrEmpty(brandId.trim())) {
      return Optional.absent();
    }

    String brandUri = PaHelper.getBrandUri(brandId);
    Alias brandAlias = PaHelper.getBrandAlias(brandId);

    Maybe<Identified> possiblePrevious =
        contentResolver.findByCanonicalUris(ImmutableList.of(brandUri)).getFirstValue();

    Brand brand =
        possiblePrevious.hasValue()
            ? (Brand) possiblePrevious.requireValue()
            : new Brand(brandUri, "pa:b-" + brandId, Publisher.PA);

    brand.addAlias(brandAlias);
    brand.setTitle(progData.getTitle());
    brand.setDescription(Strings.emptyToNull(progData.getSeriesSynopsis()));
    setCertificate(progData, brand);
    setGenres(progData, brand);
    setTopicRefs(brand);

    if (isClosedBrand(Optional.of(brand))) {
      brand.setScheduleOnly(true);
    }

    brand.setLastUpdated(updatedAt.toDateTimeUTC());

    return Optional.of(brand);
  }
示例#2
0
 private Brand extractSummaryBrand(ProgData progData, String originalURI, Timestamp updatedAt) {
   Brand summaryBrand = new Brand();
   summaryBrand.setCanonicalUri(
       originalURI.replace(Publisher.PA.key(), Publisher.PA_SERIES_SUMMARIES.key()));
   summaryBrand.setPublisher(Publisher.PA_SERIES_SUMMARIES);
   summaryBrand.setLongDescription(progData.getSeriesSummary());
   summaryBrand.setLastUpdated(updatedAt.toDateTimeUTC());
   return summaryBrand;
 }
示例#3
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;
  }
示例#4
0
  private Optional<Brand> getBrand(ProgData progData, Channel channel, Timestamp updatedAt) {
    String brandId = progData.getSeriesId();
    if (Strings.isNullOrEmpty(brandId) || Strings.isNullOrEmpty(brandId.trim())) {
      return Optional.absent();
    }

    String brandUri = PaHelper.getBrandUri(brandId);
    Alias brandAlias = PaHelper.getBrandAlias(brandId);

    Maybe<Identified> possiblePrevious =
        contentResolver.findByCanonicalUris(ImmutableList.of(brandUri)).getFirstValue();

    Brand brand =
        possiblePrevious.hasValue()
            ? (Brand) possiblePrevious.requireValue()
            : new Brand(brandUri, "pa:b-" + brandId, Publisher.PA);

    brand.addAlias(brandAlias);
    brand.setTitle(progData.getTitle());
    brand.setDescription(Strings.emptyToNull(progData.getSeriesSynopsis()));
    brand.setSpecialization(specialization(progData, channel));
    brand.setMediaType(channel.getMediaType());
    setCertificate(progData, brand);
    setGenres(progData, brand);

    selectImages(
        progData.getPictures(),
        brand,
        PA_PICTURE_TYPE_BRAND,
        PA_PICTURE_TYPE_SERIES,
        Maybe.<String>nothing());

    if (isClosedBrand(Optional.of(brand))) {
      brand.setScheduleOnly(true);
    }
    brand.setLastUpdated(updatedAt.toDateTimeUTC());

    return Optional.of(brand);
  }