Class InventoryServiceImpl

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected com.github.benmanes.caffeine.cache.Cache<java.lang.String,​java.lang.String> keyToIdCache  
      protected static int MAXIMUM_ALLOWED_UPDATE_ACTIONS  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,​java.lang.String>> cacheKeysToIdsUsingGraphQl​(java.util.Set<java.lang.String> keysToCache, GraphQlQueryResource queryResource)  
      java.util.concurrent.CompletionStage<java.util.Optional<com.commercetools.api.models.inventory.InventoryEntry>> createInventoryEntry​(com.commercetools.api.models.inventory.InventoryEntryDraft inventoryEntryDraft)
      Creates new inventory entry from inventoryEntryDraft.
      java.util.concurrent.CompletionStage<java.util.Set<com.commercetools.api.models.inventory.InventoryEntry>> fetchInventoryEntriesByIdentifiers​(java.util.Set<InventoryEntryIdentifier> identifiers)
      Queries existing InventoryEntry's against set of sku and supply channels.
      protected java.util.Set<java.lang.String> getKeysNotCached​(java.util.Set<java.lang.String> keys)
      Given a set of keys this method collects all keys which aren't already contained in the cache keyToIdCache
      java.util.concurrent.CompletionStage<com.commercetools.api.models.inventory.InventoryEntry> updateInventoryEntry​(com.commercetools.api.models.inventory.InventoryEntry inventoryEntry, java.util.List<com.commercetools.api.models.inventory.InventoryEntryUpdateAction> updateActions)
      Updates existing inventory entry with updateActions.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • keyToIdCache

        protected final com.github.benmanes.caffeine.cache.Cache<java.lang.String,​java.lang.String> keyToIdCache
      • MAXIMUM_ALLOWED_UPDATE_ACTIONS

        protected static final int MAXIMUM_ALLOWED_UPDATE_ACTIONS
        See Also:
        Constant Field Values
    • Constructor Detail

    • Method Detail

      • fetchInventoryEntriesByIdentifiers

        @Nonnull
        public java.util.concurrent.CompletionStage<java.util.Set<com.commercetools.api.models.inventory.InventoryEntry>> fetchInventoryEntriesByIdentifiers​(@Nonnull
                                                                                                                                                             java.util.Set<InventoryEntryIdentifier> identifiers)
        Description copied from interface: InventoryService
        Queries existing InventoryEntry's against set of sku and supply channels.
        Specified by:
        fetchInventoryEntriesByIdentifiers in interface InventoryService
        Parameters:
        identifiers - Set of unique inventory identifiers, used in search predicate
        Returns:
        List of matching entries or empty list when there was no matching resources.
      • createInventoryEntry

        @Nonnull
        public java.util.concurrent.CompletionStage<java.util.Optional<com.commercetools.api.models.inventory.InventoryEntry>> createInventoryEntry​(@Nonnull
                                                                                                                                                    com.commercetools.api.models.inventory.InventoryEntryDraft inventoryEntryDraft)
        Description copied from interface: InventoryService
        Creates new inventory entry from inventoryEntryDraft.
        Specified by:
        createInventoryEntry in interface InventoryService
        Parameters:
        inventoryEntryDraft - draft with data for new inventory entry
        Returns:
        CompletionStage with created InventoryEntry or an exception
      • updateInventoryEntry

        @Nonnull
        public java.util.concurrent.CompletionStage<com.commercetools.api.models.inventory.InventoryEntry> updateInventoryEntry​(@Nonnull
                                                                                                                                com.commercetools.api.models.inventory.InventoryEntry inventoryEntry,
                                                                                                                                @Nonnull
                                                                                                                                java.util.List<com.commercetools.api.models.inventory.InventoryEntryUpdateAction> updateActions)
        Description copied from interface: InventoryService
        Updates existing inventory entry with updateActions.
        Specified by:
        updateInventoryEntry in interface InventoryService
        Parameters:
        inventoryEntry - entry that should be updated
        updateActions - List of actions that should be applied to inventoryEntry
        Returns:
        CompletionStage with updated InventoryEntry or an exception
      • getKeysNotCached

        @Nonnull
        protected java.util.Set<java.lang.String> getKeysNotCached​(@Nonnull
                                                                   java.util.Set<java.lang.String> keys)
        Given a set of keys this method collects all keys which aren't already contained in the cache keyToIdCache
        Parameters:
        keys - Set of keys
        Returns:
        a Set of keys which aren't already contained in the cache or empty
      • cacheKeysToIdsUsingGraphQl

        @Nonnull
        public java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,​java.lang.String>> cacheKeysToIdsUsingGraphQl​(@Nonnull
                                                                                                                                       java.util.Set<java.lang.String> keysToCache,
                                                                                                                                       @Nonnull
                                                                                                                                       GraphQlQueryResource queryResource)