public void moveCollection( String collectionToMove, String collectionToMoveRelativeTo, RelativePosition relativePosition) throws InvalidMoveOperation { this.dao.begin(); List<Collection> allCollections = this.findAll(); MoveEntityInListOperation<Collection> moveOp = new MoveEntityInListOperation<Collection>( allCollections, collectionToMove, collectionToMoveRelativeTo, relativePosition); if (moveOp.hasMoved()) { this.dao.updatePositions(COLLECTION_TABLE_NAME, moveOp.getEntities(), moveOp.getPositions()); } this.dao.commit(); }
@Override public void moveProductInCollection( Collection collection, String productToMove, String productToMoveRelativeTo, RelativePosition relativePosition) throws InvalidMoveOperation { this.dao.begin(); List<Product> categoryProducts = this.productDao.findAllForCollection(collection); MoveEntityInListOperation<Product> moveOp = new MoveEntityInListOperation<>( categoryProducts, productToMove, productToMoveRelativeTo, relativePosition); if (moveOp.hasMoved()) { this.dao.updateProductPosition(moveOp.getEntities(), moveOp.getPositions()); } this.dao.commit(); }