2013-03-23 16:17:19 +01:00
|
|
|
package com.commafeed.frontend.model;
|
2013-03-22 09:29:30 +01:00
|
|
|
|
2013-03-23 15:52:26 +01:00
|
|
|
import java.io.Serializable;
|
2013-05-23 07:12:17 +02:00
|
|
|
import java.util.Calendar;
|
2013-04-30 16:17:34 +02:00
|
|
|
import java.util.Date;
|
2013-03-23 15:52:26 +01:00
|
|
|
|
2013-04-15 14:47:37 +02:00
|
|
|
import javax.xml.bind.annotation.XmlAccessType;
|
|
|
|
|
import javax.xml.bind.annotation.XmlAccessorType;
|
|
|
|
|
import javax.xml.bind.annotation.XmlRootElement;
|
|
|
|
|
|
2013-05-26 15:36:55 +02:00
|
|
|
import com.commafeed.backend.feeds.FeedUtils;
|
2013-05-22 16:10:50 +02:00
|
|
|
import com.commafeed.backend.model.Feed;
|
2013-04-30 16:17:34 +02:00
|
|
|
import com.commafeed.backend.model.FeedCategory;
|
|
|
|
|
import com.commafeed.backend.model.FeedSubscription;
|
2013-04-17 13:26:14 +02:00
|
|
|
import com.wordnik.swagger.annotations.ApiClass;
|
|
|
|
|
import com.wordnik.swagger.annotations.ApiProperty;
|
|
|
|
|
|
2013-03-25 12:24:00 +01:00
|
|
|
@SuppressWarnings("serial")
|
2013-04-15 14:47:37 +02:00
|
|
|
@XmlRootElement
|
|
|
|
|
@XmlAccessorType(XmlAccessType.FIELD)
|
2013-04-17 13:26:14 +02:00
|
|
|
@ApiClass("User information")
|
2013-03-23 15:52:26 +01:00
|
|
|
public class Subscription implements Serializable {
|
|
|
|
|
|
2013-04-30 16:17:34 +02:00
|
|
|
public static Subscription build(FeedSubscription subscription,
|
2013-05-26 15:36:55 +02:00
|
|
|
String publicUrl, long unreadCount) {
|
2013-05-23 07:12:17 +02:00
|
|
|
Date now = Calendar.getInstance().getTime();
|
2013-04-30 16:17:34 +02:00
|
|
|
FeedCategory category = subscription.getCategory();
|
2013-05-22 16:10:50 +02:00
|
|
|
Feed feed = subscription.getFeed();
|
2013-04-30 16:17:34 +02:00
|
|
|
Subscription sub = new Subscription();
|
|
|
|
|
sub.setId(subscription.getId());
|
|
|
|
|
sub.setName(subscription.getTitle());
|
2013-06-01 21:00:10 +02:00
|
|
|
sub.setPosition(subscription.getPosition());
|
2013-05-22 16:10:50 +02:00
|
|
|
sub.setMessage(feed.getMessage());
|
|
|
|
|
sub.setErrorCount(feed.getErrorCount());
|
|
|
|
|
sub.setFeedUrl(feed.getUrl());
|
|
|
|
|
sub.setFeedLink(feed.getLink());
|
2013-06-11 13:01:12 +02:00
|
|
|
sub.setIconUrl(FeedUtils.getFaviconUrl(subscription, publicUrl));
|
2013-05-22 16:10:50 +02:00
|
|
|
sub.setLastRefresh(feed.getLastUpdated());
|
2013-05-23 07:12:17 +02:00
|
|
|
sub.setNextRefresh((feed.getDisabledUntil() != null && feed
|
2013-05-24 11:48:20 +02:00
|
|
|
.getDisabledUntil().before(now)) ? null : feed
|
2013-05-23 07:12:17 +02:00
|
|
|
.getDisabledUntil());
|
2013-04-30 16:17:34 +02:00
|
|
|
sub.setUnread(unreadCount);
|
|
|
|
|
sub.setCategoryId(category == null ? null : String.valueOf(category
|
|
|
|
|
.getId()));
|
|
|
|
|
return sub;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-17 13:26:14 +02:00
|
|
|
@ApiProperty(value = "subscription id", required = true)
|
2013-03-22 09:29:30 +01:00
|
|
|
private Long id;
|
2013-04-17 13:26:14 +02:00
|
|
|
|
|
|
|
|
@ApiProperty(value = "subscription name", required = true)
|
2013-03-22 09:29:30 +01:00
|
|
|
private String name;
|
2013-04-17 13:26:14 +02:00
|
|
|
|
|
|
|
|
@ApiProperty(value = "error message while fetching the feed", required = true)
|
2013-03-25 12:24:00 +01:00
|
|
|
private String message;
|
2013-04-17 13:26:14 +02:00
|
|
|
|
|
|
|
|
@ApiProperty(value = "error count", required = true)
|
2013-04-09 10:39:02 +02:00
|
|
|
private int errorCount;
|
2013-04-17 13:26:14 +02:00
|
|
|
|
2013-04-30 16:17:34 +02:00
|
|
|
@ApiProperty(value = "last time the feed was refreshed", required = true)
|
|
|
|
|
private Date lastRefresh;
|
|
|
|
|
|
2013-05-24 11:48:20 +02:00
|
|
|
@ApiProperty(value = "next time the feed refresh is planned, null if refresh is already queued", required = true)
|
2013-05-22 16:10:50 +02:00
|
|
|
private Date nextRefresh;
|
|
|
|
|
|
2013-04-17 13:26:14 +02:00
|
|
|
@ApiProperty(value = "this subscription's feed url", required = true)
|
2013-04-03 15:53:57 +02:00
|
|
|
private String feedUrl;
|
2013-04-17 13:26:14 +02:00
|
|
|
|
2013-04-30 16:17:34 +02:00
|
|
|
@ApiProperty(value = "this subscription's website url", required = true)
|
|
|
|
|
private String feedLink;
|
|
|
|
|
|
2013-05-26 15:36:55 +02:00
|
|
|
@ApiProperty(value = "The favicon url to use for this feed")
|
|
|
|
|
private String iconUrl;
|
|
|
|
|
|
2013-04-17 13:26:14 +02:00
|
|
|
@ApiProperty(value = "unread count", required = true)
|
2013-04-06 17:21:48 +02:00
|
|
|
private long unread;
|
2013-03-22 09:29:30 +01:00
|
|
|
|
2013-04-30 16:17:34 +02:00
|
|
|
@ApiProperty(value = "category id")
|
|
|
|
|
private String categoryId;
|
|
|
|
|
|
2013-06-01 21:00:10 +02:00
|
|
|
@ApiProperty("position of the subscription's in the list")
|
|
|
|
|
private Integer position;
|
|
|
|
|
|
2013-03-22 09:29:30 +01:00
|
|
|
public Long getId() {
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setId(Long id) {
|
|
|
|
|
this.id = id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
|
this.name = name;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-06 17:21:48 +02:00
|
|
|
public long getUnread() {
|
2013-03-22 09:29:30 +01:00
|
|
|
return unread;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-06 17:21:48 +02:00
|
|
|
public void setUnread(long unread) {
|
2013-03-22 09:29:30 +01:00
|
|
|
this.unread = unread;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-25 12:24:00 +01:00
|
|
|
public String getMessage() {
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMessage(String message) {
|
|
|
|
|
this.message = message;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-03 15:53:57 +02:00
|
|
|
public String getFeedUrl() {
|
|
|
|
|
return feedUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFeedUrl(String feedUrl) {
|
|
|
|
|
this.feedUrl = feedUrl;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-09 10:39:02 +02:00
|
|
|
public int getErrorCount() {
|
|
|
|
|
return errorCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setErrorCount(int errorCount) {
|
|
|
|
|
this.errorCount = errorCount;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-30 16:17:34 +02:00
|
|
|
public String getFeedLink() {
|
|
|
|
|
return feedLink;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFeedLink(String feedLink) {
|
|
|
|
|
this.feedLink = feedLink;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Date getLastRefresh() {
|
|
|
|
|
return lastRefresh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setLastRefresh(Date lastRefresh) {
|
|
|
|
|
this.lastRefresh = lastRefresh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getCategoryId() {
|
|
|
|
|
return categoryId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setCategoryId(String categoryId) {
|
|
|
|
|
this.categoryId = categoryId;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-22 16:10:50 +02:00
|
|
|
public Date getNextRefresh() {
|
|
|
|
|
return nextRefresh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setNextRefresh(Date nextRefresh) {
|
|
|
|
|
this.nextRefresh = nextRefresh;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-26 15:36:55 +02:00
|
|
|
public String getIconUrl() {
|
|
|
|
|
return iconUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setIconUrl(String iconUrl) {
|
|
|
|
|
this.iconUrl = iconUrl;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-01 21:00:10 +02:00
|
|
|
public Integer getPosition() {
|
|
|
|
|
return position;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPosition(Integer position) {
|
|
|
|
|
this.position = position;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 09:29:30 +01:00
|
|
|
}
|