@Override public void moveProductInCollection(Collection collection, String slugOfProductToMove, String relativeSlug) throws InvalidMoveOperation { this.moveProductInCollection(collection, slugOfProductToMove, relativeSlug, InsertPosition.BEFORE); }
@Override public void moveProduct(String slugOfProductToMove, String slugOfProductToMoveBeforeOf) throws InvalidMoveOperation { this.moveProduct(slugOfProductToMove, slugOfProductToMoveBeforeOf, InsertPosition.BEFORE); }
@Override public void moveCollection(String slugOfCollectionToMove, String slugOfCollectionToMoveBeforeOf) throws InvalidMoveOperation { this.moveCollection(slugOfCollectionToMove, slugOfCollectionToMoveBeforeOf, InsertPosition.BEFORE); }
@Override public void removeProductFromCollection(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)) { // It does not contain it : nothing to do return; } this.collectionStore.get().removeProduct(c, p); }
@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 <E extends Entity> void loadList(List<EntityData<E>> entities, LoadingOption... options) { // TODO improve perf by doing only one query for (EntityData<E> entityData : entities) { load(entityData, options); } }
@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); }
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()); }
@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()); }