use of org.apache.cxf.jaxrs.ext.search.client.SearchConditionBuilder in project tesb-rt-se by Talend.
the class RESTClient method useSearchService.
/**
* SearchService is a service which shares the information about Persons with the PersonService.
* It lets users search for individual people using simple or complex search expressions.
* The interaction with this service also verifies that the JAX-RS server is capable of supporting multiple
* root resource classes
*/
private void useSearchService() throws Exception {
System.out.println("Searching...");
WebClient wc = WebClient.create("http://localhost:" + port + "/services/personservice/search");
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
wc.accept(MediaType.APPLICATION_XML);
// Moves to "/services/personservice/search"
wc.path("person");
SearchConditionBuilder builder = SearchConditionBuilder.instance();
System.out.println("Find people with the name Fred or Lorraine:");
String query = builder.is("name").equalTo("Fred").or().is("name").equalTo("Lorraine").query();
findPersons(wc, query);
System.out.println("Find all people who are no more than 30 years old");
query = builder.is("age").lessOrEqualTo(30).query();
findPersons(wc, query);
System.out.println("Find all people who are older than 28 and whose father name is John");
query = builder.is("age").greaterThan(28).and("fatherName").equalTo("John").query();
findPersons(wc, query);
System.out.println("Find all people who have children with name Fred");
query = builder.is("childName").equalTo("Fred").query();
findPersons(wc, query);
// Moves to "/services/personservice/personinfo"
wc.reset().accept(MediaType.APPLICATION_XML);
wc.path("personinfo");
System.out.println("Find all people younger than 40 using JPA2 Tuples");
query = builder.is("age").lessThan(40).query();
// Use URI path component to capture the query expression
wc.path(query);
Collection<? extends PersonInfo> personInfos = wc.getCollection(PersonInfo.class);
for (PersonInfo pi : personInfos) {
System.out.println("ID : " + pi.getId());
}
wc.close();
}
use of org.apache.cxf.jaxrs.ext.search.client.SearchConditionBuilder in project cxf by apache.
the class SearchContextImpl method convertPlainQueriesToFiqlExp.
private String convertPlainQueriesToFiqlExp(MultivaluedMap<String, String> params) {
SearchConditionBuilder builder = SearchConditionBuilder.instance();
List<CompleteCondition> list = new ArrayList<>(params.size());
for (Map.Entry<String, List<String>> entry : params.entrySet()) {
list.add(getOrCondition(builder, entry));
}
return builder.and(list).query();
}
Aggregations