Package com.commafeed.backend.model

Examples of com.commafeed.backend.model.FeedEntryStatus


      return;
    }

    final ReadingOrder order = StringUtils.equals(orderParam, "asc") ? ReadingOrder.asc : ReadingOrder.desc;

    FeedEntryStatus status = new UnitOfWork<FeedEntryStatus>(sessionFactory) {
      @Override
      protected FeedEntryStatus runInSession() throws Exception {
        FeedEntryStatus status = null;
        if (StringUtils.isBlank(categoryId) || CategoryREST.ALL.equals(categoryId)) {
          List<FeedSubscription> subs = feedSubscriptionDAO.findAll(user.get());
          List<FeedEntryStatus> statuses = feedEntryStatusDAO.findBySubscriptions(user.get(), subs, true, null, null, 0, 1,
              order, true, false, null);
          status = Iterables.getFirst(statuses, null);
        } else {
          FeedCategory category = feedCategoryDAO.findById(user.get(), Long.valueOf(categoryId));
          if (category != null) {
            List<FeedCategory> children = feedCategoryDAO.findAllChildrenCategories(user.get(), category);
            List<FeedSubscription> subscriptions = feedSubscriptionDAO.findByCategories(user.get(), children);
            List<FeedEntryStatus> statuses = feedEntryStatusDAO.findBySubscriptions(user.get(), subscriptions, true, null,
                null, 0, 1, order, true, false, null);
            status = Iterables.getFirst(statuses, null);
          }
        }
        if (status != null) {
          status.setRead(true);
          feedEntryStatusDAO.saveOrUpdate(status);
        }
        return status;
      }
    }.run();

    if (status == null) {
      resp.sendRedirect(resp.encodeRedirectURL(config.getApplicationSettings().getPublicUrl()));
    } else {
      String url = status.getEntry().getUrl();
      resp.sendRedirect(resp.encodeRedirectURL(url));
    }
  }
View Full Code Here


        matches = feedEntryFilteringService.filterMatchesEntry(sub.getFilter(), entry);
      } catch (FeedEntryFilterException e) {
        log.error("could not evaluate filter {}", sub.getFilter(), e);
      }
      if (!matches) {
        FeedEntryStatus status = new FeedEntryStatus(sub.getUser(), sub, entry);
        status.setRead(true);
        feedEntryStatusDAO.saveOrUpdate(status);
      }
    }

    return true;
View Full Code Here

  private static final Comparator<FeedEntryStatus> STATUS_COMPARATOR_ASC = Ordering.from(STATUS_COMPARATOR_DESC).reverse();

  public FeedEntryStatus getStatus(User user, FeedSubscription sub, FeedEntry entry) {
    List<FeedEntryStatus> statuses = newQuery().from(status).where(status.entry.eq(entry), status.subscription.eq(sub)).list(status);
    FeedEntryStatus status = Iterables.getFirst(statuses, null);
    return handleStatus(user, status, sub, entry);
  }
View Full Code Here

  private FeedEntryStatus handleStatus(User user, FeedEntryStatus status, FeedSubscription sub, FeedEntry entry) {
    if (status == null) {
      Date unreadThreshold = config.getApplicationSettings().getUnreadThreshold();
      boolean read = unreadThreshold == null ? false : entry.getUpdated().before(unreadThreshold);
      status = new FeedEntryStatus(user, sub, entry);
      status.setRead(read);
      status.setMarkable(!read);
    } else {
      status.setMarkable(true);
    }
View Full Code Here

        FeedEntry entry = new FeedEntry();
        entry.setId(id);
        entry.setUpdated(updated);

        FeedEntryStatus status = new FeedEntryStatus();
        status.setId(statusId);
        status.setEntryUpdated(updated);
        status.setEntry(entry);
        status.setSubscription(sub);

        set.add(status);
      }
    }

    List<FeedEntryStatus> placeholders = set.asList();
    int size = placeholders.size();
    if (size < offset) {
      return Lists.newArrayList();
    }
    placeholders = placeholders.subList(Math.max(offset, 0), size);

    List<FeedEntryStatus> statuses = null;
    if (onlyIds) {
      statuses = placeholders;
    } else {
      statuses = Lists.newArrayList();
      for (FeedEntryStatus placeholder : placeholders) {
        Long statusId = placeholder.getId();
        FeedEntry entry = feedEntryDAO.findById(placeholder.getEntry().getId());
        FeedEntryStatus status = handleStatus(user, statusId == null ? null : findById(statusId), placeholder.getSubscription(),
            entry);
        status = fetchTags(user, status);
        statuses.add(status);
      }
      statuses = lazyLoadContent(includeContent, statuses);
View Full Code Here

    FeedSubscription sub = feedSubscriptionDAO.findByFeed(user, entry.getFeed());
    if (sub == null) {
      return;
    }

    FeedEntryStatus status = feedEntryStatusDAO.getStatus(user, sub, entry);
    if (status.isMarkable()) {
      status.setRead(read);
      feedEntryStatusDAO.saveOrUpdate(status);
      cache.invalidateUnreadCount(sub);
      cache.invalidateUserRootCategory(user);
    }
  }
View Full Code Here

    FeedEntry entry = feedEntryDAO.findById(entryId);
    if (entry == null) {
      return;
    }

    FeedEntryStatus status = feedEntryStatusDAO.getStatus(user, sub, entry);
    status.setStarred(starred);
    feedEntryStatusDAO.saveOrUpdate(status);
  }
View Full Code Here

TOP

Related Classes of com.commafeed.backend.model.FeedEntryStatus

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.