@Override public List<Collection> findAllCollections(int number, int offset) { return this.collectionStore.get().findAll(number, offset); }
@Override public void updateCollection(Collection entity) throws EntityDoesNotExistException, InvalidEntityException { this.collectionStore.get().update(entity); }
@Override public List<Collection> findCollectionsForProduct(Product product) { return this.collectionStore.get().findAllForProduct(product); }
public Product findProductBySlug(String slug) { return this.productStore.get().findBySlug(slug); }
@Override public <E extends Entity> void load(EntityData<E> entity, LoadingOption... options) { if (!Product.class.isAssignableFrom(entity.getEntity().getClass())) { return; } List<LoadingOption> optionsAsList = Arrays.asList(options); if (optionsAsList.contains(ProductLoadingOptions.WITH_FEATURE_AND_VARIANTS)) { entity.setChildren(Feature.class, this.productStore.findFeatures((Product) entity.getEntity())); entity.setChildren(Product.class, this.productStore.findVariants((Product) entity.getEntity())); } }
@Override public List<Product> findProductsForCollection(Collection collection) { return this.productStore.get().findAllForCollection(collection); }
@Override public Collection findCollectionBySlug(String slug) { return this.collectionStore.get().findBySlug(slug); }
@Override public void addProductToCollection(String collection, String product) throws InvalidOperation { Collection c = this.findCollectionBySlug(collection); Product p = this.findProductBySlug(product); if (p == null || c == null) { throw new InvalidOperation("Product or collection does not exist"); } List<Collection> collections = this.collectionStore.get().findAllForProduct(p); if (collections.contains(c)) { // Already has it : nothing to do return; } this.collectionStore.get().addProduct(c, p); }
@Override public List<EntityAndCount<Collection>> findAllCollectionsWithProductCount() { return this.collectionStore.get().findAllWithProductCount(); }
public List<Product> findAllProducts(int number, int offset) { return this.productStore.get().findAll(number, offset); }
public void updateProduct(Product entity) throws EntityDoesNotExistException, InvalidEntityException { this.productStore.get().update(entity); }
public List<Product> findOrphanProducts() { return this.productStore.get().findOrphanProducts(); }
@Override public void moveCollection(String slugOfCollectionToMove, String slugOfCollectionToMoveRelativeTo, InsertPosition position) throws InvalidMoveOperation { this.collectionStore.get().moveCollection(slugOfCollectionToMove, slugOfCollectionToMoveRelativeTo, position.equals(InsertPosition.AFTER) ? HasOrderedCollections.RelativePosition.AFTER : HasOrderedCollections.RelativePosition.BEFORE); }
@Override public void moveProductInCollection(Collection collection, String slugOfProductToMove, String relativeSlug, InsertPosition insertPosition) throws InvalidMoveOperation { this.collectionStore.get().moveProductInCollection(collection, slugOfProductToMove, relativeSlug, insertPosition.equals(InsertPosition.AFTER) ? HasOrderedCollections.RelativePosition.AFTER : HasOrderedCollections.RelativePosition.BEFORE); } }
@Override public void moveProduct(String slugOfProductToMove, String slugOfProductToRelativeTo, InsertPosition position) throws InvalidMoveOperation { this.productStore.get().moveProduct(slugOfProductToMove, slugOfProductToRelativeTo, position.equals(InsertPosition.AFTER) ? HasOrderedCollections.RelativePosition.AFTER : HasOrderedCollections.RelativePosition.BEFORE); }
@Override public void deleteProduct(String productSlug) throws EntityDoesNotExistException { Product product = this.findProductBySlug(productSlug); if (product == null) { throw new EntityDoesNotExistException(); } this.productStore.get().delete(product); }
@Override public void deleteCollection(String collectionSlug) throws EntityDoesNotExistException { Collection collection = this.findCollectionBySlug(collectionSlug); if (collection == null) { throw new EntityDoesNotExistException(); } this.collectionStore.get().delete(collection); }
@Override public Collection createCollection(Collection entity) throws InvalidEntityException, EntityAlreadyExistsException { if (Strings.isNullOrEmpty(entity.getSlug())) { entity.setSlug(this.slugifier.slugify(entity.getTitle())); } this.collectionStore.get().create(entity); return this.findCollectionBySlug(entity.getSlug()); }
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()); }
public <E extends Entity> E load(String slug) { return (E) productStore.get().findBySlug(slug); }