本文整理汇总了Java中org.alfresco.repo.search.impl.querymodel.Ordering.getOrder方法的典型用法代码示例。如果您正苦于以下问题:Java Ordering.getOrder方法的具体用法?Java Ordering.getOrder怎么用?Java Ordering.getOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.repo.search.impl.querymodel.Ordering
的用法示例。
在下文中一共展示了Ordering.getOrder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildSort
import org.alfresco.repo.search.impl.querymodel.Ordering; //导入方法依赖的package包/类
@Override
public Sort buildSort(List<Ordering> orderings, FunctionEvaluationContext functionContext) throws ParseException
{
int index = 0;
SortField[] fields = new SortField[orderings.size()];
for (Ordering ordering : orderings)
{
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 luceneField = functionContext.getLuceneSortField(this, propertyName);
if (luceneField != null)
{
if (LuceneUtils.fieldHasTerm(lqp.getIndexReader(), luceneField))
{
Locale locale = this.getSearchParameters().getSortLocale();
fields[index++] = new SortField(luceneField, locale, (ordering.getOrder() == Order.DESCENDING));
}
else
{
fields[index++] = new SortField(null, SortField.DOC, (ordering.getOrder() == Order.DESCENDING));
}
}
else
{
throw new IllegalStateException();
}
}
else if (ordering.getColumn().getFunction().getName().equals(Score.NAME))
{
fields[index++] = new SortField(null, SortField.SCORE, !(ordering.getOrder() == Order.DESCENDING));
}
else
{
throw new IllegalStateException();
}
}
return new Sort(fields);
}