Java Code Examples for org.alfresco.service.cmr.search.SearchParameters#copy()
The following examples show how to use
org.alfresco.service.cmr.search.SearchParameters#copy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SortConstraint.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected SearchParameters applyDecorations(ActualEnvironment environment, SearchParameters searchParameters, VirtualQuery query) { SearchParameters searchParametersCopy = searchParameters.copy(); for (Pair<QName, Boolean> sort : sortProps) { if (!IGNORED_SORT_PROPERTIES.contains(sort.getFirst())) { SortDefinition sortDefinition = new SortDefinition(SortType.FIELD, sort.getFirst().getPrefixString(), sort.getSecond()); searchParametersCopy.addSort(sortDefinition); } } return searchParametersCopy; }
Example 2
Source File: PropertyValueConstraint.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public SearchParameters applyDecorations(ActualEnvironment environment, SearchParameters searchParameters, VirtualQuery query) throws VirtualizationException { // TODO: allow custom language and not only constraint appliers if (SearchService.LANGUAGE_FTS_ALFRESCO.equals(searchParameters.getLanguage())) { SearchParameters searchParametersCopy = searchParameters.copy(); return applyFTS(searchParametersCopy); } else { throw new VirtualizationException("Unsupported constrating language " + searchParameters.getLanguage()); } }
Example 3
Source File: IgnoreConstraint.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected SearchParameters applyDecorations(ActualEnvironment environment, SearchParameters searchParameters, VirtualQuery query) { if ((ignoreAspectQNames != null && !ignoreAspectQNames.isEmpty()) || (ignoreTypeNames != null && !ignoreTypeNames.isEmpty())) { if (SearchService.LANGUAGE_FTS_ALFRESCO.equals(searchParameters.getLanguage())) { SearchParameters searchParametersCopy = searchParameters.copy(); return applyFTSDecorations(searchParametersCopy, environment.getNamespacePrefixResolver()); } else { throw new VirtualizationException("Unsupported constrating language " + searchParameters.getLanguage()); } } else { return searchParameters; } }
Example 4
Source File: IgnoreConstraint.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private SearchParameters applyFTSDecorations(SearchParameters searchParameters, NamespacePrefixResolver nspResolver) { SearchParameters constrainedParameters = searchParameters.copy(); String theQuery = constrainedParameters.getQuery(); theQuery = "(" + theQuery + ")"; if (ignoreAspectQNames != null) { for (QName ignoredAspect : ignoreAspectQNames) { theQuery = theQuery + " and " + "!ASPECT:'" + ignoredAspect.toPrefixString(nspResolver) + "'"; } } if (ignoreTypeNames != null) { for (QName ignoredType : ignoreTypeNames) { theQuery = theQuery + " and " + "!TYPE:'" + ignoredType.toPrefixString(nspResolver) + "'"; } } constrainedParameters.setQuery(theQuery); return constrainedParameters; }
Example 5
Source File: SolrXPathQueryLanguage.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ResultSet executeQuery(SearchParameters searchParameters) { String query = "PATH:\""+searchParameters.getQuery()+"\""; SearchParameters sp = searchParameters.copy(); sp.setLanguage(SearchService.LANGUAGE_SOLR_FTS_ALFRESCO); sp.setQuery(query); return solrQueryLanguage.executeQuery(sp); }
Example 6
Source File: DbOrIndexSwitchingQueryLanguage.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private SearchParameters flattenDBQuery(SearchParameters sp) { if (sp.getFilterQueries().size() == 0) { return sp; } else { SearchParameters flatten = sp.copy(); StringBuilder queryBuilder = new StringBuilder(); queryBuilder.append("( ").append(sp.getQuery()).append(" )"); for(String filter : sp.getFilterQueries()) { Matcher matcher = LuceneQueryLanguageSPI.AFTS_QUERY.matcher(filter); if (matcher.find()) { queryBuilder.append("AND ( ").append(matcher.group(2)).append(" )"); } else { queryBuilder.append("AND ( ").append(filter).append(" )"); } } flatten.setQuery(queryBuilder.toString()); // the filter can be left and will be ignored by the DB query return flatten; } }
Example 7
Source File: PagingRequestConstraint.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected SearchParameters applyDecorations(ActualEnvironment environment, SearchParameters searchParameters, VirtualQuery query) { SearchParameters searchParametersCopy = searchParameters.copy(); if (pagingRequest != null) { searchParametersCopy.setSkipCount(pagingRequest.getSkipCount()); searchParametersCopy.setMaxItems(pagingRequest.getMaxItems()); } return searchParametersCopy; }
Example 8
Source File: NamePatternPropertyValueConstraint.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected SearchParameters applyFTS(SearchParameters searchParameters) { String filePattern; StringBuffer luceneReserved = new StringBuffer(); for(int i=0;i<value.toString().length();i++){ if(SearchLanguageConversion.DEF_LUCENE.isReserved(value.toString().charAt(i))){ luceneReserved.append(value.toString().charAt(i)); } } String luceneReservedStr=luceneReserved.toString(); String pattern =org.alfresco.util.ISO9075.encode(value.toString()); for (int i = 0; i < luceneReservedStr.length(); i++) { pattern = pattern.replace(org.alfresco.util.ISO9075.encode(luceneReservedStr.substring(i,i + 1)), luceneReservedStr.substring(i,i + 1)); } filePattern=SearchLanguageConversion.escapeForLucene(pattern); SearchParameters constrainedParameters = searchParameters.copy(); String theQuery = constrainedParameters.getQuery(); StringBuilder sb = new StringBuilder(); sb.append("(" + theQuery + ")"); sb.append(" and ("); sb.append("TEXT:(").append(filePattern).append(") "); sb.append("or ("); sb.append(" =").append(property.toPrefixString(this.nspResolver)); sb.append(":").append(filePattern); sb.append(" ) "); sb.append(")"); theQuery = sb.toString(); constrainedParameters.setQuery(theQuery); return constrainedParameters; }
Example 9
Source File: FilesFoldersConstraint.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected SearchParameters applyDecorations(ActualEnvironment environment, SearchParameters searchParameters, VirtualQuery query) { String queryString = searchParameters.getQuery(); String language = searchParameters.getLanguage(); String filteredQuery = filter(language, queryString, files, folders); SearchParameters searchParametersCopy = searchParameters.copy(); searchParametersCopy.setQuery(filteredQuery); return searchParametersCopy; }
Example 10
Source File: PropertyValueConstraint.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
protected SearchParameters applyFTS(SearchParameters searchParameters) { SearchParameters constrainedParameters = searchParameters.copy(); String theQuery = constrainedParameters.getQuery(); // TODO: introduce and use operator theQuery = "(" + theQuery + ")" + " and " + "( " + "=" + property.toPrefixString(this.nspResolver) + ":" +"\""+value.toString() + "\" )"; constrainedParameters.setQuery(theQuery); return constrainedParameters; }