Package evolaris.framework.blog.datamodel

Examples of evolaris.framework.blog.datamodel.Label


  @SuppressWarnings("unchecked")
  public void _testgetByLabel() {
    GroupManager grp = new GroupManager(Locale.getDefault(), session);
    Blog b = mgr.getBlog("tstblg1", grp.getGroup("administrator"));
    Label lab = mgr.getLabel(b, "demo");
    Collection l = mgr.getArchivedArticles(b, lab);
    assertNotNull(l);
  }
View Full Code Here


    // attach labels
    article.setLabels(new HashSet<Label>());
    if (labels != null && labels.length > 0) {
      for (String s : labels) {
        s = s.replaceAll("[\"',;]", "")// cleanup label
        Label label = getLabel(gameBlog, s);
        if (label == null) {
          label = new Label();
          label.setLabel(s);
          label.setBlog(article.getBlog());
          label.getArticles().add(article);
          addLabel(gameBlog, label);
        }
        article.getLabels().add(label);
        label.getArticles().add(article);
      }   
      session.update(article);   
    }
    return article;   
  }
View Full Code Here

        to = cal.getTime();
      } catch (ParseException e) {
        from = to = null;
      }     
    } else if (labelArchiveParam != null && labelArchiveParam.length() > 0) {
      Label label = blogMgr.getLabel(blog, Long.parseLong(labelArchiveParam));
      articles = blogMgr.getArchivedArticles(blog, label);
      req.setAttribute("subheader", getLocalizedMessage("BloggingWeb", "blog.ArchiveForLabel", label.getLabel()));     
    } else if (unlabelledParam != null) {
      articles = blogMgr.getUnlabelledArticles(blog);
      req.setAttribute("subheader", getLocalizedMessage("BloggingWeb", "blog.ArchiveForUnlabelled"));     
    } else {
      articles = blog.getArticles();
View Full Code Here

    Blog gameBlog = blogMgr.getBlog("mgblgameinstances", mgblGroup);
    List<DisplayableApplicationType> entries = new ArrayList<DisplayableApplicationType>();
    for (Long id : searchResults) {
      Article blogArticle = blogMgr.getArticle(id);
      DisplayableApplicationType entry = new DisplayableApplicationType(blogArticle);
      Label label = blogMgr.getLabel(gameBlog, blogArticle.getTitle());
      Collection<Article> gameList = label != null ? blogMgr.getArchivedArticles(gameBlog, label) : null;
      entry.setGameCount(gameList != null ? gameList.size() : 0);
      entries.add(entry);
    }
    req.setAttribute("articleList", entries);
View Full Code Here

    List<DisplayableApplicationType> gameStyles = new ArrayList<DisplayableApplicationType>();
    Blog gameBlog = blogMgr.getBlog("mgblgameinstances", mgblGroup);
    for (DisplayableArticle a : displayArticles) {
      Article blogArticle = blogMgr.getArticle(a.getId());
      DisplayableApplicationType entry = new DisplayableApplicationType(blogArticle);
      Label label = blogMgr.getLabel(gameBlog, blogArticle.getTitle());
      Collection<Article> gameList = label != null ? blogMgr.getArchivedArticles(gameBlog, label) : null;
      entry.setGameCount(gameList != null ? gameList.size() : 0);
      gameStyles.add(entry);
    }
    Collections.sort(gameStyles, new Comparator<DisplayableApplicationType>() {
View Full Code Here

    // inject labelarchive param if mgblpresetlabel is there
    String labelArchiveParam = req.getParameter("labelarchive");
    if (labelArchiveParam == null) {  // try mgblPresetLabel
      String presetLabelString = (String)req.getSession().getAttribute("mgblPresetLabel");
      if (presetLabelString != null) {
        Label presetLabel = blogMgr.getLabel(blog, presetLabelString);
        if (presetLabel != null) {
          labelArchiveParam = Long.toString(presetLabel.getId());
          req.setAttribute("labelarchive", labelArchiveParam);
        }
      }
    }
   
    ActionForward fwd = super.view(mapping, form, req, resp);

    if (labelArchiveParam != null && labelArchiveParam.length() > 0) {
      Label label = blogMgr.getLabel(blog, Long.parseLong(labelArchiveParam));
      req.getSession().setAttribute("mgblPresetLabel", label.getLabel());
      Blog gameStyleBlog = blogMgr.getBlog("mgblgamestyles", blog.getGroup());
      req.getSession().removeAttribute("mgblCurrentGameStyle");
      req.getSession().removeAttribute("mgblCurrentGameStyleBelongsToSearchResult");
      for (Article style : gameStyleBlog.getArticles()) {
        if (label.getLabel().equals(style.getTitle())) {
          req.getSession().setAttribute("mgblCurrentGameStyle", new DisplayableArticle(style));
          List<Long> searchResults = (List<Long>)req.getSession().getAttribute("mgblSearchResults");
          if (searchResults != null && searchResults.contains(style.getId())) {
            req.getSession().setAttribute("mgblCurrentGameStyleBelongsToSearchResult", Boolean.TRUE);
          }
View Full Code Here

    req.setAttribute("commentList", comments);

    // list of game instances
    Blog gameBlog = blogMgr.getBlog("mgblgameinstances", blog.getGroup());
    List<DisplayableArticle> gameList = new ArrayList<DisplayableArticle>();
    Label label = blogMgr.getLabel(gameBlog, article.getTitle());
    if (label == null) {
      // do some self healing magic ...
      label = new Label();
      label.setLabel(article.getTitle());
      blogMgr.addLabel(gameBlog, label);
    }
    Collection<Article> gameArticles = blogMgr.getArchivedArticles(gameBlog, label);
    for (Article gameArticle : gameArticles) {
      DisplayableArticle entry = new DisplayableArticle(gameArticle);
View Full Code Here

    return label;
  }

  private void removeUnusedLabels(Blog blog) {
    for (Iterator<Label> i = blog.getLabels().iterator(); i.hasNext(); ) {
      Label label = i.next();
      if (label.getArticles() == null || label.getArticles().size() == 0) {
        session.delete(label);
        i.remove();
      }
    }
    session.update(blog);
View Full Code Here

   
    if (labelString != null && labelString.length() > 0) {
      String[] labelStrings = labelString.split("\\s*,\\s*");     
      for (String s : labelStrings) {
        s = cleanLabelString(s);
        Label label = getLabel(article.getBlog(), s);
        if (label == null) {
          label = new Label();
          label.setLabel(s);
          label.setBlog(article.getBlog());
          label.getArticles().add(article);
          addLabel(article.getBlog(), label);
        }
        article.getLabels().add(label);
        label.getArticles().add(article);
      }   
    }
    session.update(article);
    removeUnusedLabels(article.getBlog());
  }
View Full Code Here

TOP

Related Classes of evolaris.framework.blog.datamodel.Label

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.