use of org.broadleafcommerce.core.catalog.domain.CategoryXref in project BroadleafCommerce by BroadleafCommerce.
the class CategoryParentCategoryFieldPersistenceProvider method getDefaultCategory.
protected Category getDefaultCategory(Category category) {
Category response = null;
List<CategoryXref> xrefs = category.getAllParentCategoryXrefs();
if (!CollectionUtils.isEmpty(xrefs)) {
for (CategoryXref xref : xrefs) {
if (xref.getCategory().isActive() && xref.getDefaultReference() != null && xref.getDefaultReference()) {
response = xref.getCategory();
break;
}
}
}
return response;
}
use of org.broadleafcommerce.core.catalog.domain.CategoryXref in project BroadleafCommerce by BroadleafCommerce.
the class CategoryXrefDaoImpl method readXrefByIds.
@Override
public CategoryXref readXrefByIds(Long categoryId, Long subCategoryId) {
Query query = em.createNamedQuery("BC_READ_CATEGORY_XREF_BY_IDS");
query.setParameter("categoryId", categoryId);
query.setParameter("subCategoryId", subCategoryId);
return (CategoryXref) query.getSingleResult();
}
use of org.broadleafcommerce.core.catalog.domain.CategoryXref in project BroadleafCommerce by BroadleafCommerce.
the class CategoryCustomPersistenceHandler method setupXref.
protected void setupXref(Category adminInstance) {
if (isDefaultCategoryLegacyMode()) {
CategoryXref categoryXref = new CategoryXrefImpl();
categoryXref.setCategory(getExistingDefaultCategory(adminInstance));
categoryXref.setSubCategory(adminInstance);
if (!adminInstance.getAllParentCategoryXrefs().contains(categoryXref) && categoryXref.getCategory() != null) {
adminInstance.getAllParentCategoryXrefs().add(categoryXref);
}
}
}
use of org.broadleafcommerce.core.catalog.domain.CategoryXref in project BroadleafCommerce by BroadleafCommerce.
the class ChildCategoriesCustomPersistenceHandler method createXref.
protected CategoryXref createXref(Tuple<Category, Category> parentAndChild) {
CategoryXref xref = new CategoryXrefImpl();
xref.setCategory(parentAndChild.getFirst());
xref.setSubCategory(parentAndChild.getSecond());
return xref;
}
use of org.broadleafcommerce.core.catalog.domain.CategoryXref in project BroadleafCommerce by BroadleafCommerce.
the class ChildCategoriesCustomPersistenceHandler method checkCategoryAncestry.
protected void checkCategoryAncestry(Category category, Set<Category> knownAncestors) {
List<CategoryXref> parentXrefs = ListUtils.emptyIfNull(category.getAllParentCategoryXrefs());
knownAncestors.add(category);
for (CategoryXref parentXref : parentXrefs) {
final Category parentCategory = parentXref.getCategory();
if (!knownAncestors.contains(parentCategory)) {
checkCategoryAncestry(parentCategory, knownAncestors);
}
}
}
Aggregations