use of org.broadleafcommerce.common.extension.ExtensionResultHolder in project BroadleafCommerce by BroadleafCommerce.
the class SkuDaoImpl method findSkuByURI.
@Override
public List<Sku> findSkuByURI(String uri) {
if (extensionManager != null) {
ExtensionResultHolder holder = new ExtensionResultHolder();
ExtensionResultStatusType result = extensionManager.getProxy().findSkuByURI(uri, holder);
if (ExtensionResultStatusType.HANDLED.equals(result)) {
return (List<Sku>) holder.getResult();
}
}
String skuUrlKey = uri.substring(uri.lastIndexOf('/'));
String productUrl = uri.substring(0, uri.lastIndexOf('/'));
Query query;
query = em.createNamedQuery("BC_READ_SKU_BY_OUTGOING_URL");
query.setParameter("url", uri);
query.setParameter("productUrl", productUrl);
query.setParameter("skuUrlKey", skuUrlKey);
query.setParameter("currentDate", DateUtil.getCurrentDateAfterFactoringInDateResolution(cachedDate, currentDateResolution));
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog");
@SuppressWarnings("unchecked") List<Sku> results = query.getResultList();
return results;
}
use of org.broadleafcommerce.common.extension.ExtensionResultHolder in project BroadleafCommerce by BroadleafCommerce.
the class CategoryDaoImpl method findCategoryByURI.
@Override
public Category findCategoryByURI(String uri) {
if (extensionManager != null) {
ExtensionResultHolder holder = new ExtensionResultHolder();
ExtensionResultStatusType result = extensionManager.getProxy().findCategoryByURI(uri, holder);
if (ExtensionResultStatusType.HANDLED.equals(result)) {
return (Category) holder.getResult();
}
}
Query query;
query = em.createNamedQuery("BC_READ_CATEGORY_OUTGOING_URL");
query.setParameter("currentDate", getCurrentDateAfterFactoringInDateResolution());
query.setParameter("url", uri);
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog");
@SuppressWarnings("unchecked") List<Category> results = query.getResultList();
if (results != null && !results.isEmpty()) {
return results.get(0);
} else {
return null;
}
}
use of org.broadleafcommerce.common.extension.ExtensionResultHolder in project BroadleafCommerce by BroadleafCommerce.
the class ProductDaoImpl method findProductByURI.
@Override
public List<Product> findProductByURI(String uri) {
if (extensionManager != null) {
ExtensionResultHolder holder = new ExtensionResultHolder();
ExtensionResultStatusType result = extensionManager.getProxy().findProductByURI(uri, holder);
if (ExtensionResultStatusType.HANDLED.equals(result)) {
return (List<Product>) holder.getResult();
}
}
String urlKey = uri.substring(uri.lastIndexOf('/'));
Query query;
query = em.createNamedQuery("BC_READ_PRODUCTS_BY_OUTGOING_URL");
query.setParameter("url", uri);
query.setParameter("urlKey", urlKey);
query.setParameter("currentDate", DateUtil.getCurrentDateAfterFactoringInDateResolution(cachedDate, currentDateResolution));
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog");
@SuppressWarnings("unchecked") List<Product> results = query.getResultList();
return results;
}
use of org.broadleafcommerce.common.extension.ExtensionResultHolder in project BroadleafCommerce by BroadleafCommerce.
the class UpdateCartServiceImpl method updateAndValidateCart.
@Override
public void updateAndValidateCart(Order cart) {
if (extensionManager != null) {
ExtensionResultHolder erh = new ExtensionResultHolder();
extensionManager.getProxy().updateAndValidateCart(cart, erh);
Boolean clearCart = (Boolean) erh.getContextMap().get("clearCart");
Boolean repriceCart = (Boolean) erh.getContextMap().get("repriceCart");
Boolean saveCart = (Boolean) erh.getContextMap().get("saveCart");
if (clearCart != null && clearCart.booleanValue()) {
orderService.cancelOrder(cart);
cart = orderService.createNewCartForCustomer(cart.getCustomer());
} else {
try {
if (repriceCart != null && repriceCart.booleanValue()) {
orderService.save(cart, true, true);
} else if (saveCart != null && saveCart.booleanValue()) {
orderService.save(cart, false);
}
} catch (PricingException pe) {
LOG.error("Pricing Exception while validating cart. Clearing cart.", pe);
orderService.cancelOrder(cart);
cart = orderService.createNewCartForCustomer(cart.getCustomer());
}
}
}
}
use of org.broadleafcommerce.common.extension.ExtensionResultHolder in project BroadleafCommerce by BroadleafCommerce.
the class AdminBasicEntityController method isAddRequest.
private boolean isAddRequest(Entity entity) {
ExtensionResultHolder<Boolean> resultHolder = new ExtensionResultHolder<>();
ExtensionResultStatusType result = extensionManager.getProxy().isAddRequest(entity, resultHolder);
if (result.equals(ExtensionResultStatusType.NOT_HANDLED)) {
return false;
}
return resultHolder.getResult();
}
Aggregations