use of org.alfresco.repo.search.impl.querymodel.Column in project alfresco-repository by Alfresco.
the class CMISResultSetRow method getValue.
/*
* (non-Javadoc)
*
* @see org.alfresco.cmis.search.CMISResultSetRow#getValue(java.lang.String)
*/
public Serializable getValue(String columnName) {
CmisFunctionEvaluationContext context = new CmisFunctionEvaluationContext();
context.setCmisDictionaryService(cmisDictionaryService);
context.setNodeRefs(nodeRefs);
context.setNodeInfos(nodeInfos);
context.setNodeService(nodeService);
context.setScores(scores);
context.setScore(getScore());
for (Column column : query.getColumns()) {
// When an SCORE selector is included, score must be adapted to range 0..1 due to CMIS specification
if (column.getFunction() != null && column.getFunction().getName().equals(Score.NAME)) {
return getNormalisedScore();
} else if (column.getAlias().equals(columnName)) {
return column.getFunction().getValue(column.getFunctionArguments(), context);
}
// TODO: check SQL 92 for single alias table behaviour for selectors
if (nodeRefs.size() == 1) {
if (column.getFunction().getName().equals(PropertyAccessor.NAME)) {
PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY);
String propertyName = arg.getPropertyName();
if (propertyName.equals(columnName)) {
return column.getFunction().getValue(column.getFunctionArguments(), context);
}
StringBuilder builder = new StringBuilder();
builder.append(arg.getSelector()).append(".").append(propertyName);
propertyName = builder.toString();
if (propertyName.equals(columnName)) {
return column.getFunction().getValue(column.getFunctionArguments(), context);
}
}
} else {
if (column.getFunction().getName().equals(PropertyAccessor.NAME)) {
PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY);
StringBuilder builder = new StringBuilder();
builder.append(arg.getSelector()).append(".").append(arg.getPropertyName());
String propertyName = builder.toString();
if (propertyName.equals(columnName)) {
return column.getFunction().getValue(column.getFunctionArguments(), context);
}
}
}
}
return null;
}
use of org.alfresco.repo.search.impl.querymodel.Column in project alfresco-repository by Alfresco.
the class AbstractAlfrescoFtsQueryLanguage method buildOrderings.
public List<Ordering> buildOrderings(QueryModelFactory factory, SearchParameters searchParameters) {
List<Ordering> orderings = new ArrayList<Ordering>(searchParameters.getSortDefinitions().size());
for (SortDefinition sd : searchParameters.getSortDefinitions()) {
if (sd.getSortType() == SortType.FIELD) {
Function function = factory.getFunction(PropertyAccessor.NAME);
Argument arg = factory.createPropertyArgument(PropertyAccessor.ARG_PROPERTY, true, true, "", sd.getField());
Map<String, Argument> functionArguments = new LinkedHashMap<String, Argument>();
functionArguments.put(arg.getName(), arg);
Column column = factory.createColumn(function, functionArguments, sd.getField());
Order order = sd.isAscending() ? Order.ASCENDING : Order.DESCENDING;
Ordering ordering = factory.createOrdering(column, order);
orderings.add(ordering);
} else if (sd.getSortType() == SortType.SCORE) {
Function function = factory.getFunction(Score.NAME);
Map<String, Argument> functionArguments = new LinkedHashMap<String, Argument>();
Column column = factory.createColumn(function, functionArguments, Score.NAME);
Order order = sd.isAscending() ? Order.ASCENDING : Order.DESCENDING;
Ordering ordering = factory.createOrdering(column, order);
orderings.add(ordering);
} else {
throw new UnsupportedOperationException("Unsupported Ordering " + sd.getSortType());
}
}
return orderings;
}
Aggregations