Search in sources :

Example 1 with FilterConverter

use of io.jmix.ui.component.filter.converter.FilterConverter in project jmix by jmix-framework.

the class FilterCopyAction method copyConfiguration.

@SuppressWarnings({ "unchecked", "rawtypes" })
public void copyConfiguration(Filter.Configuration sourceConfiguration, Filter.Configuration destConfiguration) {
    destConfiguration.getRootLogicalFilterComponent().removeAll();
    Map<String, Object> valuesMap = filterSupport.initConfigurationValuesMap(sourceConfiguration);
    LogicalFilterComponent sourceRootComponent = sourceConfiguration.getRootLogicalFilterComponent();
    FilterConverter converter = filterComponents.getConverterByComponentClass(sourceRootComponent.getClass(), filter);
    FilterCondition filterCondition = converter.convertToModel(sourceRootComponent);
    filterSupport.resetConfigurationValuesMap(sourceConfiguration, valuesMap);
    LogicalFilterComponent copy = (LogicalFilterComponent) converter.convertToComponent(filterCondition);
    destConfiguration.setRootLogicalFilterComponent(copy);
    filterSupport.refreshConfigurationDefaultValues(destConfiguration);
    filterSupport.resetConfigurationValuesMap(destConfiguration, valuesMap);
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent)

Example 2 with FilterConverter

use of io.jmix.ui.component.filter.converter.FilterConverter in project jmix by jmix-framework.

the class FilterConfigurationConverter method toConfiguration.

public Filter.Configuration toConfiguration(FilterConfiguration configurationModel, Filter filter) {
    String id = configurationModel.getConfigurationId();
    LogicalFilterCondition rootCondition = configurationModel.getRootCondition();
    FilterConverter converter = filterComponents.getConverterByModelClass(rootCondition.getClass(), filter);
    LogicalFilterComponent logicalFilterComponent = (LogicalFilterComponent) converter.convertToComponent(rootCondition);
    Filter.Configuration configuration = new RunTimeConfiguration(id, logicalFilterComponent, filter);
    configuration.setName(configurationModel.getName());
    for (FilterComponent filterComponent : logicalFilterComponent.getFilterComponents()) {
        if (filterComponent instanceof SingleFilterComponent) {
            configuration.setFilterComponentDefaultValue(((SingleFilterComponent<?>) filterComponent).getParameterName(), ((SingleFilterComponent<?>) filterComponent).getValue());
        }
    }
    return configuration;
}
Also used : Filter(io.jmix.ui.component.Filter) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) SingleFilterComponent(io.jmix.ui.component.SingleFilterComponent) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent) FilterComponent(io.jmix.ui.component.FilterComponent) RunTimeConfiguration(io.jmix.ui.component.filter.configuration.RunTimeConfiguration) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent) SingleFilterComponent(io.jmix.ui.component.SingleFilterComponent)

Example 3 with FilterConverter

use of io.jmix.ui.component.filter.converter.FilterConverter in project jmix by jmix-framework.

the class FilterSaveAsAction method copyConfiguration.

@SuppressWarnings({ "rawtypes", "unchecked" })
protected Filter.Configuration copyConfiguration(String newId, Filter.Configuration existingConfiguration) {
    LogicalFilterComponent rootLogicalFilterComponent = existingConfiguration.getRootLogicalFilterComponent();
    FilterConverter converter = filterComponents.getConverterByComponentClass(rootLogicalFilterComponent.getClass(), filter);
    Map<String, Object> valuesMap = filterSupport.initConfigurationValuesMap(existingConfiguration);
    LogicalFilterCondition logicalFilterCondition = (LogicalFilterCondition) converter.convertToModel(rootLogicalFilterComponent);
    filterSupport.resetConfigurationValuesMap(existingConfiguration, valuesMap);
    LogicalFilterComponent logicalFilterComponent = (LogicalFilterComponent) converter.convertToComponent(logicalFilterCondition);
    Filter.Configuration newConfiguration = new RunTimeConfiguration(newId, logicalFilterComponent, existingConfiguration.getOwner());
    filterSupport.refreshConfigurationDefaultValues(newConfiguration);
    filterSupport.resetConfigurationValuesMap(newConfiguration, valuesMap);
    return newConfiguration;
}
Also used : Filter(io.jmix.ui.component.Filter) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) RunTimeConfiguration(io.jmix.ui.component.filter.configuration.RunTimeConfiguration) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent)

Example 4 with FilterConverter

use of io.jmix.ui.component.filter.converter.FilterConverter in project jmix by jmix-framework.

the class PredefinedConditionBuilder method createFilterConditions.

protected List<FilterCondition> createFilterConditions(Filter filter) {
    List<FilterComponent> components = filter.getConditions();
    List<FilterCondition> conditions = new ArrayList<>();
    HeaderFilterCondition conditionsHeaderCondition = createHeaderFilterCondition(messages.getMessage(PredefinedConditionBuilder.class, "predefinedConditionBuilder.headerCaption"));
    conditions.add(conditionsHeaderCondition);
    for (FilterComponent component : components) {
        FilterConverter converter = filterComponents.getConverterByComponentClass(component.getClass(), filter);
        FilterCondition condition = converter.convertToModel(component);
        condition.setParent(conditionsHeaderCondition);
        conditions.add(condition);
        if (condition instanceof LogicalFilterCondition) {
            List<FilterCondition> children = createFilterConditionsByLogicalFilterCondition((LogicalFilterCondition) condition, condition, true);
            conditions.addAll(children);
        }
    }
    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) FilterComponent(io.jmix.ui.component.FilterComponent) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter)

Example 5 with FilterConverter

use of io.jmix.ui.component.filter.converter.FilterConverter in project jmix by jmix-framework.

the class GroupFilterConverter method convertToModel.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public GroupFilterCondition convertToModel(GroupFilter groupFilter) {
    GroupFilterCondition groupFilterCondition = super.convertToModel(groupFilter);
    groupFilterCondition.setOperation(groupFilter.getOperation());
    groupFilterCondition.setCaption(groupFilter.getCaption());
    groupFilterCondition.setLocalizedCaption(getLocalizedModelCaption(groupFilter));
    groupFilterCondition.setOperationCaptionVisible(groupFilter.isOperationCaptionVisible());
    List<FilterCondition> ownFilterConditions = new ArrayList<>();
    for (FilterComponent ownFilterComponent : groupFilter.getOwnFilterComponents()) {
        FilterConverter ownFilterConverter = filterComponents.getConverterByComponentClass(ownFilterComponent.getClass(), filter);
        FilterCondition ownFilterCondition = ownFilterConverter.convertToModel(ownFilterComponent);
        ownFilterCondition.setParent(groupFilterCondition);
        ownFilterConditions.add(ownFilterCondition);
    }
    if (!ownFilterConditions.isEmpty()) {
        groupFilterCondition.setOwnFilterConditions(ownFilterConditions);
    }
    return groupFilterCondition;
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) GroupFilterCondition(io.jmix.ui.entity.GroupFilterCondition) ArrayList(java.util.ArrayList) GroupFilterCondition(io.jmix.ui.entity.GroupFilterCondition) FilterComponent(io.jmix.ui.component.FilterComponent) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter)

Aggregations

FilterConverter (io.jmix.ui.component.filter.converter.FilterConverter)10 LogicalFilterComponent (io.jmix.ui.component.LogicalFilterComponent)7 FilterCondition (io.jmix.ui.entity.FilterCondition)6 Filter (io.jmix.ui.component.Filter)5 LogicalFilterCondition (io.jmix.ui.entity.LogicalFilterCondition)5 FilterComponent (io.jmix.ui.component.FilterComponent)4 HeaderFilterCondition (io.jmix.ui.entity.HeaderFilterCondition)3 ArrayList (java.util.ArrayList)3 SingleFilterComponent (io.jmix.ui.component.SingleFilterComponent)2 RunTimeConfiguration (io.jmix.ui.component.filter.configuration.RunTimeConfiguration)2 GroupFilterCondition (io.jmix.ui.entity.GroupFilterCondition)2 FilterConditionEdit (io.jmix.ui.app.filter.condition.FilterConditionEdit)1 GroupFilterConditionEdit (io.jmix.ui.app.filter.condition.GroupFilterConditionEdit)1 Component (io.jmix.ui.component.Component)1 Fragment (io.jmix.ui.component.Fragment)1 GroupFilter (io.jmix.ui.component.GroupFilter)1 Screen (io.jmix.ui.screen.Screen)1 ScreenFragment (io.jmix.ui.screen.ScreenFragment)1