Finally I managed to publish draft version, it's already commited as revision
1078380 (unfortunatelly Hudson/Jenkins shows previous builds failed so I
guess the one ignited by my commit also will fail). Anyway you can find
"org.apache.cxf.jaxrs.ext.search.client" package that has
SearchConditionBuilder fluent interface with FIQL implementation.
The interface is composed of subinterfaces to allow writer use only these
operations that make sense at the moment e.g. one cannot say
'is("foo").and().greaterThan(10)'. This syntax checking makes writing more
fluent for developer especially in IDE with intelli-type mechanism.

Most examples are built-in unit test, but just to make a teaser, let me
share couple examples:

FiqlSearchConditionBuilder b = new FiqlSearchConditionBuilder();
b.query().is("price").greaterThan(30).and().is("price").lessThan(50).build();
// gives "price=gt=30.0;price=lt=50.0"

for complex situation with multilateral junctions, fluent interface is a bit
broken but one can still express it like this one:

PartialCondition c = b.query();
c.is("price").lessThan(100).and().or(
      c.is("title").equalTo("The lord*"), 
      c.is("author").equalTo("R.R.Tolkien")).build();
// gives "price=lt=100.0;(title==The lord*,author==R.R.Tolkien)"


As always I am waiting for comments.

The other issue I fixed is my second commit (revision 1078381) regarding
flaw in SimpleSearchCondition. Till now it was not checked that condition
object of type T cannot have property (getter to be precise) that returns
primitive type. This is limiting but is necessary: mechanism heavily rely on
nullability of properties - null field means it is not used as criterion;
since primitive types are not nullable, this led to misbehavior of engine
(which was not detected by unit tests so far). This fix introduces check
that throws exception when detects using primitive type in property of type
T. It means that if we want to use jaxrs-annotated POJOs they are
additinally constrained (I had to change SearchContextImplTest to not use
Book class from resources having getId() returning int).

cheers,
-andy.

--
View this message in context: 
http://cxf.547215.n5.nabble.com/SeachConditionBuilder-for-CXF-JAX-RS-clients-tp3357826p3411039.html
Sent from the cxf-dev mailing list archive at Nabble.com.

Reply via email to