use of com.evolveum.midpoint.util.DisplayableValue in project midpoint by Evolveum.
the class SearchItemPanel method loadPopoverItems.
private SearchItemPopoverDto loadPopoverItems() {
SearchItemPopoverDto dto = new SearchItemPopoverDto();
SearchItem item = getModelObject();
for (DisplayableValue<? extends Serializable> value : (List<DisplayableValue>) item.getValues()) {
DisplayableValue itemValue = new SearchValue(value.getValue(), value.getLabel());
dto.getValues().add(itemValue);
}
if (dto.getValues().isEmpty()) {
dto.getValues().add(new SearchValue());
}
return dto;
}
use of com.evolveum.midpoint.util.DisplayableValue in project midpoint by Evolveum.
the class SearchItemPanel method updateItemPerformed.
private void updateItemPerformed(AjaxRequestTarget target) {
SearchItem item = getModelObject();
item.getValues().clear();
SearchItemPopoverDto dto = popoverModel.getObject();
for (DisplayableValue value : dto.getValues()) {
item.getValues().add(value);
}
LOG.debug("Update item performed, item {} value is {}", item.getName(), item.getValues());
SearchPanel panel = findParent(SearchPanel.class);
panel.refreshSearchForm(target);
panel.searchPerformed(target);
}
use of com.evolveum.midpoint.util.DisplayableValue in project midpoint by Evolveum.
the class SearchValue method setValue.
public void setValue(T value) {
this.value = value;
this.label = null;
if (value instanceof DisplayableValue) {
DisplayableValue dv = (DisplayableValue) value;
setLabel(dv.getLabel());
}
}
use of com.evolveum.midpoint.util.DisplayableValue in project midpoint by Evolveum.
the class Search method createFilterForSearchValue.
private ObjectFilter createFilterForSearchValue(SearchItem item, DisplayableValue searchValue, PrismContext ctx) {
ItemDefinition definition = item.getDefinition();
ItemPath path = item.getPath();
if (definition instanceof PrismReferenceDefinition) {
return QueryBuilder.queryFor(ObjectType.class, ctx).item(path, definition).ref((PrismReferenceValue) searchValue.getValue()).buildFilter();
}
PrismPropertyDefinition propDef = (PrismPropertyDefinition) definition;
if ((propDef.getAllowedValues() != null && !propDef.getAllowedValues().isEmpty()) || DOMUtil.XSD_BOOLEAN.equals(propDef.getTypeName())) {
//we're looking for enum value, therefore equals filter is ok
//or if it's boolean value
DisplayableValue displayableValue = (DisplayableValue) searchValue.getValue();
Object value = displayableValue.getValue();
return QueryBuilder.queryFor(ObjectType.class, ctx).item(path, propDef).eq(value).buildFilter();
} else if (DOMUtil.XSD_INT.equals(propDef.getTypeName()) || DOMUtil.XSD_INTEGER.equals(propDef.getTypeName()) || DOMUtil.XSD_LONG.equals(propDef.getTypeName()) || DOMUtil.XSD_SHORT.equals(propDef.getTypeName())) {
String text = (String) searchValue.getValue();
if (!StringUtils.isNumeric(text) && (searchValue instanceof SearchValue)) {
((SearchValue) searchValue).clear();
return null;
}
Object value = Long.parseLong((String) searchValue.getValue());
return QueryBuilder.queryFor(ObjectType.class, ctx).item(path, propDef).eq(value).buildFilter();
} else if (DOMUtil.XSD_STRING.equals(propDef.getTypeName())) {
String text = (String) searchValue.getValue();
return QueryBuilder.queryFor(ObjectType.class, ctx).item(path, propDef).contains(text).matchingCaseIgnore().buildFilter();
} else if (SchemaConstants.T_POLY_STRING_TYPE.equals(propDef.getTypeName())) {
//we're looking for string value, therefore substring filter should be used
String text = (String) searchValue.getValue();
PolyStringNormalizer normalizer = ctx.getDefaultPolyStringNormalizer();
String value = normalizer.normalize(text);
return QueryBuilder.queryFor(ObjectType.class, ctx).item(path, propDef).contains(text).matchingNorm().buildFilter();
}
if (searchValue instanceof SearchValue) {
((SearchValue) searchValue).clear();
}
return null;
}
use of com.evolveum.midpoint.util.DisplayableValue in project midpoint by Evolveum.
the class SearchItem method getAllowedValues.
public List<DisplayableValue> getAllowedValues() {
List<DisplayableValue> list = new ArrayList();
if (!(definition instanceof PrismPropertyDefinition)) {
return list;
}
PrismPropertyDefinition def = (PrismPropertyDefinition) definition;
list.addAll(def.getAllowedValues());
return list;
}
Aggregations