/** * Return named criteria. * * @param name name of criteria * @return new criteria */ public Criteria criteria(String name) { Criteria criteria = new Criteria(name); Restriction result = getRestrictions(); criteria.setRestriction(result); return criteria; }
/** * Create new {@code Search} object with default kind to {@link KIND#AND}. * * @return Search helper */ public static Search query() { Search search = query(KIND.AND); return search; }
/** * Return the first element in result * * Can throw an exception if no element available * @return first element */ public T getFirst() { T result = get(0); return result; }
@Test public void testBinaryOperators() throws Exception { checkSearch( q().eq(elementName, value), RestrictionName.EQUALS ); checkSearch( q().neq(elementName, value), RestrictionName.NOT_EQUALS ); checkSearch( q().lt(elementName, value), RestrictionName.LESS ); checkSearch( q().le(elementName, value), RestrictionName.LESS_OR_EQUAL ); checkSearch( q().gt(elementName, value), RestrictionName.GREATER ); checkSearch( q().ge(elementName, value), RestrictionName.GREATER_OR_EQUAL ); checkSearch( q().sw(elementName, value), RestrictionName.STARTS_WITH ); checkSearch( q().ew(elementName, value), RestrictionName.ENDS_WITH ); }
protected void checkSearch( Search search, RestrictionName name ) throws Exception { Restriction dto = search.criteria().getRestriction(); checkRestriction( dto, name, elementName, value ); }
/** * Id equals. * * Restrict search to wikitties that got the id in parameter. * * @param value the id to restrict the results to * @return {@code this} with the {@code ideq} restriction added. */ public Search ideq(String value) { restrictions.add(RestrictionHelper.eq(elt(Element.ELT_ID), value)); return this; }
/** * Return unnamed criteria. * * @return new criteria */ public Criteria criteria() { Criteria criteria = criteria(null); return criteria; }
/** * Unlike. * * @param element the element on which the restriction is put * @param value * @param searchAs * @return {@code this} */ public Search unlike(String element, String value, Like.SearchAs searchAs) { restrictions.add(RestrictionHelper.unlike(elt(element), value, searchAs)); return this; }
@Override public String toString() { return toXML(this); } }
/** * Id not equals. * * Restrict search to wikitties that do not have the id given in parameter. * * @param value the id the wikitties must not have. * @return {@code this} with the {@code idneq} restriction added. */ public Search idneq(String value) { restrictions.add(RestrictionHelper.neq(elt(Element.ELT_ID), value)); return this; }
/** * Less than. * * Search if an element value is less than the parameter. * * @param element the element on which the restriction is put * @param value the value to be compared to * @return {@code this} with the {@code lt} restriction added. */ public Search lt(String element, String value) { restrictions.add(RestrictionHelper.less(elt(element), value)); return this; }
/** * Starts with. * * Search if an element starts with the value in parameter. * * @param element the element on which the restriction is put. * @param value the value the element must start with. * @return {@code this} with the {@code sw} restriction added. */ public Search sw(String element, String value) { restrictions.add(RestrictionHelper.start(elt(element), value)); return this; }
/** * Create new {@code Search} object with custom kind. * * @param kind kind * @return Search helper */ public static Search query(KIND kind) { Search search = new Search(); search.kind = kind; return search; }
/** * Retourne l'objet associe avec ce noeud (id, wikitty ou BusinessEntity) * @return l'objet associe avec ce noeud (id, wikitty ou BusinessEntity) */ public T getObject() { return getUserObject(); }
/** * Substitue la restriction de ce critere par celui de search * @param search */ public void setRestriction(Search search) { this.restriction = search.getRestrictions(); }
/** * Call {@link #cast(WikittyProxy, Class, boolean)} with * autoconvert = true * * @param proxy used to retrieve securityToken and WikittyService * @param clazz target PagedResult type * @return new PagedResult, this result can have less elements that original * for some reason (security, ...) */ public <E extends BusinessEntityImpl> PagedResult<E> cast( WikittyProxy proxy, Class<E> clazz) { return cast(proxy, clazz, true); }
/** * Extension equals. * * Restrict search to wikitties that got the extension in parameter. * * @param value the extension to restrict the results to * @return {@code this} with the {@code exteq} restriction added. */ public Search exteq(String value) { restrictions.add(RestrictionHelper.eq(elt(Element.ELT_EXTENSION), value)); return this; }