Search in sources :

Example 11 with MapBasedQueryWalker

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());
}
Also used : QueryParameterDefImpl(org.alfresco.repo.search.QueryParameterDefImpl) Query(org.alfresco.rest.framework.resource.parameters.where.Query) Paging(org.alfresco.rest.framework.resource.parameters.Paging) ArrayList(java.util.ArrayList) ResultSetRow(org.alfresco.service.cmr.search.ResultSetRow) PagingRequest(org.alfresco.query.PagingRequest) SearchParameters(org.alfresco.service.cmr.search.SearchParameters) NodeRef(org.alfresco.service.cmr.repository.NodeRef) MapBasedQueryWalker(org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker) ResultSet(org.alfresco.service.cmr.search.ResultSet) QuickShareLink(org.alfresco.rest.api.model.QuickShareLink) QueryParameterDefinition(org.alfresco.service.cmr.search.QueryParameterDefinition)

Example 12 with MapBasedQueryWalker

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());
}
Also used : Query(org.alfresco.rest.framework.resource.parameters.where.Query) MapBasedQueryWalker(org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker) ModeratedInvitation(org.alfresco.service.cmr.invitation.ModeratedInvitation) Invitation(org.alfresco.service.cmr.invitation.Invitation) InvitationSearchCriteriaImpl(org.alfresco.repo.invitation.InvitationSearchCriteriaImpl)

Aggregations

Query (org.alfresco.rest.framework.resource.parameters.where.Query)12 MapBasedQueryWalker (org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker)12 QName (org.alfresco.service.namespace.QName)5 HashSet (java.util.HashSet)4 FilterProp (org.alfresco.repo.node.getchildren.FilterProp)4 FilterPropBoolean (org.alfresco.repo.node.getchildren.FilterPropBoolean)4 GetChildrenCannedQuery (org.alfresco.repo.node.getchildren.GetChildrenCannedQuery)4 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)4 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 PagingRequest (org.alfresco.query.PagingRequest)3 Paging (org.alfresco.rest.framework.resource.parameters.Paging)3 InvalidParameterException (java.security.InvalidParameterException)2 AbstractList (java.util.AbstractList)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Set (java.util.Set)2 FileInfo (org.alfresco.service.cmr.model.FileInfo)2 QNamePattern (org.alfresco.service.namespace.QNamePattern)2 RegexQNamePattern (org.alfresco.service.namespace.RegexQNamePattern)2 Pair (org.alfresco.util.Pair)2