From 701a1903ba3362909a064c4b9fb3d0b9aec01e5a Mon Sep 17 00:00:00 2001 From: Athou Date: Wed, 7 Aug 2013 10:08:03 +0200 Subject: [PATCH] move feedcount in its own file --- .../com/commafeed/backend/dao/FeedDAO.java | 16 ++----- .../commafeed/frontend/model/FeedCount.java | 42 +++++++++++++++++++ .../frontend/rest/resources/AdminREST.java | 2 +- 3 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/commafeed/frontend/model/FeedCount.java diff --git a/src/main/java/com/commafeed/backend/dao/FeedDAO.java b/src/main/java/com/commafeed/backend/dao/FeedDAO.java index 957d8b1f..4514f8e2 100644 --- a/src/main/java/com/commafeed/backend/dao/FeedDAO.java +++ b/src/main/java/com/commafeed/backend/dao/FeedDAO.java @@ -15,8 +15,6 @@ import javax.persistence.criteria.Root; import javax.persistence.criteria.SetJoin; import javax.persistence.criteria.Subquery; import javax.persistence.metamodel.SingularAttribute; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; 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.User; import com.commafeed.backend.model.User_; +import com.commafeed.frontend.model.FeedCount; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @Stateless public class FeedDAO extends GenericDAO { - @XmlRootElement - @XmlAccessorType(XmlAccessType.FIELD) - public static class FeedCount { - public String value; - public List feeds; - } - private List getUpdatablePredicates(CriteriaQuery query, Root root, Date lastLoginThreshold) { List preds = Lists.newArrayList(); @@ -154,14 +146,12 @@ public class FeedDAO extends GenericDAO { List result = Lists.newArrayList(); for (String pathValue : pathValues) { - FeedCount fc = new FeedCount(); - fc.value = pathValue; - fc.feeds = Lists.newArrayList(); + FeedCount fc = new FeedCount(pathValue); for (Feed feed : findByField(mode.getPath(), pathValue)) { Feed f = new Feed(); f.setId(feed.getId()); f.setUrl(feed.getUrl()); - fc.feeds.add(f); + fc.getFeeds().add(f); } result.add(fc); } diff --git a/src/main/java/com/commafeed/frontend/model/FeedCount.java b/src/main/java/com/commafeed/frontend/model/FeedCount.java new file mode 100644 index 00000000..74bcda64 --- /dev/null +++ b/src/main/java/com/commafeed/frontend/model/FeedCount.java @@ -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 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 getFeeds() { + return feeds; + } + + public void setFeeds(List feeds) { + this.feeds = feeds; + } + +} diff --git a/src/main/java/com/commafeed/frontend/rest/resources/AdminREST.java b/src/main/java/com/commafeed/frontend/rest/resources/AdminREST.java index d1476e17..b738c712 100644 --- a/src/main/java/com/commafeed/frontend/rest/resources/AdminREST.java +++ b/src/main/java/com/commafeed/frontend/rest/resources/AdminREST.java @@ -22,7 +22,6 @@ import com.commafeed.backend.MetricsBean; import com.commafeed.backend.StartupBean; import com.commafeed.backend.dao.FeedDAO; 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.UserRoleDAO; 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.UserService; import com.commafeed.frontend.SecurityCheck; +import com.commafeed.frontend.model.FeedCount; import com.commafeed.frontend.model.UserModel; import com.commafeed.frontend.model.request.FeedMergeRequest; import com.commafeed.frontend.model.request.IDRequest;