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);
}
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);
}
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();
}
}
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);
}
}
}
}
}
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);
}
}
}
}
Aggregations