set parent category of children categories to null when removing a category (fix #38)

This commit is contained in:
Athou
2013-05-01 14:49:03 +02:00
parent fb881ff3bb
commit bfda641501

View File

@@ -210,6 +210,16 @@ public class CategoryREST extends AbstractResourceREST {
sub.setCategory(null);
}
feedSubscriptionDAO.update(subs);
List<FeedCategory> categories = feedCategoryDAO
.findAllChildrenCategories(getUser(), cat);
for (FeedCategory child : categories) {
if (!child.getId().equals(cat.getId())
&& child.getParent().getId().equals(cat.getId())) {
child.setParent(null);
}
}
feedCategoryDAO.update(categories);
feedCategoryDAO.delete(cat);
return Response.ok().build();
} else {