major classes refactoring

This commit is contained in:
Athou
2013-04-11 20:49:08 +02:00
parent 54ebf7b9db
commit 5b5ad242e0
31 changed files with 380 additions and 297 deletions

View File

@@ -22,9 +22,10 @@ import org.apache.commons.lang.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.commafeed.backend.dao.FeedEntryService;
import com.commafeed.backend.dao.FeedService;
import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.dao.FeedEntryDAO;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.services.FeedUpdateService;
import com.google.common.collect.Iterables;
@Stateless
@@ -40,10 +41,13 @@ public class FeedRefreshWorker {
FeedFetcher fetcher;
@Inject
FeedService feedService;
FeedDAO feedDAO;
@Inject
FeedEntryService feedEntryService;
FeedEntryDAO feedEntryDAO;
@Inject
FeedUpdateService feedUpdateService;
@Resource
private UserTransaction transaction;
@@ -102,13 +106,13 @@ public class FeedRefreshWorker {
transaction.begin();
if (fetchedFeed != null) {
feedEntryService.updateEntries(feed.getUrl(),
feedUpdateService.updateEntries(feed.getUrl(),
fetchedFeed.getEntries());
if (feed.getLink() == null) {
feed.setLink(fetchedFeed.getLink());
}
}
feedService.update(feed);
feedDAO.update(feed);
transaction.commit();
@@ -121,10 +125,10 @@ public class FeedRefreshWorker {
Feed feed = null;
lock.lock();
try {
feed = Iterables.getFirst(feedService.findNextUpdatable(1), null);
feed = Iterables.getFirst(feedDAO.findNextUpdatable(1), null);
if (feed != null) {
feed.setLastUpdated(Calendar.getInstance().getTime());
feedService.update(feed);
feedDAO.update(feed);
}
} finally {
lock.unlock();

View File

@@ -7,11 +7,11 @@ import javax.inject.Inject;
import org.apache.commons.lang.StringUtils;
import com.commafeed.backend.dao.FeedCategoryService;
import com.commafeed.backend.dao.FeedService;
import com.commafeed.backend.dao.FeedSubscriptionService;
import com.commafeed.backend.dao.FeedCategoryDAO;
import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.model.FeedCategory;
import com.commafeed.backend.model.User;
import com.commafeed.backend.services.FeedSubscriptionService;
import com.sun.syndication.feed.opml.Opml;
import com.sun.syndication.feed.opml.Outline;
import com.sun.syndication.io.FeedException;
@@ -20,13 +20,13 @@ import com.sun.syndication.io.WireFeedInput;
public class OPMLImporter {
@Inject
FeedService feedService;
FeedDAO feedDAO;
@Inject
FeedSubscriptionService feedSubscriptionService;
@Inject
FeedCategoryService feedCategoryService;
FeedCategoryDAO feedCategoryDAO;
@SuppressWarnings("unchecked")
public void importOpml(User user, String xml) throws FeedException {
@@ -43,14 +43,14 @@ public class OPMLImporter {
private void handleOutline(User user, Outline outline, FeedCategory parent) {
if (StringUtils.isEmpty(outline.getType())) {
FeedCategory category = feedCategoryService.findByName(user,
FeedCategory category = feedCategoryDAO.findByName(user,
outline.getText(), parent);
if (category == null) {
category = new FeedCategory();
category.setName(outline.getText());
category.setParent(parent);
category.setUser(user);
feedCategoryService.save(category);
feedCategoryDAO.save(category);
}
List<Outline> children = outline.getChildren();