Class VocabularySearchRequest

java.lang.Object
com.persequor.event.VocabularySearchRequest

public final class VocabularySearchRequest extends Object
Parametrized query used for searching vocabularies
  • Method Details

    • build

      public static VocabularySearchRequest build(VocabularyUri vocabularyUri)
    • getVocabularyUri

      @Nonnull public VocabularyUri getVocabularyUri()
    • getElementId

      @Nullable @Deprecated public ElementUri getElementId()
      Deprecated.
      because multiple element ids are now supported, use getElementIds() instead
      Returns:
      the FIRST element id to search for, or null if no element id is set
      See Also:
    • getElementIds

      @Nullable public Set<ElementUri> getElementIds()
      Get the element ids to search for

      Only one of the element IDs need to match for a vocabulary element to be returned

      This will NOT return an empty list if no element id filtering is set, but instead null to clearly indicate that no filtering is set

      Returns:
      element ids to search for, or null if no element id filtering is set
    • setElementId

      public VocabularySearchRequest setElementId(@Nullable ElementUri elementId)
      Set the element id to search for

      Only elements matching the provided element id will be returned

      If null is provided then the request will not filter by element id

      Convenience method for setElementIds(Collection) for single element id requests

      Parameters:
      elementId - element id to search for, or null to not filter by element id
      Returns:
      instance of this request
      See Also:
    • setElementIds

      public VocabularySearchRequest setElementIds(@Nullable ElementUri... elementIds)
      Set the element ids to search for

      Only elements matching one of the provided element ids will be returned

      If no element ids are provided, or if the array is null, it is equivalent to calling setElementId(ElementUri) with null.

      Parameters:
      elementIds - element ids to search for, or null or an empty array to not filter by element id
      Returns:
      instance of this request
      Throws:
      IllegalArgumentException - if an array containing null element ids is provided
      See Also:
    • setElementIds

      public VocabularySearchRequest setElementIds(@Nullable Collection<ElementUri> elementIds)
      Set the element ids to search for

      Only elements matching one of the provided element ids will be returned

      If no element ids are provided, or if the collection is null, it is equivalent to calling setElementId(ElementUri) with null.

      Elements in the provided collection must not be null, otherwise an exception will be thrown

      Parameters:
      elementIds - element ids to search for, or null or an empty collection to not filter by element id
      Returns:
      instance of this request
      Throws:
      IllegalArgumentException - if a collection containing null element ids is provided
    • addElementIds

      public VocabularySearchRequest addElementIds(@Nonnull ElementUri... elementIds)
      Add element ids to the search request, in addition to any existing element ids

      Elements in the provided array must not be null, otherwise an exception will be thrown

      Parameters:
      elementIds - element ids to add
      Returns:
      instance of this request
    • addElementIds

      public VocabularySearchRequest addElementIds(@Nonnull Collection<ElementUri> elementIds)
      Add element ids to the search request, in addition to any existing element ids

      Elements in the provided collection must not be null, otherwise an exception will be thrown

      Parameters:
      elementIds - element ids to add
      Returns:
      instance of this request
    • isIncludeAttributes

      public boolean isIncludeAttributes()
    • setIncludeAttributes

      public VocabularySearchRequest setIncludeAttributes(boolean includeAttributes)
    • getAttributeFilters

      @Nonnull public Set<String> getAttributeFilters()
    • addAttributeFilters

      public VocabularySearchRequest addAttributeFilters(String... attributeFilters)
    • isIncludeChildList

      public boolean isIncludeChildList()
    • setIncludeChildList

      public VocabularySearchRequest setIncludeChildList(boolean includeChildList)
    • getFromDate

      @Nullable public Date getFromDate()
    • setFromDate

      public VocabularySearchRequest setFromDate(Date fromDate)
    • getToDate

      @Nullable public Date getToDate()
    • setToDate

      public VocabularySearchRequest setToDate(Date toDate)
    • getAttributeMatch

      @Nonnull public Map<String,List<String>> getAttributeMatch()
    • addAttributeMatch

      public VocabularySearchRequest addAttributeMatch(String attribute, String... valueMatches)
    • addPartialAttributeMatch

      public VocabularySearchRequest addPartialAttributeMatch(String attribute, String... valueMatches)
    • getHasAttributes

      @Nonnull public Set<String> getHasAttributes()
    • addHasAttributes

      public VocabularySearchRequest addHasAttributes(String... hasAttributes)
    • setAttributeFilters

      public VocabularySearchRequest setAttributeFilters(Collection<String> attributeNames)
      Clear all attributes and if the provided collection is not null use all the attributes from that collection

      Attribute filters are used to filter out attributes of matched elements by the attribute names. They do not affect what elements will match, only what attributes will be included in the result.

      Parameters:
      attributeNames - collection of attributes names to allow
      Returns:
      instance of this request
    • setAttributeMatch

      public VocabularySearchRequest setAttributeMatch(Map<String,List<String>> attributeMatch)
      Clear all attributes and if the provided collection is not null use all the attributes from that collection

      Attribute matchers are used to filter out vocabulary elements by attribute name and values. Element has to match all attribute matchers.

      Parameters:
      attributeMatch - allowed values for matching attribute name
      Returns:
      instance of this request
    • setHasAttributes

      public VocabularySearchRequest setHasAttributes(Collection<String> hasAttributes)
      Clear all attributes and if the provided collection is not null use all the attributes from that collection

      Has attributes is used to filter out vocabulary elements that don't have any of the required attribute names

      Parameters:
      hasAttributes - need vocabulary element attributes
      Returns:
      instance of this request
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • setVocabularyUri

      public void setVocabularyUri(VocabularyUri uri)
    • getAttributeFiltersAsPredicate

      @Nonnull public Predicate<String> getAttributeFiltersAsPredicate()
    • getOffset

      public Integer getOffset()
    • setOffset

      public VocabularySearchRequest setOffset(Integer offset)
      Set the offset for the search, not-inclusive

      E.g. if offset is 10, the first 10 elements will be skipped

      If set to null, no offset will be applied

      Parameters:
      offset - positive offset or null
      Returns:
      instance of this request
    • getLimit

      public Integer getLimit()
    • setLimit

      public VocabularySearchRequest setLimit(Integer limit)
      Set the page size limit for the search

      E.g. if limit is 10, only 10 elements will be returned even if more elements match the search

      If set to null, the maximum number of elements will be returned

      Parameters:
      limit - positive limit or null
      Returns:
      instance of this request
    • getFreeTextSearch

      public String getFreeTextSearch()
    • setFreeTextSearch

      public VocabularySearchRequest setFreeTextSearch(String freeTextSearch)
      Set the free text search string

      Free text search depends on the database implementation, but generally matches as many elements as possible, both by element id and attribute values

      If a null or blank string is provided, the free text search will be disabled

      Parameters:
      freeTextSearch - free text search string or null
      Returns:
      instance of this request
    • getPartialAttributeMatch

      public Map<String,List<String>> getPartialAttributeMatch()
    • setPartialAttributeMatch

      public void setPartialAttributeMatch(Map<String,List<String>> partialAttributeMatch)