mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
REPO-Tags: GET tags endpoint should provide aggregation info
This commit is contained in:
@@ -26,9 +26,11 @@
|
|||||||
package org.alfresco.rest.api.impl;
|
package org.alfresco.rest.api.impl;
|
||||||
|
|
||||||
import java.util.AbstractList;
|
import java.util.AbstractList;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.query.PagingResults;
|
import org.alfresco.query.PagingResults;
|
||||||
import org.alfresco.repo.tagging.NonExistentTagException;
|
import org.alfresco.repo.tagging.NonExistentTagException;
|
||||||
import org.alfresco.repo.tagging.TagExistsException;
|
import org.alfresco.repo.tagging.TagExistsException;
|
||||||
@@ -135,25 +137,23 @@ public class TagsImpl implements Tags
|
|||||||
List<Pair<NodeRef, String>> page = results.getPage();
|
List<Pair<NodeRef, String>> page = results.getPage();
|
||||||
List<Tag> tags = new ArrayList<Tag>(page.size());
|
List<Tag> tags = new ArrayList<Tag>(page.size());
|
||||||
List<Pair<String, Integer>> tagsByCount = null;
|
List<Pair<String, Integer>> tagsByCount = null;
|
||||||
|
Map<String, Integer> tagsByCountMap = new HashMap<String, Integer>();
|
||||||
|
|
||||||
if (params.getInclude().contains(PARAM_INCLUDE_COUNT))
|
if (params.getInclude().contains(PARAM_INCLUDE_COUNT))
|
||||||
{
|
{
|
||||||
tagsByCount = taggingService.findTaggedNodesAndCountByTagName(storeRef);
|
tagsByCount = taggingService.findTaggedNodesAndCountByTagName(storeRef);
|
||||||
|
if (tagsByCount != null)
|
||||||
|
{
|
||||||
|
for (Pair<String, Integer> tagByCountElem : tagsByCount)
|
||||||
|
{
|
||||||
|
tagsByCountMap.put(tagByCountElem.getFirst(), tagByCountElem.getSecond());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (Pair<NodeRef, String> pair : page)
|
for (Pair<NodeRef, String> pair : page)
|
||||||
{
|
{
|
||||||
Tag selectedTag = new Tag(pair.getFirst(), pair.getSecond());
|
Tag selectedTag = new Tag(pair.getFirst(), pair.getSecond());
|
||||||
if (tagsByCount != null)
|
selectedTag.setCount(tagsByCountMap.get(selectedTag.getTag()));
|
||||||
{
|
|
||||||
for (Pair<String, Integer> tagByCount : tagsByCount)
|
|
||||||
{
|
|
||||||
if (tagByCount.getFirst().equals(selectedTag.getTag()))
|
|
||||||
{
|
|
||||||
selectedTag.setCount(tagByCount.getSecond());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tags.add(selectedTag);
|
tags.add(selectedTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user