use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker in project records-management by Alfresco.
the class FilePlanComponentsApiUtils method getListChildrenFilterProps.
/**
* Returns a List of filter properties specified by request parameters.
* @param parameters The {@link Parameters} object to get the parameters passed into the request
* including:
* - filter, sort & paging params (where, orderBy, skipCount, maxItems)
* @return The list of {@link FilterProp}. Can be null.
*/
public List<FilterProp> getListChildrenFilterProps(Parameters parameters, Set<String> listFolderChildrenEqualsQueryProperties) {
List<FilterProp> filterProps = null;
Query q = parameters.getQuery();
if (q != null) {
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(listFolderChildrenEqualsQueryProperties, null);
QueryHelper.walk(q, propertyWalker);
Boolean isPrimary = propertyWalker.getProperty(RMNode.PARAM_ISPRIMARY, WhereClauseParser.EQUALS, Boolean.class);
if (isPrimary != null) {
filterProps = new ArrayList<>(1);
filterProps.add(new FilterPropBoolean(GetChildrenCannedQuery.FILTER_QNAME_NODE_IS_PRIMARY, isPrimary));
}
Boolean isClosed = propertyWalker.getProperty(RMNode.PARAM_IS_CLOSED, WhereClauseParser.EQUALS, Boolean.class);
if (isClosed != null) {
filterProps = new ArrayList<>(1);
filterProps.add(new FilterPropBoolean(RecordsManagementModel.PROP_IS_CLOSED, isClosed));
}
// TODO see how we can filter for categories that have retention schedule
// Boolean hasRetentionSchedule = propertyWalker.getProperty(RMNode.PARAM_HAS_RETENTION_SCHEDULE, WhereClauseParser.EQUALS, Boolean.class);
// if (hasRetentionSchedule != null)
// {
// filterProps = new ArrayList<>(1);
// }
}
return filterProps;
}
use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker in project alfresco-remote-api by Alfresco.
the class SitesImpl method getSiteMembers.
public CollectionWithPagingInfo<SiteMember> getSiteMembers(String siteId, Parameters parameters) {
SiteInfo siteInfo = validateSite(siteId);
if (siteInfo == null) {
// site does not exist
throw new EntityNotFoundException(siteId);
}
// set the site id to the short name (to deal with case sensitivity issues with using the siteId from the url)
siteId = siteInfo.getShortName();
Paging paging = parameters.getPaging();
PagingRequest pagingRequest = Util.getPagingRequest(paging);
pagingRequest.setRequestTotalCountMax(100);
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(new HashSet<>(Collections.singletonList(PARAM_IS_MEMBER_OF_GROUP)), null);
;
QueryHelper.walk(parameters.getQuery(), propertyWalker);
Boolean expandGroups = propertyWalker.getProperty(PARAM_IS_MEMBER_OF_GROUP, WhereClauseParser.EQUALS, Boolean.class);
if (expandGroups == null) {
expandGroups = true;
}
final List<Pair<SiteService.SortFields, Boolean>> sort = new ArrayList<Pair<SiteService.SortFields, Boolean>>();
sort.add(new Pair<SiteService.SortFields, Boolean>(SiteService.SortFields.LastName, Boolean.TRUE));
sort.add(new Pair<SiteService.SortFields, Boolean>(SiteService.SortFields.FirstName, Boolean.TRUE));
sort.add(new Pair<SiteService.SortFields, Boolean>(SiteService.SortFields.Role, Boolean.TRUE));
sort.add(new Pair<SiteService.SortFields, Boolean>(SiteService.SortFields.Username, Boolean.TRUE));
PagingResults<SiteMembership> pagedResults = siteService.listMembersPaged(siteId, expandGroups, sort, pagingRequest);
List<SiteMember> ret = pagedResults.getPage().stream().map((siteMembership) -> new SiteMember(siteMembership.getPersonId(), siteMembership.getRole(), siteMembership.isMemberOfGroup())).collect(Collectors.toList());
return CollectionWithPagingInfo.asPaged(paging, ret, pagedResults.hasMoreItems(), pagedResults.getTotalResultCount().getFirst());
}
use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker in project alfresco-remote-api by Alfresco.
the class NodesImpl method listChildren.
@Override
public CollectionWithPagingInfo<Node> listChildren(String parentFolderNodeId, Parameters parameters) {
String path = parameters.getParameter(PARAM_RELATIVE_PATH);
final NodeRef parentNodeRef = validateOrLookupNode(parentFolderNodeId, path);
final List<String> includeParam = parameters.getInclude();
QName assocTypeQNameParam = null;
Query q = parameters.getQuery();
if (q != null) {
// filtering via "where" clause
MapBasedQueryWalker propertyWalker = createListChildrenQueryWalker();
QueryHelper.walk(q, propertyWalker);
String assocTypeQNameStr = propertyWalker.getProperty(PARAM_ASSOC_TYPE, WhereClauseParser.EQUALS, String.class);
if (assocTypeQNameStr != null) {
assocTypeQNameParam = getAssocType(assocTypeQNameStr);
}
}
List<Pair<QName, Boolean>> sortProps = getListChildrenSortProps(parameters);
List<FilterProp> filterProps = getListChildrenFilterProps(parameters);
Paging paging = parameters.getPaging();
PagingRequest pagingRequest = Util.getPagingRequest(paging);
final PagingResults<FileInfo> pagingResults;
Pair<Set<QName>, Set<QName>> pair = buildSearchTypesAndIgnoreAspects(parameters);
Set<QName> searchTypeQNames = pair.getFirst();
Set<QName> ignoreAspectQNames = pair.getSecond();
Set<QName> assocTypeQNames = buildAssocTypes(assocTypeQNameParam);
// call GetChildrenCannedQuery (via FileFolderService)
if (((filterProps == null) || (filterProps.size() == 0)) && ((assocTypeQNames == null) || (assocTypeQNames.size() == 0)) && (smartStore.isVirtual(parentNodeRef) || (smartStore.canVirtualize(parentNodeRef)))) {
pagingResults = fileFolderService.list(parentNodeRef, searchTypeQNames, ignoreAspectQNames, sortProps, pagingRequest);
} else {
// TODO smart folders (see REPO-1173)
pagingResults = fileFolderService.list(parentNodeRef, assocTypeQNames, searchTypeQNames, ignoreAspectQNames, sortProps, filterProps, pagingRequest);
}
final Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
final List<FileInfo> page = pagingResults.getPage();
List<Node> nodes = new AbstractList<Node>() {
@Override
public Node get(int index) {
FileInfo fInfo = page.get(index);
// minimal info by default (unless "include"d otherwise)
// (pass in null as parentNodeRef to force loading of primary
// parent node as parentId)
Node node = getFolderOrDocument(fInfo.getNodeRef(), null, fInfo.getType(), includeParam, mapUserInfo);
if (node.getPath() != null) {
calculateRelativePath(parentFolderNodeId, node);
}
return node;
}
private void calculateRelativePath(String parentFolderNodeId, Node node) {
NodeRef rootNodeRef = validateOrLookupNode(parentFolderNodeId, null);
try {
// get the path elements
List<String> pathInfos = fileFolderService.getNameOnlyPath(rootNodeRef, node.getNodeRef());
int sizePathInfos = pathInfos.size();
if (sizePathInfos > 1) {
// remove the current child
pathInfos.remove(sizePathInfos - 1);
// build the path string
StringBuilder sb = new StringBuilder(pathInfos.size() * 20);
for (String fileInfo : pathInfos) {
sb.append("/");
sb.append(fileInfo);
}
node.getPath().setRelativePath(sb.toString());
}
} catch (FileNotFoundException e) {
// NOTE: return null as relativePath
}
}
@Override
public int size() {
return page.size();
}
};
Node sourceEntity = null;
if (parameters.includeSource()) {
sourceEntity = getFolderOrDocumentFullInfo(parentNodeRef, null, null, null, mapUserInfo);
}
return CollectionWithPagingInfo.asPaged(paging, nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
}
use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker in project alfresco-remote-api by Alfresco.
the class RenditionsImpl method getStatus.
private String getStatus(Parameters parameters) {
Query query = parameters.getQuery();
String status = null;
if (query != null) {
// Filtering via "where" clause
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(RENDITION_STATUS_COLLECTION_EQUALS_QUERY_PROPERTIES, null);
QueryHelper.walk(query, propertyWalker);
status = propertyWalker.getProperty(PARAM_STATUS, WhereClauseParser.EQUALS);
}
return status;
}
use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker in project alfresco-remote-api by Alfresco.
the class NodesImpl method buildSearchTypesAndIgnoreAspects.
protected Pair<Set<QName>, Set<QName>> buildSearchTypesAndIgnoreAspects(final Parameters parameters) {
// filters
Boolean includeFolders = null;
Boolean includeFiles = null;
QName filterNodeTypeQName = null;
// note: for files/folders, include subtypes by default (unless filtering by a specific nodeType - see below)
boolean filterIncludeSubTypes = true;
Query q = parameters.getQuery();
if (q != null) {
// filtering via "where" clause
MapBasedQueryWalker propertyWalker = createListChildrenQueryWalker();
QueryHelper.walk(q, propertyWalker);
Boolean isFolder = propertyWalker.getProperty(PARAM_ISFOLDER, WhereClauseParser.EQUALS, Boolean.class);
Boolean isFile = propertyWalker.getProperty(PARAM_ISFILE, WhereClauseParser.EQUALS, Boolean.class);
if (isFolder != null) {
includeFolders = isFolder;
}
if (isFile != null) {
includeFiles = isFile;
}
if (Boolean.TRUE.equals(includeFiles) && Boolean.TRUE.equals(includeFolders)) {
throw new InvalidArgumentException("Invalid filter (isFile=true and isFolder=true) - a node cannot be both a file and a folder");
}
String nodeTypeStr = propertyWalker.getProperty(PARAM_NODETYPE, WhereClauseParser.EQUALS, String.class);
if ((nodeTypeStr != null) && (!nodeTypeStr.isEmpty())) {
if ((isFile != null) || (isFolder != null)) {
throw new InvalidArgumentException("Invalid filter - nodeType and isFile/isFolder are mutually exclusive");
}
Pair<QName, Boolean> pair = parseNodeTypeFilter(nodeTypeStr);
filterNodeTypeQName = pair.getFirst();
filterIncludeSubTypes = pair.getSecond();
}
}
if (filterNodeTypeQName == null) {
if ((includeFiles == null) && (includeFolders == null)) {
// no additional filtering
filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
} else if ((includeFiles != null) && (includeFolders != null)) {
if ((!includeFiles) && (!includeFolders)) {
// no files or folders
filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
}
} else if ((includeFiles != null) && (!includeFiles)) {
// no files
filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
} else if ((includeFolders != null) && (!includeFolders)) {
// no folders
filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
}
}
return buildSearchTypesAndIgnoreAspects(filterNodeTypeQName, filterIncludeSubTypes, ignoreQNames, includeFiles, includeFolders);
}
Aggregations