Interface ProductIndex

  • All Superinterfaces:
    Configurable
    All Known Implementing Classes:
    ExtentIndex, JDBCProductIndex

    public interface ProductIndex
    extends Configurable
    An index of products. The Indexer uses a ProductIndex to store received Products, and associate them together into Events. The transaction methods are used when one product results in several changes to the database. For instance, add a ProductSummary then add an association to an event.
    • Method Detail

      • beginTransaction

        void beginTransaction()
                       throws java.lang.Exception
        If the index supports transactions, begin a transaction.
        Throws:
        java.lang.Exception - if error occurs
      • commitTransaction

        void commitTransaction()
                        throws java.lang.Exception
        If the index supports transactions, and beginTransaction was previously called, commit the pending transaction.
        Throws:
        java.lang.Exception - if error occurs
      • rollbackTransaction

        void rollbackTransaction()
                          throws java.lang.Exception
        If the index supports transactions, and beginTransaction was previously called, rollback the pending transaction.
        Throws:
        java.lang.Exception - if error occurs
      • getEvents

        java.util.List<Event> getEvents​(ProductIndexQuery query)
                                 throws java.lang.Exception
        Get events in this index.
        Parameters:
        query - a description of which events to retrieve.
        Returns:
        a list of matching events.
        Throws:
        java.lang.Exception - if error occurs
      • getProducts

        java.util.List<ProductSummary> getProducts​(ProductIndexQuery query)
                                            throws java.lang.Exception
        Get products in this index.
        Parameters:
        query - a description of which products to retrieve.
        Returns:
        a list of matching products.
        Throws:
        java.lang.Exception - if error occurs
      • hasProduct

        boolean hasProduct​(ProductId id)
                    throws java.lang.Exception
        Check whether index has product. May be more efficient than getProducts(ProductIndexQuery).
        Parameters:
        id - a ProductId
        Returns:
        boolean if index has product
        Throws:
        java.lang.Exception - if error occurs
      • getUnassociatedProducts

        java.util.List<ProductSummary> getUnassociatedProducts​(ProductIndexQuery query)
                                                        throws java.lang.Exception
        Get products in this index that aren't associated to any event.
        Parameters:
        query - a description of which products to retrieve.
        Returns:
        a list of unassociated products
        Throws:
        java.lang.Exception - if error occurs
      • addEvent

        Event addEvent​(Event event)
                throws java.lang.Exception
        Add an event to the index.
        Parameters:
        event - the event to add.
        Returns:
        Copy of event with the eventId attribute set to the id in the database
        Throws:
        java.lang.Exception - if error occurs
      • removeEvent

        java.util.List<ProductId> removeEvent​(Event event)
                                       throws java.lang.Exception
        Remove an event from the index.
        Parameters:
        event - the event to remove.
        Returns:
        Copy of the event removed
        Throws:
        java.lang.Exception - if the event is associated to products.
      • addProductSummary

        ProductSummary addProductSummary​(ProductSummary summary)
                                  throws java.lang.Exception
        Add a product summary to the index.
        Parameters:
        summary - the summary to add.
        Returns:
        Copy of the product summary object with the indexId set to the newly inserted id.
        Throws:
        java.lang.Exception - if error occurs
      • removeProductSummary

        ProductId removeProductSummary​(ProductSummary summary)
                                throws java.lang.Exception
        Remove a product summary from the index.
        Parameters:
        summary - the summary to remove.
        Returns:
        id of removed summary.
        Throws:
        java.lang.Exception - if error occurs
      • addAssociation

        Event addAssociation​(Event event,
                             ProductSummary summary)
                      throws java.lang.Exception
        Associate an Event and ProductSummary that are already in the index.
        Parameters:
        event - the event.
        summary - the summary.
        Returns:
        Copy of event with summary added to the products list
        Throws:
        java.lang.Exception - if error occurs
      • removeAssociation

        Event removeAssociation​(Event event,
                                ProductSummary summary)
                         throws java.lang.Exception
        Remove an association between and Event and ProductSummary.
        Parameters:
        event - the event.
        summary - the summary.
        Returns:
        Copy of event with summary removed from the products list
        Throws:
        java.lang.Exception - if error occurs
      • eventsUpdated

        void eventsUpdated​(java.util.List<Event> events)
                    throws java.lang.Exception
        An opportunity for the ProductIndex to update summary information it may or may not store for efficient event searches. This method is called by the indexer after it has finished updating events during onProduct.
        Parameters:
        events - events that may have new preferred attributes.
        Throws:
        java.lang.Exception - if error occurs