Search in sources :

Example 16 with ExtensionResultHolder

use of org.broadleafcommerce.common.extension.ExtensionResultHolder in project BroadleafCommerce by BroadleafCommerce.

the class CatalogServiceImpl method findProductByURI.

@Override
public Product findProductByURI(String uri) {
    if (extensionManager != null) {
        ExtensionResultHolder holder = new ExtensionResultHolder();
        ExtensionResultStatusType result = extensionManager.getProxy().findProductByURI(createCatalogContextDTO(), uri, holder);
        if (ExtensionResultStatusType.HANDLED.equals(result)) {
            return (Product) holder.getResult();
        }
    }
    return findOriginalProductByURI(uri);
}
Also used : Product(org.broadleafcommerce.core.catalog.domain.Product) ExtensionResultStatusType(org.broadleafcommerce.common.extension.ExtensionResultStatusType) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder)

Example 17 with ExtensionResultHolder

use of org.broadleafcommerce.common.extension.ExtensionResultHolder in project BroadleafCommerce by BroadleafCommerce.

the class CatalogServiceImpl method findCategoryByURI.

@Override
public Category findCategoryByURI(String uri) {
    if (extensionManager != null) {
        ExtensionResultHolder holder = new ExtensionResultHolder();
        ExtensionResultStatusType result = extensionManager.getProxy().findCategoryByURI(createCatalogContextDTO(), uri, holder);
        if (ExtensionResultStatusType.HANDLED.equals(result)) {
            return (Category) holder.getResult();
        }
    }
    return findOriginalCategoryByURI(uri);
}
Also used : Category(org.broadleafcommerce.core.catalog.domain.Category) ExtensionResultStatusType(org.broadleafcommerce.common.extension.ExtensionResultStatusType) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder)

Example 18 with ExtensionResultHolder

use of org.broadleafcommerce.common.extension.ExtensionResultHolder in project BroadleafCommerce by BroadleafCommerce.

the class InventoryServiceImpl method retrieveQuantitiesAvailable.

@Override
public Map<Sku, Integer> retrieveQuantitiesAvailable(Collection<Sku> skus, Map<String, Object> context) {
    ExtensionResultHolder<Map<Sku, Integer>> holder = new ExtensionResultHolder<Map<Sku, Integer>>();
    ExtensionResultStatusType res = extensionManager.getProxy().retrieveQuantitiesAvailable(skus, context, holder);
    if (ExtensionResultStatusType.NOT_HANDLED.equals(res)) {
        Map<Sku, Integer> inventories = new HashMap<>();
        for (Sku sku : skus) {
            Integer quantityAvailable = 0;
            if (checkBasicAvailablility(sku)) {
                InventoryType skuInventoryType = sku.getInventoryType();
                if (InventoryType.CHECK_QUANTITY.equals(skuInventoryType)) {
                    if (sku.getQuantityAvailable() != null) {
                        quantityAvailable = sku.getQuantityAvailable();
                    }
                } else if (sku.getInventoryType() == null || InventoryType.ALWAYS_AVAILABLE.equals(skuInventoryType)) {
                    quantityAvailable = null;
                }
            }
            inventories.put(sku, quantityAvailable);
        }
        return inventories;
    } else {
        return holder.getResult();
    }
}
Also used : HashMap(java.util.HashMap) InventoryType(org.broadleafcommerce.core.inventory.service.type.InventoryType) ExtensionResultStatusType(org.broadleafcommerce.common.extension.ExtensionResultStatusType) Sku(org.broadleafcommerce.core.catalog.domain.Sku) HashMap(java.util.HashMap) Map(java.util.Map) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder)

Example 19 with ExtensionResultHolder

use of org.broadleafcommerce.common.extension.ExtensionResultHolder in project BroadleafCommerce by BroadleafCommerce.

the class TranslationServiceImpl method removeTranslationFromCache.

@Override
public void removeTranslationFromCache(Translation translation) {
    if (BroadleafRequestContext.getBroadleafRequestContext().isProductionSandBox()) {
        ResultType resultType = ResultType.STANDARD;
        if (extensionManager != null) {
            ExtensionResultHolder<ResultType> response = new ExtensionResultHolder<ResultType>();
            extensionManager.getProxy().getResultType(translation, response);
            resultType = response.getResult();
            if (ResultType.STANDARD == resultType) {
                String key = getCacheKey(resultType, translation.getEntityType());
                LOG.debug("Removing key [" + key + "] for STANDARD site");
                getCache().remove(key);
            } else {
                List<String> cacheKeysList = getCacheKeyListForTemplateSite(translation.getEntityType().getFriendlyType());
                for (String key : cacheKeysList) {
                    LOG.debug("Removing key [" + key + "] for TEMPLATE site");
                    getCache().remove(key);
                }
            }
        }
    }
}
Also used : ResultType(org.broadleafcommerce.common.extension.ResultType) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder)

Example 20 with ExtensionResultHolder

use of org.broadleafcommerce.common.extension.ExtensionResultHolder in project BroadleafCommerce by BroadleafCommerce.

the class SolrSearchServiceImpl method getQueryFields.

/**
 * This helper method gathers the query fields for the given field and stores them in the List parameter.
 * @param currentField the current field
 * @param query
 * @param queryFields the query fields for this query
 * @param searchCriteria
 */
protected void getQueryFields(SolrQuery query, final List<String> queryFields, IndexField indexField, SearchCriteria searchCriteria) {
    if (indexField != null && BooleanUtils.isTrue(indexField.getSearchable())) {
        List<IndexFieldType> fieldTypes = indexField.getFieldTypes();
        for (IndexFieldType indexFieldType : fieldTypes) {
            FieldType fieldType = indexFieldType.getFieldType();
            // this will hold the list of query fields for our given field
            ExtensionResultHolder<List<String>> queryFieldResult = new ExtensionResultHolder<>();
            queryFieldResult.setResult(queryFields);
            // here we try to get the query field's for this search field
            ExtensionResultStatusType result = extensionManager.getProxy().getQueryField(query, searchCriteria, indexFieldType, queryFieldResult);
            if (Objects.equals(ExtensionResultStatusType.NOT_HANDLED, result)) {
                // if we didn't get any query fields we just add a default one
                String solrFieldName = shs.getPropertyNameForIndexField(indexFieldType.getIndexField(), fieldType);
                queryFields.add(solrFieldName);
            }
        }
    }
}
Also used : IndexFieldType(org.broadleafcommerce.core.search.domain.IndexFieldType) List(java.util.List) ArrayList(java.util.ArrayList) ExtensionResultStatusType(org.broadleafcommerce.common.extension.ExtensionResultStatusType) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder) IndexFieldType(org.broadleafcommerce.core.search.domain.IndexFieldType) FieldType(org.broadleafcommerce.core.search.domain.solr.FieldType)

Aggregations

ExtensionResultHolder (org.broadleafcommerce.common.extension.ExtensionResultHolder)56 ExtensionResultStatusType (org.broadleafcommerce.common.extension.ExtensionResultStatusType)35 ArrayList (java.util.ArrayList)11 Product (org.broadleafcommerce.core.catalog.domain.Product)7 Sku (org.broadleafcommerce.core.catalog.domain.Sku)6 PersistenceException (org.broadleafcommerce.openadmin.server.service.persistence.PersistenceException)6 ParentEntityPersistenceException (org.broadleafcommerce.openadmin.server.service.persistence.ParentEntityPersistenceException)5 FieldNotAvailableException (org.broadleafcommerce.openadmin.server.service.persistence.module.FieldNotAvailableException)5 List (java.util.List)4 Set (java.util.Set)4 File (java.io.File)3 Serializable (java.io.Serializable)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 HashMap (java.util.HashMap)3 Query (javax.persistence.Query)3 TypedQuery (javax.persistence.TypedQuery)3 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)3 AdminMainEntity (org.broadleafcommerce.common.admin.domain.AdminMainEntity)3 Site (org.broadleafcommerce.common.site.domain.Site)3 Category (org.broadleafcommerce.core.catalog.domain.Category)3