Ajout versions "lightweight" des classes Sale et Product; MAJ des diagrammes de classe

This commit is contained in:
Notmoo 2017-07-23 22:13:48 +02:00
parent d2d45d93a0
commit 524838cd09
3 changed files with 199 additions and 0 deletions

View File

@ -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<Long> 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<Long> getComponentIds() {
return componentIds;
}
public void setComponentIds(List<Long> componentIds) {
this.componentIds = componentIds;
}
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
}

View File

@ -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<Long, Integer> 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<Long, Integer> getProducts() {
return products;
}
public void setProducts(Map<Long, Integer> 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;
}
}