mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
added needed fields in models and needed libraries for frontend (#67)
This commit is contained in:
@@ -35,6 +35,8 @@ public class FeedCategory extends AbstractModel {
|
||||
|
||||
private boolean collapsed;
|
||||
|
||||
private Integer position;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -86,4 +88,12 @@ public class FeedCategory extends AbstractModel {
|
||||
this.collapsed = collapsed;
|
||||
}
|
||||
|
||||
public Integer getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(Integer position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ public class FeedSubscription extends AbstractModel {
|
||||
@OneToMany(mappedBy = "subscription", cascade = CascadeType.REMOVE)
|
||||
private Set<FeedEntryStatus> statuses;
|
||||
|
||||
private Integer position;
|
||||
|
||||
public Feed getFeed() {
|
||||
return feed;
|
||||
}
|
||||
@@ -73,4 +75,12 @@ public class FeedSubscription extends AbstractModel {
|
||||
this.statuses = statuses;
|
||||
}
|
||||
|
||||
public Integer getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(Integer position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.util.List;
|
||||
import javax.ejb.ApplicationException;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.commafeed.backend.dao.FeedEntryDAO;
|
||||
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
||||
import com.commafeed.backend.dao.FeedSubscriptionDAO;
|
||||
@@ -50,7 +52,7 @@ public class FeedSubscriptionService {
|
||||
FeedCategory category) {
|
||||
|
||||
final String pubUrl = applicationSettingsService.get().getPublicUrl();
|
||||
if (pubUrl == null) {
|
||||
if (StringUtils.isBlank(pubUrl)) {
|
||||
throw new FeedSubscriptionException(
|
||||
"Public URL of this CommaFeed instance is not set");
|
||||
}
|
||||
|
||||
@@ -8,19 +8,36 @@ import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.wordnik.swagger.annotations.ApiClass;
|
||||
import com.wordnik.swagger.annotations.ApiProperty;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@ApiClass("Entry details")
|
||||
public class Category implements Serializable {
|
||||
|
||||
@ApiProperty("category id")
|
||||
private String id;
|
||||
|
||||
@ApiProperty("parent category id")
|
||||
private String parentId;
|
||||
|
||||
@ApiProperty("category id")
|
||||
private String name;
|
||||
|
||||
@ApiProperty("category children categories")
|
||||
private List<Category> children = Lists.newArrayList();
|
||||
|
||||
@ApiProperty("category feeds")
|
||||
private List<Subscription> feeds = Lists.newArrayList();
|
||||
|
||||
@ApiProperty("wether the category is expanded or collapsed")
|
||||
private boolean expanded;
|
||||
|
||||
@ApiProperty("position of the category in the list")
|
||||
private Integer position;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -68,4 +85,13 @@ public class Category implements Serializable {
|
||||
public void setExpanded(boolean expanded) {
|
||||
this.expanded = expanded;
|
||||
}
|
||||
|
||||
public Integer getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(Integer position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,6 +29,7 @@ public class Subscription implements Serializable {
|
||||
Subscription sub = new Subscription();
|
||||
sub.setId(subscription.getId());
|
||||
sub.setName(subscription.getTitle());
|
||||
sub.setPosition(subscription.getPosition());
|
||||
sub.setMessage(feed.getMessage());
|
||||
sub.setErrorCount(feed.getErrorCount());
|
||||
sub.setFeedUrl(feed.getUrl());
|
||||
@@ -77,6 +78,9 @@ public class Subscription implements Serializable {
|
||||
@ApiProperty(value = "category id")
|
||||
private String categoryId;
|
||||
|
||||
@ApiProperty("position of the subscription's in the list")
|
||||
private Integer position;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -165,4 +169,12 @@ public class Subscription implements Serializable {
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
public Integer getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(Integer position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -289,6 +289,19 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
return Response.ok(Status.OK).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/unreadCount")
|
||||
@ApiOperation(value = "Get unread count for feed subscriptions", responseClass = "List[com.commafeed.frontend.model.UnreadCount]")
|
||||
public Response getUnreadCount() {
|
||||
List<UnreadCount> list = Lists.newArrayList();
|
||||
Map<Long, Long> unreadCount = feedEntryStatusDAO
|
||||
.getUnreadCount(getUser());
|
||||
for (Map.Entry<Long, Long> e : unreadCount.entrySet()) {
|
||||
list.add(new UnreadCount(e.getKey(), e.getValue()));
|
||||
}
|
||||
return Response.ok(list).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/get")
|
||||
@ApiOperation(value = "Get feed categories", notes = "Get all categories and subscriptions of the user", responseClass = "com.commafeed.frontend.model.Category")
|
||||
@@ -308,19 +321,6 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
return Response.ok(root).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/unreadCount")
|
||||
@ApiOperation(value = "Get unread count for feed subscriptions", responseClass = "List[com.commafeed.frontend.model.UnreadCount]")
|
||||
public Response getUnreadCount() {
|
||||
List<UnreadCount> list = Lists.newArrayList();
|
||||
Map<Long, Long> unreadCount = feedEntryStatusDAO
|
||||
.getUnreadCount(getUser());
|
||||
for (Map.Entry<Long, Long> e : unreadCount.entrySet()) {
|
||||
list.add(new UnreadCount(e.getKey(), e.getValue()));
|
||||
}
|
||||
return Response.ok(list).build();
|
||||
}
|
||||
|
||||
private Category buildCategory(Long id, List<FeedCategory> categories,
|
||||
List<FeedSubscription> subscriptions, Map<Long, Long> unreadCount) {
|
||||
Category category = new Category();
|
||||
@@ -335,6 +335,7 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
subscriptions, unreadCount);
|
||||
child.setId(String.valueOf(c.getId()));
|
||||
child.setName(c.getName());
|
||||
child.setPosition(c.getPosition());
|
||||
if (c.getParent() != null && c.getParent().getId() != null) {
|
||||
child.setParentId(String.valueOf(c.getParent().getId()));
|
||||
}
|
||||
@@ -345,7 +346,7 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
Collections.sort(category.getChildren(), new Comparator<Category>() {
|
||||
@Override
|
||||
public int compare(Category o1, Category o2) {
|
||||
return ObjectUtils.compare(o1.getName(), o2.getName());
|
||||
return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -364,7 +365,7 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
Collections.sort(category.getFeeds(), new Comparator<Subscription>() {
|
||||
@Override
|
||||
public int compare(Subscription o1, Subscription o2) {
|
||||
return ObjectUtils.compare(o1.getName(), o2.getName());
|
||||
return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
|
||||
}
|
||||
});
|
||||
return category;
|
||||
|
||||
Reference in New Issue
Block a user