mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126576 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 124677 jvonka: RA-767: Queries API - "live-search-nodes" - add orderBy options (& more tests) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126921 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -42,4 +42,8 @@ public interface Queries
|
||||
String PARAM_TERM = "term";
|
||||
String PARAM_ROOT_NODE_ID = "rootNodeId";
|
||||
String PARAM_NODE_TYPE = "nodeType";
|
||||
|
||||
String PARAM_NAME = "name";
|
||||
String PARAM_CREATEDAT = "createdAt";
|
||||
String PARAM_MODIFIEDAT = "modifiedAt";
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ import org.alfresco.rest.framework.core.exceptions.NotFoundException;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.resource.parameters.SortColumn;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -46,6 +47,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -55,8 +57,6 @@ import java.util.Map;
|
||||
*/
|
||||
public class QueriesImpl implements Queries, InitializingBean
|
||||
{
|
||||
//private static final Log logger = LogFactory.getLog(QueriesImpl.class);
|
||||
|
||||
private ServiceRegistry sr;
|
||||
private SearchService searchService;
|
||||
private NodeService nodeService;
|
||||
@@ -66,6 +66,19 @@ public class QueriesImpl implements Queries, InitializingBean
|
||||
|
||||
private final static String QUERY_LIVE_SEARCH_NODES = "live-search-nodes";
|
||||
|
||||
private final static Map<String,QName> MAP_PARAM_SORT_QNAME;
|
||||
static
|
||||
{
|
||||
Map<String,QName> aMap = new HashMap<>(3);
|
||||
|
||||
aMap.put(PARAM_NAME, ContentModel.PROP_NAME);
|
||||
aMap.put(PARAM_CREATEDAT, ContentModel.PROP_CREATED);
|
||||
aMap.put(PARAM_MODIFIEDAT, ContentModel.PROP_MODIFIED);
|
||||
|
||||
MAP_PARAM_SORT_QNAME = Collections.unmodifiableMap(aMap);
|
||||
}
|
||||
|
||||
|
||||
private Nodes nodes;
|
||||
|
||||
public void setServiceRegistry(ServiceRegistry sr)
|
||||
@@ -142,7 +155,7 @@ public class QueriesImpl implements Queries, InitializingBean
|
||||
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
|
||||
// query template / field
|
||||
sp.addQueryTemplate(QT_FIELD, "%(cm:name cm:title cm:description lnk:title lnk:description TEXT TAG)");
|
||||
sp.addQueryTemplate(QT_FIELD, "%(cm:name cm:title cm:description TEXT TAG)");
|
||||
|
||||
Paging paging = parameters.getPaging();
|
||||
PagingRequest pagingRequest = Util.getPagingRequest(paging);
|
||||
@@ -150,8 +163,24 @@ public class QueriesImpl implements Queries, InitializingBean
|
||||
sp.setSkipCount(pagingRequest.getSkipCount());
|
||||
sp.setMaxItems(pagingRequest.getMaxItems());
|
||||
|
||||
// TODO modifiedAt, createdAt or name
|
||||
sp.addSort("@" + ContentModel.PROP_MODIFIED, false);
|
||||
List<SortColumn> sortCols = parameters.getSorting();
|
||||
if ((sortCols != null) && (sortCols.size() > 0))
|
||||
{
|
||||
for (SortColumn sortCol : sortCols)
|
||||
{
|
||||
QName sortPropQName = MAP_PARAM_SORT_QNAME.get(sortCol.column);
|
||||
if (sortPropQName == null)
|
||||
{
|
||||
throw new InvalidArgumentException("Invalid sort field: "+sortCol.column);
|
||||
}
|
||||
sp.addSort("@" + sortPropQName, sortCol.asc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// default sort order
|
||||
sp.addSort("@" + ContentModel.PROP_MODIFIED, false);
|
||||
}
|
||||
|
||||
ResultSet results = searchService.query(sp);
|
||||
|
||||
|
Reference in New Issue
Block a user