Esempio n. 1
0
  public List<TagRecommendationGroup> getTagRecommendationGroups() {
    if (tagRecommendationGroups == null) {
      tagRecommendationGroups = new LinkedList<TagRecommendationGroup>();

      /*for (Map.Entry<String, Collection<TagRecommendation>> entry : tagRecommendationService.getGroupedRecommendations(currentContentItem).entrySet()) {
      	tagRecommendationGroups.add(new TagRecommendationGroup(entry.getKey(), new LinkedList<TagRecommendation> (entry.getValue())));
      }*/

      // Here we use the suggestion action, instead of the tagRecommendationService,
      // which can create recommendations based on current editor suggestions.
      for (Map.Entry<String, Collection<TagRecommendation>> entry :
          suggestionAction.getGroupedRecommendations().entrySet()) {
        tagRecommendationGroups.add(
            new TagRecommendationGroup(
                entry.getKey(), new LinkedList<TagRecommendation>(entry.getValue())));
      }

      log.debug("tag recommendations: #0", tagRecommendationGroups);

      for (ExtendedTagCloudEntry e : getTagCloud()) {
        for (TagRecommendationGroup group : tagRecommendationGroups) {
          List<TagRecommendation> list = group.getRecommendations();
          Iterator<TagRecommendation> it = list.iterator();
          while (it.hasNext()) {
            if (it.next().getLabel().equals(e.getTag().getTitle())) {
              it.remove();
            }
          }
        }
      }
    }

    return tagRecommendationGroups;
  }
Esempio n. 2
0
  public Collection<TagRecommendation> getTagRecommendations() {
    if (tagRecommendations == null) {
      tagRecommendations = tagRecommendationService.getRecommendations(currentContentItem);

      log.debug("tag recommendations: #0", tagRecommendations);

      for (ExtendedTagCloudEntry e : getTagCloud()) {
        Iterator<TagRecommendation> it = tagRecommendations.iterator();
        while (it.hasNext()) {
          if (it.next().getLabel().equals(e.getTag().getTitle())) {
            it.remove();
          }
        }
      }
    }
    return tagRecommendations;
  }