INewsMark Model Changes

From RSSOwl

Jump to: navigation, search

Contents

Motivation

  • Support for storing news in bins
  • Generic API for any subclass of IMark providing access to News


New entity INewsMark

Idea

  • Base class of any IMark providing access to news
    • IBookMark: News from a Feed
    • ISearchMark: News matching a Search
    • INewsBin: News contained in a Bin

API

  • Return resolved News
  • Return References
    • including knowledge about state of news
  • Return number of News for a certain state
    • May delegate to NewsCounter in the IBookMark implementation


New entity INewsBin

  • Provides API to add and remove News


Open issues

NewsCounter

  • When a news from a bin is added or its state changes the newscounter must not update since the news is not part of a feed but part of a bin that maintains its own counter. One way to fix this is to have a INews.isCopy() method. I think we talked about this before, but it solves a number of problems in addition to this one. We can use it in the query to find only the INews that could be in INewsBins based on the feedLink when a BM is deleted. We can also use it in setNewsState if we decide that we want INews in INewsBins to be disconnected when copied.

ISearchMark

  • getResult and getResultCount are now duplicates of the methods defined in INewsMark. We should probably remove them.
  • We should rename setResult to setNews for consistency if we remove the methods above.
  • Drag a news item in a SM to a NB. At the moment, this removes it from the BM and copies it to the NB. Is that what we want? It seems a bit surprising, but I am not sure if the alternative is much better.

INewsMark

  • Do we need to provide getNews and getNewsRefs? This could be useful for optimization. e.g. if a Mark needs to resolve the INews and the caller needs the resolved INews, it would be wasteful to do getNewsRefs followed by a resolve for each news. One way to make this work in a generic fashion would be to have a isGetNewsRefsEfficient (with a better name if possible). The idea is that the caller could find out what method to use most efficiently without having to do instanceof checks for specific INewsMark subclasses.
  • For getNews(Set<INews.State> states), need to decide how to deal with cases where the subclass doesn't hold news in a certain state. For example, a SM never includes INews in HIDDEN or DELETED state, since it's not possible to define a SM that returns those from the UI. The core itself doesn't restrict it though. On the other hand, INewsBin will store HIDDEN news. Seems like we need to document that subclasses will define the exact details of what states are returned. Another example is a Recycle Bin that would only show items in HIDDEN state.
  • For getNewsCount(Set<INews.State> states), we must make sure that the IBookMark implementation can return a result efficiently. It seems like the easiest way is to delegate to NewsCounter, which means that the NewsCounter should be injected to the IBookMark on activation in a transient field. With the current model, there's one downside, we can only return efficient responses for our current usage (in other words what we keep track in NewsCounter). If someone asks getNewsCount(EnumSet.of(State.NEW, State.READ)), the calculation will not be efficient.
  • Do we need a getStickyCount too? If we add this method to INewsMark, we can then remove all usages of NewsService.

INewsBin

  • If a SM matches a INews that was copied from a IFeed to a INewsBin, it will show both. This looks a bit strange at first especially because SMs have an icon for the feed. In this case, the feed is the same, but one is from a BM and the other from a INewsBin. So, I think the icon for the INews from the INewsBin should be the same icon as the INewsBin one with a tooltip showing the name of the INewsBin. An aside, it seems to me that INewsBins work best if users move the INews from the IFeed instead of copy. I think that should be the default DnD behaviour.
  • If a Bookmark is deleted we need to consider any news-bin containing news from that feed to defer deleting the feed the bookmark is pointing at. Otherwise there would be news left over in a bin pointing to a deleted feed. The issue here is that there is no cheap way to find out, which news bins contain news from the feed that is about to be deleted. The reason for this is that the news bin is only storing the IDs of news. One possible solution is to perform a query on all INews that have the feedLink for the deleted BM and then pass those in a Map<INews.State, List<NewsReference> to INewsBin#containsNews for each INewsBin in the system. We should be able to make that efficient with an index in feedLink (not sure if it already exists) and the current implementation of INewsBin. A better solution in my opinion is to add the isCopy method to INews and then a query on the feedLink + isCopy is enough to tell us if we should delete the feed or not.
  • We need to be able to delete a IFeed that was retained because of the item above, which means that we'd need to check this everytime a INews with isCopy == true is deleted.
  • Must document that callers should never call INewsBin#removeNews. They should instead just change the state of the INews and then save the INews. The former would cause the INews to leak because the INewsBin would be saved without the id, but we would not have the information to actually delete the INews.
  • Must keep INewsBin in sync with INews#setState calls. We can add code in the db layer that checks for state changes by using the oldNews and updates the appropriate INewsBin. We can take advantage of this to also delete items from INewsBin by looking at the INews whose state changed to INews.State.DELETED

Other

  • When a bookmark is deleted but some news kept from it in a bin, there is no way of showing the favicon of the feed next to the news, because its associated with the bookmark and deleted when the bookmark gets deleted. Minor, but visible issue.
  • See through new API added and think about good naming
Personal tools