added needed fields in models and needed libraries for frontend (#67)

This commit is contained in:
Athou
2013-06-01 21:00:10 +02:00
parent 33eb99b8c6
commit 7ffd044a86
11 changed files with 195 additions and 67 deletions

View File

@@ -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;