use of org.broadleafcommerce.common.exception.ServiceException in project BroadleafCommerce by BroadleafCommerce.
the class ProductCustomPersistenceHandler method remove.
@Override
public void remove(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
Entity entity = persistencePackage.getEntity();
try {
Product adminInstance = getAdminInstance(persistencePackage, dynamicEntityDao, helper, entity);
removeProduct(persistencePackage, adminInstance, helper);
} catch (ClassNotFoundException e) {
throw new ServiceException("Unable to remove entity for " + entity.getType()[0], e);
}
}
use of org.broadleafcommerce.common.exception.ServiceException in project BroadleafCommerce by BroadleafCommerce.
the class SearchFacetCustomPersistenceHandler method remove.
@Override
public void remove(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
Entity entity = persistencePackage.getEntity();
try {
SearchFacet adminInstance = getAdminInstance(persistencePackage, dynamicEntityDao, helper, entity);
if (Status.class.isAssignableFrom(adminInstance.getClass())) {
((Status) adminInstance).setArchived('Y');
dynamicEntityDao.merge(adminInstance);
}
} catch (Exception e) {
throw new ServiceException("Unable to remove entity for " + entity.getType()[0], e);
}
}
use of org.broadleafcommerce.common.exception.ServiceException in project BroadleafCommerce by BroadleafCommerce.
the class SearchFacetRangeCustomPersistenceHandler method remove.
@Override
public void remove(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
Entity entity = persistencePackage.getEntity();
try {
SearchFacetRange adminInstance = getAdminInstance(persistencePackage, dynamicEntityDao, helper, entity);
if (Status.class.isAssignableFrom(adminInstance.getClass())) {
((Status) adminInstance).setArchived('Y');
dynamicEntityDao.merge(adminInstance);
}
} catch (Exception e) {
throw new ServiceException("Unable to remove entity for " + entity.getType()[0], e);
}
}
use of org.broadleafcommerce.common.exception.ServiceException in project BroadleafCommerce by BroadleafCommerce.
the class SkuBundleItemCustomPersistenceHandler method inspect.
@Override
public DynamicResultSet inspect(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, InspectHelper helper) throws ServiceException {
try {
PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective();
Map<MergedPropertyType, Map<String, FieldMetadata>> allMergedProperties = new HashMap<MergedPropertyType, Map<String, FieldMetadata>>();
// retrieve the default properties for Inventory
Map<String, FieldMetadata> properties = helper.getSimpleMergedProperties(SkuBundleItem.class.getName(), persistencePerspective);
// add in the consolidated product options field
FieldMetadata options = skuPersistenceHandler.createConsolidatedOptionField(SkuBundleItemImpl.class);
options.setOrder(3);
properties.put(SkuCustomPersistenceHandler.CONSOLIDATED_PRODUCT_OPTIONS_FIELD_NAME, options);
allMergedProperties.put(MergedPropertyType.PRIMARY, properties);
Class<?>[] entityClasses = dynamicEntityDao.getAllPolymorphicEntitiesFromCeiling(SkuBundleItem.class);
ClassMetadata mergedMetadata = helper.buildClassMetadata(entityClasses, persistencePackage, allMergedProperties);
return new DynamicResultSet(mergedMetadata, null, null);
} catch (Exception e) {
String className = persistencePackage.getCeilingEntityFullyQualifiedClassname();
ServiceException ex = new ServiceException("Unable to retrieve inspection results for " + className, e);
LOG.error("Unable to retrieve inspection results for " + className, ex);
throw ex;
}
}
use of org.broadleafcommerce.common.exception.ServiceException in project BroadleafCommerce by BroadleafCommerce.
the class SkuCustomPersistenceHandler method fetch.
@SuppressWarnings("unchecked")
@Override
public DynamicResultSet fetch(PersistencePackage persistencePackage, CriteriaTransferObject cto, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
String ceilingEntityFullyQualifiedClassname = persistencePackage.getCeilingEntityFullyQualifiedClassname();
try {
PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective();
// get the default properties from Sku and its subclasses
Map<String, FieldMetadata> originalProps = helper.getSimpleMergedProperties(Sku.class.getName(), persistencePerspective);
// Pull back the Skus based on the criteria from the client
List<FilterMapping> filterMappings = helper.getFilterMappings(persistencePerspective, cto, ceilingEntityFullyQualifiedClassname, originalProps);
// allow subclasses to provide additional criteria before executing the query
applyProductOptionValueCriteria(filterMappings, cto, persistencePackage, null);
applySkuBundleItemValueCriteria(filterMappings, cto, persistencePackage);
applyAdditionalFetchCriteria(filterMappings, cto, persistencePackage);
List<Serializable> records = helper.getPersistentRecords(persistencePackage.getCeilingEntityFullyQualifiedClassname(), filterMappings, cto.getFirstResult(), cto.getMaxResults());
// Convert Skus into the client-side Entity representation
Entity[] payload = helper.getRecords(originalProps, records);
int totalRecords = helper.getTotalRecords(persistencePackage.getCeilingEntityFullyQualifiedClassname(), filterMappings);
// Now fill out the relevant properties for the product options for the Skus that were returned
updateProductOptionFieldsForFetch(records, payload);
return new DynamicResultSet(payload, totalRecords);
} catch (Exception e) {
throw new ServiceException("Unable to perform fetch for entity: " + ceilingEntityFullyQualifiedClassname, e);
}
}
Aggregations