It's all about the answers!

Ask a question

SCM query for custom attribute value supports EQUALS but not CONTAINS?


Steven Hovater (109126) | asked Nov 11 '20, 11:11 a.m.
hi all
When constructing an SCM query for a custom attribute value, it appears that you can do this:

 IGenericQueryNode query1 = IGenericQueryNode.FACTORY.newInstance(QueryOperations.OPERATION_EQUALS)
                .addChild(customAttrName).addChild(customAttrVal);

but not

IGenericQueryNode query1 = IGenericQueryNode.FACTORY.newInstance(QueryOperations.OPERATION_CONTAINS)
                .addChild(customAttrName).addChild(customAttrVal);

Neither OPERATION_CONTAINS nor OPERATION_MATCHES works.

RTC 6.0.6.1

Thoughts?

One answer



permanent link
Steven Hovater (109126) | answered Nov 11 '20, 11:20 a.m.
ah. CONTAINS is for tags. That wasn't obvious.

    private static class CustomAttributeTableQueryHandler extends AbstractScmQueryHandler<ICustomAttributeHandle, CustomAttributeQueryModel> {
    
        private CustomAttributeTableQueryHandler(ScmTransactionContext rtc, CustomAttributeQueryModel model) {
    
            super(rtc, model);
    
            Map<String, QueryOperationHandler> queryFunctions = new HashMap<String, QueryOperationHandler>();
    
            queryFunctions.put(QueryOperations.OPERATION_AND, ScmQueryOperationLibrary.genericANDOperationHandler);
    
            queryFunctions.put(QueryOperations.OPERATION_OR, ScmQueryOperationLibrary.genericOROperationHandler);
    
            queryFunctions.put(QueryOperations.OPERATION_EQUALS, ScmQueryOperationLibrary.customAttributeEQOperationHandler);
    
            queryFunctions.put(QueryOperations.OPERATION_HAS_ATTRIBUTE, ScmQueryOperationLibrary.customAttributeExistOperationHandler);
    
            queryFunctions.put(QueryOperations.OPERATION_BASELINE, new InBaselineQueryOperation());
    
            queryFunctions.put(QueryOperations.OPERATION_CONTAINS, ScmQueryOperationLibrary.genericTagsContainsOperationHandler);
    
            queryFunctions.put(QueryOperations.OPERATION_HAS_LINK, ScmQueryOperationLibrary.genericHasLinkOperationHandler);
    
            super.setOperationHandlers(queryFunctions);
    
        }
    

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.