forked from Archives/Athou_commafeed
add long keys to all entities
This commit is contained in:
@@ -8,20 +8,26 @@ import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
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
|
||||
public class FeedEntryService extends GenericDAO<FeedEntry, String> {
|
||||
public class FeedEntryService extends GenericDAO<FeedEntry, Long> {
|
||||
|
||||
@Inject
|
||||
FeedService feedService;
|
||||
|
||||
public void updateEntries(String url, Collection<FeedEntry> entries) {
|
||||
Feed feed = feedService.findById(url);
|
||||
Feed feed = Iterables.getFirst(
|
||||
feedService.findByField(MF.i(MF.p(Feed.class).getUrl()), url),
|
||||
null);
|
||||
for (FeedEntry entry : entries) {
|
||||
FeedEntry existing = findById(entry.getGuid());
|
||||
FeedEntry existing = Iterables.getFirst(
|
||||
findByField(MF.i(MF.p(getType()).getGuid()),
|
||||
entry.getGuid()), null);
|
||||
if (existing == null) {
|
||||
entry.setFeed(feed);
|
||||
save(entry);
|
||||
|
||||
@@ -5,6 +5,6 @@ import javax.ejb.Stateless;
|
||||
import com.commafeed.model.Feed;
|
||||
|
||||
@Stateless
|
||||
public class FeedService extends GenericDAO<Feed, String> {
|
||||
public class FeedService extends GenericDAO<Feed, Long> {
|
||||
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class FeedEntriesREST extends JSONPage {
|
||||
|
||||
private Entry buildEntry(FeedEntry feedEntry) {
|
||||
Entry entry = new Entry();
|
||||
entry.setId(feedEntry.getGuid());
|
||||
entry.setId(String.valueOf(feedEntry.getId()));
|
||||
entry.setTitle(feedEntry.getTitle());
|
||||
entry.setContent(feedEntry.getContent());
|
||||
entry.setDate(feedEntry.getUpdated());
|
||||
|
||||
26
src/main/java/com/commafeed/model/AbstractModel.java
Normal file
26
src/main/java/com/commafeed/model/AbstractModel.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.commafeed.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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.commafeed.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
@@ -18,9 +16,8 @@ import com.google.common.collect.Sets;
|
||||
@Entity
|
||||
@Table(name = "FEEDS")
|
||||
@SuppressWarnings("serial")
|
||||
public class Feed implements Serializable {
|
||||
public class Feed extends AbstractModel {
|
||||
|
||||
@Id
|
||||
@Column(length = 2048)
|
||||
private String url;
|
||||
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
package com.commafeed.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
@@ -18,11 +14,7 @@ import com.google.common.collect.Sets;
|
||||
@Entity
|
||||
@Table(name = "FEEDCATEGORIES")
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedCategory implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
public class FeedCategory extends AbstractModel {
|
||||
|
||||
@Column(length = 128)
|
||||
private String name;
|
||||
@@ -60,14 +52,6 @@ public class FeedCategory implements Serializable {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Set<FeedSubscription> getSubscriptions() {
|
||||
return subscriptions;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.commafeed.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
@@ -15,9 +13,8 @@ import javax.persistence.TemporalType;
|
||||
@Entity
|
||||
@Table(name = "FEEDENTRIES")
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedEntry implements Serializable {
|
||||
public class FeedEntry extends AbstractModel {
|
||||
|
||||
@Id
|
||||
@Column(length = 2048)
|
||||
private String guid;
|
||||
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
package com.commafeed.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDENTRYSTATUSES")
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedEntryStatus implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
public class FeedEntryStatus extends AbstractModel {
|
||||
|
||||
@ManyToOne
|
||||
private User user;
|
||||
@@ -61,12 +52,4 @@ public class FeedEntryStatus implements Serializable {
|
||||
this.starred = starred;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
package com.commafeed.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDSUBSCRIPTIONS")
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedSubscription implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
public class FeedSubscription extends AbstractModel {
|
||||
|
||||
@ManyToOne
|
||||
private User user;
|
||||
@@ -63,12 +54,4 @@ public class FeedSubscription implements Serializable {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
package com.commafeed.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "USERS")
|
||||
@SuppressWarnings("serial")
|
||||
public class User implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
public class User extends AbstractModel {
|
||||
|
||||
@Column(length = 32)
|
||||
private String name;
|
||||
@@ -43,14 +34,6 @@ public class User implements Serializable {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public byte[] getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
@@ -1,29 +1,20 @@
|
||||
package com.commafeed.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "USERSETTINGS")
|
||||
@SuppressWarnings("serial")
|
||||
public class UserSettings implements Serializable {
|
||||
public class UserSettings extends AbstractModel {
|
||||
|
||||
public enum ReadingMode {
|
||||
ALL, UNREAD
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@@ -38,14 +29,6 @@ public class UserSettings implements Serializable {
|
||||
this.readingMode = readingMode;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user