mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
move injection points where they belong
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user