Files
Athou_commafeed/src/main/java/com/commafeed/frontend/model/Subscription.java

137 lines
3.2 KiB
Java
Raw Normal View History

2013-03-23 16:17:19 +01:00
package com.commafeed.frontend.model;
2013-03-22 09:29:30 +01:00
import java.io.Serializable;
import java.util.Date;
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;
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")
public class Subscription implements Serializable {
public static Subscription build(FeedSubscription subscription,
long unreadCount) {
FeedCategory category = subscription.getCategory();
Subscription sub = new Subscription();
sub.setId(subscription.getId());
sub.setName(subscription.getTitle());
sub.setMessage(subscription.getFeed().getMessage());
sub.setErrorCount(subscription.getFeed().getErrorCount());
sub.setFeedUrl(subscription.getFeed().getUrl());
sub.setFeedLink(subscription.getFeed().getLink());
sub.setLastRefresh(subscription.getFeed().getLastUpdated());
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
@ApiProperty(value = "last time the feed was refreshed", required = true)
private Date lastRefresh;
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
@ApiProperty(value = "this subscription's website url", required = true)
private String feedLink;
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
@ApiProperty(value = "category id")
private String categoryId;
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;
}
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-03-22 09:29:30 +01:00
}