Search in sources :

Example 1 with DisplayableValue

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;
}
Also used : DisplayableValue(com.evolveum.midpoint.util.DisplayableValue) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with DisplayableValue

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);
}
Also used : DisplayableValue(com.evolveum.midpoint.util.DisplayableValue)

Example 3 with DisplayableValue

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());
    }
}
Also used : DisplayableValue(com.evolveum.midpoint.util.DisplayableValue)

Example 4 with DisplayableValue

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;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) DisplayableValue(com.evolveum.midpoint.util.DisplayableValue) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Example 5 with DisplayableValue

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;
}
Also used : DisplayableValue(com.evolveum.midpoint.util.DisplayableValue) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) ArrayList(java.util.ArrayList)

Aggregations

DisplayableValue (com.evolveum.midpoint.util.DisplayableValue)7 ArrayList (java.util.ArrayList)3 List (java.util.List)2 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 PolyStringNormalizer (com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)1 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)1 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)1 IChoiceRenderer (org.apache.wicket.markup.html.form.IChoiceRenderer)1 IModel (org.apache.wicket.model.IModel)1