mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
ACS-4023: Update GET /tags to support getting tags by name (#1766)
* ACS-4023: Update GET /tags to support getting tags by name
This commit is contained in:
committed by
GitHub
parent
0cb03c2a38
commit
f2fdf958f2
File diff suppressed because it is too large
Load Diff
@@ -42,6 +42,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
@@ -914,51 +915,23 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
return new EmptyPagingResults<Pair<NodeRef, String>>();
|
||||
}
|
||||
|
||||
public PagingResults<Pair<NodeRef, String>> getTags(StoreRef storeRef, PagingRequest pagingRequest)
|
||||
{
|
||||
return getTags(storeRef, pagingRequest, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#getTags(org.alfresco.service.cmr.repository.StoreRef, org.alfresco.query.PagingRequest)
|
||||
*/
|
||||
public PagingResults<Pair<NodeRef, String>> getTags(StoreRef storeRef, PagingRequest pagingRequest)
|
||||
public PagingResults<Pair<NodeRef, String>> getTags(StoreRef storeRef, PagingRequest pagingRequest, Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter)
|
||||
{
|
||||
ParameterCheck.mandatory("storeRef", storeRef);
|
||||
|
||||
PagingResults<ChildAssociationRef> rootCategories = this.categoryService.getRootCategories(storeRef, ContentModel.ASPECT_TAGGABLE, pagingRequest, true);
|
||||
final List<Pair<NodeRef, String>> result = new ArrayList<Pair<NodeRef, String>>(rootCategories.getPage().size());
|
||||
for (ChildAssociationRef rootCategory : rootCategories.getPage())
|
||||
{
|
||||
String name = (String)this.nodeService.getProperty(rootCategory.getChildRef(), ContentModel.PROP_NAME);
|
||||
result.add(new Pair<NodeRef, String>(rootCategory.getChildRef(), name));
|
||||
}
|
||||
final boolean hasMoreItems = rootCategories.hasMoreItems();
|
||||
final Pair<Integer, Integer> totalResultCount = rootCategories.getTotalResultCount();
|
||||
final String queryExecutionId = rootCategories.getQueryExecutionId();
|
||||
rootCategories = null;
|
||||
PagingResults<ChildAssociationRef> rootCategories = categoryService.getRootCategories(storeRef, ContentModel.ASPECT_TAGGABLE, pagingRequest, true,
|
||||
exactNamesFilter, alikeNamesFilter);
|
||||
|
||||
return new PagingResults<Pair<NodeRef, String>>()
|
||||
{
|
||||
@Override
|
||||
public List<Pair<NodeRef, String>> getPage()
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
return hasMoreItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> getTotalResultCount()
|
||||
{
|
||||
return totalResultCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryExecutionId()
|
||||
{
|
||||
return queryExecutionId;
|
||||
}
|
||||
};
|
||||
return mapPagingResult(rootCategories,
|
||||
(childAssociation) -> new Pair<>(childAssociation.getChildRef(), childAssociation.getQName().getLocalName()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1600,4 +1573,36 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
createTagBehaviour.enable();
|
||||
}
|
||||
}
|
||||
|
||||
private <T, R> PagingResults<R> mapPagingResult(final PagingResults<T> pagingResults, final Function<T, R> mapper)
|
||||
{
|
||||
return new PagingResults<R>()
|
||||
{
|
||||
@Override
|
||||
public List<R> getPage()
|
||||
{
|
||||
return pagingResults.getPage().stream()
|
||||
.map(mapper)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
return pagingResults.hasMoreItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> getTotalResultCount()
|
||||
{
|
||||
return pagingResults.getTotalResultCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryExecutionId()
|
||||
{
|
||||
return pagingResults.getQueryExecutionId();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.alfresco.api.AlfrescoPublicApi;
|
||||
import org.alfresco.query.EmptyPagingResults;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.service.Auditable;
|
||||
@@ -136,6 +137,24 @@ public interface CategoryService
|
||||
@Auditable(parameters = {"storeRef", "aspectName", "pagingRequest", "sortByName", "filter"})
|
||||
PagingResults<ChildAssociationRef> getRootCategories(StoreRef storeRef, QName aspectName, PagingRequest pagingRequest, boolean sortByName, String filter);
|
||||
|
||||
/**
|
||||
* Get a paged list of the root categories for an aspect/classification supporting multiple name filters.
|
||||
*
|
||||
* @param storeRef
|
||||
* @param aspectName
|
||||
* @param pagingRequest
|
||||
* @param sortByName
|
||||
* @param exactNamesFilter
|
||||
* @param alikeNamesFilter
|
||||
* @return
|
||||
*/
|
||||
@Auditable(parameters = {"storeRef", "aspectName", "pagingRequest", "sortByName", "exactNamesFilter", "alikeNamesFilter"})
|
||||
default PagingResults<ChildAssociationRef> getRootCategories(StoreRef storeRef, QName aspectName, PagingRequest pagingRequest, boolean sortByName,
|
||||
Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter)
|
||||
{
|
||||
return new EmptyPagingResults<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root categories for an aspect/classification with names that start with filter
|
||||
*
|
||||
|
@@ -25,10 +25,12 @@
|
||||
*/
|
||||
package org.alfresco.service.cmr.tagging;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.api.AlfrescoPublicApi;
|
||||
import org.alfresco.api.AlfrescoPublicApi;
|
||||
import org.alfresco.query.EmptyPagingResults;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.service.Auditable;
|
||||
@@ -75,6 +77,21 @@ public interface TaggingService
|
||||
*/
|
||||
@NotAuditable
|
||||
PagingResults<Pair<NodeRef, String>> getTags(StoreRef storeRef, PagingRequest pagingRequest);
|
||||
|
||||
/**
|
||||
* Get a paged list of tags filtered by name
|
||||
*
|
||||
* @param storeRef StoreRef
|
||||
* @param pagingRequest PagingRequest
|
||||
* @param exactNamesFilter PagingRequest
|
||||
* @param alikeNamesFilter PagingRequest
|
||||
* @return PagingResults
|
||||
*/
|
||||
@NotAuditable
|
||||
default PagingResults<Pair<NodeRef, String>> getTags(StoreRef storeRef, PagingRequest pagingRequest, Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter)
|
||||
{
|
||||
return new EmptyPagingResults<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the tags currently available that match the provided filter.
|
||||
|
Reference in New Issue
Block a user