예제 #1
0
  private Map<String, SeriesRef> getSeriesRefs(Container container) {
    Map<String, SeriesRef> seriesRefs = Maps.newLinkedHashMap();

    if (container instanceof Brand) {
      ResolvedContent resolvedSeries =
          resolver.findByCanonicalUris(
              Iterables.transform(((Brand) container).getSeriesRefs(), SeriesRef.TO_URI));
      for (Series series : Iterables.filter(resolvedSeries.getAllResolvedResults(), Series.class)) {
        seriesRefs.put(series.getCanonicalUri(), series.seriesRef());
      }
    } else if (container instanceof Series) {
      // if this is a top level series then all its children *series* ref is to this too.
      seriesRefs.put(container.getCanonicalUri(), ((Series) container).seriesRef());
    } else {
      throw new IllegalArgumentException(
          "Unexpected Container type: " + container.getClass().getSimpleName());
    }
    return seriesRefs;
  }
예제 #2
0
  private Multimap<String, ChildRef> getChildRefs(Container container) {
    Multimap<String, ChildRef> seriesChildRefs = LinkedListMultimap.create();

    ResolvedContent resolvedEpisodes =
        resolver.findByCanonicalUris(
            Iterables.transform(container.getChildRefs(), ChildRef.TO_URI));
    for (Item item : Iterables.filter(resolvedEpisodes.getAllResolvedResults(), Item.class)) {
      if (!item.isActivelyPublished()) {
        continue;
      }

      ChildRef childRef = item.childRef();
      if (item instanceof Episode && ((Episode) item).getSeriesRef() != null) {
        String seriesUri = ((Episode) item).getSeriesRef().getUri();
        seriesChildRefs.put(seriesUri, childRef);
      } else {
        seriesChildRefs.put("none", childRef);
      }
    }
    return seriesChildRefs;
  }
 @Override
 public Iterable<Item> apply(@Nullable Container input) {
   Iterable<String> childUris = Iterables.transform(input.getChildRefs(), ChildRef.TO_URI);
   ResolvedContent children = contentResolver.findByCanonicalUris(childUris);
   return Iterables.filter(children.getAllResolvedResults(), Item.class);
 }
 private Iterable<Episode> childrenOf(Container container) {
   ImmutableList<ChildRef> childRefs = container.getChildRefs();
   Iterable<String> childUris = Iterables.transform(childRefs, TO_URI);
   ResolvedContent children = contentResolver.findByCanonicalUris(childUris);
   return Iterables.filter(children.getAllResolvedResults(), Episode.class);
 }