org.alfresco.repo.search.impl.querymodel.Ordering Java Examples

The following examples show how to use org.alfresco.repo.search.impl.querymodel.Ordering. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseQuery.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
public BaseQuery(List<Column> columns, Source source, Constraint constraint, List<Ordering> orderings)
{
    this.columns = columns;
    this.source = source;
    this.constraint = constraint;
    this.orderings = orderings;
}
 
Example #2
Source File: LuceneQuery.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
public List<SortDefinition> buildSortDefinitions(Set<String> selectors, LuceneQueryBuilderContext<Q, S, E> luceneContext, FunctionEvaluationContext functionContext)
{
    if ((getOrderings() == null) || (getOrderings().size() == 0))
    {
        return Collections.<SortDefinition>emptyList();
    }

    ArrayList<SortDefinition> definitions = new ArrayList<SortDefinition>(getOrderings().size());

    for (Ordering ordering : getOrderings())
    {
        if (ordering.getColumn().getFunction().getName().equals(PropertyAccessor.NAME))
        {
            PropertyArgument property = (PropertyArgument) ordering.getColumn().getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY);

            if (property == null)
            {
                throw new IllegalStateException();
            }

            String propertyName = property.getPropertyName();

            String fieldName = functionContext.getLuceneFieldName(propertyName);
            
            definitions.add(new SortDefinition(SortType.FIELD, fieldName, ordering.getOrder() == Order.ASCENDING));
        }
        else if (ordering.getColumn().getFunction().getName().equals(Score.NAME))
        {
            definitions.add(new SortDefinition(SortType.SCORE, null, ordering.getOrder() == Order.ASCENDING));
        }
    }

    return definitions;
}
 
Example #3
Source File: DBQuery.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @param source Source
 * @param constraint Constraint
 */
public DBQuery(List<Column> columns, Source source, Constraint constraint, List<Ordering> orderings)
{
    super(columns, source, constraint, orderings);
}
 
Example #4
Source File: DBQuery.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void prepare(NamespaceService namespaceService, DictionaryService dictionaryService, QNameDAO qnameDAO, NodeDAO nodeDAO, TenantService tenantService, Set<String> selectors,
        Map<String, Argument> functionArgs, FunctionEvaluationContext functionContext, boolean supportBooleanFloatAndDouble)
{
    selectorGroup = selectors;
    if (selectorGroup != null)
    {
        for (String selector : selectorGroup)
        {
            Selector current = getSource().getSelector(selector);
            if (current instanceof DBQueryBuilderComponent)
            {
                ((DBQueryBuilderComponent) current).prepare(namespaceService, dictionaryService, qnameDAO, nodeDAO, tenantService, selectorGroup, functionArgs, functionContext, supportBooleanFloatAndDouble);
            }
            else
            {
                throw new UnsupportedOperationException();
            }
        }
    }

    if (getConstraint() != null)
    {
        if (getConstraint() instanceof DBQueryBuilderComponent)
        {
            ((DBQueryBuilderComponent) getConstraint()).prepare(namespaceService, dictionaryService, qnameDAO, nodeDAO, tenantService, selectorGroup, functionArgs, functionContext, supportBooleanFloatAndDouble);
        }
        else
        {
            throw new UnsupportedOperationException();
        }
    }
    
    if(getOrderings() != null)
    {
        for(Ordering ordering : getOrderings())
        {
            if(ordering instanceof DBQueryBuilderComponent)
            {
                ((DBQueryBuilderComponent) ordering).prepare(namespaceService, dictionaryService, qnameDAO, nodeDAO, tenantService, selectorGroup, functionArgs, functionContext, supportBooleanFloatAndDouble);
            }
            else
            {
                throw new UnsupportedOperationException();
            }
        }
    }

}
 
Example #5
Source File: DBQuery.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void buildJoins(Map<QName, DBQueryBuilderJoinCommand> singleJoins, List<DBQueryBuilderJoinCommand> multiJoins)
{
    if (selectorGroup != null)
    {
        for (String selector : selectorGroup)
        {
            Selector current = getSource().getSelector(selector);
            if (current instanceof DBQueryBuilderComponent)
            {
                ((DBQueryBuilderComponent) current).buildJoins(singleJoins, multiJoins);
            }
            else
            {
                throw new UnsupportedOperationException();
            }
        }
    }

    if (getConstraint() != null)
    {
        if (getConstraint() instanceof DBQueryBuilderComponent)
        {
            ((DBQueryBuilderComponent) getConstraint()).buildJoins(singleJoins, multiJoins);
        }
        else
        {
            throw new UnsupportedOperationException();
        }
    }
    if(getOrderings() != null)
    {
        for(Ordering ordering : getOrderings())
        {
            if(ordering instanceof DBQueryBuilderComponent)
            {
                ((DBQueryBuilderComponent) ordering).buildJoins(singleJoins, multiJoins);
            }
            else
            {
                throw new UnsupportedOperationException();
            }
        }
    }

}
 
Example #6
Source File: DBQueryModelFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Query createQuery(List<Column> columns, Source source, Constraint constraint, List<Ordering> orderings)
{
    return new DBQuery(columns, source, constraint, orderings);
}
 
Example #7
Source File: DBQueryModelFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Ordering createOrdering(Column column, Order order)
{
    return new DBOrdering(column, order);
}
 
Example #8
Source File: BaseQuery.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public List<Ordering> getOrderings()
{
    return orderings;
}
 
Example #9
Source File: LuceneQuery.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @param source Source
 * @param constraint Constraint
 */
public LuceneQuery(List<Column> columns, Source source, Constraint constraint, List<Ordering> orderings)
{
    super(columns, source, constraint, orderings);
}
 
Example #10
Source File: LuceneQueryModelFactory.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Ordering createOrdering(Column column, Order order)
{
    return new LuceneOrdering(column, order);
}
 
Example #11
Source File: LuceneQueryModelFactory.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Query createQuery(List<Column> columns, Source source, Constraint constraint, List<Ordering> orderings)
{
    return new LuceneQuery<Q, S, E>(columns, source, constraint, orderings);
}
 
Example #12
Source File: Lucene4QueryParserAdaptor.java    From SearchServices with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Sort buildSort(List<Ordering> list, FunctionEvaluationContext functionContext) throws ParseException
{
    throw new UnsupportedOperationException();
}
 
Example #13
Source File: LuceneQueryParserAdaptor.java    From alfresco-data-model with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * @param list List
 * @param functionContext FunctionEvaluationContext
 * @return S
 * @throws E 
 */
S buildSort(List<Ordering> list, FunctionEvaluationContext functionContext) throws E;