move injection points where they belong

This commit is contained in:
Athou
2013-07-02 16:10:59 +02:00
parent d2a053a53c
commit beaf39c8e6
10 changed files with 176 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
package com.commafeed.backend;
import java.util.Calendar;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
@@ -10,6 +11,9 @@ import org.slf4j.LoggerFactory;
import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.dao.FeedEntryDAO;
import com.commafeed.backend.dao.FeedSubscriptionDAO;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedSubscription;
public class DatabaseCleaner {
@@ -21,6 +25,9 @@ public class DatabaseCleaner {
@Inject
FeedEntryDAO feedEntryDAO;
@Inject
FeedSubscriptionDAO feedSubscriptionDAO;
public long cleanFeedsWithoutSubscriptions() {
long total = 0;
@@ -48,4 +55,19 @@ public class DatabaseCleaner {
log.info("cleanup done: {} entries deleted", total);
return total;
}
public void mergeFeeds(Feed into, List<Feed> feeds) {
for (Feed feed : feeds) {
if (into.getId().equals(feed.getId())) {
continue;
}
List<FeedSubscription> subs = feedSubscriptionDAO.findByFeed(feed);
for (FeedSubscription sub : subs) {
sub.setFeed(into);
}
feedSubscriptionDAO.saveOrUpdate(subs);
feedDAO.delete(feed);
}
feedDAO.saveOrUpdate(into);
}
}