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