Search in sources :

Example 1 with QueryParameterDefImpl

use of org.alfresco.repo.search.QueryParameterDefImpl in project acs-community-packaging by Alfresco.

the class AbstractClipboardItem method checkExists.

protected boolean checkExists(String name, NodeRef parent) {
    QueryParameterDefinition[] params = new QueryParameterDefinition[1];
    params[0] = new QueryParameterDefImpl(ContentModel.PROP_NAME, getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.TEXT), true, name);
    // execute the query
    List<NodeRef> nodeRefs = getServiceRegistry().getSearchService().selectNodes(parent, XPATH_QUERY_NODE_MATCH, params, getServiceRegistry().getNamespaceService(), false);
    return (nodeRefs.size() != 0);
}
Also used : QueryParameterDefImpl(org.alfresco.repo.search.QueryParameterDefImpl) NodeRef(org.alfresco.service.cmr.repository.NodeRef) QueryParameterDefinition(org.alfresco.service.cmr.search.QueryParameterDefinition)

Example 2 with QueryParameterDefImpl

use of org.alfresco.repo.search.QueryParameterDefImpl 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)

Aggregations

QueryParameterDefImpl (org.alfresco.repo.search.QueryParameterDefImpl)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 QueryParameterDefinition (org.alfresco.service.cmr.search.QueryParameterDefinition)2 ArrayList (java.util.ArrayList)1 PagingRequest (org.alfresco.query.PagingRequest)1 QuickShareLink (org.alfresco.rest.api.model.QuickShareLink)1 Paging (org.alfresco.rest.framework.resource.parameters.Paging)1 Query (org.alfresco.rest.framework.resource.parameters.where.Query)1 MapBasedQueryWalker (org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker)1 ResultSet (org.alfresco.service.cmr.search.ResultSet)1 ResultSetRow (org.alfresco.service.cmr.search.ResultSetRow)1 SearchParameters (org.alfresco.service.cmr.search.SearchParameters)1