public boolean apply(@Nullable Product input) { return input.getSlug().equals(variantSlug); } }).first().orNull();
public Product createProduct(Product entity) throws InvalidEntityException, EntityAlreadyExistsException { if (Strings.isNullOrEmpty(entity.getSlug())) { entity.setSlug(this.slugifier.slugify(entity.getTitle())); } productStore.get().create(entity); return this.findProductBySlug(entity.getSlug()); }
output.println("- indexing " + tenant.getSlug() + ":" + product.getSlug()); output.flush();
put("slug", purchasedProduct.getSlug()); put("title", purchasedProduct.getTitle());
public void update(Product product) throws EntityDoesNotExistException, InvalidEntityException { this.dao.begin(); Product originalProduct = this.findBySlug(product.getSlug(), product.getParentId()); if (originalProduct == null) { this.dao.commit(); throw new EntityDoesNotExistException(); } if (!product.getAddons().isLoaded()) { product.setAddons(originalProduct.getAddons().get()); } getObservationManager().notify(new EntityUpdatingEvent(), product); product.setId(originalProduct.getId()); Integer updatedRows = this.dao.updateProduct(product); this.dao.createOrUpdateAddons(product); if (product.getLocalizedVersions() != null && !product.getLocalizedVersions().isEmpty()) { Map<Locale, Map<String, Object>> localizedVersions = product.getLocalizedVersions(); for (Locale locale : localizedVersions.keySet()) { this.dao.createOrUpdateTranslation(product.getId(), locale, localizedVersions.get(locale)); } } this.dao.commit(); if (updatedRows <= 0) { throw new StoreException("No rows was updated when updating product"); } getObservationManager().notify(new EntityUpdatedEvent(), product); }
public Product create(Product product) throws EntityAlreadyExistsException, InvalidEntityException if (this.dao.findBySlug(product.getSlug(), getTenant(), product.getParentId()) != null) { throw new EntityAlreadyExistsException();