Search in sources :

Example 16 with DateMode

use of com.celements.blog.article.ArticleLoadParameter.DateMode in project celements-blog by celements.

the class ArticleEngineHQL method getArticles.

@Override
public List<Article> getArticles(ArticleLoadParameter param) throws ArticleLoadException {
    try {
        SpaceReference spaceRef = blogService.getBlogSpaceRef(param.getBlogDocRef());
        String blogArticleSpace = spaceRef != null ? spaceRef.getName() : "";
        List<String> subscribedBlogs = new ArrayList<>();
        for (DocumentReference subsDocRef : param.getSubscribedToBlogs()) {
            SpaceReference subsSpaceRef = blogService.getBlogSpaceRef(subsDocRef);
            if (subsSpaceRef != null) {
                subscribedBlogs.add(subsSpaceRef.getName());
            }
        }
        String language = param.getLanguage();
        Set<DateMode> dateModes = param.getDateModes();
        boolean archiveOnly = ((dateModes.size() == 1) && dateModes.contains(DateMode.ARCHIVED)) || (dateModes.size() == 0);
        boolean futurOnly = ((dateModes.size() == 1) && dateModes.contains(DateMode.FUTURE)) || (dateModes.size() == 0);
        boolean subscribableOnly = !param.isWithBlogArticles();
        boolean withArchive = dateModes.contains(DateMode.ARCHIVED);
        boolean withFutur = dateModes.contains(DateMode.FUTURE);
        Set<SubscriptionMode> subsModes = param.getSubscriptionModes();
        boolean withSubscribable = subsModes.size() > 0;
        boolean withSubscribed = subsModes.contains(SubscriptionMode.SUBSCRIBED);
        boolean withUnsubscribed = subsModes.contains(SubscriptionMode.UNSUBSCRIBED);
        boolean withUndecided = subsModes.contains(SubscriptionMode.UNDECIDED);
        boolean checkAccessRights = true;
        LOGGER.debug(param + "' translated to: blogArticleSpace=" + blogArticleSpace + ", subscribedBlogs=" + subscribedBlogs + ", language=" + language + ", archiveOnly=" + archiveOnly + ", futurOnly=" + futurOnly + ", withArchive=" + withArchive + ", withFutur=" + withFutur + ", subscribableOnly=" + subscribableOnly + ", withSubscribable=" + withSubscribable + ", withSubscribed=" + withSubscribed + ", withUnsubscribed=" + withUnsubscribed + ", withUndecided=" + withUndecided + ", checkAccessRights=" + checkAccessRights);
        return getBlogArticles(blogArticleSpace, subscribedBlogs, language, archiveOnly, futurOnly, subscribableOnly, withArchive, withFutur, withSubscribable, withSubscribed, withUnsubscribed, withUndecided, checkAccessRights);
    } catch (XWikiException xwe) {
        throw new ArticleLoadException(xwe);
    }
}
Also used : DateMode(com.celements.blog.article.ArticleLoadParameter.DateMode) SubscriptionMode(com.celements.blog.article.ArticleLoadParameter.SubscriptionMode) SpaceReference(org.xwiki.model.reference.SpaceReference) ArrayList(java.util.ArrayList) DocumentReference(org.xwiki.model.reference.DocumentReference) XWikiException(com.xpn.xwiki.XWikiException)

Aggregations

DateMode (com.celements.blog.article.ArticleLoadParameter.DateMode)16 QueryRestrictionGroup (com.celements.search.lucene.query.QueryRestrictionGroup)15 Date (java.util.Date)15 Test (org.junit.Test)15 HashSet (java.util.HashSet)14 SubscriptionMode (com.celements.blog.article.ArticleLoadParameter.SubscriptionMode)1 XWikiException (com.xpn.xwiki.XWikiException)1 ArrayList (java.util.ArrayList)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 SpaceReference (org.xwiki.model.reference.SpaceReference)1