/** * 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; }
/** * False. * * Add a restriction that always return false. * * @return {@code this} with the {@code rFalse} restriction added. */ public Search rFalse() { restrictions.add(RestrictionHelper.rFalse()); return this; }
public static Restriction and(Restriction restriction1, Restriction restriction2, Restriction... otherRestrictions) { List<Restriction> restrictions = new LinkedList<Restriction>(); restrictions.add(restriction1); restrictions.add(restriction2); for (Restriction rest : otherRestrictions) { restrictions.add(rest); } return and(restrictions); }
/** * Not ends with. * * Search if an element does not ends with the value in parameter. * * @param element the element on which the restriction is put * @param value the value the element must not ends with. * @return {@code this} with the {@code notew} restriction added. */ public Search notew(String element, String value) { restrictions.add(RestrictionHelper.not( RestrictionHelper.end(elt(element), value))); return this; }
long size = solrResults.size(); if ( size == 0 ) { generatedRestriction = RestrictionHelper.rFalse(); } else if ( size == 1 ) { generatedRestriction = RestrictionHelper.eq( associated.getElement(), (String) solrResults.get(0).getFieldValue(WikittySolrConstant.SOLR_ID) ); } else { and.getRestrictions().add( generatedRestriction ); } else { and = RestrictionHelper.and( Arrays.asList(new Restriction[]{ associated.getParentRestrictionDto(), generatedRestriction }) );
protected Restriction getRestrictions() throws UnsupportedOperationException { Restriction result; if (restrictions.isEmpty() && subSearchs.isEmpty()) { result = RestrictionHelper.rFalse(); result = RestrictionHelper.not(result); result = RestrictionHelper.or(allRestrictions); break; case AND: result = RestrictionHelper.and(allRestrictions); break; default:
long size = solrResults.size(); if ( size == 0 ) { generatedRestriction = RestrictionHelper.rFalse(); } else if ( size == 1 ) { String id = SolrUtil.getStringFieldValue( solrResults.get(0), WikittySolrConstant.SOLR_ID); generatedRestriction = RestrictionHelper.eq(associated.getElement(), id); } else { List<String> ids = new ArrayList<String>(solrResults.size());
public static Restriction contains(Element element, String value1, String... otherValues) { List<String> values = new LinkedList<String>(); values.add(value1); for (String val : otherValues) { values.add(val); } return contains(element, values); }
public static Restriction in(Element element, String value1, String... otherValues) { List<String> values = new LinkedList<String>(); values.add(value1); for (String val : otherValues) { values.add(val); } return in(element, values); }
/** * Greater than. * * Search if an element value is greater 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 gt} restriction added. */ public Search gt(String element, String value) { restrictions.add(RestrictionHelper.great(elt(element), value)); return this; }
/** * Greater than or equals. * * Search if an element value is greater than or equals to the parameter. * * @param element the field on which the search is made * @param value the value to be compared to * @return {@code this} with the {@code ge} restriction added. */ public Search ge(String element, String value) { restrictions.add(RestrictionHelper.greatEq(elt(element), value)); return this; }
/** * Ends with. * * Search if an element ends with the value in parameter. * * @param element the element on which the restriction is put * @param value the value the element must ends with. * @return {@code this} with the {@code ew} restriction added. */ public Search ew(String element, String value) { restrictions.add(RestrictionHelper.end(elt(element), value)); return this; }
/** * Between. * * Restrict search so that the element value is between the lower and upper * values (it can also be equals). * * @param element the element on which the restriction is put. * @param lowerValue the lower bound. * @param upperValue the upper bound. * @return {@code this} with the {@code le} restriction added. */ public Search bw(String element, String lowerValue, String upperValue) { restrictions.add(RestrictionHelper.between(elt(element), lowerValue, upperValue)); return this; }
/** * Contains. * * Search on lists (multivalued fields) that a field contains all the values * of the list given in parameter. * * Ex : The field with value [toto,titi,tutu] contains [titi,tutu] but not * [titi,tutu,tata] * * Ps : Use wildcards if you search for substrings. * * @param element the element on which the restriction is put * @param values the values to search in the element * @return {@code this} with the {@code contains} restriction added. */ public Search contains(String element, Collection<String> values) { restrictions.add(RestrictionHelper.contains(elt(element), new ArrayList<String>(values))); return this; }
/** * In. * * Search if a field is contained in the list of values in parameter * * Ex : The field with value titi is in [titi,tutu] but not in * [tutu,tata] * * Ps : Use wildcards in the values if you search for substrings. * * @param element the element on which the restriction is put * @param values list of values the field must be in * @return {@code this} with the {@code in} restriction added. */ public Search in(String element, Collection<String> values) { restrictions.add(RestrictionHelper.in(elt(element), new ArrayList<String>(values))); return this; }
/** * 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; }
/** * Contains. * * Search on lists (multivalued fields) that a field contains all the values * given in parameter. * * Ex : The field with value [toto,titi,tutu] contains [titi,tutu] but not * [titi,tutu,tata] * * Ps : Use wildcards if you search for substrings. * * @param element the element on which the restriction is put * @param value1 first value to search in the field * @param values list of values to search in the field * @return {@code this} with the {@code contains} restriction added. */ public Search contains(String element, String value1, String ... values) { restrictions.add(RestrictionHelper.contains(elt(element), value1, values)); return this; }
/** * In. * * Search if a field is contained in the list of values in parameter * * Ex : The field with value titi is in [titi,tutu] but not in * [tutu,tata] * * Ps : Use wildcards in the values if you search for substrings. * * @param element the element on which the restriction is put * @param value1 first value the field must be in * @param values list of values the field must be in * @return {@code this} with the {@code in} restriction added. */ public Search in(String element, String value1, String ... values) { restrictions.add(RestrictionHelper.in(elt(element), value1, values)); return this; }
/** * Equals. * * Restrict search so that the field value equals the parameter. * * You might use patterns in your equality. * * @param element the field on which the search is made * @param value the value the element must be equals to * @return {@code this} */ public Search eq(String element, String value) { restrictions.add(RestrictionHelper.eq(elt(element), value)); return this; }
/** * Extension equals. * * Restrict search to wikitties that got all the extensions in parameter. * * @param values list of the extension to restrict the results to * @return {@code this} with the {@code exteq} restriction added. */ public Search exteq(Collection<String> values) { // erreur, car si le search est fait avec un OR au lieu d'un AND // on a pas ce que l'on veut. for (String value : values) { restrictions.add(RestrictionHelper.eq(elt(Element.ELT_EXTENSION), value)); } return this; }