use of com.developmentontheedge.beans.DynamicPropertyBuilder in project be5 by DevelopmentOnTheEdge.
the class FilterHelper method processFilterParams.
public <T extends DynamicPropertySet> T processFilterParams(T dps, Map<String, Object> presetValues, Map<String, String> operationParams) {
Map<String, Object> filterPresetValues = new HashMap<>(operationParams);
filterPresetValues.putAll(presetValues);
List<String> searchPresets = new ArrayList<>();
if (!filterPresetValues.containsKey(SEARCH_PARAM)) {
searchPresets.addAll(presetValues.entrySet().stream().filter(x -> x.getValue() != null).map(Map.Entry::getKey).collect(Collectors.toList()));
} else {
if (filterPresetValues.get(SEARCH_PRESETS_PARAM) != null) {
searchPresets.addAll(Arrays.asList(((String) filterPresetValues.get(SEARCH_PRESETS_PARAM)).split(",")));
}
}
for (DynamicProperty property : dps) {
if (!property.getBooleanAttribute(BeanInfoConstants.LABEL_FIELD)) {
// remove defaultValue
property.setValue(null);
}
}
dpsHelper.setValues(dps, filterPresetValues);
for (DynamicProperty property : dps) {
property.setCanBeNull(true);
if (searchPresets.contains(property.getName()))
property.setReadOnly(true);
}
dps.add(new DynamicPropertyBuilder(SEARCH_PRESETS_PARAM, String.class).value(searchPresets.size() > 0 ? String.join(",", searchPresets) : null).readonly().nullable().hidden().get());
dps.add(new DynamicPropertyBuilder(SEARCH_PARAM, Boolean.class).value(true).readonly().nullable().hidden().get());
return dps;
}
Aggregations