use of org.broadleafcommerce.common.extension.ExtensionResultStatusType 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.ExtensionResultStatusType 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.ExtensionResultStatusType 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.ExtensionResultStatusType in project BroadleafCommerce by BroadleafCommerce.
the class CategoryCustomPersistenceHandler method add.
@Override
public Entity add(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
Entity entity = persistencePackage.getEntity();
try {
entity = validateParentCategory(entity, true);
if (entity.isValidationFailure()) {
return entity;
} else {
PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective();
Category adminInstance = (Category) Class.forName(entity.getType()[0]).newInstance();
Map<String, FieldMetadata> adminProperties = helper.getSimpleMergedProperties(Category.class.getName(), persistencePerspective);
adminInstance = (Category) helper.createPopulatedInstance(adminInstance, entity, adminProperties, false);
adminInstance = dynamicEntityDao.merge(adminInstance);
boolean handled = false;
if (extensionManager != null) {
ExtensionResultStatusType result = extensionManager.getProxy().manageParentCategoryForAdd(persistencePackage, adminInstance);
handled = ExtensionResultStatusType.NOT_HANDLED != result;
}
if (!handled) {
setupXref(adminInstance);
}
adminInstance = dynamicEntityDao.merge(adminInstance);
return helper.getRecord(adminProperties, adminInstance, null, null);
}
} catch (Exception e) {
throw new ServiceException("Unable to add entity for " + entity.getType()[0], e);
}
}
use of org.broadleafcommerce.common.extension.ExtensionResultStatusType in project BroadleafCommerce by BroadleafCommerce.
the class IndexFieldCustomPersistenceHandler method getEntity.
protected Entity getEntity(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper, Entity entity, Map<String, FieldMetadata> adminProperties, IndexField adminInstance) throws ServiceException {
adminInstance = (IndexField) helper.createPopulatedInstance(adminInstance, entity, adminProperties, false);
adminInstance = dynamicEntityDao.merge(adminInstance);
ExtensionResultStatusType result = ExtensionResultStatusType.NOT_HANDLED;
if (extensionManager != null) {
result = extensionManager.getProxy().addtoSearchableFields(persistencePackage, adminInstance);
}
if (result.equals(ExtensionResultStatusType.NOT_HANDLED)) {
// If there is no searchable field types then we need to add a default as String
if (CollectionUtils.isEmpty(adminInstance.getFieldTypes())) {
IndexFieldType indexFieldType = new IndexFieldTypeImpl();
indexFieldType.setFieldType(FieldType.TEXT);
indexFieldType.setIndexField(adminInstance);
adminInstance.getFieldTypes().add(indexFieldType);
adminInstance = dynamicEntityDao.merge(adminInstance);
}
}
Entity adminEntity = helper.getRecord(adminProperties, adminInstance, null, null);
return adminEntity;
}
Aggregations