Search in sources :

Example 1 with AspectSupport

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

the class DBFTSPhrase 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, java.util.Set, java.util.Map,
     * org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext)
     */
@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) {
    Argument argument = functionArgs.get(ARG_PHRASE);
    String term = (String) argument.getValue(functionContext);
    PropertyArgument propArg = (PropertyArgument) functionArgs.get(ARG_PROPERTY);
    if ((propArg == null) || (propArg.getPropertyName() == null)) {
        throw new QueryModelException("Default field not supported");
    } else if (propArg.getPropertyName().equals(QueryConstants.FIELD_PARENT)) {
        ParentSupport parentSupport = new ParentSupport();
        String id = (String) term;
        parentSupport.setDbid(DBQuery.getDbid(id, nodeDAO, tenantService));
        parentSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.EQUALS);
        builderSupport = parentSupport;
    } else if (propArg.getPropertyName().equals(QueryConstants.FIELD_TYPE)) {
        TypeSupport typeSupport = new TypeSupport();
        typeSupport.setQnameIds(DBQuery.findTypeIds(term, namespaceService, dictionaryService, qnameDAO, false));
        typeSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.IN);
        builderSupport = typeSupport;
    } else if (propArg.getPropertyName().equals(QueryConstants.FIELD_ASPECT)) {
        AspectSupport aspectSupport = new AspectSupport();
        aspectSupport.setQnameIds(DBQuery.findAspectIds(term, namespaceService, dictionaryService, qnameDAO, false));
        builderSupport = aspectSupport;
    } else if (propArg.getPropertyName().equals(QueryConstants.FIELD_EXACTTYPE)) {
        TypeSupport typeSupport = new TypeSupport();
        typeSupport.setQnameIds(DBQuery.findTypeIds(term, namespaceService, dictionaryService, qnameDAO, true));
        typeSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.IN);
        builderSupport = typeSupport;
    } else if (propArg.getPropertyName().equals(QueryConstants.FIELD_EXACTASPECT)) {
        AspectSupport aspectSupport = new AspectSupport();
        aspectSupport.setQnameIds(DBQuery.findAspectIds(term, namespaceService, dictionaryService, qnameDAO, true));
        builderSupport = aspectSupport;
    } else {
        argument = functionArgs.get(ARG_TOKENISATION_MODE);
        AnalysisMode mode = (AnalysisMode) argument.getValue(functionContext);
        if (mode != AnalysisMode.IDENTIFIER) {
            throw new QueryModelException("Analysis mode not supported for DB " + mode);
        }
        PropertySupport propertySupport = new PropertySupport();
        propertySupport.setValue(term);
        QName propertyQName = QName.createQName(DBQuery.expandQName(functionContext.getAlfrescoPropertyName(propArg.getPropertyName()), namespaceService));
        propertySupport.setPropertyQName(propertyQName);
        propertySupport.setPropertyDataType(DBQuery.getDataTypeDefinition(dictionaryService, propertyQName));
        propertySupport.setPair(qnameDAO.getQName(propertyQName));
        propertySupport.setJoinCommandType(DBQuery.getJoinCommandType(propertyQName));
        propertySupport.setFieldName(DBQuery.getFieldName(dictionaryService, propertyQName, supportBooleanFloatAndDouble));
        propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.EQUALS);
        builderSupport = propertySupport;
    }
}
Also used : AspectSupport(org.alfresco.repo.search.impl.querymodel.impl.db.AspectSupport) Argument(org.alfresco.repo.search.impl.querymodel.Argument) PropertyArgument(org.alfresco.repo.search.impl.querymodel.PropertyArgument) TypeSupport(org.alfresco.repo.search.impl.querymodel.impl.db.TypeSupport) QName(org.alfresco.service.namespace.QName) QueryModelException(org.alfresco.repo.search.impl.querymodel.QueryModelException) ParentSupport(org.alfresco.repo.search.impl.querymodel.impl.db.ParentSupport) AnalysisMode(org.alfresco.repo.search.adaptor.lucene.AnalysisMode) PropertyArgument(org.alfresco.repo.search.impl.querymodel.PropertyArgument) PropertySupport(org.alfresco.repo.search.impl.querymodel.impl.db.PropertySupport)

Example 2 with AspectSupport

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

the class DBFTSTerm 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, java.util.Set, java.util.Map,
     * org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext)
     */
@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) {
    Argument argument = functionArgs.get(ARG_TERM);
    String term = (String) argument.getValue(functionContext);
    PropertyArgument propArg = (PropertyArgument) functionArgs.get(ARG_PROPERTY);
    if ((propArg == null) || (propArg.getPropertyName() == null)) {
        throw new QueryModelException("Default field not supported");
    } else if (propArg.getPropertyName().equals(QueryConstants.FIELD_PARENT)) {
        ParentSupport parentSupport = new ParentSupport();
        String id = (String) term;
        parentSupport.setDbid(DBQuery.getDbid(id, nodeDAO, tenantService));
        parentSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.EQUALS);
        builderSupport = parentSupport;
    } else if (propArg.getPropertyName().equals(QueryConstants.FIELD_TYPE)) {
        TypeSupport typeSupport = new TypeSupport();
        typeSupport.setQnameIds(DBQuery.findTypeIds(term, namespaceService, dictionaryService, qnameDAO, false));
        typeSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.IN);
        builderSupport = typeSupport;
    } else if (propArg.getPropertyName().equals(QueryConstants.FIELD_ASPECT)) {
        AspectSupport aspectSupport = new AspectSupport();
        aspectSupport.setQnameIds(DBQuery.findAspectIds(term, namespaceService, dictionaryService, qnameDAO, false));
        builderSupport = aspectSupport;
    } else if (propArg.getPropertyName().equals(QueryConstants.FIELD_EXACTTYPE)) {
        TypeSupport typeSupport = new TypeSupport();
        typeSupport.setQnameIds(DBQuery.findTypeIds(term, namespaceService, dictionaryService, qnameDAO, true));
        typeSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.IN);
        builderSupport = typeSupport;
    } else if (propArg.getPropertyName().equals(QueryConstants.FIELD_EXACTASPECT)) {
        AspectSupport aspectSupport = new AspectSupport();
        aspectSupport.setQnameIds(DBQuery.findAspectIds(term, namespaceService, dictionaryService, qnameDAO, true));
        builderSupport = aspectSupport;
    } else {
        argument = functionArgs.get(ARG_TOKENISATION_MODE);
        AnalysisMode mode = (AnalysisMode) argument.getValue(functionContext);
        if (mode != AnalysisMode.IDENTIFIER) {
            throw new QueryModelException("Analysis mode not supported for DB " + mode);
        }
        PropertySupport propertySupport = new PropertySupport();
        propertySupport.setValue(term);
        QName propertyQName = QName.createQName(DBQuery.expandQName(functionContext.getAlfrescoPropertyName(propArg.getPropertyName()), namespaceService));
        propertySupport.setPropertyQName(propertyQName);
        propertySupport.setPropertyDataType(DBQuery.getDataTypeDefinition(dictionaryService, propertyQName));
        propertySupport.setPair(qnameDAO.getQName(propertyQName));
        propertySupport.setJoinCommandType(DBQuery.getJoinCommandType(propertyQName));
        propertySupport.setFieldName(DBQuery.getFieldName(dictionaryService, propertyQName, supportBooleanFloatAndDouble));
        propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.EQUALS);
        builderSupport = propertySupport;
    }
}
Also used : AspectSupport(org.alfresco.repo.search.impl.querymodel.impl.db.AspectSupport) Argument(org.alfresco.repo.search.impl.querymodel.Argument) PropertyArgument(org.alfresco.repo.search.impl.querymodel.PropertyArgument) TypeSupport(org.alfresco.repo.search.impl.querymodel.impl.db.TypeSupport) QName(org.alfresco.service.namespace.QName) QueryModelException(org.alfresco.repo.search.impl.querymodel.QueryModelException) ParentSupport(org.alfresco.repo.search.impl.querymodel.impl.db.ParentSupport) AnalysisMode(org.alfresco.repo.search.adaptor.lucene.AnalysisMode) PropertyArgument(org.alfresco.repo.search.impl.querymodel.PropertyArgument) PropertySupport(org.alfresco.repo.search.impl.querymodel.impl.db.PropertySupport)

Aggregations

AnalysisMode (org.alfresco.repo.search.adaptor.lucene.AnalysisMode)2 Argument (org.alfresco.repo.search.impl.querymodel.Argument)2 PropertyArgument (org.alfresco.repo.search.impl.querymodel.PropertyArgument)2 QueryModelException (org.alfresco.repo.search.impl.querymodel.QueryModelException)2 AspectSupport (org.alfresco.repo.search.impl.querymodel.impl.db.AspectSupport)2 ParentSupport (org.alfresco.repo.search.impl.querymodel.impl.db.ParentSupport)2 PropertySupport (org.alfresco.repo.search.impl.querymodel.impl.db.PropertySupport)2 TypeSupport (org.alfresco.repo.search.impl.querymodel.impl.db.TypeSupport)2 QName (org.alfresco.service.namespace.QName)2