Search in sources :

Example 1 with Function

use of org.alfresco.repo.search.impl.querymodel.Function in project alfresco-repository by Alfresco.

the class DBFunctionalConstraint method prepare.

/* (non-Javadoc)
     * @see org.alfresco.repo.search.impl.querymodel.impl.db.DBQueryBuilderComponent#prepare(org.alfresco.service.namespace.NamespaceService, org.alfresco.service.cmr.dictionary.DictionaryService, org.alfresco.repo.domain.qname.QNameDAO, org.alfresco.repo.domain.node.NodeDAO)
     */
@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) {
    Function function = getFunction();
    if (function != null) {
        if (function instanceof DBQueryBuilderComponent) {
            DBQueryBuilderComponent dbQueryBuilderComponent = (DBQueryBuilderComponent) function;
            dbQueryBuilderComponent.prepare(namespaceService, dictionaryService, qnameDAO, nodeDAO, tenantService, selectors, getFunctionArguments(), functionContext, supportBooleanFloatAndDouble);
        } else {
            throw new UnsupportedOperationException();
        }
    }
}
Also used : Function(org.alfresco.repo.search.impl.querymodel.Function)

Example 2 with Function

use of org.alfresco.repo.search.impl.querymodel.Function in project alfresco-repository by Alfresco.

the class DBFunctionalConstraint method buildJoins.

/* (non-Javadoc)
     * @see org.alfresco.repo.search.impl.querymodel.impl.db.DBQueryBuilderComponent#buildJoins(java.util.Map, java.util.List)
     */
@Override
public void buildJoins(Map<QName, DBQueryBuilderJoinCommand> singleJoins, List<DBQueryBuilderJoinCommand> multiJoins) {
    Function function = getFunction();
    if (function != null) {
        if (function instanceof DBQueryBuilderComponent) {
            DBQueryBuilderComponent dbQueryBuilderComponent = (DBQueryBuilderComponent) function;
            dbQueryBuilderComponent.buildJoins(singleJoins, multiJoins);
        } else {
            throw new UnsupportedOperationException();
        }
    }
}
Also used : Function(org.alfresco.repo.search.impl.querymodel.Function)

Example 3 with Function

use of org.alfresco.repo.search.impl.querymodel.Function 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;
}
Also used : Order(org.alfresco.repo.search.impl.querymodel.Order) Argument(org.alfresco.repo.search.impl.querymodel.Argument) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Function(org.alfresco.repo.search.impl.querymodel.Function) Column(org.alfresco.repo.search.impl.querymodel.Column) Ordering(org.alfresco.repo.search.impl.querymodel.Ordering) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) SortDefinition(org.alfresco.service.cmr.search.SearchParameters.SortDefinition)

Example 4 with Function

use of org.alfresco.repo.search.impl.querymodel.Function in project alfresco-repository by Alfresco.

the class DBFunctionalConstraint method buildPredicateCommands.

/* (non-Javadoc)
     * @see org.alfresco.repo.search.impl.querymodel.impl.db.DBQueryBuilderComponent#buildPredicateCommands(java.util.List)
     */
@Override
public void buildPredicateCommands(List<DBQueryBuilderPredicatePartCommand> predicatePartCommands) {
    Function function = getFunction();
    if (function != null) {
        if (function instanceof DBQueryBuilderComponent) {
            DBQueryBuilderComponent dbQueryBuilderComponent = (DBQueryBuilderComponent) function;
            dbQueryBuilderComponent.buildPredicateCommands(predicatePartCommands);
        } else {
            throw new UnsupportedOperationException();
        }
    }
}
Also used : Function(org.alfresco.repo.search.impl.querymodel.Function)

Aggregations

Function (org.alfresco.repo.search.impl.querymodel.Function)4 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Argument (org.alfresco.repo.search.impl.querymodel.Argument)1 Column (org.alfresco.repo.search.impl.querymodel.Column)1 Order (org.alfresco.repo.search.impl.querymodel.Order)1 Ordering (org.alfresco.repo.search.impl.querymodel.Ordering)1 SortDefinition (org.alfresco.service.cmr.search.SearchParameters.SortDefinition)1