Class AbstractCategoriesRetriever
- java.lang.Object
-
- com.adobe.cq.commerce.core.components.models.retriever.AbstractRetriever
-
- com.adobe.cq.commerce.core.components.models.retriever.AbstractCategoriesRetriever
-
- Direct Known Subclasses:
CategoriesRetriever
,CategoriesRetriever
public abstract class AbstractCategoriesRetriever extends AbstractRetriever
-
-
Field Summary
Fields Modifier and Type Field Description protected List<com.adobe.cq.commerce.magento.graphql.CategoryTree>
categories
List of category instances.static String
CATEGORY_IMAGE_FOLDER
protected Consumer<com.adobe.cq.commerce.magento.graphql.CategoryTreeQuery>
categoryQueryHook
Lambda that extends the category query.protected List<String>
identifiers
Identifiers of the categories that should be fetched.protected UrlProvider.CategoryIdentifierType
identifierType
Identifiers of the categories that should be fetched.-
Fields inherited from class com.adobe.cq.commerce.core.components.models.retriever.AbstractRetriever
client, query
-
-
Constructor Summary
Constructors Constructor Description AbstractCategoriesRetriever(MagentoGraphqlClient client)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected com.adobe.cq.commerce.graphql.client.GraphqlResponse<com.adobe.cq.commerce.magento.graphql.Query,com.adobe.cq.commerce.magento.graphql.gson.Error>
executeQuery()
Execute the GraphQL query with the GraphQL client.void
extendCategoryQueryWith(Consumer<com.adobe.cq.commerce.magento.graphql.CategoryTreeQuery> categoryQueryHook)
Extend the category query part of the category GraphQL query with a partial query provided by a lambda hook that sets additional fields.List<com.adobe.cq.commerce.magento.graphql.CategoryTree>
fetchCategories()
Executes the GraphQL query and returns categories.protected abstract com.adobe.cq.commerce.magento.graphql.CategoryTreeQueryDefinition
generateCategoryQuery()
Generates the partial CategoryTree query part of the GraphQL category query.protected String
generateQuery(List<String> identifiers)
Generates a complete category GraphQL query with a selection of the given category identifiers.protected void
populate()
Executes the query and parses the response.void
setIdentifiers(List<String> identifiers)
Set the identifiers of the categories that should be fetched.void
setIdentifiers(List<String> identifiers, UrlProvider.CategoryIdentifierType identifierType)
Set the identifiers and identifier types of the categories that should be fetched Setting the identifiers, removes any cached data.-
Methods inherited from class com.adobe.cq.commerce.core.components.models.retriever.AbstractRetriever
setQuery
-
-
-
-
Field Detail
-
CATEGORY_IMAGE_FOLDER
public static final String CATEGORY_IMAGE_FOLDER
- See Also:
- Constant Field Values
-
categoryQueryHook
protected Consumer<com.adobe.cq.commerce.magento.graphql.CategoryTreeQuery> categoryQueryHook
Lambda that extends the category query.
-
categories
protected List<com.adobe.cq.commerce.magento.graphql.CategoryTree> categories
List of category instances. Is only available after populate() was called.
-
identifiers
protected List<String> identifiers
Identifiers of the categories that should be fetched. Which kind of identifier is used (usually id) is implementation specific and should be checked in subclass implementations.
-
identifierType
protected UrlProvider.CategoryIdentifierType identifierType
Identifiers of the categories that should be fetched. Which kind of identifier is used (usually id) is implementation specific and should be checked in subclass implementations.
-
-
Constructor Detail
-
AbstractCategoriesRetriever
public AbstractCategoriesRetriever(MagentoGraphqlClient client)
-
-
Method Detail
-
fetchCategories
public List<com.adobe.cq.commerce.magento.graphql.CategoryTree> fetchCategories()
Executes the GraphQL query and returns categories. For subsequent calls of this method, a cached list of categories is returned.- Returns:
- List of categories
-
setIdentifiers
public void setIdentifiers(List<String> identifiers)
Set the identifiers of the categories that should be fetched. Which kind of identifier is used (usually id) is implementation specific and should be checked in subclass implementations. Setting the identifiers, removes any cached data.- Parameters:
identifiers
- Category identifiers
-
setIdentifiers
public void setIdentifiers(List<String> identifiers, UrlProvider.CategoryIdentifierType identifierType)
Set the identifiers and identifier types of the categories that should be fetched Setting the identifiers, removes any cached data.- Parameters:
identifiers
- Category identifiersidentifierType
- Which kind of identifier is used: ID, UID
-
extendCategoryQueryWith
public void extendCategoryQueryWith(Consumer<com.adobe.cq.commerce.magento.graphql.CategoryTreeQuery> categoryQueryHook)
Extend the category query part of the category GraphQL query with a partial query provided by a lambda hook that sets additional fields. Example:categoryRetriever.extendCategoryQueryWith(p -> p .level());
- Parameters:
categoryQueryHook
- Lambda that extends the category query
-
generateCategoryQuery
protected abstract com.adobe.cq.commerce.magento.graphql.CategoryTreeQueryDefinition generateCategoryQuery()
Generates the partial CategoryTree query part of the GraphQL category query.- Returns:
- CategoryTree query definition
-
generateQuery
protected String generateQuery(List<String> identifiers)
Generates a complete category GraphQL query with a selection of the given category identifiers.- Parameters:
identifiers
- Category identifiers, usually the category id- Returns:
- GraphQL query as string
-
executeQuery
protected com.adobe.cq.commerce.graphql.client.GraphqlResponse<com.adobe.cq.commerce.magento.graphql.Query,com.adobe.cq.commerce.magento.graphql.gson.Error> executeQuery()
Execute the GraphQL query with the GraphQL client.- Specified by:
executeQuery
in classAbstractRetriever
- Returns:
- GraphqlResponse object
-
populate
protected void populate()
Description copied from class:AbstractRetriever
Executes the query and parses the response.- Specified by:
populate
in classAbstractRetriever
-
-