Package com.google.livingstories.client

Examples of com.google.livingstories.client.FilterSpec


  /**
   * Sets off an asynchronous call that fills in data for the event list. In some circumstances,
   * can do its work synchronously.
   */
  public void update(FilterSpec filter, Long focusedContentItemId) {
    FilterSpec oldFilter = filterList.getFilter();
    if (!filter.equals(oldFilter)) {
      boolean simpleReversal = !contentItemList.hasMore() && filter.isReverseOf(oldFilter);
      filterList.setFilter(filter);
      if (simpleReversal) {
        contentItemList.doSimpleReversal(filter.oldestFirst);
View Full Code Here


      return;
    }
    Long livingStoryId = livingStory.getId();
    Date lastVisitTime = null;
    boolean subscribedToEmails = false;
    FilterSpec defaultView = null;

    String loggedInUser = userLoginService.getUserId();
    if (loggedInUser != null) {
      lastVisitTime = userDataService.getLastVisitTimeForStory(loggedInUser, livingStoryId);
      subscribedToEmails = userDataService.isUserSubscribedToEmails(loggedInUser, livingStoryId);
View Full Code Here

  }
 
  private static FilterSpec getDefaultFilterSpec() {
    String defaultPageParams = LivingStoryData.getDefaultPage();
    return (defaultPageParams == null || defaultPageParams.isEmpty())  ?
        new FilterSpec() : new FilterSpec(defaultPageParams);
  }
View Full Code Here

        livingStoryId, filterSpec, focusedContentItemId, cutoff);
    if (result != null) {
      return result;
    }
   
    FilterSpec localFilterSpec = new FilterSpec(filterSpec);
   
    BaseContentItem focusedContentItem = null;
    if (focusedContentItemId != null) {
      focusedContentItem = getContentItem(focusedContentItemId, false);
      if (focusedContentItem != null) {
        if (adjustFilterSpecForContentItem(localFilterSpec, focusedContentItem)) {
          // If we had to adjust the filter spec to accommodate the focused content item,
          // we'll be switching filter views, so we want to clear the start date
          // and reload the list from the beginning.
          cutoff = null;
        }
      }
    }
   
    // Some preliminaries. Note that the present implementation just filters all content items for
    // a story, which could be a bit expensive if there's a cache miss. By and large, though,
    // we'd expect a lot more cache hits than cache misses, unlike the case with, say,
    // a twitter "following" feed, which is more likely to be unique to that user.
    List<BaseContentItem> allContentItems = getContentItemsForLivingStory(livingStoryId, true);
   
    Map<Long, BaseContentItem> idToContentItemMap = Maps.newHashMap();
    List<BaseContentItem> relevantContentItems = Lists.newArrayList();
    for (BaseContentItem contentItem : allContentItems) {
      idToContentItemMap.put(contentItem.getId(), contentItem);
     
      Date sortKey = contentItem.getDateSortKey();
      boolean matchesStartDate = (cutoff == null) ||
          (localFilterSpec.oldestFirst ? !sortKey.before(cutoff) : !sortKey.after(cutoff));

      if (matchesStartDate && localFilterSpec.doesContentItemMatch(contentItem)) {
        relevantContentItems.add(contentItem);
      }
    }
    sortContentItemList(relevantContentItems, localFilterSpec);
View Full Code Here

  @Override
  public synchronized DisplayContentItemBundle getRelatedContentItems(
      Long contentItemId, boolean byContribution, Date cutoff) {
    // translate contentItemId and byContribution into an appropriate FilterSpec, which we use
    // to respond from cache instead of by making fresh queries.
    FilterSpec filterSpec = new FilterSpec();
    if (byContribution) {
      filterSpec.contributorId = contentItemId;
    } else {
      filterSpec.playerId = contentItemId;
    }
View Full Code Here

    UserEntity userEntity = retrieveUserEntity(userId);
    if (userEntity == null) {
      return null;
    } else {
      String defaultStoryView = userEntity.getDefaultLspView();
      return defaultStoryView == null ? null : new FilterSpec(defaultStoryView);
    }
  }
View Full Code Here

   * @param selectedThemeId the new selectedThemeId
   */
  public void setSelectedTheme(Long selectedThemeId) {
    boolean isChange = !GlobalUtil.equal(this.selectedThemeId, selectedThemeId);
    this.selectedThemeId = selectedThemeId;
    FilterSpec filterCopy = copyCurrentFilterSpec();

    if (isChange) {
      if (loaded) {
        setContentItemTypeFilterVisibility(selectedThemeId);
      }
      filterCopy.themeId = selectedThemeId;
     
      if (!filterAppliesToTheme(filterCopy, selectedThemeId)) {
        filterCopy.contentItemType = null;
        filterCopy.assetType = null;
        filterCopy.opinion = false;
      }
    }

    HistoryManager.newTokenWithEvent(
        HistoryPages.OVERVIEW, filterCopy.getFilterParams(), null);
  }
View Full Code Here

    setAsDefaultLabel.addClickHandler(new ClickHandler() {
      @Override
      public void onClick(ClickEvent event) {
        // Get a copy of the current filters, but set themeId to null since we don't
        // care about that here.
        FilterSpec filterCopy = copyCurrentFilterSpec();
        filterCopy.themeId = null;
        userService.setDefaultStoryView(filterCopy, new NullCallback<Void>());
        setAsDefaultLabel.setVisible(false);
        defaultViewLabel.setVisible(true);
        LivingStoryData.setDefaultPage(filterCopy.getFilterParams());
      }
    });
    setAsDefaultLabel.setVisible(false);
    filterPanel.add(setAsDefaultLabel);
   
View Full Code Here

        currentFilters.contentItemType, currentFilters.assetType, currentFilters.opinion)).select();
    keyToFilterRowMap.get(getImportanceFilterKey(currentFilters.importantOnly)).select();
    keyToFilterRowMap.get(getTimeSortKey(currentFilters.oldestFirst)).select();
   
    String defaultView = LivingStoryData.getDefaultPage();
    FilterSpec defaultFilterSpec = (defaultView == null || defaultView.length() == 0 ?
        new FilterSpec() : new FilterSpec(defaultView));
    if (LivingStoryData.isLoggedIn()) {
      if (filtersEqual(currentFilters, defaultFilterSpec)) {
        setAsDefaultLabel.setVisible(false);
        defaultViewLabel.setVisible(true);
      } else {
View Full Code Here

      }
    }
  }

  public FilterSpec getFilter() {
    return currentFilters == null ? null : new FilterSpec(currentFilters);
  }
View Full Code Here

TOP

Related Classes of com.google.livingstories.client.FilterSpec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.