本文整理汇总了Java中org.alfresco.repo.search.impl.querymodel.QueryModelFactory类的典型用法代码示例。如果您正苦于以下问题:Java QueryModelFactory类的具体用法?Java QueryModelFactory怎么用?Java QueryModelFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueryModelFactory类属于org.alfresco.repo.search.impl.querymodel包,在下文中一共展示了QueryModelFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildDisjunction
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
/**
* @param orNode CommonTree
* @param factory QueryModelFactory
* @param functionEvaluationContext FunctionEvaluationContext
* @param selectors Map<String, Selector>
* @param columnMap HashMap<String, Column>
* @return Constraint
*/
private Constraint buildDisjunction(CommonTree orNode, QueryModelFactory factory,
FunctionEvaluationContext functionEvaluationContext, Map<String, Selector> selectors,
HashMap<String, Column> columnMap)
{
List<Constraint> constraints = new ArrayList<Constraint>(orNode.getChildCount());
for (int i = 0; i < orNode.getChildCount(); i++)
{
CommonTree andNode = (CommonTree) orNode.getChild(i);
Constraint constraint = buildConjunction(andNode, factory, functionEvaluationContext, selectors, columnMap);
constraints.add(constraint);
}
if (constraints.size() == 1)
{
return constraints.get(0);
} else
{
return factory.createDisjunction(constraints);
}
}
示例2: buildConjunction
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
/**
* @param andNode CommonTree
* @param factory QueryModelFactory
* @param functionEvaluationContext FunctionEvaluationContext
* @param selectors Map<String, Selector>
* @param columnMap HashMap<String, Column>
* @return Constraint
*/
private Constraint buildConjunction(CommonTree andNode, QueryModelFactory factory,
FunctionEvaluationContext functionEvaluationContext, Map<String, Selector> selectors,
HashMap<String, Column> columnMap)
{
List<Constraint> constraints = new ArrayList<Constraint>(andNode.getChildCount());
for (int i = 0; i < andNode.getChildCount(); i++)
{
CommonTree notNode = (CommonTree) andNode.getChild(i);
Constraint constraint = buildNegation(notNode, factory, functionEvaluationContext, selectors, columnMap);
constraints.add(constraint);
}
if (constraints.size() == 1 && constraints.get(0).getOccur() != Occur.EXCLUDE)
{
return constraints.get(0);
} else
{
return factory.createConjunction(constraints);
}
}
示例3: buildNegation
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
/**
* @param notNode CommonTree
* @param factory QueryModelFactory
* @param functionEvaluationContext FunctionEvaluationContext
* @param selectors Map<String, Selector>
* @param columnMap HashMap<String, Column>
* @return Constraint
*/
private Constraint buildNegation(CommonTree notNode, QueryModelFactory factory,
FunctionEvaluationContext functionEvaluationContext, Map<String, Selector> selectors,
HashMap<String, Column> columnMap)
{
if (notNode.getType() == CMISParser.NEGATION)
{
Constraint constraint = buildTest((CommonTree) notNode.getChild(0), factory, functionEvaluationContext,
selectors, columnMap);
constraint.setOccur(Occur.EXCLUDE);
return constraint;
} else
{
return buildTest(notNode, factory, functionEvaluationContext, selectors, columnMap);
}
}
示例4: buildFTSTest
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
static private Constraint buildFTSTest(CommonTree argNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext,
Selector selector, Map<String, Column> columnMap, String defaultField)
{
CommonTree testNode = argNode;
switch (testNode.getType())
{
case CMIS_FTSParser.DISJUNCTION:
case CMIS_FTSParser.CONJUNCTION:
return buildFTSConnective(testNode, factory, functionEvaluationContext, selector, columnMap, defaultField);
case CMIS_FTSParser.TERM:
return buildTerm(testNode, factory, functionEvaluationContext, selector, columnMap);
case CMIS_FTSParser.PHRASE:
return buildPhrase(testNode, factory, functionEvaluationContext, selector, columnMap);
default:
throw new FTSQueryException("Unsupported FTS option " + testNode.getText());
}
}
示例5: executeQuery
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
public ResultSet executeQuery(SearchParameters searchParameters, ADMLuceneSearcherImpl admLuceneSearcher)
{
String ftsExpression = searchParameters.getQuery();
QueryModelFactory factory = queryEngine.getQueryModelFactory();
AlfrescoFunctionEvaluationContext context = new AlfrescoFunctionEvaluationContext(getNamespacePrefixResolver(admLuceneSearcher), getDictionaryService(admLuceneSearcher),
searchParameters.getNamespace());
QueryOptions options = QueryOptions.create(searchParameters);
FTSParser.Mode mode;
if(options.getDefaultFTSConnective() == Connective.AND)
{
mode = FTSParser.Mode.DEFAULT_CONJUNCTION;
}
else
{
mode = FTSParser.Mode.DEFAULT_DISJUNCTION;
}
Constraint constraint = FTSQueryParser.buildFTS(ftsExpression, factory, context, null, null, mode, options.getDefaultFTSFieldConnective(),
searchParameters.getQueryTemplates(), options.getDefaultFieldName(), FTSQueryParser.RerankPhase.SINGLE_PASS);
org.alfresco.repo.search.impl.querymodel.Query query = factory.createQuery(null, null, constraint, buildOrderings(factory, searchParameters));
QueryEngineResults results = queryEngine.executeQuery(query, options, context);
ResultSet resultSet = results.getResults().values().iterator().next();
return resultSet;
}
示例6: buildTest
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
/**
* @param testNode CommonTree
* @param factory QueryModelFactory
* @param functionEvaluationContext FunctionEvaluationContext
* @param selectors Map<String, Selector>
* @param columnMap HashMap<String, Column>
* @return Constraint
*/
private Constraint buildTest(CommonTree testNode, QueryModelFactory factory,
FunctionEvaluationContext functionEvaluationContext, Map<String, Selector> selectors,
HashMap<String, Column> columnMap)
{
if (testNode.getType() == CMISParser.DISJUNCTION)
{
return buildDisjunction(testNode, factory, functionEvaluationContext, selectors, columnMap);
} else
{
return buildPredicate(testNode, factory, functionEvaluationContext, selectors, columnMap);
}
}
示例7: buildFTS
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
@SuppressWarnings("unused")
static public Constraint buildFTS(String ftsExpression, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext, Selector selector,
Map<String, Column> columnMap, String defaultField)
{
// TODO: Decode sql escape for '' should do in CMIS layer
// parse templates to trees ...
CMIS_FTSParser parser = null;
try
{
CharStream cs = new ANTLRStringStream(ftsExpression);
CMIS_FTSLexer lexer = new CMIS_FTSLexer(cs);
CommonTokenStream tokens = new CommonTokenStream(lexer);
parser = new CMIS_FTSParser(tokens);
CommonTree ftsNode = (CommonTree) parser.cmisFtsQuery().getTree();
return buildFTSConnective(ftsNode, factory, functionEvaluationContext, selector, columnMap, defaultField);
}
catch (RecognitionException e)
{
if (parser != null)
{
String[] tokenNames = parser.getTokenNames();
String hdr = parser.getErrorHeader(e);
String msg = parser.getErrorMessage(e, tokenNames);
throw new FTSQueryException(hdr + "\n" + msg, e);
}
return null;
}
}
示例8: buildPhrase
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
static private Constraint buildPhrase(CommonTree testNode, QueryModelFactory factory,
FunctionEvaluationContext functionEvaluationContext, Selector selector, Map<String, Column> columnMap)
{
String functionName = FTSPhrase.NAME;
Function function = factory.getFunction(functionName);
Map<String, Argument> functionArguments = new LinkedHashMap<String, Argument>();
LiteralArgument larg = factory.createLiteralArgument(FTSPhrase.ARG_PHRASE, DataTypeDefinition.TEXT, getText(testNode.getChild(0)));
functionArguments.put(larg.getName(), larg);
larg = factory.createLiteralArgument(FTSPhrase.ARG_TOKENISATION_MODE, DataTypeDefinition.ANY, AnalysisMode.DEFAULT);
functionArguments.put(larg.getName(), larg);
return factory.createFunctionalConstraint(function, functionArguments);
}
示例9: buildTerm
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
static private Constraint buildTerm(CommonTree testNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext,
Selector selector, Map<String, Column> columnMap)
{
String functionName = FTSTerm.NAME;
Function function = factory.getFunction(functionName);
Map<String, Argument> functionArguments = new LinkedHashMap<String, Argument>();
LiteralArgument larg = factory.createLiteralArgument(FTSTerm.ARG_TERM, DataTypeDefinition.TEXT, getText(testNode.getChild(0)));
functionArguments.put(larg.getName(), larg);
larg = factory.createLiteralArgument(FTSTerm.ARG_TOKENISATION_MODE, DataTypeDefinition.ANY, AnalysisMode.DEFAULT);
functionArguments.put(larg.getName(), larg);
return factory.createFunctionalConstraint(function, functionArguments);
}
示例10: getQueryModelFactory
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
@Override
public QueryModelFactory getQueryModelFactory()
{
return new DBQueryModelFactory();
}
示例11: getQueryModelFactory
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
public QueryModelFactory getQueryModelFactory()
{
return new LuceneQueryModelFactory<org.apache.lucene.search.Query, Sort, ParseException>();
}
示例12: buildFieldReference
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
static public PropertyArgument buildFieldReference(String argumentName, CommonTree fieldReferenceNode, QueryModelFactory factory,
FunctionEvaluationContext functionEvaluationContext, Selector selector, Map<String, Column> columnMap)
{
if (fieldReferenceNode.getType() != FTSParser.FIELD_REF)
{
throw new FTSQueryException("Not column ref ..." + fieldReferenceNode.getText());
}
String fieldName = getText(fieldReferenceNode.getChild(0));
if (columnMap != null)
{
for (Column column : columnMap.values())
{
if (column.getAlias().equals(fieldName))
{
// TODO: Check selector matches ...
PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY);
fieldName = arg.getPropertyName();
break;
}
}
}
// prepend prefixes and name spaces
if (fieldReferenceNode.getChildCount() > 1)
{
CommonTree child = (CommonTree) fieldReferenceNode.getChild(1);
if (child.getType() == FTSParser.PREFIX)
{
fieldName = getText(child.getChild(0)) + ":" + fieldName;
}
else if (child.getType() == FTSParser.NAME_SPACE)
{
fieldName = getText(child.getChild(0)) + fieldName;
}
}
String alias = "";
if (selector != null)
{
functionEvaluationContext.checkFieldApplies(selector, fieldName);
alias = selector.getAlias();
}
return factory.createPropertyArgument(argumentName, functionEvaluationContext.isQueryable(fieldName), functionEvaluationContext.isOrderable(fieldName), alias, fieldName);
}
示例13: buildColumnReference
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
public PropertyArgument buildColumnReference(String argumentName, CommonTree columnReferenceNode,
QueryModelFactory factory, Map<String, Selector> selectors, Map<String, Column> columnMap)
{
String cmisPropertyName = columnReferenceNode.getChild(0).getText();
String qualifier = "";
if (columnReferenceNode.getChildCount() > 1)
{
qualifier = columnReferenceNode.getChild(1).getText();
}
if ((qualifier == "") && (columnMap != null))
{
Column column = columnMap.get(cmisPropertyName);
if (column != null)
{
// check for function type
if (column.getFunction().getName().equals(PropertyAccessor.NAME))
{
PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(
PropertyAccessor.ARG_PROPERTY);
cmisPropertyName = arg.getPropertyName();
qualifier = arg.getSelector();
} else
{
// TODO: should be able to return non property arguments
// The implementation should throw out what it can not
// support at build time.
throw new CmisInvalidArgumentException(
"Complex column reference unsupported (only direct column references are currently supported) "
+ cmisPropertyName);
}
}
}
PropertyDefinitionWrapper propDef = cmisDictionaryService.findPropertyByQueryName(cmisPropertyName);
if (propDef == null)
{
throw new CmisInvalidArgumentException("Unknown column/property " + cmisPropertyName);
}
if (selectors != null)
{
Selector selector = selectors.get(qualifier);
if (selector == null)
{
if ((qualifier.equals("")) && (selectors.size() == 1))
{
selector = selectors.get(selectors.keySet().iterator().next());
} else
{
throw new CmisInvalidArgumentException("No selector for " + qualifier);
}
}
TypeDefinitionWrapper typeDef = cmisDictionaryService.findTypeForClass(selector.getType(), validScopes);
if (typeDef == null)
{
throw new CmisInvalidArgumentException("Type unsupported in CMIS queries: " + selector.getAlias());
}
// Check column/property applies to selector/type
if (typeDef.getPropertyById(propDef.getPropertyId()) == null)
{
throw new CmisInvalidArgumentException("Invalid column for "
+ typeDef.getTypeDefinition(false).getQueryName() + "." + cmisPropertyName);
}
}
if (options.getQueryMode() == CMISQueryMode.CMS_STRICT)
{
if (!propDef.getPropertyDefinition().isQueryable())
{
throw new CmisInvalidArgumentException("Column is not queryable " + qualifier + "." + cmisPropertyName);
}
}
return factory.createPropertyArgument(argumentName, propDef.getPropertyDefinition().isQueryable(), propDef
.getPropertyDefinition().isOrderable(), qualifier, propDef.getPropertyId());
}
示例14: testMapLoneStar
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
public void testMapLoneStar() throws Exception
{
final String ftsExpression = "* AND * AND * AND * AND * AND * AND * AND * AND * AND * AND *";
AlfrescoFunctionEvaluationContext functionContext = new AlfrescoFunctionEvaluationContext(null, null, NamespaceService.CONTENT_MODEL_1_0_URI);
Map<String, String> templates = new HashMap<String, String>();
String keywordsTemplate = "%(cm:name cm:title cm:description ia:whatEvent ia:descriptionEvent lnk:title lnk:description TEXT TAG)";
String keywordsKey = "keywords";
templates.put(keywordsKey, keywordsTemplate);
final FTSParser.Mode mode = FTSParser.Mode.DEFAULT_DISJUNCTION;
final Connective defaultFieldConnective = Connective.OR;
class TestMock extends FTSQueryParser.TestNodeBuilder
{
private void test(CommonTree initialNode, CommonTree replacedNode)
{
if (initialNode.getType() == FTSParser.TERM &&
initialNode.getChildCount() == 1 &&
initialNode.getChild(0).getType() == FTSParser.STAR)
{
// input is the lone star
Tree node = replacedNode;
while (true)
{
if (node.getChildCount() == 1)
{
node = node.getChild(0);
if (node.getType() == FTSParser.TERM)
{
assertEquals("Lone star should be mapped to " + FTSQueryParser.VALUE_REPLACELONESTAR, node.getChildCount(), 2);
Tree child1 = node.getChild(0);
assertEquals("Lone star should be mapped to " + FTSQueryParser.VALUE_REPLACELONESTAR, child1.getType(), FTSParser.ID);
assertEquals("Lone star should be mapped to " + FTSQueryParser.VALUE_REPLACELONESTAR, child1.getText(), "T");
Tree child2 = node.getChild(1);
assertEquals("Lone star should be mapped to " + FTSQueryParser.VALUE_REPLACELONESTAR, child2.getType(), FTSParser.FIELD_REF);
assertEquals("Lone star should be mapped to " + FTSQueryParser.VALUE_REPLACELONESTAR, child2.getChild(0).getText(), "ISNODE");
// checking done
break;
}
}
else
{
// wrong structure of the replaced node
fail("Lone star should be mapped to " + FTSQueryParser.VALUE_REPLACELONESTAR);
}
}
}
}
@Override
protected CommonTree build(CommonTree fieldReferenceNode, CommonTree argNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext,
Selector selector, Map<String, Column> columnMap, Map<String, CommonTree> templateTrees, String defaultField)
{
CommonTree testNode = super.build(fieldReferenceNode, argNode, factory, functionEvaluationContext, selector, columnMap, templateTrees, defaultField);
test(argNode, testNode);
return testNode;
}
}
FTSQueryParser.setTestNodeBuilder(new TestMock());
try
{
FTSQueryParser.buildFTS(ftsExpression, new LuceneQueryModelFactory(), functionContext, null, null,
mode, defaultFieldConnective, templates, keywordsKey, FTSQueryParser.RerankPhase.SINGLE_PASS);
}
finally
{
// set default logic
FTSQueryParser.setTestNodeBuilder(new FTSQueryParser.TestNodeBuilder());
}
}
示例15: buildFTSConnective
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; //导入依赖的package包/类
static private Constraint buildFTSConnective(CommonTree node, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext,
Selector selector, Map<String, Column> columnMap, String defaultField)
{
Connective connective;
switch (node.getType())
{
case CMIS_FTSParser.DISJUNCTION:
connective = Connective.OR;
break;
case CMIS_FTSParser.CONJUNCTION:
connective = Connective.AND;
break;
default:
throw new FTSQueryException("Invalid connective ..." + node.getText());
}
List<Constraint> constraints = new ArrayList<Constraint>(node.getChildCount());
CommonTree testNode;
for (int i = 0; i < node.getChildCount(); i++)
{
CommonTree subNode = (CommonTree) node.getChild(i);
Constraint constraint;
switch (subNode.getType())
{
case CMIS_FTSParser.DISJUNCTION:
case CMIS_FTSParser.CONJUNCTION:
constraint = buildFTSConnective(subNode, factory, functionEvaluationContext, selector, columnMap, defaultField);
break;
case CMIS_FTSParser.DEFAULT:
testNode = (CommonTree) subNode.getChild(0);
constraint = buildFTSTest(testNode, factory, functionEvaluationContext, selector, columnMap, defaultField);
constraint.setOccur(Occur.DEFAULT);
break;
case CMIS_FTSParser.EXCLUDE:
testNode = (CommonTree) subNode.getChild(0);
constraint = buildFTSTest(testNode, factory, functionEvaluationContext, selector, columnMap, defaultField);
constraint.setOccur(Occur.EXCLUDE);
break;
default:
throw new FTSQueryException("Unsupported FTS option " + subNode.getText());
}
constraints.add(constraint);
}
if (constraints.size() == 1)
{
return constraints.get(0);
}
else
{
if (connective == Connective.OR)
{
return factory.createDisjunction(constraints);
}
else
{
return factory.createConjunction(constraints);
}
}
}