Class MongoIndexable<SpecT,IndexedT>

java.lang.Object
dev.getelements.elements.dao.mongo.MongoIndexable<SpecT,IndexedT>
All Implemented Interfaces:
Indexable
Direct Known Subclasses:
MongoIndexable.DistinctInventoryItem, MongoIndexable.Item, MongoIndexable.Metadata

public abstract class MongoIndexable<SpecT,IndexedT> extends Object implements Indexable
  • Field Details

  • Constructor Details

    • MongoIndexable

      public MongoIndexable(Class<SpecT> spec, Class<IndexedT> indexed)
      Creates a new MongoIndexable instance with the default name and metadata spec extractors.
      Parameters:
      spec - the type that contains the specification and unique name
      indexed - the type that will be indexed based on the spec provided
    • MongoIndexable

      public MongoIndexable(Class<SpecT> spec, Class<IndexedT> indexed, Function<SpecT,String> nameExtractor, Function<SpecT,MongoMetadataSpec> metadataSpecExtractor)
      Creates a new MongoIndexable instance with the default name and metadata spec extractors. This allows for specification of custom name and metadata spec extractors in case the default bean properties ones are not sufficient.
      Parameters:
      spec - the type that contains the specification and unique name
      indexed - the type that will be indexed based on the spec provided
  • Method Details

    • plan

      public void plan()
      Description copied from interface: Indexable
      Plans the indexes. Writing the contents of the to-be indexed content to the database.
      Specified by:
      plan in interface Indexable
    • getCollection

      protected com.mongodb.client.MongoCollection<IndexedT> getCollection()
      Returns the collection which will be indexed.
      Returns:
      the collection
    • getCollectionName

      protected String getCollectionName()
      Returns the name of the collection which will be indexed.
      Returns:
      the collection name
    • generate

      protected IndexMetadata<org.bson.Document> generate(Path path, MetadataSpecProperty metadataSpecProperty)
      Generates the index metadata for the given path and metadata spec property.
      Parameters:
      path - the path to generate the index for
      metadataSpecProperty - the metadata spec property to use
      Returns:
      the generated index metadata
    • updatePlanWithMetadataSpecs

      protected void updatePlanWithMetadataSpecs(IndexPlanner<org.bson.Document> planner)
      Updates the index plan with metadata specifications.
      Parameters:
      planner - the index planner to update
    • buildIndexes

      public void buildIndexes()
      Description copied from interface: Indexable
      Builds the indexes based on the last plan operation.
      Specified by:
      buildIndexes in interface Indexable
    • getMapper

      public MapperRegistry getMapper()
    • setMapper

      @Inject public void setMapper(MapperRegistry mapperRegistry)
    • getDatastore

      public dev.morphia.Datastore getDatastore()
    • setDatastore

      @Inject public void setDatastore(dev.morphia.Datastore datastore)