Page tree
Skip to end of metadata
Go to start of metadata

This page is outdated. Please see Query API instead.

MidPoint Query API can be used to construct queries and different filters used by search method. With current implementation it is possible to construct following filters:

  • logical filters : and, or, not
  • value filters: equals, like, in, greater, less

Logical filters

Logical filters can be simply created using factory methods. You can create and, or or not filter in the following way:

And filter:

AndFilter and = AndFilter.createAnd(filter1, filter2, filter3);


List<ObjectFilter> filters = new ArrayList<ObjectFilter>();
AndFilter and = AndFilter.createAnd(filters);

where filter1, filter2 and filter3 can represent another logical or value filter. 

Or filter:

OrFilter or = OrFilter.createOr(filter1, filter2, filter3);


List<ObjectFilter> filters = new ArrayList<ObjectFilter>();
OrFilter and = OrFilter.createOr(filters); 

where filter1, filter2 and filter3 can represent another logical or value filter.

Not filter:

NotFilter not = NotFilter.createNot(filter); 

where filter can represent another logical or value filter.

Value filters

Supported value filters in midPoint are equal, like, in, greater and less. Value filters consist of:

  • fullPath – path to the property. It is required to use full property path. Examples: UserType.F_NAME – path to the name property, new ItemPath(ShadowType.F_ATTRIBUTES, attributeName.
  • itemDefinition – definition of the property (reference), e.g. user.getDefinition().findPropertyDefinition(UserType.F_NAME)
  • prismContext
  • matchingRule – matching rule to use by querying objects. Following matching rules are supported in midPoint:

    PolyStringNormMatchingRulenormalized value will be used in query
    PolyStringOrigMatchingRuleoriginal value will be used in query
    PolyStringStrictMatchingRuleboth, normalized and original value will be used in query
    StringIgnoreCaseMatchingRulethe query will be constructed as case insensitive
    DefaultMatchingRuleused by default
  • values – possible values which the object's property should have. It can be null and instead of concrete value the expression may be used.
  • expression (e.g. script) – the values will be evaluated from the expression.

For greater and less filter there is one more property

  • isEqual - tells if the query will be represented as greaterEquals or simple greater (lessEqual or simple less).

Each of the filters can be also simply created using factory methods. The usage is as follows:

Equals filter

MidPoint representation for equal filter is EqualsFilter for properties and RefFilter for references. Different factory methods can be used to construct equals filter. It depends on programmer choice which factory method is the most suitable. Some examples are described bellow:

 EqualsFilter equals = EqualsFilter.createEqual(UserType.F_NAME, nameProperty);


 EqualsFilter equals = EqualsFilter.createEqual(new ItemPath(UserType.F_NAME), user.getDefinition().findPropertyDefinition(UserType.F_NAME), null, new PolyString("someName"));


 EqualsFilter equals = EqualsFilter.createEqual(UserType.F_NAME, UserType.class, prismContext, PolyStringNormMatchingRule.NAME, new PolyString("someName"));


RefFilter refEquals = RefFilter.createReferenceEqual(ShadowType.F_RESOURCE_REF, shadow.getResourceRef());


PrismReferenceDefinition definition = repositoryShadow.getDefinition().findReferenceDefinition(ShadowType.F_RESOURCE_REF);
RefFilter refEquals = RefFilter.createReferenceEqual(ShadowType.F_RESOURCE_REF, definition, "aae7be60-df56-11df-8608-0002a5d5c51b");


RefFilter refEquals = RefFilter.createReferenceEqual(ShadowType.F_RESOURCE_REF, ShadowType.class, resource);

Like filter

Like filter can be created usig SubstringFilter class and its factory methods. Different factory methods are provided and the choise is left on the programmer. Bellow are some examples how to use midPoint's Substring filter:

SubstringFilter substring = SubstringFilter.createSubstring(propertyName, propertyDefinition, matchingRule, values);


SubstringFilter substring = SubstringFilter.createSubstring(fullItemPath, type, prismContext, matchingRule, values);

In filter

If you need to compare property agains some collection of values, use in filter. Its representation in midpoint is InFilter.  Example usage for InFilter: 

InFilter in = InFilter.createIn(fullItemPath, propertyDefnition, matchingRule, valueCollection);


InFilter in = InFilter.createIn(propertyName, type, prismContext, matchingRule, valueCollection);

One speciality in midPoint is InOidFilter which can be used for „multi-get“ operation. InOidFilter can be used when you want to select more than one object at the same time and you know identifier of these objects. Example usage of InOidFilter is listed bellow:

InOidFilter inOid = InOidFilter.createInOid(collectionOfOids);

Greater filter

Factory methods in GreaterFilter class are used to construct greater filter. The example usage of these factory methods are bellow:

GreaterFilter greater = GreaterFilter.createGreater(fullItemPath, propertyDefinition, value(s), true);


GreaterFilter greater = GreaterFilter.createGreater(propertyName, propertyDefinition, value(s), false);

Less filter

Less filter can be simply constructed using factory methods in LessFilter class. There are similar methods like in the GreaterFilter class and the usage is almost the same. For example:

LessFilter greater = LessFilter.createLess(fullItemPath, propertyDefinition, value(s), true);


LessFilter greater = LessFilter.createLess(propertyName, propertyDefinition, value(s), false);

Constructing Query

After the filter is successfully created following facotry method can be used to construct query.

ObjectQuery query = ObjectQuery.create(filter);

TODO paging

External links

  • No labels