Search in sources :

Example 21 with FilterCondition

use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.

the class ConfigurationConditionBuilder method createFilterConditionsByConfiguration.

protected List<FilterCondition> createFilterConditionsByConfiguration(Filter.Configuration configuration, @Nullable FilterCondition parent, boolean addHeaderCondition) {
    List<FilterCondition> conditions = new ArrayList<>();
    LogicalFilterComponent rootLogicalFilterComponent = configuration.getRootLogicalFilterComponent();
    FilterConverter converter = filterComponents.getConverterByComponentClass(rootLogicalFilterComponent.getClass(), configuration.getOwner());
    LogicalFilterCondition rootGroupCondition = (LogicalFilterCondition) converter.convertToModel(rootLogicalFilterComponent);
    FilterCondition configurationHeaderCondition = null;
    if (addHeaderCondition) {
        configurationHeaderCondition = createHeaderFilterCondition(configuration.getName());
        configurationHeaderCondition.setParent(parent);
        conditions.add(configurationHeaderCondition);
    }
    List<FilterCondition> groupConditions = createFilterConditionsByLogicalFilterCondition(rootGroupCondition, addHeaderCondition ? configurationHeaderCondition : parent, true);
    conditions.addAll(groupConditions);
    return conditions;
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) ArrayList(java.util.ArrayList) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent)

Example 22 with FilterCondition

use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.

the class ConfigurationConditionBuilder method createFilterConditionsByLogicalFilterCondition.

public List<FilterCondition> createFilterConditionsByLogicalFilterCondition(LogicalFilterCondition logicalFilterCondition, FilterCondition parent, boolean isRootGroupFilterComponent) {
    List<FilterCondition> conditions = new ArrayList<>();
    if (!isRootGroupFilterComponent) {
        logicalFilterCondition.setParent(parent);
        conditions.add(logicalFilterCondition);
    }
    if (logicalFilterCondition.getOwnFilterConditions() != null) {
        for (FilterCondition ownFilterCondition : logicalFilterCondition.getOwnFilterConditions()) {
            FilterCondition parentCondition = isRootGroupFilterComponent ? parent : logicalFilterCondition;
            if (ownFilterCondition instanceof LogicalFilterCondition) {
                List<FilterCondition> children = createFilterConditionsByLogicalFilterCondition((LogicalFilterCondition) ownFilterCondition, parentCondition, false);
                conditions.addAll(children);
            } else {
                ownFilterCondition.setParent(parentCondition);
                conditions.add(ownFilterCondition);
            }
        }
    }
    return conditions;
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) ArrayList(java.util.ArrayList)

Example 23 with FilterCondition

use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.

the class ConfigurationConditionBuilder method createFilterConditionsByConfigurations.

protected List<FilterCondition> createFilterConditionsByConfigurations(List<Filter.Configuration> configurations) {
    List<FilterCondition> conditions = new ArrayList<>();
    HeaderFilterCondition configurationsHeaderCondition = createHeaderFilterCondition(messages.getMessage(ConfigurationConditionBuilder.class, "configurationConditionBuilder.headerCaption"));
    conditions.add(configurationsHeaderCondition);
    for (Filter.Configuration configuration : configurations) {
        conditions.addAll(createFilterConditionsByConfiguration(configuration, configurationsHeaderCondition, true));
    }
    return conditions;
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) Filter(io.jmix.ui.component.Filter) ArrayList(java.util.ArrayList) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition)

Example 24 with FilterCondition

use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.

the class PropertyConditionBuilder method createFilterConditionByPath.

protected FilterCondition createFilterConditionByPath(MetaPropertyPath metaPropertyPath) {
    Class modelClass = filterComponents.getModelClass(PropertyFilter.class);
    FilterCondition filterCondition = (FilterCondition) metadata.create(modelClass);
    MetaClass metaClass = metaPropertyPath.getMetaClass();
    if (PropertyFilterCondition.class.isAssignableFrom(modelClass)) {
        String property = metaPropertyPath.toPathString();
        ((PropertyFilterCondition) filterCondition).setProperty(property);
        ((PropertyFilterCondition) filterCondition).setParameterName(PropertyConditionUtils.generateParameterName(property));
        ((PropertyFilterCondition) filterCondition).setCaptionPosition(SupportsCaptionPosition.CaptionPosition.LEFT);
        String localizedCaption = messageTools.getPropertyCaption(metaClass, property);
        filterCondition.setLocalizedCaption(localizedCaption);
        String propertyFilterPrefix = propertyFilterSupport.getPropertyFilterPrefix(null, property);
        filterCondition.setComponentId(propertyFilterPrefix.substring(0, propertyFilterPrefix.length() - 1));
        PropertyFilter.Operation operation = propertyFilterSupport.getDefaultOperation(metaClass, property);
        ((PropertyFilterCondition) filterCondition).setOperation(operation);
        FilterValueComponent modelValueComponent = metadata.create(FilterValueComponent.class);
        HasValue valueComponent = singleFilterSupport.generateValueComponent(metaClass, property, operation);
        modelValueComponent.setComponentId(valueComponent.getId());
        modelValueComponent.setComponentName(singleFilterSupport.getValueComponentName(valueComponent));
        ((PropertyFilterCondition) filterCondition).setValueComponent(modelValueComponent);
    }
    return filterCondition;
}
Also used : PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) MetaClass(io.jmix.core.metamodel.model.MetaClass) FilterCondition(io.jmix.ui.entity.FilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) FilterValueComponent(io.jmix.ui.entity.FilterValueComponent) MetaClass(io.jmix.core.metamodel.model.MetaClass) PropertyFilter(io.jmix.ui.component.PropertyFilter) HasValue(io.jmix.ui.component.HasValue)

Example 25 with FilterCondition

use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.

the class PropertyConditionBuilder method createFilterConditionsByPaths.

protected List<FilterCondition> createFilterConditionsByPaths(List<MetaPropertyPath> paths) {
    List<FilterCondition> conditions = new ArrayList<>();
    HeaderFilterCondition propertiesHeaderCondition = createHeaderFilterCondition(messages.getMessage(PropertyConditionBuilder.class, "propertyConditionBuilder.headerCaption"));
    conditions.add(propertiesHeaderCondition);
    for (MetaPropertyPath path : paths) {
        FilterCondition condition = createFilterConditionByPath(path);
        FilterCondition parent = path.isDirectProperty() ? propertiesHeaderCondition : getParentCondition(path, conditions);
        condition.setParent(parent);
        conditions.add(condition);
    }
    conditions.sort((condition1, condition2) -> ObjectUtils.compare(condition1.getLocalizedCaption(), condition2.getLocalizedCaption()));
    return conditions;
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) ArrayList(java.util.ArrayList) MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition)

Aggregations

FilterCondition (io.jmix.ui.entity.FilterCondition)25 HeaderFilterCondition (io.jmix.ui.entity.HeaderFilterCondition)14 LogicalFilterCondition (io.jmix.ui.entity.LogicalFilterCondition)13 ArrayList (java.util.ArrayList)8 FilterConverter (io.jmix.ui.component.filter.converter.FilterConverter)6 GroupFilterCondition (io.jmix.ui.entity.GroupFilterCondition)6 PropertyFilterCondition (io.jmix.ui.entity.PropertyFilterCondition)6 AbstractSingleFilterCondition (io.jmix.ui.entity.AbstractSingleFilterCondition)4 JpqlFilterCondition (io.jmix.ui.entity.JpqlFilterCondition)4 FilterComponent (io.jmix.ui.component.FilterComponent)3 LogicalFilterComponent (io.jmix.ui.component.LogicalFilterComponent)3 Subscribe (io.jmix.ui.screen.Subscribe)3 Filter (io.jmix.ui.component.Filter)2 FilterValueComponent (io.jmix.ui.entity.FilterValueComponent)2 MetaClass (io.jmix.core.metamodel.model.MetaClass)1 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 AddConditionScreen (io.jmix.ui.app.filter.condition.AddConditionScreen)1 GroupFilter (io.jmix.ui.component.GroupFilter)1 HasValue (io.jmix.ui.component.HasValue)1 PropertyFilter (io.jmix.ui.component.PropertyFilter)1