Class SearchMetadataCollection

java.lang.Object
org.opencastproject.elasticsearch.impl.SearchMetadataCollection
All Implemented Interfaces:
Iterable<org.opencastproject.elasticsearch.api.SearchMetadata<?>>, Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>

public class SearchMetadataCollection extends Object implements Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
Wrapper that facilitates in posting business objects to the search index.

This implementation provides utility methods that will ease handling of objects such as dates or users and help prevent posting of null values.

  • Field Details

    • metadata

      protected Map<String,org.opencastproject.elasticsearch.api.SearchMetadata<?>> metadata
      The metadata
    • identifier

      protected String identifier
      Returns the document identifier
    • documentType

      protected String documentType
      Returns the document type
  • Constructor Details

    • SearchMetadataCollection

      public SearchMetadataCollection(String documentType)
      Creates a new resource metadata collection for the given document type.

      Make sure to set the identifier after the fact using setIdentifier(String).

      Parameters:
      documentType - the document type
    • SearchMetadataCollection

      public SearchMetadataCollection(String identifier, String documentType)
      Creates a new resource metadata collection for the given document type.
      Parameters:
      identifier - the document identifier
      documentType - the document type
  • Method Details

    • setIdentifier

      public void setIdentifier(String identifier)
      Sets the document identifier.
      Parameters:
      identifier - the identifier
    • getIdentifier

      public String getIdentifier()
      Returns the document identifier.
      Returns:
      the identifier
    • getDocumentType

      public String getDocumentType()
      Returns the document type that determines where the document is posted to the index.
      Returns:
      the document type
    • addField

      public void addField(String fieldName, Object fieldValue, boolean addToText)
      Adds the field and its value to the search index.
      Parameters:
      fieldName - the field name
      fieldValue - the value
      addToText - true to add the contents to the fulltext field as well
    • getLocalizedFieldName

      protected String getLocalizedFieldName(String fieldName, org.opencastproject.elasticsearch.api.Language language)
      Returns the localized field name, which is the original field name extended by an underscore and the language identifier.
      Parameters:
      fieldName - the field name
      language - the language
      Returns:
      the localized field name
    • getMetadata

      public List<org.opencastproject.elasticsearch.api.SearchMetadata<?>> getMetadata()
      Returns the metadata as a list of SearchMetadata items.
      Returns:
      the metadata items
    • add

      public boolean add(org.opencastproject.elasticsearch.api.SearchMetadata<?> e)
      Specified by:
      add in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also:
    • addAll

      public boolean addAll(Collection<? extends org.opencastproject.elasticsearch.api.SearchMetadata<?>> c)
      Specified by:
      addAll in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also:
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also:
    • contains

      public boolean contains(Object o)
      Specified by:
      contains in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also:
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also:
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also:
    • iterator

      public Iterator<org.opencastproject.elasticsearch.api.SearchMetadata<?>> iterator()
      Specified by:
      iterator in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      Specified by:
      iterator in interface Iterable<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also:
    • remove

      public boolean remove(Object o)
      Specified by:
      remove in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also:
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also:
    • retainAll

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also:
    • size

      public int size()
      Specified by:
      size in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also:
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also:
    • toMap

      public Map<String,org.opencastproject.elasticsearch.api.SearchMetadata<?>> toMap()
      Returns the metadata keys and the metadata items as a map for convenient access of search metadata by key.
      Returns:
      the map
    • toArray

      public <T> T[] toArray(T[] arg0)
      Specified by:
      toArray in interface Collection<org.opencastproject.elasticsearch.api.SearchMetadata<?>>
      See Also: