move feedcount in its own file

This commit is contained in:
Athou
2013-08-07 10:08:03 +02:00
parent ff7458dfc1
commit 701a1903ba
3 changed files with 46 additions and 14 deletions

View File

@@ -15,8 +15,6 @@ import javax.persistence.criteria.Root;
import javax.persistence.criteria.SetJoin; import javax.persistence.criteria.SetJoin;
import javax.persistence.criteria.Subquery; import javax.persistence.criteria.Subquery;
import javax.persistence.metamodel.SingularAttribute; import javax.persistence.metamodel.SingularAttribute;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
@@ -29,19 +27,13 @@ import com.commafeed.backend.model.FeedSubscription_;
import com.commafeed.backend.model.Feed_; import com.commafeed.backend.model.Feed_;
import com.commafeed.backend.model.User; import com.commafeed.backend.model.User;
import com.commafeed.backend.model.User_; import com.commafeed.backend.model.User_;
import com.commafeed.frontend.model.FeedCount;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@Stateless @Stateless
public class FeedDAO extends GenericDAO<Feed> { public class FeedDAO extends GenericDAO<Feed> {
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public static class FeedCount {
public String value;
public List<Feed> feeds;
}
private List<Predicate> getUpdatablePredicates(CriteriaQuery<?> query, Root<Feed> root, Date lastLoginThreshold) { private List<Predicate> getUpdatablePredicates(CriteriaQuery<?> query, Root<Feed> root, Date lastLoginThreshold) {
List<Predicate> preds = Lists.newArrayList(); List<Predicate> preds = Lists.newArrayList();
@@ -154,14 +146,12 @@ public class FeedDAO extends GenericDAO<Feed> {
List<FeedCount> result = Lists.newArrayList(); List<FeedCount> result = Lists.newArrayList();
for (String pathValue : pathValues) { for (String pathValue : pathValues) {
FeedCount fc = new FeedCount(); FeedCount fc = new FeedCount(pathValue);
fc.value = pathValue;
fc.feeds = Lists.newArrayList();
for (Feed feed : findByField(mode.getPath(), pathValue)) { for (Feed feed : findByField(mode.getPath(), pathValue)) {
Feed f = new Feed(); Feed f = new Feed();
f.setId(feed.getId()); f.setId(feed.getId());
f.setUrl(feed.getUrl()); f.setUrl(feed.getUrl());
fc.feeds.add(f); fc.getFeeds().add(f);
} }
result.add(fc); result.add(fc);
} }

View File

@@ -0,0 +1,42 @@
package com.commafeed.frontend.model;
import java.io.Serializable;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import com.commafeed.backend.model.Feed;
import com.google.common.collect.Lists;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class FeedCount implements Serializable {
private static final long serialVersionUID = 1L;
private String value;
private List<Feed> feeds = Lists.newArrayList();;
public FeedCount(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public List<Feed> getFeeds() {
return feeds;
}
public void setFeeds(List<Feed> feeds) {
this.feeds = feeds;
}
}

View File

@@ -22,7 +22,6 @@ import com.commafeed.backend.MetricsBean;
import com.commafeed.backend.StartupBean; import com.commafeed.backend.StartupBean;
import com.commafeed.backend.dao.FeedDAO; import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.dao.FeedDAO.DuplicateMode; import com.commafeed.backend.dao.FeedDAO.DuplicateMode;
import com.commafeed.backend.dao.FeedDAO.FeedCount;
import com.commafeed.backend.dao.UserDAO; import com.commafeed.backend.dao.UserDAO;
import com.commafeed.backend.dao.UserRoleDAO; import com.commafeed.backend.dao.UserRoleDAO;
import com.commafeed.backend.feeds.FeedRefreshTaskGiver; import com.commafeed.backend.feeds.FeedRefreshTaskGiver;
@@ -38,6 +37,7 @@ import com.commafeed.backend.services.FeedService;
import com.commafeed.backend.services.PasswordEncryptionService; import com.commafeed.backend.services.PasswordEncryptionService;
import com.commafeed.backend.services.UserService; import com.commafeed.backend.services.UserService;
import com.commafeed.frontend.SecurityCheck; import com.commafeed.frontend.SecurityCheck;
import com.commafeed.frontend.model.FeedCount;
import com.commafeed.frontend.model.UserModel; import com.commafeed.frontend.model.UserModel;
import com.commafeed.frontend.model.request.FeedMergeRequest; import com.commafeed.frontend.model.request.FeedMergeRequest;
import com.commafeed.frontend.model.request.IDRequest; import com.commafeed.frontend.model.request.IDRequest;