<commit_before>package ua.com.fielden.platform.basic.autocompleter;

import ua.com.fielden.platform.basic.IValueMatcherWithContext;
import ua.com.fielden.platform.dao.IEntityDao;
import ua.com.fielden.platform.entity.AbstractEntity;
import ua.com.fielden.platform.entity.query.fluent.EntityQueryProgressiveInterfaces.ICompoundCondition0;
import ua.com.fielden.platform.entity.query.model.EntityResultQueryModel;

/**
 * This is a fall back implementation for {@link IValueMatcherWithContext}, which does not support context. It simply performs the search by key operation.
 *
 * @author TG Team
 *
 * @param <CONTEXT>
 * @param <T>
 */
public class FallbackValueMatcherWithContext<CONTEXT extends AbstractEntity<?>, T extends AbstractEntity<?>> extends AbstractSearchEntityByKeyWithContext<CONTEXT, T> {

    public FallbackValueMatcherWithContext(final IEntityDao<T> dao) {
        super(dao);
    }

    @Override
    public void setContext(final CONTEXT context) {

    }

    @Override
    public CONTEXT getContext() {
        return null;
    }

    @Override
    public Integer getPageSize() {
        return 10;
    }

    @Override
    protected EntityResultQueryModel<T> completeEqlBasedOnContext(
            final CONTEXT context,
            final String searchString,
            final ICompoundCondition0<T> incompleteEql) {
        return incompleteEql.model();
    }

}<commit_msg>#589 Modified the default matching logic to include both 'key' and 'desc' for entities that have property 'desc'. Matching by 'desc' is made less strict than by 'key',  whereby the seach pattern includes search anywhere in the text.<commit_after>package ua.com.fielden.platform.basic.autocompleter;

import ua.com.fielden.platform.basic.IValueMatcherWithContext;
import ua.com.fielden.platform.dao.IEntityDao;
import ua.com.fielden.platform.entity.AbstractEntity;
import ua.com.fielden.platform.entity.query.fluent.EntityQueryProgressiveInterfaces.ICompoundCondition0;
import ua.com.fielden.platform.entity.query.model.EntityResultQueryModel;
import ua.com.fielden.platform.utils.EntityUtils;

/**
 * This is a fall back implementation for {@link IValueMatcherWithContext}, which does not support context. It simply performs the search by key operation.
 *
 * @author <NAME>
 *
 * @param <CONTEXT>
 * @param <T>
 */
public class FallbackValueMatcherWithContext<CONTEXT extends AbstractEntity<?>, T extends AbstractEntity<?>> extends AbstractSearchEntityByKeyWithContext<CONTEXT, T> {

    private final Class<T> entityType;
    
    public FallbackValueMatcherWithContext(final IEntityDao<T> co) {
        super(co);
        
        entityType = co.getEntityType();
    }

    @Override
    public void setContext(final CONTEXT context) {

    }

    @Override
    public CONTEXT getContext() {
        return null;
    }

    @Override
    public Integer getPageSize() {
        return IEntityDao.DEFAULT_PAGE_CAPACITY;
    }

    @Override
    protected EntityResultQueryModel<T> completeEqlBasedOnContext(
            final CONTEXT context,
            final String searchString,
            final ICompoundCondition0<T> incompleteEql) {
        if (EntityUtils.hasDescProperty(entityType)) {
            return incompleteEql.or().upperCase().prop(AbstractEntity.DESC).iLike().val("%" + searchString).model();
        } else {
            return incompleteEql.model();
        }
    }

}
{'fraction_non_alphanumeric': 0.09147241074063145, 'fraction_numerical': 0.0026556506344054295, 'mean_word_length': 3.7148817802503475, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7397607', 'n_tokens_mistral': 967, 'n_tokens_neox': 956, 'n_words': 230}