Search in sources :

Example 11 with PropertySupport

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

the class DBGreaterThanOrEquals 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) {
    setPropertyAndStaticArguments(functionArgs);
    Serializable staticValue = getStaticArgument().getValue(functionContext);
    if (getPropertyName().equals(PropertyIds.CONTENT_STREAM_MIME_TYPE)) {
        PropertySupport propertySupport = new PropertySupport();
        propertySupport.setValue(staticValue.toString());
        QName basePropertyQName = QName.createQName(DBQuery.expandQName(functionContext.getAlfrescoPropertyName(getPropertyName()), namespaceService));
        propertySupport.setPropertyQName(basePropertyQName);
        propertySupport.setPropertyDataType(DBQuery.getDataTypeDefinition(dictionaryService, basePropertyQName));
        propertySupport.setPair(qnameDAO.getQName(basePropertyQName));
        propertySupport.setJoinCommandType(DBQueryBuilderJoinCommandType.CONTENT_MIMETYPE);
        propertySupport.setFieldName("mimetype_str");
        propertySupport.setCommandType(getStaticPosition().equals(ARG_RHS) ? DBQueryBuilderPredicatePartCommandType.GTE : DBQueryBuilderPredicatePartCommandType.GTE.propertyAndValueReversed());
        propertySupport.setLuceneFunction(functionContext.getLuceneFunction(getFunctionArgument()));
        builderSupport = propertySupport;
    } else if (getPropertyName().equals(PropertyIds.CONTENT_STREAM_LENGTH)) {
        PropertySupport propertySupport = new PropertySupport();
        propertySupport.setValue(staticValue.toString());
        QName basePropertyQName = QName.createQName(DBQuery.expandQName(functionContext.getAlfrescoPropertyName(getPropertyName()), namespaceService));
        propertySupport.setPropertyQName(basePropertyQName);
        propertySupport.setPropertyDataType(DBQuery.getDataTypeDefinition(dictionaryService, basePropertyQName));
        propertySupport.setPair(qnameDAO.getQName(basePropertyQName));
        propertySupport.setJoinCommandType(DBQueryBuilderJoinCommandType.CONTENT_URL);
        propertySupport.setFieldName("content_size");
        propertySupport.setCommandType(getStaticPosition().equals(ARG_RHS) ? DBQueryBuilderPredicatePartCommandType.GTE : DBQueryBuilderPredicatePartCommandType.GTE.propertyAndValueReversed());
        propertySupport.setLuceneFunction(functionContext.getLuceneFunction(getFunctionArgument()));
        builderSupport = propertySupport;
    } else {
        PropertySupport propertySupport = new PropertySupport();
        propertySupport.setValue(staticValue.toString());
        QName propertyQName = QName.createQName(DBQuery.expandQName(functionContext.getAlfrescoPropertyName(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(getStaticPosition().equals(ARG_RHS) ? DBQueryBuilderPredicatePartCommandType.GTE : DBQueryBuilderPredicatePartCommandType.GTE.propertyAndValueReversed());
        propertySupport.setLuceneFunction(functionContext.getLuceneFunction(getFunctionArgument()));
        builderSupport = propertySupport;
    }
}
Also used : Serializable(java.io.Serializable) QName(org.alfresco.service.namespace.QName) PropertySupport(org.alfresco.repo.search.impl.querymodel.impl.db.PropertySupport)

Example 12 with PropertySupport

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

the class DBNotEquals 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) {
    setPropertyAndStaticArguments(functionArgs);
    Serializable staticValue = getStaticArgument().getValue(functionContext);
    if (getPropertyName().equals(PropertyIds.PARENT_ID)) {
        ParentSupport parentSupport = new ParentSupport();
        String id = (String) staticValue;
        parentSupport.setDbid(DBQuery.getDbid(id, nodeDAO, tenantService));
        parentSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTEQUALS);
        builderSupport = parentSupport;
    } else if (getPropertyName().equals(PropertyIds.OBJECT_ID)) {
        UUIDSupport uuidSupport = new UUIDSupport();
        uuidSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTEQUALS);
        uuidSupport.setUuid(DBQuery.getUUID((String) staticValue));
        builderSupport = uuidSupport;
    } else if (getPropertyName().equals(PropertyIds.OBJECT_TYPE_ID)) {
        TypeSupport typeSupport = new TypeSupport();
        String typeName = functionContext.getAlfrescoTypeName((String) staticValue);
        typeSupport.setQnameIds(DBQuery.findTypeIds(typeName, namespaceService, dictionaryService, qnameDAO, true));
        typeSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTIN);
        builderSupport = typeSupport;
    } else if (getPropertyName().equals(PropertyIds.BASE_TYPE_ID)) {
        TypeSupport typeSupport = new TypeSupport();
        String typeName = functionContext.getAlfrescoTypeName((String) staticValue);
        typeSupport.setQnameIds(DBQuery.findTypeIds(typeName, namespaceService, dictionaryService, qnameDAO, false));
        typeSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTIN);
        builderSupport = typeSupport;
    } else if (getPropertyName().equals(PropertyIds.CONTENT_STREAM_MIME_TYPE)) {
        PropertySupport propertySupport = new PropertySupport();
        propertySupport.setValue(staticValue.toString());
        QName basePropertyQName = QName.createQName(DBQuery.expandQName(functionContext.getAlfrescoPropertyName(getPropertyName()), namespaceService));
        propertySupport.setPropertyQName(basePropertyQName);
        propertySupport.setPropertyDataType(DBQuery.getDataTypeDefinition(dictionaryService, basePropertyQName));
        propertySupport.setPair(qnameDAO.getQName(basePropertyQName));
        propertySupport.setJoinCommandType(DBQueryBuilderJoinCommandType.CONTENT_MIMETYPE);
        propertySupport.setFieldName("mimetype_str");
        propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTEQUALS);
        propertySupport.setLuceneFunction(functionContext.getLuceneFunction(getFunctionArgument()));
        builderSupport = propertySupport;
    } else if (getPropertyName().equals(PropertyIds.CONTENT_STREAM_LENGTH)) {
        PropertySupport propertySupport = new PropertySupport();
        propertySupport.setValue(staticValue.toString());
        QName basePropertyQName = QName.createQName(DBQuery.expandQName(functionContext.getAlfrescoPropertyName(getPropertyName()), namespaceService));
        propertySupport.setPropertyQName(basePropertyQName);
        propertySupport.setPropertyDataType(DBQuery.getDataTypeDefinition(dictionaryService, basePropertyQName));
        propertySupport.setPair(qnameDAO.getQName(basePropertyQName));
        propertySupport.setJoinCommandType(DBQueryBuilderJoinCommandType.CONTENT_URL);
        propertySupport.setFieldName("content_size");
        propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTEQUALS);
        propertySupport.setLuceneFunction(functionContext.getLuceneFunction(getFunctionArgument()));
        builderSupport = propertySupport;
    } else {
        PropertySupport propertySupport = new PropertySupport();
        propertySupport.setValue(staticValue.toString());
        QName propertyQName = QName.createQName(DBQuery.expandQName(functionContext.getAlfrescoPropertyName(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.NOTEQUALS);
        propertySupport.setLuceneFunction(functionContext.getLuceneFunction(getFunctionArgument()));
        builderSupport = propertySupport;
    }
}
Also used : Serializable(java.io.Serializable) UUIDSupport(org.alfresco.repo.search.impl.querymodel.impl.db.UUIDSupport) TypeSupport(org.alfresco.repo.search.impl.querymodel.impl.db.TypeSupport) QName(org.alfresco.service.namespace.QName) ParentSupport(org.alfresco.repo.search.impl.querymodel.impl.db.ParentSupport) PropertySupport(org.alfresco.repo.search.impl.querymodel.impl.db.PropertySupport)

Aggregations

PropertySupport (org.alfresco.repo.search.impl.querymodel.impl.db.PropertySupport)12 QName (org.alfresco.service.namespace.QName)12 Serializable (java.io.Serializable)7 Argument (org.alfresco.repo.search.impl.querymodel.Argument)6 PropertyArgument (org.alfresco.repo.search.impl.querymodel.PropertyArgument)6 ParentSupport (org.alfresco.repo.search.impl.querymodel.impl.db.ParentSupport)6 TypeSupport (org.alfresco.repo.search.impl.querymodel.impl.db.TypeSupport)6 UUIDSupport (org.alfresco.repo.search.impl.querymodel.impl.db.UUIDSupport)4 AnalysisMode (org.alfresco.repo.search.adaptor.lucene.AnalysisMode)3 QueryModelException (org.alfresco.repo.search.impl.querymodel.QueryModelException)3 AspectSupport (org.alfresco.repo.search.impl.querymodel.impl.db.AspectSupport)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 ListArgument (org.alfresco.repo.search.impl.querymodel.ListArgument)1