@Override public Collection<ProductBundle> findProductBundlesContaining(final Product product) { final Set<ProductBundle> bundles = new HashSet<ProductBundle>(); bundles.addAll(getProductBundleDao().findByProduct(product.getCode())); for (final ProductSku sku : product.getProductSkus().values()) { bundles.addAll(getProductSkuService().findProductBundlesContaining(sku)); } return bundles; }
/** * Finds id tuples of ProductBundles that directly contain the given product or any of the * product's skus as a BundleConstituent. * * <p>Each tuple is an 2 element Object array containing the ProductBundle's id as the first * element and the bundle's product code as the second element. * * @param product the product * @return a list of [uidpk, code] tuples */ private List<Object[]> findProductBundleIdsContainingProduct(final Product product) { final List<Object[]> bundleProductIds = findProductBundleUidsContainingProductCode(product.getCode()); final List<Object[]> bundleProductSkuIds = getPersistenceEngine() .retrieveByNamedQueryWithList( "FIND_BUNDLE_IDS_BY_CONSTITUENT_PRODUCT_SKUS", "list", new ArrayList<String>(product.getProductSkus().keySet())); List<Object[]> result = new ArrayList<Object[]>(); result.addAll(bundleProductIds); result.addAll(bundleProductSkuIds); return result; }