mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (Cloud33/4.3) to HEAD (Cloud33/4.3)
62901: Merged PLATFORM1 (Cloud33) to HEAD-BUG-FIX (Cloud33/4.3) 61252: ACE-479 Provide Search Adapter - Reintegrated BRANCHES/DEV/PLATFORM1 from BRANCHES/DEV/PLATFORM1-AHIND git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62955 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -23,15 +23,14 @@ import java.util.Collection;
|
||||
|
||||
import org.alfresco.cmis.CMISPropertyAccessor;
|
||||
import org.alfresco.opencmis.dictionary.CMISPropertyLuceneBuilder;
|
||||
import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneFunction;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParserAdaptor;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParserExpressionAdaptor;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
||||
/**
|
||||
* Base class for all property accessors
|
||||
@@ -84,54 +83,66 @@ public abstract class AbstractProperty implements CMISPropertyAccessor, CMISProp
|
||||
return null;
|
||||
}
|
||||
|
||||
public Query buildLuceneEquality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Query buildLuceneExists(AbstractLuceneQueryParser lqp, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, Boolean not) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Query buildLuceneGreaterThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Query buildLuceneGreaterThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Query buildLuceneIn(AbstractLuceneQueryParser lqp, Collection<Serializable> values, Boolean not,
|
||||
PredicateMode mode) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneIn(LuceneQueryParserAdaptor<Q, S, E> lqpa, Collection<Serializable> values, Boolean not,
|
||||
PredicateMode mode) throws E
|
||||
{
|
||||
LuceneQueryParserExpressionAdaptor<Q, E> expressionAdaptor = lqpa.getExpressionAdaptor();
|
||||
for(Serializable value : values)
|
||||
{
|
||||
expressionAdaptor.addOptional(buildLuceneEquality(lqpa, value, mode, LuceneFunction.FIELD));
|
||||
}
|
||||
if(not)
|
||||
{
|
||||
return expressionAdaptor.getNegatedQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return expressionAdaptor.getQuery();
|
||||
}
|
||||
}
|
||||
|
||||
public <Q, S, E extends Throwable> Q buildLuceneInequality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return lqpa.getNegatedQuery(buildLuceneEquality(lqpa, value, mode, luceneFunction));
|
||||
}
|
||||
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Query buildLuceneInequality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Query buildLuceneLessThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws ParseException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Query buildLuceneLessThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws ParseException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Query buildLuceneLike(AbstractLuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, Boolean not) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -141,7 +152,7 @@ public abstract class AbstractProperty implements CMISPropertyAccessor, CMISProp
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String getLuceneSortField(AbstractLuceneQueryParser lqp)
|
||||
public <Q, S, E extends Throwable> String getLuceneSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa) throws E
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
@@ -21,21 +21,14 @@ package org.alfresco.cmis.mapping;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.lucene.AnalysisMode;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneFunction;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParserAdaptor;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
|
||||
/**
|
||||
* Common support for lucene query building.
|
||||
@@ -71,24 +64,24 @@ public abstract class AbstractSimpleProperty extends AbstractProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneEquality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return lqp.getFieldQuery(getLuceneFieldName(), getValueAsString(value), AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
return lqpa.getFieldQuery(getLuceneFieldName(), getValueAsString(value), AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean)
|
||||
*/
|
||||
public Query buildLuceneExists(AbstractLuceneQueryParser lqp, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, Boolean not) throws E
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
return lqp.getFieldQuery("ISNULL", getQNameForExists().toString(), AnalysisMode.DEFAULT, LuceneFunction.FIELD);
|
||||
return lqpa.getFieldQuery("ISNULL", getQNameForExists().toString(), AnalysisMode.DEFAULT, LuceneFunction.FIELD);
|
||||
}
|
||||
else
|
||||
{
|
||||
return lqp.getFieldQuery("ISNOTNULL", getQNameForExists().toString(), AnalysisMode.DEFAULT, LuceneFunction.FIELD);
|
||||
return lqpa.getFieldQuery("ISNOTNULL", getQNameForExists().toString(), AnalysisMode.DEFAULT, LuceneFunction.FIELD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,144 +89,68 @@ public abstract class AbstractSimpleProperty extends AbstractProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneGreaterThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
return lqp.getRangeQuery(field, stringValue, getRangeMax(), false, true, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
return lqpa.getRangeQuery(field, stringValue, getRangeMax(), false, true, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneGreaterThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
return lqp.getRangeQuery(field, stringValue, getRangeMax(), true, true, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneIn(AbstractLuceneQueryParser lqp, Collection<Serializable> values, Boolean not, PredicateMode mode) throws ParseException
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
|
||||
// Check type conversion
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Object converted = DefaultTypeConverter.INSTANCE.convert(getInDataType(), values);
|
||||
Collection<String> asStrings = DefaultTypeConverter.INSTANCE.convert(String.class, values);
|
||||
|
||||
if (asStrings.size() == 0)
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
}
|
||||
else if (asStrings.size() == 1)
|
||||
{
|
||||
String value = asStrings.iterator().next();
|
||||
if (not)
|
||||
{
|
||||
return lqp.getDoesNotMatchFieldQuery(field, value, AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
}
|
||||
else
|
||||
{
|
||||
return lqp.getFieldQuery(field, value, AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BooleanQuery booleanQuery = new BooleanQuery();
|
||||
if (not)
|
||||
{
|
||||
booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
}
|
||||
for (String value : asStrings)
|
||||
{
|
||||
Query any = lqp.getFieldQuery(field, value, AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
if (not)
|
||||
{
|
||||
booleanQuery.add(any, Occur.MUST_NOT);
|
||||
}
|
||||
else
|
||||
{
|
||||
booleanQuery.add(any, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
return booleanQuery;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneInequality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
return lqp.getDoesNotMatchFieldQuery(field, stringValue, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
return lqpa.getRangeQuery(field, stringValue, getRangeMax(), true, true, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneLessThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
return lqp.getRangeQuery(field, getRangeMin(), stringValue, true, false, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
return lqpa.getRangeQuery(field, getRangeMin(), stringValue, true, false, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneLessThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
return lqp.getRangeQuery(field, getRangeMin(), stringValue, true, true, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
return lqpa.getRangeQuery(field, getRangeMin(), stringValue, true, true, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean)
|
||||
*/
|
||||
public Query buildLuceneLike(AbstractLuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, Boolean not) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
|
||||
Q q = lqpa.getLikeQuery(field, stringValue, AnalysisMode.IDENTIFIER);
|
||||
if (not)
|
||||
{
|
||||
BooleanQuery booleanQuery = new BooleanQuery();
|
||||
booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
booleanQuery.add(lqp.getLikeQuery(field, stringValue, AnalysisMode.IDENTIFIER), Occur.MUST_NOT);
|
||||
return booleanQuery;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lqp.getLikeQuery(field, stringValue, AnalysisMode.IDENTIFIER);
|
||||
q = lqpa.getNegatedQuery(q);
|
||||
}
|
||||
return q;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField()
|
||||
*/
|
||||
public String getLuceneSortField(AbstractLuceneQueryParser lqp)
|
||||
public <Q, S, E extends Throwable> String getLuceneSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa) throws E
|
||||
{
|
||||
return getLuceneFieldName();
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.lucene.AnalysisMode;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneFunction;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParserAdaptor;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
@@ -35,7 +36,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
@@ -80,83 +80,21 @@ public class BaseTypeIdProperty extends AbstractProperty
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query buildLuceneEquality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return lqp.getFieldQuery("TYPE", getBaseType(getValueAsString(value)), AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
return lqpa.getFieldQuery("TYPE", getBaseType(getValueAsString(value)), AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query buildLuceneInequality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
{
|
||||
return lqp.getDoesNotMatchFieldQuery("TYPE", getBaseType(getValueAsString(value)), AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query buildLuceneIn(AbstractLuceneQueryParser lqp, Collection<Serializable> values, Boolean not, PredicateMode mode) throws ParseException
|
||||
{
|
||||
String field = "TYPE";
|
||||
|
||||
// Check type conversion
|
||||
|
||||
|
||||
Collection<String> asStrings = DefaultTypeConverter.INSTANCE.convert(String.class, values);
|
||||
|
||||
if (asStrings.size() == 0)
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
}
|
||||
else if (asStrings.size() == 1)
|
||||
{
|
||||
String value = asStrings.iterator().next();
|
||||
if (not)
|
||||
{
|
||||
return lqp.getDoesNotMatchFieldQuery(field, getBaseType(value), AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
}
|
||||
else
|
||||
{
|
||||
return lqp.getFieldQuery(field, getBaseType(value), AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BooleanQuery booleanQuery = new BooleanQuery();
|
||||
if (not)
|
||||
{
|
||||
booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
}
|
||||
for (String value : asStrings)
|
||||
{
|
||||
Query any = lqp.getFieldQuery(field, getBaseType(value), AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
if (not)
|
||||
{
|
||||
booleanQuery.add(any, Occur.MUST_NOT);
|
||||
}
|
||||
else
|
||||
{
|
||||
booleanQuery.add(any, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
return booleanQuery;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query buildLuceneExists(AbstractLuceneQueryParser lqp, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, Boolean not) throws E
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
return lqpa.getMatchAllQuery();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,10 +24,8 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.alfresco.repo.dictionary.IndexTokenisationMode;
|
||||
import org.alfresco.repo.search.MLAnalysisMode;
|
||||
import org.alfresco.repo.search.SearcherException;
|
||||
import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParserAdaptor;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
@@ -36,7 +34,7 @@ import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.lucene.index.IndexReader.FieldOption;
|
||||
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
@@ -91,7 +89,7 @@ public class DirectProperty extends AbstractSimpleProperty
|
||||
* @see org.alfresco.cmis.mapping.AbstractSimpleProperty#getLuceneSortField()
|
||||
*/
|
||||
@Override
|
||||
public String getLuceneSortField(AbstractLuceneQueryParser lqp)
|
||||
public <Q, S, E extends Throwable> String getLuceneSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa) throws E
|
||||
{
|
||||
|
||||
String field = getLuceneFieldName();
|
||||
@@ -102,30 +100,67 @@ public class DirectProperty extends AbstractSimpleProperty
|
||||
|
||||
if (propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT))
|
||||
{
|
||||
throw new SearcherException("Order on content properties is not curently supported");
|
||||
throw new CmisInvalidArgumentException("Order on content properties is not curently supported");
|
||||
}
|
||||
else if(propertyDef.getDataType().getName().equals(DataTypeDefinition.TEXT))
|
||||
else if ((propertyDef.getDataType().getName().equals(DataTypeDefinition.MLTEXT)) || (propertyDef.getDataType().getName().equals(DataTypeDefinition.TEXT)))
|
||||
{
|
||||
if(propertyDef.getIndexTokenisationMode() == IndexTokenisationMode.FALSE)
|
||||
{
|
||||
return field;
|
||||
}
|
||||
|
||||
String noLocalField = field+".no_locale";
|
||||
for (Object current : lqp.getIndexReader().getFieldNames(FieldOption.INDEXED))
|
||||
{
|
||||
String currentString = (String) current;
|
||||
if (currentString.equals(noLocalField))
|
||||
{
|
||||
return noLocalField;
|
||||
}
|
||||
}
|
||||
|
||||
return findSortField(lqp, field);
|
||||
}
|
||||
else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.MLTEXT))
|
||||
{
|
||||
field = findSortField(lqp, field);
|
||||
// List<Locale> locales = lqpa.getSearchParameters().getLocales();
|
||||
// if (((locales == null) || (locales.size() == 0)))
|
||||
// {
|
||||
// locales = Collections.singletonList(I18NUtil.getLocale());
|
||||
// }
|
||||
//
|
||||
// if (locales.size() > 1)
|
||||
// {
|
||||
// throw new CmisInvalidArgumentException("Order on text/mltext properties with more than one locale is not curently supported");
|
||||
// }
|
||||
//
|
||||
// sortLocale = locales.get(0);
|
||||
// // find best field match
|
||||
//
|
||||
// HashSet<String> allowableLocales = new HashSet<String>();
|
||||
// MLAnalysisMode analysisMode = lqpa.getDefaultSearchMLAnalysisMode();
|
||||
// for (Locale l : MLAnalysisMode.getLocales(analysisMode, sortLocale, false))
|
||||
// {
|
||||
// allowableLocales.add(l.toString());
|
||||
// }
|
||||
|
||||
field = lqpa.getSortField(field);
|
||||
// String sortField = field;
|
||||
//
|
||||
// for (Object current : lqp.getIndexReader().getFieldNames(FieldOption.INDEXED))
|
||||
// {
|
||||
// String currentString = (String) current;
|
||||
// if (currentString.startsWith(field) && currentString.endsWith(".sort"))
|
||||
// {
|
||||
// String fieldLocale = currentString.substring(field.length() + 1, currentString.length() - 5);
|
||||
// if (allowableLocales.contains(fieldLocale))
|
||||
// {
|
||||
// if (fieldLocale.equals(sortLocale.toString()))
|
||||
// {
|
||||
// sortField = currentString;
|
||||
// break;
|
||||
// }
|
||||
// else if (sortLocale.toString().startsWith(fieldLocale))
|
||||
// {
|
||||
// if (sortField.equals(field) || (currentString.length() < sortField.length()))
|
||||
// {
|
||||
// sortField = currentString;
|
||||
// }
|
||||
// }
|
||||
// else if (fieldLocale.startsWith(sortLocale.toString()))
|
||||
// {
|
||||
// if (sortField.equals(field) || (currentString.length() < sortField.length()))
|
||||
// {
|
||||
// sortField = currentString;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// field = sortField;
|
||||
|
||||
}
|
||||
else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DATETIME))
|
||||
{
|
||||
@@ -144,66 +179,68 @@ public class DirectProperty extends AbstractSimpleProperty
|
||||
* @param field
|
||||
* @return
|
||||
*/
|
||||
private String findSortField(AbstractLuceneQueryParser lqp, String field)
|
||||
{
|
||||
Locale sortLocale;
|
||||
List<Locale> locales = lqp.getSearchParameters().getLocales();
|
||||
if (((locales == null) || (locales.size() == 0)))
|
||||
{
|
||||
locales = Collections.singletonList(I18NUtil.getLocale());
|
||||
}
|
||||
|
||||
if (locales.size() > 1)
|
||||
{
|
||||
throw new SearcherException("Order on text/mltext properties with more than one locale is not curently supported");
|
||||
}
|
||||
|
||||
sortLocale = locales.get(0);
|
||||
// find best field match
|
||||
|
||||
HashSet<String> allowableLocales = new HashSet<String>();
|
||||
MLAnalysisMode analysisMode = lqp.getDefaultSearchMLAnalysisMode();
|
||||
for (Locale l : MLAnalysisMode.getLocales(analysisMode, sortLocale, false))
|
||||
{
|
||||
allowableLocales.add(l.toString());
|
||||
}
|
||||
|
||||
String sortField = field;
|
||||
|
||||
for (Object current : lqp.getIndexReader().getFieldNames(FieldOption.INDEXED))
|
||||
{
|
||||
String currentString = (String) current;
|
||||
if (currentString.startsWith(field) && currentString.endsWith(".sort"))
|
||||
{
|
||||
String fieldLocale = currentString.substring(field.length() + 1, currentString.length() - 5);
|
||||
if (allowableLocales.contains(fieldLocale))
|
||||
{
|
||||
if (fieldLocale.equals(sortLocale.toString()))
|
||||
{
|
||||
sortField = currentString;
|
||||
break;
|
||||
}
|
||||
else if (sortLocale.toString().startsWith(fieldLocale))
|
||||
{
|
||||
if (sortField.equals(field) || (currentString.length() < sortField.length()))
|
||||
{
|
||||
sortField = currentString;
|
||||
}
|
||||
}
|
||||
else if (fieldLocale.startsWith(sortLocale.toString()))
|
||||
{
|
||||
if (sortField.equals(field) || (currentString.length() < sortField.length()))
|
||||
{
|
||||
sortField = currentString;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
field = sortField;
|
||||
return field;
|
||||
}
|
||||
// private <Q, S, E extends Throwable> String findSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa, String field)
|
||||
// {
|
||||
// Locale sortLocale;
|
||||
// List<Locale> locales = lqpa.getSearchParameters().getLocales();
|
||||
// if (((locales == null) || (locales.size() == 0)))
|
||||
// {
|
||||
// locales = Collections.singletonList(I18NUtil.getLocale());
|
||||
// }
|
||||
//
|
||||
// if (locales.size() > 1)
|
||||
// {
|
||||
// throw new SearcherException("Order on text/mltext properties with more than one locale is not curently supported");
|
||||
// }
|
||||
//
|
||||
// sortLocale = locales.get(0);
|
||||
// // find best field match
|
||||
//
|
||||
// HashSet<String> allowableLocales = new HashSet<String>();
|
||||
// MLAnalysisMode analysisMode = lqpa.getDefaultSearchMLAnalysisMode();
|
||||
// for (Locale l : MLAnalysisMode.getLocales(analysisMode, sortLocale, false))
|
||||
// {
|
||||
// allowableLocales.add(l.toString());
|
||||
// }
|
||||
//
|
||||
// field = lqpa.getSortField(field);
|
||||
//
|
||||
// String sortField = field;
|
||||
//
|
||||
// for (Object current : lqp.getIndexReader().getFieldNames(FieldOption.INDEXED))
|
||||
// {
|
||||
// String currentString = (String) current;
|
||||
// if (currentString.startsWith(field) && currentString.endsWith(".sort"))
|
||||
// {
|
||||
// String fieldLocale = currentString.substring(field.length() + 1, currentString.length() - 5);
|
||||
// if (allowableLocales.contains(fieldLocale))
|
||||
// {
|
||||
// if (fieldLocale.equals(sortLocale.toString()))
|
||||
// {
|
||||
// sortField = currentString;
|
||||
// break;
|
||||
// }
|
||||
// else if (sortLocale.toString().startsWith(fieldLocale))
|
||||
// {
|
||||
// if (sortField.equals(field) || (currentString.length() < sortField.length()))
|
||||
// {
|
||||
// sortField = currentString;
|
||||
// }
|
||||
// }
|
||||
// else if (fieldLocale.startsWith(sortLocale.toString()))
|
||||
// {
|
||||
// if (sortField.equals(field) || (currentString.length() < sortField.length()))
|
||||
// {
|
||||
// sortField = currentString;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// field = sortField;
|
||||
// return field;
|
||||
// }
|
||||
|
||||
private QName alfrescoName;
|
||||
|
||||
|
@@ -25,6 +25,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneFunction;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParserAdaptor;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
@@ -33,7 +34,6 @@ import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.alfresco.util.SearchLanguageConversion;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
@@ -82,15 +82,15 @@ public class FixedValueProperty extends AbstractProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneEquality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
if (EqualsHelper.nullSafeEquals(value, fixedValue))
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
return lqpa.getMatchAllQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,28 +98,28 @@ public class FixedValueProperty extends AbstractProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean)
|
||||
*/
|
||||
public Query buildLuceneExists(AbstractLuceneQueryParser lqp, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, Boolean not) throws E
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
if (fixedValue == null)
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
return lqpa.getMatchAllQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fixedValue == null)
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
return lqpa.getMatchAllQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,23 +130,23 @@ public class FixedValueProperty extends AbstractProperty
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Query buildLuceneGreaterThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
if (value instanceof Comparable)
|
||||
{
|
||||
Comparable comparable = (Comparable) value;
|
||||
if (comparable.compareTo(fixedValue) > 0)
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
return lqpa.getMatchAllQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,65 +155,23 @@ public class FixedValueProperty extends AbstractProperty
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Query buildLuceneGreaterThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
if (value instanceof Comparable)
|
||||
{
|
||||
Comparable comparable = (Comparable) value;
|
||||
if (comparable.compareTo(fixedValue) >= 0)
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
return lqpa.getMatchAllQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneIn(AbstractLuceneQueryParser lqp, Collection<Serializable> values, Boolean not, PredicateMode mode) throws ParseException
|
||||
{
|
||||
boolean in = false;
|
||||
for (Serializable value : values)
|
||||
{
|
||||
if (EqualsHelper.nullSafeEquals(value, fixedValue))
|
||||
{
|
||||
in = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (in == !not)
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneInequality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
{
|
||||
if (!EqualsHelper.nullSafeEquals(value, fixedValue))
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,23 +180,23 @@ public class FixedValueProperty extends AbstractProperty
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Query buildLuceneLessThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
if (value instanceof Comparable)
|
||||
{
|
||||
Comparable comparable = (Comparable) value;
|
||||
if (comparable.compareTo(fixedValue) < 0)
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
return lqpa.getMatchAllQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,23 +205,23 @@ public class FixedValueProperty extends AbstractProperty
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Query buildLuceneLessThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
if (value instanceof Comparable)
|
||||
{
|
||||
Comparable comparable = (Comparable) value;
|
||||
if (comparable.compareTo(fixedValue) <= 0)
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
return lqpa.getMatchAllQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +229,7 @@ public class FixedValueProperty extends AbstractProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean)
|
||||
*/
|
||||
public Query buildLuceneLike(AbstractLuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, Boolean not) throws E
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
@@ -290,16 +248,16 @@ public class FixedValueProperty extends AbstractProperty
|
||||
|
||||
if (matches == !not)
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
return lqpa.getMatchAllQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,7 +265,7 @@ public class FixedValueProperty extends AbstractProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField()
|
||||
*/
|
||||
public String getLuceneSortField(AbstractLuceneQueryParser lqp)
|
||||
public <Q, S, E extends Throwable> String getLuceneSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
@@ -28,14 +29,15 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.lucene.AnalysisMode;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneFunction;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParserAdaptor;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
@@ -93,9 +95,32 @@ public class ObjectIdProperty extends AbstractVersioningProperty
|
||||
return "ID";
|
||||
}
|
||||
|
||||
private String getValueAsString(Serializable value)
|
||||
private <Q, S, E extends Throwable> StoreRef getStore(LuceneQueryParserAdaptor<Q, S, E> lqpa)
|
||||
{
|
||||
Object converted = DefaultTypeConverter.INSTANCE.convert(getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.NODE_REF), value);
|
||||
ArrayList<StoreRef> stores = lqpa.getSearchParameters().getStores();
|
||||
if(stores.size() < 1)
|
||||
{
|
||||
// default
|
||||
return StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
|
||||
}
|
||||
return stores.get(0);
|
||||
}
|
||||
|
||||
private <Q, S, E extends Throwable> String getValueAsString(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value)
|
||||
{
|
||||
String nodeRefStr = null;
|
||||
if(!NodeRef.isNodeRef((String)value))
|
||||
{
|
||||
// assume the object id is the node guid
|
||||
StoreRef storeRef = getStore(lqpa);
|
||||
nodeRefStr = storeRef.toString() + "/" + (String)value;
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeRefStr = (String)value;
|
||||
}
|
||||
|
||||
Object converted = DefaultTypeConverter.INSTANCE.convert(getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.NODE_REF), nodeRefStr);
|
||||
String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted);
|
||||
return asString;
|
||||
}
|
||||
@@ -104,60 +129,33 @@ public class ObjectIdProperty extends AbstractVersioningProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneEquality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
String[] split = stringValue.split(";");
|
||||
if(split.length == 1)
|
||||
{
|
||||
return lqp.getFieldQuery(field, stringValue, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(split[1].equalsIgnoreCase("PWC"))
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
|
||||
BooleanQuery query = new BooleanQuery();
|
||||
BooleanQuery part1 = new BooleanQuery();
|
||||
part1.add(lqp.getFieldQuery(field, split[0], AnalysisMode.IDENTIFIER, luceneFunction), Occur.MUST);
|
||||
part1.add(lqp.getFieldQuery("@"+ContentModel.PROP_VERSION_LABEL.toString(), split[1], AnalysisMode.IDENTIFIER, luceneFunction), Occur.MUST);
|
||||
query.add(part1, Occur.SHOULD);
|
||||
|
||||
if(split[1].equals("1.0"))
|
||||
{
|
||||
BooleanQuery part2 = new BooleanQuery();
|
||||
part2.add(lqp.getFieldQuery(field, split[0], AnalysisMode.IDENTIFIER, luceneFunction), Occur.MUST);
|
||||
part2.add(lqp.getFieldQuery(AbstractLuceneQueryParser.FIELD_ASPECT, ContentModel.ASPECT_VERSIONABLE.toString(), AnalysisMode.IDENTIFIER, luceneFunction), Occur.MUST_NOT);
|
||||
query.add(part2, Occur.SHOULD);
|
||||
}
|
||||
return query;
|
||||
}
|
||||
String stringValue = getValueAsString(lqpa, value);
|
||||
return lqpa.getIdentifierQuery(field, stringValue, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean)
|
||||
*/
|
||||
public Query buildLuceneExists(AbstractLuceneQueryParser lqp, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, Boolean not) throws E
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
else
|
||||
return lqpa.getMatchNoneQuery();
|
||||
} else
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
}
|
||||
return lqpa.getMatchAllQuery();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneGreaterThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
throw new CMISQueryException("Property " + getName() +" can not be used in a 'greater than' comparison");
|
||||
}
|
||||
@@ -166,90 +164,16 @@ public class ObjectIdProperty extends AbstractVersioningProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneGreaterThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
throw new CMISQueryException("Property " + getName() + " can not be used in a 'greater than or equals' comparison");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneIn(AbstractLuceneQueryParser lqp, Collection<Serializable> values, Boolean not, PredicateMode mode) throws ParseException
|
||||
{
|
||||
|
||||
// Check type conversion
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Object converted = DefaultTypeConverter.INSTANCE.convert(getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.NODE_REF), values);
|
||||
Collection<String> asStrings = DefaultTypeConverter.INSTANCE.convert(String.class, values);
|
||||
|
||||
if (asStrings.size() == 0)
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
}
|
||||
else if (asStrings.size() == 1)
|
||||
{
|
||||
String value = asStrings.iterator().next();
|
||||
if (not)
|
||||
{
|
||||
BooleanQuery booleanQuery = new BooleanQuery();
|
||||
booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
booleanQuery.add(buildLuceneEquality(lqp, value, mode, LuceneFunction.FIELD), Occur.MUST_NOT);
|
||||
return booleanQuery;
|
||||
}
|
||||
else
|
||||
{
|
||||
return buildLuceneEquality(lqp, value, mode, LuceneFunction.FIELD);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BooleanQuery booleanQuery = new BooleanQuery();
|
||||
if (not)
|
||||
{
|
||||
booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
}
|
||||
for (String value : asStrings)
|
||||
{
|
||||
Query any = buildLuceneEquality(lqp, value, mode, LuceneFunction.FIELD);
|
||||
if (not)
|
||||
{
|
||||
booleanQuery.add(any, Occur.MUST_NOT);
|
||||
}
|
||||
else
|
||||
{
|
||||
booleanQuery.add(any, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
return booleanQuery;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneInequality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
{
|
||||
BooleanQuery booleanQuery = new BooleanQuery();
|
||||
booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
booleanQuery.add(buildLuceneEquality(lqp, value, mode, LuceneFunction.FIELD), Occur.MUST_NOT);
|
||||
return booleanQuery;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneLessThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
throw new CMISQueryException("Property " + getName() + " can not be used in a 'less than' comparison");
|
||||
}
|
||||
@@ -258,7 +182,7 @@ public class ObjectIdProperty extends AbstractVersioningProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneLessThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
throw new CMISQueryException("Property " + getName() + " can not be used in a 'less than or equals' comparison");
|
||||
}
|
||||
@@ -269,7 +193,7 @@ public class ObjectIdProperty extends AbstractVersioningProperty
|
||||
* @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser,
|
||||
* java.lang.String, java.io.Serializable, java.lang.Boolean)
|
||||
*/
|
||||
public Query buildLuceneLike(AbstractLuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, Boolean not) throws E
|
||||
{
|
||||
throw new CMISQueryException("Property " + getName() + " can not be used in a 'like' comparison");
|
||||
}
|
||||
@@ -277,7 +201,7 @@ public class ObjectIdProperty extends AbstractVersioningProperty
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String)
|
||||
*/
|
||||
public String getLuceneSortField(AbstractLuceneQueryParser lqp)
|
||||
public <Q, S, E extends Throwable> String getLuceneSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa)
|
||||
{
|
||||
return getLuceneFieldName();
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.lucene.AnalysisMode;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneFunction;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParserAdaptor;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
@@ -36,7 +37,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
@@ -98,27 +98,27 @@ public class ObjectTypeIdProperty extends AbstractProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneEquality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
CMISTypeDefinition type = getServiceRegistry().getCMISDictionaryService().findType(stringValue);
|
||||
return lqp.getFieldQuery(field, type.getTypeId().getQName().toString(), AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
return lqpa.getFieldQuery(field, type.getTypeId().getQName().toString(), AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean)
|
||||
*/
|
||||
public Query buildLuceneExists(AbstractLuceneQueryParser lqp, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, Boolean not) throws E
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
return lqpa.getMatchAllQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class ObjectTypeIdProperty extends AbstractProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneGreaterThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
throw new CMISQueryException("Property " + getName() + " can not be used in a 'greater than' comparison");
|
||||
}
|
||||
@@ -135,90 +135,16 @@ public class ObjectTypeIdProperty extends AbstractProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneGreaterThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
throw new CMISQueryException("Property " + getName() + " can not be used in a 'greater than or equals' comparison");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneIn(AbstractLuceneQueryParser lqp, Collection<Serializable> values, Boolean not, PredicateMode mode) throws ParseException
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
|
||||
Collection<String> asStrings = new ArrayList<String>(values.size());
|
||||
for (Serializable value : values)
|
||||
{
|
||||
String stringValue = getValueAsString(value);
|
||||
CMISTypeDefinition type = getServiceRegistry().getCMISDictionaryService().findType(stringValue);
|
||||
asStrings.add(type.getTypeId().getQName().toString());
|
||||
}
|
||||
|
||||
if (asStrings.size() == 0)
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
}
|
||||
else if (asStrings.size() == 1)
|
||||
{
|
||||
String value = asStrings.iterator().next();
|
||||
if (not)
|
||||
{
|
||||
return lqp.getDoesNotMatchFieldQuery(field, value, AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
}
|
||||
else
|
||||
{
|
||||
return lqp.getFieldQuery(field, value, AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BooleanQuery booleanQuery = new BooleanQuery();
|
||||
if (not)
|
||||
{
|
||||
booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
}
|
||||
for (String value : asStrings)
|
||||
{
|
||||
Query any = lqp.getFieldQuery(field, value, AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
if (not)
|
||||
{
|
||||
booleanQuery.add(any, Occur.MUST_NOT);
|
||||
}
|
||||
else
|
||||
{
|
||||
booleanQuery.add(any, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
return booleanQuery;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneInequality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
CMISTypeDefinition type = getServiceRegistry().getCMISDictionaryService().findType(stringValue);
|
||||
return lqp.getDoesNotMatchFieldQuery(field, type.getTypeId().getQName().toString(), AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneLessThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
throw new CMISQueryException("Property " + getName() + " can not be used in a 'less than' comparison");
|
||||
}
|
||||
@@ -227,7 +153,7 @@ public class ObjectTypeIdProperty extends AbstractProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneLessThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
throw new CMISQueryException("Property " + getName() + " can not be used in a 'less than or equals' comparison");
|
||||
}
|
||||
@@ -236,31 +162,26 @@ public class ObjectTypeIdProperty extends AbstractProperty
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean)
|
||||
*/
|
||||
public Query buildLuceneLike(AbstractLuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, Boolean not) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
CMISTypeDefinition type = getServiceRegistry().getCMISDictionaryService().findType(stringValue);
|
||||
String typeQName = type.getTypeId().getQName().toString();
|
||||
|
||||
Q q = lqpa.getLikeQuery(field, typeQName, AnalysisMode.IDENTIFIER);
|
||||
if (not)
|
||||
{
|
||||
BooleanQuery booleanQuery = new BooleanQuery();
|
||||
booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
booleanQuery.add(lqp.getLikeQuery(field, typeQName, AnalysisMode.IDENTIFIER), Occur.MUST_NOT);
|
||||
return booleanQuery;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lqp.getLikeQuery(field, typeQName, AnalysisMode.IDENTIFIER);
|
||||
q = lqpa.getNegatedQuery(q);
|
||||
}
|
||||
return q;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField()
|
||||
*/
|
||||
public String getLuceneSortField(AbstractLuceneQueryParser lqp)
|
||||
public <Q, S, E extends Throwable> String getLuceneSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa)
|
||||
{
|
||||
return getLuceneFieldName();
|
||||
}
|
||||
|
@@ -19,20 +19,22 @@
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.lucene.AnalysisMode;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneFunction;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParserAdaptor;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
@@ -91,132 +93,82 @@ public class ParentProperty extends AbstractProperty
|
||||
return asString;
|
||||
}
|
||||
|
||||
private <Q, S, E extends Throwable> StoreRef getStore(LuceneQueryParserAdaptor<Q, S, E> lqpa)
|
||||
{
|
||||
ArrayList<StoreRef> stores = lqpa.getSearchParameters().getStores();
|
||||
if(stores.size() < 1)
|
||||
{
|
||||
// default
|
||||
return StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
|
||||
}
|
||||
return stores.get(0);
|
||||
}
|
||||
|
||||
private <Q, S, E extends Throwable> String getValueAsString(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value)
|
||||
{
|
||||
String nodeRefStr = (String)value;
|
||||
if(!NodeRef.isNodeRef((String)value))
|
||||
{
|
||||
// assume the value (object id) is the node guid
|
||||
StoreRef storeRef = getStore(lqpa);
|
||||
nodeRefStr = storeRef.toString() + "/" + (String)value;
|
||||
}
|
||||
|
||||
Object converted = DefaultTypeConverter.INSTANCE.convert(getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.NODE_REF), nodeRefStr);
|
||||
String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted);
|
||||
return asString;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneEquality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
return lqp.getFieldQuery(field, stringValue, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
return lqpa.getFieldQuery(field, stringValue, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean)
|
||||
*/
|
||||
public Query buildLuceneExists(AbstractLuceneQueryParser lqp, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, Boolean not) throws E
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
return new TermQuery(new Term("ISROOT", "T"));
|
||||
}
|
||||
else
|
||||
return lqpa.getFieldQuery("ISROOT", "T", AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
//return new TermQuery(new Term("ISROOT", "T"));
|
||||
} else
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
return lqpa.getNegatedQuery(lqpa.getFieldQuery("ISROOT", "T", AnalysisMode.IDENTIFIER, LuceneFunction.FIELD));
|
||||
//return new MatchAllDocsQuery();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneIn(AbstractLuceneQueryParser lqp, Collection<Serializable> values, Boolean not, PredicateMode mode) throws ParseException
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
|
||||
// Check type conversion
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Object converted = DefaultTypeConverter.INSTANCE.convert(getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.NODE_REF), values);
|
||||
Collection<String> asStrings = DefaultTypeConverter.INSTANCE.convert(String.class, values);
|
||||
|
||||
if (asStrings.size() == 0)
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
return new MatchAllDocsQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
}
|
||||
else if (asStrings.size() == 1)
|
||||
{
|
||||
String value = asStrings.iterator().next();
|
||||
if (not)
|
||||
{
|
||||
return lqp.getDoesNotMatchFieldQuery(field, value, AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
}
|
||||
else
|
||||
{
|
||||
return lqp.getFieldQuery(field, value, AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BooleanQuery booleanQuery = new BooleanQuery();
|
||||
if (not)
|
||||
{
|
||||
booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
}
|
||||
for (String value : asStrings)
|
||||
{
|
||||
Query any = lqp.getFieldQuery(field, value, AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
|
||||
if (not)
|
||||
{
|
||||
booleanQuery.add(any, Occur.MUST_NOT);
|
||||
}
|
||||
else
|
||||
{
|
||||
booleanQuery.add(any, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
return booleanQuery;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneInequality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
return lqp.getDoesNotMatchFieldQuery(field, stringValue, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean)
|
||||
*/
|
||||
public Query buildLuceneLike(AbstractLuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, Boolean not) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
|
||||
Q q = lqpa.getLikeQuery(field, stringValue, AnalysisMode.IDENTIFIER);
|
||||
if (not)
|
||||
{
|
||||
BooleanQuery booleanQuery = new BooleanQuery();
|
||||
booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
booleanQuery.add(lqp.getLikeQuery(field, stringValue, AnalysisMode.IDENTIFIER), Occur.MUST_NOT);
|
||||
return booleanQuery;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lqp.getLikeQuery(field, stringValue, AnalysisMode.IDENTIFIER);
|
||||
q = lqpa.getNegatedQuery(q);
|
||||
}
|
||||
return q;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField()
|
||||
*/
|
||||
public String getLuceneSortField(AbstractLuceneQueryParser lqp)
|
||||
public <Q, S, E extends Throwable> String getLuceneSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa)
|
||||
{
|
||||
return getLuceneFieldName();
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ import org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper;
|
||||
import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
|
||||
import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneFunction;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParserAdaptor;
|
||||
import org.alfresco.repo.search.impl.querymodel.FunctionArgument;
|
||||
import org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
@@ -46,7 +47,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
||||
/**
|
||||
@@ -226,10 +226,10 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public Query buildLuceneEquality(AbstractLuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneEquality(lqp, value, mode, luceneFunction);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneEquality(lqpa, value, mode, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -238,10 +238,10 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
|
||||
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser,
|
||||
* org.alfresco.service.namespace.QName, java.lang.Boolean)
|
||||
*/
|
||||
public Query buildLuceneExists(AbstractLuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, String propertyName, Boolean not) throws E
|
||||
{
|
||||
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneExists(lqp, not);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneExists(lqpa, not);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -251,10 +251,10 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
|
||||
* org.alfresco.service.namespace.QName, java.io.Serializable,
|
||||
* org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneGreaterThan(AbstractLuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneGreaterThan(lqp, value, mode, luceneFunction);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneGreaterThan(lqpa, value, mode, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -264,10 +264,10 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
|
||||
* org.alfresco.service.namespace.QName, java.io.Serializable,
|
||||
* org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneGreaterThanOrEquals(AbstractLuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneGreaterThanOrEquals(lqp, value, mode, luceneFunction);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneGreaterThanOrEquals(lqpa, value, mode, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -277,10 +277,10 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
|
||||
* org.alfresco.service.namespace.QName, java.util.Collection, java.lang.Boolean,
|
||||
* org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneIn(AbstractLuceneQueryParser lqp, String propertyName, Collection<Serializable> values, Boolean not, PredicateMode mode) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneIn(LuceneQueryParserAdaptor<Q, S, E> lqpa, String propertyName, Collection<Serializable> values, Boolean not, PredicateMode mode) throws E
|
||||
{
|
||||
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneIn(lqp, values, not, mode);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneIn(lqpa, values, not, mode);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -290,10 +290,10 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
|
||||
* org.alfresco.service.namespace.QName, java.io.Serializable,
|
||||
* org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneInequality(AbstractLuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneInequality(LuceneQueryParserAdaptor<Q, S, E> lqpa, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneInequality(lqp, value, mode, luceneFunction);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneInequality(lqpa, value, mode, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -303,10 +303,10 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
|
||||
* org.alfresco.service.namespace.QName, java.io.Serializable,
|
||||
* org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneLessThan(AbstractLuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneLessThan(lqp, value, mode, luceneFunction);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneLessThan(lqpa, value, mode, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -316,10 +316,10 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
|
||||
* org.alfresco.service.namespace.QName, java.io.Serializable,
|
||||
* org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public Query buildLuceneLessThanOrEquals(AbstractLuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneLessThanOrEquals(lqp, value, mode, luceneFunction);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneLessThanOrEquals(lqpa, value, mode, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -328,19 +328,19 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
|
||||
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser,
|
||||
* org.alfresco.service.namespace.QName, java.io.Serializable, java.lang.Boolean)
|
||||
*/
|
||||
public Query buildLuceneLike(AbstractLuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, String propertyName, Serializable value, Boolean not) throws E
|
||||
{
|
||||
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneLike(lqp, value, not);
|
||||
return propertyDef.getPropertyLuceneBuilder().buildLuceneLike(lqpa, value, not);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#getLuceneSortField(org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
public String getLuceneSortField(AbstractLuceneQueryParser lqp, String propertyName)
|
||||
public <Q, S, E extends Throwable> String getLuceneSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa, String propertyName) throws E
|
||||
{
|
||||
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null);
|
||||
return propertyDef.getPropertyLuceneBuilder().getLuceneSortField(lqp);
|
||||
return propertyDef.getPropertyLuceneBuilder().getLuceneSortField(lqpa);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -217,10 +217,11 @@ public class LuceneQueryEngine implements QueryEngine
|
||||
{
|
||||
LuceneSearcher luceneSearcher = (LuceneSearcher) searchService;
|
||||
ClosingIndexSearcher searcher = luceneSearcher.getClosingIndexSearcher();
|
||||
LuceneQueryBuilderContext luceneContext = new LuceneQueryBuilderContextImpl(dictionaryService, namespaceService, tenantService, searchParameters, indexAndSearcher.getDefaultMLSearchAnalysisMode(),
|
||||
LuceneQueryBuilderContext<org.apache.lucene.search.Query, Sort, ParseException> luceneContext = new LuceneQueryBuilderContextImpl(dictionaryService, namespaceService, tenantService, searchParameters, indexAndSearcher.getDefaultMLSearchAnalysisMode(),
|
||||
searcher.getIndexReader());
|
||||
|
||||
LuceneQueryBuilder builder = (LuceneQueryBuilder) query;
|
||||
@SuppressWarnings("unchecked")
|
||||
LuceneQueryBuilder<org.apache.lucene.search.Query, Sort, ParseException> builder = (LuceneQueryBuilder<org.apache.lucene.search.Query, Sort, ParseException>) query;
|
||||
org.apache.lucene.search.Query luceneQuery = builder.buildQuery(selectorGroup, luceneContext, functionContext);
|
||||
|
||||
if(logger.isDebugEnabled())
|
||||
|
Reference in New Issue
Block a user