private DBObject updateForItem(Container container, SeriesRef seriesRef) { MongoUpdateBuilder childUpdate = MongoBuilders.update().setField(ItemTranslator.CONTAINER_ID, container.getId()); if (seriesRef != null) { childUpdate.setField(ItemTranslator.SERIES_ID, seriesRef.getId()); } DBObject update = childUpdate.build(); return update; }
private void updateContainersRefs( Container container, Map<String, SeriesRef> seriesRefs, Multimap<String, ChildRef> childRefs) { MongoUpdateBuilder brandUpdate = update().setField(ContainerTranslator.CHILDREN_KEY, dbosFromChildRefs(childRefs.values())); if (!seriesRefs.isEmpty()) { brandUpdate.setField( ContainerTranslator.FULL_SERIES_KEY, dbosFromSeriesRefs(seriesRefs.values())); } containers.update(where().idEquals(container.getCanonicalUri()).build(), brandUpdate.build()); }
private void updateSeriesRefs( Container container, Map<String, SeriesRef> seriesRefs, Multimap<String, ChildRef> seriesChildRefs) { if (seriesRefs.size() == 1 && seriesRefs.containsKey(container.getCanonicalUri())) { return; // container is a top level series. } for (String seriesUri : Iterables.transform(seriesRefs.values(), SeriesRef.TO_URI)) { MongoUpdateBuilder seriesUpdate = update().setField(ContainerTranslator.CONTAINER_ID, container.getId()); Collection<ChildRef> seriesChildren = seriesChildRefs.get(seriesUri); if (!seriesChildren.isEmpty()) { seriesUpdate.setField(ContainerTranslator.CHILDREN_KEY, dbosFromChildRefs(seriesChildren)); } programmeGroups.update(where().idEquals(seriesUri).build(), seriesUpdate.build()); } }