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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations