candlepin/candlepin — pull request #466 by mstead (2013-12-19 15:33:06+00:00)
Title: Support filtering Pools by attribute

Pool filtering by attribute can now be done by adding
'attribute' query parameters to the request URI.

For example:
GET /owners/{owner_key}/pools?attribute=support_type:Premium

A @CandlepinParam can be added to a @QueryParam arguement definition
to customize the parsing of a parameteter. Since 'attribute' parameters
are specified as 'attribute={attributeName}:{attributeValue}', the
attributes parameter is specified as follows:

@QueryParam("attribute") @CandlepinParam(type=KeyValueParameter.class)

This results in a list of KeyValueParameter objects that parse the
attribute name/value from the value string.

A FilterBuilder is then used to determine what attribute filters to
apply to the criteria in the Curators. The intent of this object is
to allow further customizing filters without having to pass more
params down to the curator level. If you want more filtering
capabilities later on, bolt it onto this object.

The current implementation follows the following filter rules:
- parameters specifying the same attribute names will result in
an OR between values.
- parameters specifying different attibute names will result in an
AND between values.
- combinations are Ok between like/unlike attribute names and follow
the same rules.

For example consider:
GET /owners/admin/pools?attribute=support_level:premium&attribute=support_level:none&attribute=sockets:4

This results in:
(support_level == premium OR none) AND sockets == 4

Value comparisons are NOT case sensitive and empty values are supported.

NOTE: Filtering has been omitted from the PoolResource as it is depricated.