diff --git a/Documentation/Diagrammes/diagrammes.asta b/Documentation/Diagrammes/diagrammes.asta index fd5ff37d..06c8e081 100644 Binary files a/Documentation/Diagrammes/diagrammes.asta and b/Documentation/Diagrammes/diagrammes.asta differ diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/product/LightweightProduct.java b/Workspace/core/src/main/java/com/pqt/core/entities/product/LightweightProduct.java new file mode 100644 index 00000000..e13118ed --- /dev/null +++ b/Workspace/core/src/main/java/com/pqt/core/entities/product/LightweightProduct.java @@ -0,0 +1,97 @@ +package com.pqt.core.entities.product; + +import java.util.ArrayList; +import java.util.List; + +public class LightweightProduct { + private long id; + private String name; + private int amountRemaining; + private int amountSold; + private boolean sellable; + private double price; + private List componentIds; + private Category category; + + public LightweightProduct() { + componentIds = new ArrayList<>(); + } + + public LightweightProduct(Product product) { + this.id = product.getId(); + this.name = product.getName(); + this.amountRemaining = product.getAmountRemaining(); + this.amountSold = product.getAmountSold(); + this.sellable = product.isSellable(); + this.price = product.getPrice(); + this.category = product.getCategory(); + this.componentIds = new ArrayList<>(); + if(componentIds!=null){ + product.getComponents().stream().forEach((component -> componentIds.add(component.getId()))); + } + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAmountRemaining() { + return amountRemaining; + } + + public void setAmountRemaining(int amountRemaining) { + this.amountRemaining = amountRemaining; + } + + public int getAmountSold() { + return amountSold; + } + + public void setAmountSold(int amountSold) { + this.amountSold = amountSold; + } + + public boolean isSellable() { + return sellable; + } + + public void setSellable(boolean sellable) { + this.sellable = sellable; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + public List getComponentIds() { + return componentIds; + } + + public void setComponentIds(List componentIds) { + this.componentIds = componentIds; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } +} diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/sale/LightweightSale.java b/Workspace/core/src/main/java/com/pqt/core/entities/sale/LightweightSale.java new file mode 100644 index 00000000..b605721d --- /dev/null +++ b/Workspace/core/src/main/java/com/pqt/core/entities/sale/LightweightSale.java @@ -0,0 +1,102 @@ +package com.pqt.core.entities.sale; + +import com.pqt.core.entities.members.Client; +import com.pqt.core.entities.product.Product; +import com.pqt.core.entities.user_account.Account; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +public class LightweightSale { + + private int id; + private Map products; + private Date orderedAt; + private Client orderedWith; + private Account orderedBy; + private Account orderedFor; + private SaleType type; + private SaleStatus status; + + public LightweightSale() { + } + + public LightweightSale(Sale sale) { + this.id = sale.getId(); + this.orderedAt = sale.getOrderedAt(); + this.orderedWith = sale.getOrderedWith(); + this.orderedBy = sale.getOrderedBy(); + this.orderedFor = sale.getOrderedFor(); + this.type = sale.getType(); + this.status = sale.getStatus(); + products = new HashMap<>(); + for(Product product : sale.getProducts().keySet()){ + products.put(product.getId(), sale.getProducts().get(product)); + } + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Map getProducts() { + return products; + } + + public void setProducts(Map products) { + this.products = products; + } + + public Date getOrderedAt() { + return orderedAt; + } + + public void setOrderedAt(Date orderedAt) { + this.orderedAt = orderedAt; + } + + public Client getOrderedWith() { + return orderedWith; + } + + public void setOrderedWith(Client orderedWith) { + this.orderedWith = orderedWith; + } + + public Account getOrderedBy() { + return orderedBy; + } + + public void setOrderedBy(Account orderedBy) { + this.orderedBy = orderedBy; + } + + public Account getOrderedFor() { + return orderedFor; + } + + public void setOrderedFor(Account orderedFor) { + this.orderedFor = orderedFor; + } + + public SaleType getType() { + return type; + } + + public void setType(SaleType type) { + this.type = type; + } + + public SaleStatus getStatus() { + return status; + } + + public void setStatus(SaleStatus status) { + this.status = status; + } +}