use of com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery in project stdlib by petergeneric.
the class DynamicQueryTest method testEqRefReturnsValue.
@Test
public void testEqRefReturnsValue() throws Exception {
ParentEntity obj = new ParentEntity();
obj.setName("Name");
obj.setOtherObject(new ChildEntity());
obj.getOtherObject().setName("Name");
childDao.save(obj.getOtherObject());
dao.save(obj);
assertEquals(1, dao.findByUriQuery(new WebQuery().eqRef("name", "otherObject.name")).getList().size());
assertEquals(0, dao.findByUriQuery(new WebQuery().neqRef("name", "otherObject.name")).getList().size());
}
use of com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery in project stdlib by petergeneric.
the class DynamicQueryTest method testOrderAsc.
@Test
public void testOrderAsc() throws Exception {
ParentEntity obj1 = new ParentEntity();
obj1.setName("Name1");
dao.save(obj1);
ParentEntity obj2 = new ParentEntity();
obj2.setName("Name2");
dao.save(obj2);
assertEquals(getIds(Arrays.asList(obj1, obj2)), getIds(dao.findByUriQuery(new WebQuery().orderAsc("id")).getList()));
}
use of com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery in project stdlib by petergeneric.
the class DynamicQueryTest method testByBooleanField.
@Test
public void testByBooleanField() throws Exception {
{
ParentEntity obj1 = new ParentEntity();
obj1.setName("Name1");
obj1.setDeprecated(true);
dao.save(obj1);
ParentEntity obj2 = new ParentEntity();
obj2.setName("Name2");
obj2.setDeprecated(true);
dao.save(obj2);
}
assertEquals("deprecated=true matches 2 rows", 2, dao.findByUriQuery(new WebQuery().eq("deprecated", true)).getList().size());
assertEquals("deprecated=false matches nothing", 0, dao.findByUriQuery(new WebQuery().eq("deprecated", false)).getList().size());
}
use of com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery in project stdlib by petergeneric.
the class DynamicQueryTest method testGetUsingPropertiesOfEmbeddedCollection.
@Test
public void testGetUsingPropertiesOfEmbeddedCollection() throws Exception {
// Hibernate will throw if the property doesn't work
WebQuery q = new WebQuery();
q.eq("friends[r0].firstName", "Firstname");
q.eq("friends[r0].lastName", "Surname");
dao.findByUriQuery(q);
}
use of com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery in project stdlib by petergeneric.
the class ResultSetConstraintBuilder method buildQuery.
/**
* Construct a WebQueryDefinition from this, applying the web query semantics
*
* @return
*/
public WebQuery buildQuery() {
Map<String, List<String>> map = new HashMap<>(constraints);
applyDefault(WQUriControlField.FETCH, map, defaultFetch);
applyDefault(WQUriControlField.EXPAND, map, defaultExpand);
applyDefault(WQUriControlField.ORDER, map, defaultOrder);
applyDefault(WQUriControlField.OFFSET, map, "0");
applyDefault(WQUriControlField.LIMIT, map, Integer.toString(defaultLimit));
return new WebQuery().decode(map);
}
Aggregations