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

207 lines
4.4 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.Arrays;
2013-03-22 22:11:40 +01:00
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;
2013-04-18 12:50:44 +02:00
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedEntryStatus;
import com.sun.syndication.feed.synd.SyndContentImpl;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndEntryImpl;
2013-04-16 12:36:18 +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-16 12:36:18 +02:00
@ApiClass("Entry details")
public class Entry implements Serializable {
2013-04-18 12:50:44 +02:00
public static Entry build(FeedEntryStatus status) {
Entry entry = new Entry();
FeedEntry feedEntry = status.getEntry();
entry.setId(String.valueOf(status.getId()));
entry.setGuid(feedEntry.getGuid());
2013-04-18 12:50:44 +02:00
entry.setTitle(feedEntry.getContent().getTitle());
entry.setContent(feedEntry.getContent().getContent());
entry.setEnclosureUrl(status.getEntry().getContent().getEnclosureUrl());
entry.setEnclosureType(status.getEntry().getContent()
.getEnclosureType());
entry.setDate(feedEntry.getUpdated());
entry.setUrl(feedEntry.getUrl());
entry.setRead(status.isRead());
2013-04-30 11:29:02 +02:00
entry.setStarred(status.isStarred());
2013-04-18 12:50:44 +02:00
entry.setFeedName(status.getSubscription().getTitle());
entry.setFeedId(String.valueOf(status.getSubscription().getId()));
entry.setFeedUrl(status.getSubscription().getFeed().getLink());
return entry;
}
public SyndEntry asRss() {
SyndEntry entry = new SyndEntryImpl();
entry.setUri(getGuid());
entry.setTitle(getTitle());
SyndContentImpl content = new SyndContentImpl();
content.setValue(getContent());
entry.setContents(Arrays.asList(content));
entry.setLink(getUrl());
entry.setPublishedDate(getDate());
return entry;
}
2013-04-16 12:36:18 +02:00
@ApiProperty("entry id")
2013-03-22 09:29:30 +01:00
private String id;
2013-04-18 12:50:44 +02:00
@ApiProperty("entry guid")
private String guid;
2013-04-16 12:36:18 +02:00
@ApiProperty("entry title")
2013-03-22 09:29:30 +01:00
private String title;
2013-04-18 12:50:44 +02:00
2013-04-16 12:36:18 +02:00
@ApiProperty("entry content")
2013-03-22 09:29:30 +01:00
private String content;
2013-04-18 12:50:44 +02:00
2013-04-16 12:36:18 +02:00
@ApiProperty("entry enclosure url, if any")
2013-04-09 13:37:00 +02:00
private String enclosureUrl;
2013-04-18 12:50:44 +02:00
2013-04-16 12:36:18 +02:00
@ApiProperty("entry enclosure mime type, if any")
2013-04-09 13:37:00 +02:00
private String enclosureType;
2013-04-18 12:50:44 +02:00
2013-04-16 12:36:18 +02:00
@ApiProperty("entry publication date")
2013-03-22 22:11:40 +01:00
private Date date;
2013-04-18 12:50:44 +02:00
2013-04-16 12:36:18 +02:00
@ApiProperty("feed id")
2013-03-22 09:29:30 +01:00
private String feedId;
2013-04-18 12:50:44 +02:00
2013-04-16 12:36:18 +02:00
@ApiProperty("feed name")
2013-03-22 09:29:30 +01:00
private String feedName;
2013-04-18 12:50:44 +02:00
2013-04-16 12:36:18 +02:00
@ApiProperty("feed url")
2013-04-09 12:03:03 +02:00
private String feedUrl;
2013-04-18 12:50:44 +02:00
2013-04-16 12:36:18 +02:00
@ApiProperty("entry url")
2013-03-22 09:29:30 +01:00
private String url;
2013-04-18 12:50:44 +02:00
2013-04-16 12:36:18 +02:00
@ApiProperty("read sttaus")
2013-03-22 09:29:30 +01:00
private boolean read;
2013-04-18 12:50:44 +02:00
2013-04-16 12:36:18 +02:00
@ApiProperty("starred status")
2013-03-22 09:29:30 +01:00
private boolean starred;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
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;
}
2013-03-22 22:11:40 +01:00
public Date getDate() {
2013-03-22 09:29:30 +01:00
return date;
}
2013-03-22 22:11:40 +01:00
public void setDate(Date date) {
2013-03-22 09:29:30 +01:00
this.date = date;
}
public String getFeedId() {
return feedId;
}
public void setFeedId(String feedId) {
this.feedId = feedId;
}
public String getFeedName() {
return feedName;
}
public void setFeedName(String feedName) {
this.feedName = feedName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
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;
}
2013-04-09 12:03:03 +02:00
public String getFeedUrl() {
return feedUrl;
}
public void setFeedUrl(String feedUrl) {
this.feedUrl = feedUrl;
}
2013-04-09 13:37:00 +02:00
public String getEnclosureUrl() {
return enclosureUrl;
}
public void setEnclosureUrl(String enclosureUrl) {
this.enclosureUrl = enclosureUrl;
}
public String getEnclosureType() {
return enclosureType;
}
public void setEnclosureType(String enclosureType) {
this.enclosureType = enclosureType;
}
public String getGuid() {
return guid;
}
public void setGuid(String guid) {
this.guid = guid;
}
2013-03-22 09:29:30 +01:00
}