use of org.broadleafcommerce.common.extension.ExtensionResultStatusType in project BroadleafCommerce by BroadleafCommerce.
the class ValidateAddRequestActivity method execute.
@Override
public ProcessContext<CartOperationRequest> execute(ProcessContext<CartOperationRequest> context) throws Exception {
ExtensionResultHolder<Exception> resultHolder = new ExtensionResultHolder<>();
resultHolder.setResult(null);
if (extensionManager != null && extensionManager.getProxy() != null) {
ExtensionResultStatusType result = extensionManager.getProxy().validate(context.getSeedData(), resultHolder);
if (!ExtensionResultStatusType.NOT_HANDLED.equals(result)) {
if (resultHolder.getResult() != null) {
throw resultHolder.getResult();
}
}
}
return validate(context);
}
use of org.broadleafcommerce.common.extension.ExtensionResultStatusType in project BroadleafCommerce by BroadleafCommerce.
the class OfferCodeDaoImpl method readOfferCodesQuery.
protected Query readOfferCodesQuery(String code) {
Query query;
ExtensionResultHolder<Query> resultHolder = new ExtensionResultHolder<Query>();
ExtensionResultStatusType extensionResult = extensionManager.getProxy().createReadOfferCodeByCodeQuery(em, resultHolder, code, true, "query.Offer");
if (extensionResult != null && ExtensionResultStatusType.HANDLED.equals(extensionResult)) {
query = resultHolder.getResult();
} else {
query = em.createNamedQuery("BC_READ_OFFER_CODE_BY_CODE");
query.setParameter("code", code);
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "query.Offer");
}
return query;
}
use of org.broadleafcommerce.common.extension.ExtensionResultStatusType in project BroadleafCommerce by BroadleafCommerce.
the class ValidateCheckoutActivity method execute.
@Override
public ProcessContext<CheckoutSeed> execute(ProcessContext<CheckoutSeed> context) throws Exception {
ExtensionResultHolder<Exception> resultHolder = new ExtensionResultHolder<>();
resultHolder.setResult(null);
ExtensionResultStatusType result = extensionManager.getProxy().validateCheckout(context.getSeedData(), resultHolder);
if (!ExtensionResultStatusType.NOT_HANDLED.equals(result)) {
if (resultHolder.getResult() != null) {
throw resultHolder.getResult();
}
}
return context;
}
use of org.broadleafcommerce.common.extension.ExtensionResultStatusType in project BroadleafCommerce by BroadleafCommerce.
the class SolrIndexServiceImpl method attachIndexableDocumentFields.
@Override
public void attachIndexableDocumentFields(SolrInputDocument document, Indexable indexable, List<IndexField> fields, List<Locale> locales) {
for (IndexField indexField : fields) {
try {
// If we find an IndexField entry for this field, then we need to store it in the index
if (indexField != null) {
List<IndexFieldType> searchableFieldTypes = indexField.getFieldTypes();
// For each of its search field types, get the property values, and add a field to the document for each property value
for (IndexFieldType sft : searchableFieldTypes) {
FieldType fieldType = sft.getFieldType();
Map<String, Object> propertyValues = getPropertyValues(indexable, indexField.getField(), fieldType, locales);
ExtensionResultStatusType result = extensionManager.getProxy().populateDocumentForIndexField(document, indexField, fieldType, propertyValues);
if (ExtensionResultStatusType.NOT_HANDLED.equals(result)) {
// Build out the field for every prefix
for (Entry<String, Object> entry : propertyValues.entrySet()) {
String prefix = entry.getKey();
prefix = StringUtils.isBlank(prefix) ? prefix : prefix + "_";
String solrPropertyName = shs.getPropertyNameForIndexField(indexField, fieldType, prefix);
Object value = entry.getValue();
if (FieldType.isMultiValued(fieldType)) {
document.addField(solrPropertyName, value);
} else {
document.setField(solrPropertyName, value);
}
}
}
}
}
} catch (Exception e) {
LOG.error("Could not get value for property[" + indexField.getField().getQualifiedFieldName() + "] for product id[" + indexable.getId() + "]", e);
throw ExceptionHelper.refineException(e);
}
}
}
use of org.broadleafcommerce.common.extension.ExtensionResultStatusType in project BroadleafCommerce by BroadleafCommerce.
the class SolrIndexServiceImpl method getPropertyValues.
/**
* Returns a map of prefix to value for the requested attributes. For example, if the requested field corresponds to
* a Sku's description and the locales list has the en_US locale and the es_ES locale, the resulting map could be
*
* { "en_US" : "A description",
* "es_ES" : "Una descripcion" }
*
* @param product
* @param sku
* @param field
* @param fieldType
* @param locales
* @return the value of the property
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
*/
protected Map<String, Object> getPropertyValues(Indexable indexedItem, Field field, FieldType fieldType, List<Locale> locales) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
String propertyName = field.getPropertyName();
Map<String, Object> values = new HashMap<>();
ExtensionResultStatusType extensionResult = ExtensionResultStatusType.NOT_HANDLED;
if (extensionManager != null) {
extensionResult = extensionManager.getProxy().addPropertyValues(indexedItem, field, fieldType, values, propertyName, locales);
}
if (ExtensionResultStatusType.NOT_HANDLED.equals(extensionResult)) {
Object propertyValue = shs.getPropertyValue(indexedItem, field);
if (propertyValue != null) {
values.put("", propertyValue);
}
}
return values;
}
Aggregations