mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Datamodel fix for SEARCH-312 Support query templates in the CONTAINS() clause of CMIS QL
MNT-14506 Templates ignored for CMIS queries
This commit is contained in:
@@ -82,6 +82,11 @@ public class CMISQueryOptions extends QueryOptions
|
|||||||
options.setBulkFetchEnabled(searchParameters.isBulkFetchEnabled());
|
options.setBulkFetchEnabled(searchParameters.isBulkFetchEnabled());
|
||||||
options.setExcludeTenantFilter(searchParameters.getExcludeTenantFilter());
|
options.setExcludeTenantFilter(searchParameters.getExcludeTenantFilter());
|
||||||
options.setSinceTxId(searchParameters.getSinceTxId());
|
options.setSinceTxId(searchParameters.getSinceTxId());
|
||||||
|
for(String name : searchParameters.getQueryTemplates().keySet())
|
||||||
|
{
|
||||||
|
String template = searchParameters.getQueryTemplates().get(name);
|
||||||
|
options.addQueryTemplate(name, template);
|
||||||
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,6 +193,11 @@ public class CMISQueryOptions extends QueryOptions
|
|||||||
searchParameters.setBulkFetchEnabled(isBulkFetchEnabled());
|
searchParameters.setBulkFetchEnabled(isBulkFetchEnabled());
|
||||||
searchParameters.setQueryConsistency(this.getQueryConsistency());
|
searchParameters.setQueryConsistency(this.getQueryConsistency());
|
||||||
searchParameters.setSinceTxId(getSinceTxId());
|
searchParameters.setSinceTxId(getSinceTxId());
|
||||||
|
for(String name : getQueryTemplates().keySet())
|
||||||
|
{
|
||||||
|
String template = getQueryTemplates().get(name);
|
||||||
|
searchParameters.addQueryTemplate(name, template);
|
||||||
|
}
|
||||||
return searchParameters;
|
return searchParameters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -477,7 +477,7 @@ public class CMISQueryParser
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
ftsConstraint = FTSQueryParser.buildFTS(ftsExpression, factory, functionEvaluationContext, selector,
|
ftsConstraint = FTSQueryParser.buildFTS(ftsExpression, factory, functionEvaluationContext, selector,
|
||||||
columnMap, mode, defaultFieldConnective, null, options.getDefaultFieldName(), FTSQueryParser.RerankPhase.SINGLE_PASS);
|
columnMap, mode, defaultFieldConnective, options.getQueryTemplates(), options.getDefaultFieldName(), FTSQueryParser.RerankPhase.SINGLE_PASS);
|
||||||
}
|
}
|
||||||
ftsConstraint.setBoost(1000.0f);
|
ftsConstraint.setBoost(1000.0f);
|
||||||
hasContains = true;
|
hasContains = true;
|
||||||
|
@@ -26,8 +26,10 @@
|
|||||||
package org.alfresco.repo.search.impl.querymodel;
|
package org.alfresco.repo.search.impl.querymodel;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.repo.search.MLAnalysisMode;
|
import org.alfresco.repo.search.MLAnalysisMode;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
@@ -90,6 +92,8 @@ public class QueryOptions
|
|||||||
|
|
||||||
private Long sinceTxId;
|
private Long sinceTxId;
|
||||||
|
|
||||||
|
private Map<String, String> queryTemplates = new HashMap<String, String>();
|
||||||
|
|
||||||
public static QueryOptions create(SearchParameters searchParameters)
|
public static QueryOptions create(SearchParameters searchParameters)
|
||||||
{
|
{
|
||||||
QueryOptions options = new QueryOptions(searchParameters.getQuery(), null);
|
QueryOptions options = new QueryOptions(searchParameters.getQuery(), null);
|
||||||
@@ -119,8 +123,16 @@ public class QueryOptions
|
|||||||
options.setExcludeTenantFilter(searchParameters.getExcludeTenantFilter());
|
options.setExcludeTenantFilter(searchParameters.getExcludeTenantFilter());
|
||||||
options.setQueryConsistency(searchParameters.getQueryConsistency());
|
options.setQueryConsistency(searchParameters.getQueryConsistency());
|
||||||
options.setSinceTxId(searchParameters.getSinceTxId());
|
options.setSinceTxId(searchParameters.getSinceTxId());
|
||||||
|
for(String name : searchParameters.getQueryTemplates().keySet())
|
||||||
|
{
|
||||||
|
String template = searchParameters.getQueryTemplates().get(name);
|
||||||
|
options.addQueryTemplate(name, template);
|
||||||
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a CMISQueryOptions instance with the default options other than the query and store ref. The query will be
|
* Create a CMISQueryOptions instance with the default options other than the query and store ref. The query will be
|
||||||
* run using the locale returned by I18NUtil.getLocale()
|
* run using the locale returned by I18NUtil.getLocale()
|
||||||
@@ -506,6 +518,30 @@ public class QueryOptions
|
|||||||
this.sinceTxId = sinceTxId;
|
this.sinceTxId = sinceTxId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the query templates
|
||||||
|
*
|
||||||
|
* @return - the query templates
|
||||||
|
*/
|
||||||
|
public Map<String, String> getQueryTemplates()
|
||||||
|
{
|
||||||
|
return queryTemplates;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add/replace a query template Not all languages support query templates
|
||||||
|
*
|
||||||
|
* @param name String
|
||||||
|
* @param template String
|
||||||
|
* @return any removed template or null
|
||||||
|
*/
|
||||||
|
public String addQueryTemplate(String name, String template)
|
||||||
|
{
|
||||||
|
return queryTemplates.put(name, template);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return SearchParameters
|
* @return SearchParameters
|
||||||
*/
|
*/
|
||||||
@@ -548,6 +584,12 @@ public class QueryOptions
|
|||||||
//searchParameters.addTextAttribute()
|
//searchParameters.addTextAttribute()
|
||||||
searchParameters.setQueryConsistency(this.getQueryConsistency());
|
searchParameters.setQueryConsistency(this.getQueryConsistency());
|
||||||
searchParameters.setSinceTxId(getSinceTxId());
|
searchParameters.setSinceTxId(getSinceTxId());
|
||||||
|
for(String name : getQueryTemplates().keySet())
|
||||||
|
{
|
||||||
|
String template = getQueryTemplates().get(name);
|
||||||
|
searchParameters.addQueryTemplate(name, template);
|
||||||
|
}
|
||||||
|
|
||||||
return searchParameters;
|
return searchParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user