// Path: flow-bookstore/bookstore-ui/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/authentication/AccessControl.java
// public interface AccessControl extends Serializable {
// 
//     String ADMIN_ROLE_NAME = "admin";
//     String ADMIN_USERNAME = "admin";
// 
//     public boolean signIn(String username, String password);
// 
//     public boolean isUserSignedIn();
// 
//     public boolean isUserInRole(String role);
// 
//     public String getPrincipalName();
// }
// 
// Path: flow-bookstore/bookstore-ui/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/authentication/AccessControlFactory.java
// public class AccessControlFactory {
//     private static final AccessControlFactory INSTANCE = new AccessControlFactory();
//     private final AccessControl accessControl = new BasicAccessControl();
// 
//     private AccessControlFactory() {
//     }
// 
//     public static AccessControlFactory getInstance() {
//         return INSTANCE;
//     }
// 
//     public AccessControl createAccessControl() {
//         return accessControl;
//     }
// }
// 
// Path: flow-bookstore/bookstore-backend/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/DataService.java
// public abstract class DataService implements Serializable {
// 
//     public abstract Collection<Product> getAllProducts();
// 
//     public abstract Collection<Category> getAllCategories();
// 
//     public abstract void updateProduct(Product p);
// 
//     public abstract void deleteProduct(int productId);
// 
//     public abstract Product getProductById(int productId);
// 
//     public static DataService get() {
//         return MockDataService.getInstance();
//     }
// 
// }
// 
// Path: flow-bookstore/bookstore-backend/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/data/Product.java
// public class Product implements Serializable {
// 
//     @NotNull
//     private int id = -1;
//     @NotNull
//     @Size(min = 2, message = "Product name must have at least two characters")
//     private String productName = "";
//     @Min(0)
//     private BigDecimal price = BigDecimal.ZERO;
//     private Set<Category> category;
//     @Min(value = 0, message = "Can't have negative amount in stock")
//     private int stockCount = 0;
//     @NotNull
//     private Availability availability = Availability.COMING;
// 
//     private String image;
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public String getProductName() {
//         return productName;
//     }
// 
//     public void setProductName(String productName) {
//         this.productName = productName;
//     }
// 
//     public BigDecimal getPrice() {
//         return price;
//     }
// 
//     public void setPrice(BigDecimal price) {
//         this.price = price;
//     }
// 
//     public Set<Category> getCategory() {
//         return category;
//     }
// 
//     public void setCategory(Set<Category> category) {
//         this.category = category;
//     }
// 
//     public int getStockCount() {
//         return stockCount;
//     }
// 
//     public void setStockCount(int stockCount) {
//         this.stockCount = stockCount;
//     }
// 
//     public Availability getAvailability() {
//         return availability;
//     }
// 
//     public void setAvailability(Availability availability) {
//         this.availability = availability;
//     }
// 
//     public boolean isNewProduct() {
//         return getId() == -1;
//     }
// 
//     public String getImage() {
//         return image;
//     }
// 
//     public void setImage(String image) {
//         this.image = image;
//     }
// }


import com.vaadin.flow.component.UI;
import com.github.mcollovati.vertxvaadin.flowdemo.authentication.AccessControl;
import com.github.mcollovati.vertxvaadin.flowdemo.authentication.AccessControlFactory;
import com.github.mcollovati.vertxvaadin.flowdemo.backend.DataService;
import com.github.mcollovati.vertxvaadin.flowdemo.backend.data.Product;
import java.io.Serializable;
package com.github.mcollovati.vertxvaadin.flowdemo.crud;



/**
 * This class provides an interface for the logical operations between the CRUD
 * view, its parts like the product editor form and the data source, including
 * fetching and saving products.
 *
 * Having this separate from the view makes it easier to test various parts of
 * the system separately, and to e.g. provide alternative views for the same
 * data.
 */
public class SampleCrudLogic implements Serializable {

    private SampleCrudView view;

    public SampleCrudLogic(SampleCrudView simpleCrudView) {
        view = simpleCrudView;
    }

    public void init() {
        editProduct(null);
        // Hide and disable if not admin
        if (!AccessControlFactory.getInstance().createAccessControl()
// Path: flow-bookstore/bookstore-ui/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/authentication/AccessControl.java
// public interface AccessControl extends Serializable {
// 
//     String ADMIN_ROLE_NAME = "admin";
//     String ADMIN_USERNAME = "admin";
// 
//     public boolean signIn(String username, String password);
// 
//     public boolean isUserSignedIn();
// 
//     public boolean isUserInRole(String role);
// 
//     public String getPrincipalName();
// }
// 
// Path: flow-bookstore/bookstore-ui/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/authentication/AccessControlFactory.java
// public class AccessControlFactory {
//     private static final AccessControlFactory INSTANCE = new AccessControlFactory();
//     private final AccessControl accessControl = new BasicAccessControl();
// 
//     private AccessControlFactory() {
//     }
// 
//     public static AccessControlFactory getInstance() {
//         return INSTANCE;
//     }
// 
//     public AccessControl createAccessControl() {
//         return accessControl;
//     }
// }
// 
// Path: flow-bookstore/bookstore-backend/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/DataService.java
// public abstract class DataService implements Serializable {
// 
//     public abstract Collection<Product> getAllProducts();
// 
//     public abstract Collection<Category> getAllCategories();
// 
//     public abstract void updateProduct(Product p);
// 
//     public abstract void deleteProduct(int productId);
// 
//     public abstract Product getProductById(int productId);
// 
//     public static DataService get() {
//         return MockDataService.getInstance();
//     }
// 
// }
// 
// Path: flow-bookstore/bookstore-backend/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/data/Product.java
// public class Product implements Serializable {
// 
//     @NotNull
//     private int id = -1;
//     @NotNull
//     @Size(min = 2, message = "Product name must have at least two characters")
//     private String productName = "";
//     @Min(0)
//     private BigDecimal price = BigDecimal.ZERO;
//     private Set<Category> category;
//     @Min(value = 0, message = "Can't have negative amount in stock")
//     private int stockCount = 0;
//     @NotNull
//     private Availability availability = Availability.COMING;
// 
//     private String image;
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public String getProductName() {
//         return productName;
//     }
// 
//     public void setProductName(String productName) {
//         this.productName = productName;
//     }
// 
//     public BigDecimal getPrice() {
//         return price;
//     }
// 
//     public void setPrice(BigDecimal price) {
//         this.price = price;
//     }
// 
//     public Set<Category> getCategory() {
//         return category;
//     }
// 
//     public void setCategory(Set<Category> category) {
//         this.category = category;
//     }
// 
//     public int getStockCount() {
//         return stockCount;
//     }
// 
//     public void setStockCount(int stockCount) {
//         this.stockCount = stockCount;
//     }
// 
//     public Availability getAvailability() {
//         return availability;
//     }
// 
//     public void setAvailability(Availability availability) {
//         this.availability = availability;
//     }
// 
//     public boolean isNewProduct() {
//         return getId() == -1;
//     }
// 
//     public String getImage() {
//         return image;
//     }
// 
//     public void setImage(String image) {
//         this.image = image;
//     }
// }


// Path: flow-bookstore/bookstore-ui/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/crud/SampleCrudLogic.java
import com.vaadin.flow.component.UI;
import com.github.mcollovati.vertxvaadin.flowdemo.authentication.AccessControl;
import com.github.mcollovati.vertxvaadin.flowdemo.authentication.AccessControlFactory;
import com.github.mcollovati.vertxvaadin.flowdemo.backend.DataService;
import com.github.mcollovati.vertxvaadin.flowdemo.backend.data.Product;
import java.io.Serializable;

package com.github.mcollovati.vertxvaadin.flowdemo.crud;



/**
 * This class provides an interface for the logical operations between the CRUD
 * view, its parts like the product editor form and the data source, including
 * fetching and saving products.
 *
 * Having this separate from the view makes it easier to test various parts of
 * the system separately, and to e.g. provide alternative views for the same
 * data.
 */
public class SampleCrudLogic implements Serializable {

    private SampleCrudView view;

    public SampleCrudLogic(SampleCrudView simpleCrudView) {
        view = simpleCrudView;
    }

    public void init() {
        editProduct(null);
        // Hide and disable if not admin
        if (!AccessControlFactory.getInstance().createAccessControl()
                .isUserInRole(AccessControl.ADMIN_ROLE_NAME)) {