mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
package refactoring
This commit is contained in:
@@ -12,11 +12,11 @@ import com.commafeed.backend.dao.FeedCategoryService;
|
||||
import com.commafeed.backend.dao.FeedService;
|
||||
import com.commafeed.backend.dao.FeedSubscriptionService;
|
||||
import com.commafeed.backend.dao.UserService;
|
||||
import com.commafeed.backend.model.Feed;
|
||||
import com.commafeed.backend.model.FeedCategory;
|
||||
import com.commafeed.backend.model.FeedSubscription;
|
||||
import com.commafeed.backend.model.User;
|
||||
import com.commafeed.backend.security.PasswordEncryptionService;
|
||||
import com.commafeed.model.Feed;
|
||||
import com.commafeed.model.FeedCategory;
|
||||
import com.commafeed.model.FeedSubscription;
|
||||
import com.commafeed.model.User;
|
||||
|
||||
@Startup
|
||||
@Singleton
|
||||
|
||||
@@ -4,9 +4,9 @@ import java.util.List;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
|
||||
import com.commafeed.backend.model.FeedCategory;
|
||||
import com.commafeed.backend.model.User;
|
||||
import com.commafeed.frontend.utils.ModelFactory.MF;
|
||||
import com.commafeed.model.FeedCategory;
|
||||
import com.commafeed.model.User;
|
||||
|
||||
@Stateless
|
||||
public class FeedCategoryService extends GenericDAO<FeedCategory, Long> {
|
||||
|
||||
@@ -8,10 +8,10 @@ import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import com.commafeed.backend.model.Feed;
|
||||
import com.commafeed.backend.model.FeedEntry;
|
||||
import com.commafeed.backend.model.User;
|
||||
import com.commafeed.frontend.utils.ModelFactory.MF;
|
||||
import com.commafeed.model.Feed;
|
||||
import com.commafeed.model.FeedEntry;
|
||||
import com.commafeed.model.User;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
@Stateless
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.commafeed.backend.dao;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
|
||||
import com.commafeed.model.FeedEntryStatus;
|
||||
import com.commafeed.backend.model.FeedEntryStatus;
|
||||
|
||||
@Stateless
|
||||
public class FeedEntryStatusService extends GenericDAO<FeedEntryStatus, Long> {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.commafeed.backend.dao;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
|
||||
import com.commafeed.model.Feed;
|
||||
import com.commafeed.backend.model.Feed;
|
||||
|
||||
@Stateless
|
||||
public class FeedService extends GenericDAO<Feed, Long> {
|
||||
|
||||
@@ -8,10 +8,10 @@ import javax.persistence.TypedQuery;
|
||||
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
|
||||
import com.commafeed.backend.model.FeedCategory;
|
||||
import com.commafeed.backend.model.FeedSubscription;
|
||||
import com.commafeed.backend.model.User;
|
||||
import com.commafeed.frontend.utils.ModelFactory.MF;
|
||||
import com.commafeed.model.FeedCategory;
|
||||
import com.commafeed.model.FeedSubscription;
|
||||
import com.commafeed.model.User;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.uaihebert.factory.EasyCriteriaFactory;
|
||||
import com.uaihebert.model.EasyCriteria;
|
||||
|
||||
@@ -5,9 +5,9 @@ import java.util.List;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.commafeed.backend.model.User;
|
||||
import com.commafeed.backend.security.PasswordEncryptionService;
|
||||
import com.commafeed.frontend.utils.ModelFactory.MF;
|
||||
import com.commafeed.model.User;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
@Stateless
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.commafeed.model.Feed;
|
||||
import com.commafeed.backend.model.Feed;
|
||||
|
||||
@Singleton
|
||||
public class FeedFetcher {
|
||||
|
||||
@@ -11,8 +11,8 @@ import org.apache.commons.lang.SystemUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
import com.commafeed.model.Feed;
|
||||
import com.commafeed.model.FeedEntry;
|
||||
import com.commafeed.backend.model.Feed;
|
||||
import com.commafeed.backend.model.FeedEntry;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.sun.syndication.feed.synd.SyndContent;
|
||||
|
||||
@@ -9,7 +9,7 @@ import javax.inject.Inject;
|
||||
|
||||
import com.commafeed.backend.dao.FeedEntryService;
|
||||
import com.commafeed.backend.dao.FeedService;
|
||||
import com.commafeed.model.Feed;
|
||||
import com.commafeed.backend.model.Feed;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@Singleton
|
||||
|
||||
26
src/main/java/com/commafeed/backend/model/AbstractModel.java
Normal file
26
src/main/java/com/commafeed/backend/model/AbstractModel.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@MappedSuperclass
|
||||
public abstract class AbstractModel implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
62
src/main/java/com/commafeed/backend/model/Feed.java
Normal file
62
src/main/java/com/commafeed/backend/model/Feed.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDS")
|
||||
@SuppressWarnings("serial")
|
||||
public class Feed extends AbstractModel {
|
||||
|
||||
@Column(length = 2048)
|
||||
private String url;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdated;
|
||||
|
||||
@OneToMany(mappedBy = "feed", fetch = FetchType.EAGER)
|
||||
private Set<FeedEntry> entries = Sets.newHashSet();
|
||||
|
||||
public Feed() {
|
||||
|
||||
}
|
||||
|
||||
public Feed(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Date getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
public void setLastUpdated(Date lastUpdated) {
|
||||
this.lastUpdated = lastUpdated;
|
||||
}
|
||||
|
||||
public Set<FeedEntry> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
public void setEntries(Set<FeedEntry> entries) {
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
}
|
||||
63
src/main/java/com/commafeed/backend/model/FeedCategory.java
Normal file
63
src/main/java/com/commafeed/backend/model/FeedCategory.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDCATEGORIES")
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedCategory extends AbstractModel {
|
||||
|
||||
@Column(length = 128)
|
||||
private String name;
|
||||
|
||||
@ManyToOne
|
||||
private User user;
|
||||
|
||||
@ManyToOne
|
||||
private FeedCategory parent;
|
||||
|
||||
@OneToMany(mappedBy = "category", fetch = FetchType.EAGER)
|
||||
private Set<FeedSubscription> subscriptions = Sets.newHashSet();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public FeedCategory getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(FeedCategory parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Set<FeedSubscription> getSubscriptions() {
|
||||
return subscriptions;
|
||||
}
|
||||
|
||||
public void setSubscriptions(Set<FeedSubscription> subscriptions) {
|
||||
this.subscriptions = subscriptions;
|
||||
}
|
||||
|
||||
}
|
||||
84
src/main/java/com/commafeed/backend/model/FeedEntry.java
Normal file
84
src/main/java/com/commafeed/backend/model/FeedEntry.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDENTRIES")
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedEntry extends AbstractModel {
|
||||
|
||||
@Column(length = 2048)
|
||||
private String guid;
|
||||
|
||||
@ManyToOne
|
||||
private Feed feed;
|
||||
|
||||
@Column(length = 256)
|
||||
private String title;
|
||||
|
||||
@Lob
|
||||
private String content;
|
||||
|
||||
@Column(length = 2048)
|
||||
private String url;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updated;
|
||||
|
||||
public String getGuid() {
|
||||
return guid;
|
||||
}
|
||||
|
||||
public void setGuid(String guid) {
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Date getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void setUpdated(Date updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
|
||||
public Feed getFeed() {
|
||||
return feed;
|
||||
}
|
||||
|
||||
public void setFeed(Feed feed) {
|
||||
this.feed = feed;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDENTRYSTATUSES")
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedEntryStatus extends AbstractModel {
|
||||
|
||||
@ManyToOne
|
||||
private User user;
|
||||
|
||||
@ManyToOne
|
||||
private FeedEntry entry;
|
||||
|
||||
@Column(name = "read_status")
|
||||
private boolean read;
|
||||
private boolean starred;
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public FeedEntry getEntry() {
|
||||
return entry;
|
||||
}
|
||||
|
||||
public void setEntry(FeedEntry entry) {
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
public void setRead(boolean read) {
|
||||
this.read = read;
|
||||
}
|
||||
|
||||
public boolean isStarred() {
|
||||
return starred;
|
||||
}
|
||||
|
||||
public void setStarred(boolean starred) {
|
||||
this.starred = starred;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDSUBSCRIPTIONS")
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedSubscription extends AbstractModel {
|
||||
|
||||
@ManyToOne
|
||||
private User user;
|
||||
|
||||
@ManyToOne
|
||||
private Feed feed;
|
||||
|
||||
@Column(length = 128)
|
||||
private String title;
|
||||
|
||||
@ManyToOne
|
||||
private FeedCategory category;
|
||||
|
||||
public Feed getFeed() {
|
||||
return feed;
|
||||
}
|
||||
|
||||
public void setFeed(Feed feed) {
|
||||
this.feed = feed;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public FeedCategory getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(FeedCategory category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
}
|
||||
45
src/main/java/com/commafeed/backend/model/User.java
Normal file
45
src/main/java/com/commafeed/backend/model/User.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "USERS")
|
||||
@SuppressWarnings("serial")
|
||||
public class User extends AbstractModel {
|
||||
|
||||
@Column(length = 32)
|
||||
private String name;
|
||||
|
||||
@Column(length = 256)
|
||||
private byte[] password;
|
||||
|
||||
@Column(length = 8)
|
||||
private byte[] salt;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public byte[] getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(byte[] password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public byte[] getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
public void setSalt(byte[] salt) {
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
}
|
||||
40
src/main/java/com/commafeed/backend/model/UserSettings.java
Normal file
40
src/main/java/com/commafeed/backend/model/UserSettings.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "USERSETTINGS")
|
||||
@SuppressWarnings("serial")
|
||||
public class UserSettings extends AbstractModel {
|
||||
|
||||
public enum ReadingMode {
|
||||
ALL, UNREAD
|
||||
}
|
||||
|
||||
@Column(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private ReadingMode readingMode;
|
||||
|
||||
public ReadingMode getReadingMode() {
|
||||
return readingMode;
|
||||
}
|
||||
|
||||
public void setReadingMode(ReadingMode readingMode) {
|
||||
this.readingMode = readingMode;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user