Package com.commafeed.backend.model

Examples of com.commafeed.backend.model.FeedCategory


        entries.getEntries().add(
            Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
                .isImageProxyEnabled()));
      }
    } else {
      FeedCategory parent = feedCategoryDAO.findById(user, Long.valueOf(id));
      if (parent != null) {
        List<FeedCategory> categories = feedCategoryDAO.findAllChildrenCategories(user, parent);
        List<FeedSubscription> subs = feedSubscriptionDAO.findByCategories(user, categories);
        removeExcludedSubscriptions(subs, excludedIds);
        List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, subs, unreadOnly, entryKeywords, newerThanDate,
            offset, limit + 1, order, true, onlyIds, tag);

        for (FeedEntryStatus status : list) {
          entries.getEntries().add(
              Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
                  .isImageProxyEnabled()));
        }
        entries.setName(parent.getName());
      } else {
        return Response.status(Status.NOT_FOUND).entity("<message>category not found</message>").build();
      }
    }
View Full Code Here


      removeExcludedSubscriptions(subs, req.getExcludedSubscriptions());
      feedEntryService.markSubscriptionEntries(user, subs, olderThan, entryKeywords);
    } else if (STARRED.equals(req.getId())) {
      feedEntryService.markStarredEntries(user, olderThan);
    } else {
      FeedCategory parent = feedCategoryDAO.findById(user, Long.valueOf(req.getId()));
      List<FeedCategory> categories = feedCategoryDAO.findAllChildrenCategories(user, parent);
      List<FeedSubscription> subs = feedSubscriptionDAO.findByCategories(user, categories);
      removeExcludedSubscriptions(subs, req.getExcludedSubscriptions());
      feedEntryService.markSubscriptionEntries(user, subs, olderThan, entryKeywords);
    }
View Full Code Here

  @ApiOperation(value = "Add a category", notes = "Add a new feed category", response = Long.class)
  public Response addCategory(@SecurityCheck User user, @ApiParam(required = true) AddCategoryRequest req) {
    Preconditions.checkNotNull(req);
    Preconditions.checkNotNull(req.getName());

    FeedCategory cat = new FeedCategory();
    cat.setName(req.getName());
    cat.setUser(user);
    cat.setPosition(0);
    String parentId = req.getParentId();
    if (parentId != null && !ALL.equals(parentId)) {
      FeedCategory parent = new FeedCategory();
      parent.setId(Long.valueOf(parentId));
      cat.setParent(parent);
    }
    feedCategoryDAO.saveOrUpdate(cat);
    cache.invalidateUserRootCategory(user);
    return Response.ok(cat.getId()).build();
View Full Code Here

  public Response deleteCategory(@SecurityCheck User user, @ApiParam(required = true) IDRequest req) {

    Preconditions.checkNotNull(req);
    Preconditions.checkNotNull(req.getId());

    FeedCategory cat = feedCategoryDAO.findById(user, req.getId());
    if (cat != null) {
      List<FeedSubscription> subs = feedSubscriptionDAO.findByCategory(user, cat);
      for (FeedSubscription sub : subs) {
        sub.setCategory(null);
      }
      feedSubscriptionDAO.saveOrUpdate(subs);
      List<FeedCategory> categories = feedCategoryDAO.findAllChildrenCategories(user, cat);
      for (FeedCategory child : categories) {
        if (!child.getId().equals(cat.getId()) && child.getParent().getId().equals(cat.getId())) {
          child.setParent(null);
        }
      }
      feedCategoryDAO.saveOrUpdate(categories);
View Full Code Here

  @ApiOperation(value = "Rename a category", notes = "Rename an existing feed category")
  public Response modifyCategory(@SecurityCheck User user, @ApiParam(required = true) CategoryModificationRequest req) {
    Preconditions.checkNotNull(req);
    Preconditions.checkNotNull(req.getId());

    FeedCategory category = feedCategoryDAO.findById(user, req.getId());

    if (StringUtils.isNotBlank(req.getName())) {
      category.setName(req.getName());
    }

    FeedCategory parent = null;
    if (req.getParentId() != null && !CategoryREST.ALL.equals(req.getParentId())
        && !StringUtils.equals(req.getParentId(), String.valueOf(req.getId()))) {
      parent = feedCategoryDAO.findById(user, Long.valueOf(req.getParentId()));
    }
    category.setParent(parent);
View Full Code Here

  @ApiOperation(value = "Collapse a category", notes = "Save collapsed or expanded status for a category")
  public Response collapse(@SecurityCheck User user, @ApiParam(required = true) CollapseRequest req) {
    Preconditions.checkNotNull(req);
    Preconditions.checkNotNull(req.getId());

    FeedCategory category = feedCategoryDAO.findById(user, req.getId());
    if (category == null) {
      return Response.status(Status.NOT_FOUND).build();
    }
    category.setCollapsed(req.isCollapse());
    feedCategoryDAO.saveOrUpdate(category);
    cache.invalidateUserRootCategory(user);
    return Response.ok().build();
  }
View Full Code Here

    String url = prependHttp(req.getUrl());
    try {
      url = fetchFeedInternal(url).getUrl();

      FeedCategory category = null;
      if (req.getCategoryId() != null && !CategoryREST.ALL.equals(req.getCategoryId())) {
        category = feedCategoryDAO.findById(Long.valueOf(req.getCategoryId()));
      }
      FeedInfo info = fetchFeedInternal(url);
      feedSubscriptionService.subscribe(user, info.getUrl(), req.getTitle(), category);
View Full Code Here

    if (StringUtils.isNotBlank(req.getName())) {
      subscription.setTitle(req.getName());
    }

    FeedCategory parent = null;
    if (req.getCategoryId() != null && !CategoryREST.ALL.equals(req.getCategoryId())) {
      parent = feedCategoryDAO.findById(user, Long.valueOf(req.getCategoryId()));
    }
    subscription.setCategory(parent);
View Full Code Here

@Data
public class Subscription implements Serializable {

  public static Subscription build(FeedSubscription subscription, String publicUrl, UnreadCount unreadCount) {
    Date now = new Date();
    FeedCategory category = subscription.getCategory();
    Feed feed = subscription.getFeed();
    Subscription sub = new Subscription();
    sub.setId(subscription.getId());
    sub.setName(subscription.getTitle());
    sub.setPosition(subscription.getPosition());
    sub.setMessage(feed.getMessage());
    sub.setErrorCount(feed.getErrorCount());
    sub.setFeedUrl(feed.getUrl());
    sub.setFeedLink(feed.getLink());
    sub.setIconUrl(FeedUtils.getFaviconUrl(subscription, publicUrl));
    sub.setLastRefresh(feed.getLastUpdated());
    sub.setNextRefresh((feed.getDisabledUntil() != null && feed.getDisabledUntil().before(now)) ? null : feed.getDisabledUntil());
    sub.setUnread(unreadCount.getUnreadCount());
    sub.setNewestItemTime(unreadCount.getNewestItemTime());
    sub.setCategoryId(category == null ? null : String.valueOf(category.getId()));
    sub.setFilter(subscription.getFilter());
    return sub;
  }
View Full Code Here

          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);
View Full Code Here

TOP

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

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.