use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker in project alfresco-remote-api by Alfresco.
the class QuickShareLinksImpl method findLinks.
public CollectionWithPagingInfo<QuickShareLink> findLinks(Parameters parameters) {
checkEnabled();
String queryString = "ASPECT:\"" + QuickShareModel.ASPECT_QSHARE.toString() + "\"";
SearchParameters sp = new SearchParameters();
// note: REST API query parameter (ie. where clause filter) - not to be confused with search query ;-)
Query q = parameters.getQuery();
if (q != null) {
// filtering via "where" clause
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(FIND_SHARED_LINKS_QUERY_PROPERTIES, null);
QueryHelper.walk(q, propertyWalker);
String sharedByUserId = propertyWalker.getProperty(PARAM_SHAREDBY, WhereClauseParser.EQUALS, String.class);
if (sharedByUserId != null) {
if (People.DEFAULT_USER.equalsIgnoreCase(sharedByUserId)) {
sharedByUserId = AuthenticationUtil.getFullyAuthenticatedUser();
}
QueryParameterDefinition qpd = new QueryParameterDefImpl(QuickShareModel.PROP_QSHARE_SHAREDBY, dictionaryService.getDataType(DataTypeDefinition.TEXT), true, sharedByUserId);
sp.addQueryParameterDefinition(qpd);
String qsharedBy = QuickShareModel.PROP_QSHARE_SHAREDBY.toPrefixString(namespaceService);
queryString += " +@" + SearchLanguageConversion.escapeLuceneQuery(qsharedBy) + ":\"${" + qsharedBy + "}\"";
}
}
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery(queryString);
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
Paging paging = parameters.getPaging();
PagingRequest pagingRequest = Util.getPagingRequest(paging);
sp.setSkipCount(pagingRequest.getSkipCount());
sp.setMaxItems(pagingRequest.getMaxItems());
sp.addSort("@" + ContentModel.PROP_MODIFIED, false);
ResultSet results = searchService.query(sp);
List<QuickShareLink> qsLinks = new ArrayList<>(results.length());
List<String> includeParam = parameters.getInclude();
for (ResultSetRow row : results) {
NodeRef nodeRef = row.getNodeRef();
qsLinks.add(getQuickShareInfo(nodeRef, false, includeParam));
}
results.close();
return CollectionWithPagingInfo.asPaged(paging, qsLinks, results.hasMore(), Long.valueOf(results.getNumberFound()).intValue());
}
use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker in project alfresco-remote-api by Alfresco.
the class SiteMembershipRequestsImpl method getPagedSiteMembershipRequests.
@Override
public CollectionWithPagingInfo<SiteMembershipRequest> getPagedSiteMembershipRequests(final Parameters parameters) {
InvitationSearchCriteriaImpl criteria = new InvitationSearchCriteriaImpl();
criteria.setInvitationType(InvitationType.MODERATED);
criteria.setResourceType(ResourceType.WEB_SITE);
// Parse where clause properties.
Query q = parameters.getQuery();
if (q != null) {
// Filtering via "where" clause.
MapBasedQueryWalker propertyWalker = createSiteMembershipRequestQueryWalker();
QueryHelper.walk(q, propertyWalker);
String siteId = propertyWalker.getProperty(PARAM_SITE_ID, WhereClauseParser.EQUALS, String.class);
if (siteId != null && !siteId.isEmpty()) {
criteria.setResourceName(siteId);
}
String personId = propertyWalker.getProperty(PARAM_PERSON_ID, WhereClauseParser.EQUALS, String.class);
if (personId != null && !personId.isEmpty()) {
criteria.setInvitee(personId);
}
}
List<Invitation> invitations = invitationService.searchInvitation(criteria);
return createPagedSiteMembershipRequests(toSiteMembershipRequests(invitations, true), parameters.getPaging());
}
Aggregations