Initial commit : ajout des fichiers existants

This commit is contained in:
Notmoo-PC\Notmoo
2017-07-21 17:12:47 +02:00
parent 33cdbba13b
commit e1dd5d0b61
79 changed files with 3459 additions and 0 deletions

15
Workspace/core/core.iml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

15
Workspace/core/pom.xml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>Main</artifactId>
<groupId>com.pqt</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>core</artifactId>
</project>

View File

@ -0,0 +1,49 @@
package com.pqt.core.entities.client;
import com.pqt.core.entities.log.ILoggable;
import java.io.Serializable;
import java.util.Date;
/**
* Created by Notmoo on 18/07/2017.
*/
public class Client implements ILoggable, Serializable {
private int id;
private String address;
private Date lastUpdate;
public Client() {
}
public Client(int id, String address, Date lastUpdate) {
this.id = id;
this.address = address;
this.lastUpdate = lastUpdate;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Date getLastUpdate() {
return lastUpdate;
}
public void setLastUpdate(Date lastUpdate) {
this.lastUpdate = lastUpdate;
}
}

View File

@ -0,0 +1,7 @@
package com.pqt.core.entities.log;
/**
* Created by Notmoo on 18/07/2017.
*/
public interface ILoggable {
}

View File

@ -0,0 +1,66 @@
package com.pqt.core.entities.log;
import java.io.Serializable;
import java.util.Date;
/**
* Created by Notmoo on 18/07/2017.
*/
public class LogLine implements Serializable{
private int id;
private String description;
private Date timestamp;
private ILoggable relatedItem;
private LogLineActionType type;
public LogLine() {
}
public LogLine(int id, String description, Date timestamp, ILoggable relatedItem, LogLineActionType type) {
this.id = id;
this.description = description;
this.timestamp = timestamp;
this.relatedItem = relatedItem;
this.type = type;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getTimestamp() {
return timestamp;
}
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
public ILoggable getRelatedItem() {
return relatedItem;
}
public void setRelatedItem(ILoggable relatedItem) {
this.relatedItem = relatedItem;
}
public LogLineActionType getType() {
return type;
}
public void setType(LogLineActionType type) {
this.type = type;
}
}

View File

@ -0,0 +1,11 @@
package com.pqt.core.entities.log;
/**
* Created by Notmoo on 18/07/2017.
*/
public enum LogLineActionType {
ADD_PRODUCT_ACTION, REMOVE_PRODUCT_ACTION, MODIFY_PRODUCT_ACTION,
COMMIT_SALE_ACTION, REVERT_SALE_ACTION,
LOG_IN_ACCOUNT_ACTION, LOG_OUT_ACCOUNT_ACTION,
CONNECT_CLIENT_ACTION, DISCONNECT_CLIENT_ACTION
}

View File

@ -0,0 +1,35 @@
package com.pqt.core.entities.product;
import java.io.Serializable;
/**
* Created by Notmoo on 18/07/2017.
*/
public class Category implements Serializable{
private int id;
private String name;
public Category() {
}
public Category(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,100 @@
package com.pqt.core.entities.product;
import com.pqt.core.entities.log.ILoggable;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Notmoo on 18/07/2017.
*/
public class Product implements ILoggable, Serializable{
private int id;
private String name;
private int amountRemaining;
private int amountSold;
private boolean sellable;
private boolean price;
private List<Product> components;
private Category category;
public Product() {
components = new ArrayList<>();
}
public Product(int id, String name, int amountRemaining, int amountSold, boolean sellable, boolean price, List<Product> components, Category category) {
this.id = id;
this.name = name;
this.amountRemaining = amountRemaining;
this.amountSold = amountSold;
this.sellable = sellable;
this.price = price;
this.components = components;
this.category = category;
}
public int getId() {
return id;
}
public void setId(int 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 boolean isPrice() {
return price;
}
public void setPrice(boolean price) {
this.price = price;
}
public List<Product> getComponents() {
return components;
}
public void setComponents(List<Product> components) {
this.components = components;
}
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
}

View File

@ -0,0 +1,53 @@
package com.pqt.core.entities.product;
import com.pqt.core.entities.log.ILoggable;
import sun.misc.Version;
import java.io.Serializable;
import java.util.Date;
public class ProductUpdate implements ILoggable, Serializable {
private Date createdAt;
private Product oldVersion;
private Product newVersion;
public ProductUpdate() {
}
public ProductUpdate(Product oldVersion, Product newVersion) {
this.createdAt = new Date();
this.oldVersion = oldVersion;
this.newVersion = newVersion;
}
public ProductUpdate(Date createdAt, Product oldVersion, Product newVersion) {
this.createdAt = createdAt;
this.oldVersion = oldVersion;
this.newVersion = newVersion;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Product getOldVersion() {
return oldVersion;
}
public void setOldVersion(Product oldVersion) {
this.oldVersion = oldVersion;
}
public Product getNewVersion() {
return newVersion;
}
public void setNewVersion(Product newVersion) {
this.newVersion = newVersion;
}
}

View File

@ -0,0 +1,19 @@
package com.pqt.core.entities.query;
public class ConnectQuery extends SimpleQuery {
private String serverAddress;
public ConnectQuery(String serverAddress) {
super(QueryType.CONNECT);
this.serverAddress = serverAddress;
}
public String getServerAddress() {
return serverAddress;
}
public void setServerAddress(String serverAddress) {
this.serverAddress = serverAddress;
}
}

View File

@ -0,0 +1,5 @@
package com.pqt.core.entities.query;
public interface IQuery {
}

View File

@ -0,0 +1,32 @@
package com.pqt.core.entities.query;
import com.pqt.core.entities.user_account.Account;
public class LogQuery extends SimpleQuery {
private Account account;
private boolean newDesiredState;
public LogQuery(Account account, boolean newDesiredState) {
super(QueryType.LOG);
this.account = account;
this.newDesiredState = newDesiredState;
}
public Account getAccount() {
return account;
}
public void setAccount(Account account) {
this.account = account;
}
public boolean isNewDesiredState() {
return newDesiredState;
}
public void setNewDesiredState(boolean newDesiredState) {
this.newDesiredState = newDesiredState;
}
}

View File

@ -0,0 +1,6 @@
package com.pqt.core.entities.query;
public enum QueryType {
CONNECT, SALE, STOCL, STAT, LOG, UPDATE
}

View File

@ -0,0 +1,21 @@
package com.pqt.core.entities.query;
import com.pqt.core.entities.sale.Sale;
public class SaleQuery extends SimpleQuery {
private Sale sale;
public SaleQuery(Sale sale) {
super(QueryType.SALE);
this.sale = sale;
}
public Sale getSale() {
return sale;
}
public void setSale(Sale sale) {
this.sale = sale;
}
}

View File

@ -0,0 +1,21 @@
package com.pqt.core.entities.query;
public class SimpleQuery implements IQuery {
private QueryType type;
/**
*
* @param type
* @throws NullPointerException if type is null
*/
public SimpleQuery(QueryType type) {
if(type==null) throw new NullPointerException("null value not allowed as query type");
this.type = type;
}
public QueryType getType() {
return type;
}
}

View File

@ -0,0 +1,23 @@
package com.pqt.core.entities.query;
import com.pqt.core.entities.product.ProductUpdate;
import java.util.List;
public class UpdateQuery extends SimpleQuery {
private List<ProductUpdate> updates;
public UpdateQuery(List<ProductUpdate> updates) {
super(QueryType.UPDATE);
this.updates = updates;
}
public List<ProductUpdate> getUpdates() {
return updates;
}
public void setUpdates(List<ProductUpdate> updates) {
this.updates = updates;
}
}

View File

@ -0,0 +1,103 @@
package com.pqt.core.entities.sale;
import com.pqt.core.entities.log.ILoggable;
import com.pqt.core.entities.client.Client;
import com.pqt.core.entities.product.Product;
import com.pqt.core.entities.user_account.Account;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
/**
* Created by Notmoo on 18/07/2017.
*/
public class Sale implements ILoggable, Serializable{
private int id;
private Map<Product, Integer> products;
private Date orderedAt;
private Client orderedWith;
private Account orderedBy;
private Account orderedFor;
private SaleType type;
private SaleStatus status;
public Sale() {
}
public Sale(int id, Map<Product, Integer> products, Date orderedAt, Client orderedWith, Account orderedBy, Account orderedFor, SaleType type, SaleStatus status) {
this.id = id;
this.products = products;
this.orderedAt = orderedAt;
this.orderedWith = orderedWith;
this.orderedBy = orderedBy;
this.orderedFor = orderedFor;
this.type = type;
this.status = status;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Map<Product, Integer> getProducts() {
return products;
}
public void setProducts(Map<Product, 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;
}
}

View File

@ -0,0 +1,19 @@
package com.pqt.core.entities.sale;
/**
* Created by Notmoo on 18/07/2017.
*/
public enum SaleStatus {
PENDING(0), REFUSED(1), ACCEPTED(2), ABORTED(3);
private int id;
private SaleStatus(int id){
this.id = id;
}
public int getId() {
return id;
}
}

View File

@ -0,0 +1,8 @@
package com.pqt.core.entities.sale;
/**
* Created by Notmoo on 18/07/2017.
*/
public enum SaleType {
CASH, BANK_CHECK, STUDENT_ASSOCIATION_ACCOUNT, OFFERED_GUEST, OFFERED_STAFF_MEMBER
}

View File

@ -0,0 +1,68 @@
package com.pqt.core.entities.user_account;
import com.pqt.core.entities.log.ILoggable;
import java.io.Serializable;
import java.util.Date;
/**
* Created by Notmoo on 18/07/2017.
*/
public class Account implements ILoggable, Serializable {
private int id;
private String username;
private String passwordHash;
private Date creationDate;
private AccountLevel permissionLevel;
public Account() {
}
public Account(int id, String username, String passwordHash, Date creationDate, AccountLevel permissionLevel) {
this.id = id;
this.username = username;
this.passwordHash = passwordHash;
this.creationDate = creationDate;
this.permissionLevel = permissionLevel;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPasswordHash() {
return passwordHash;
}
public void setPasswordHash(String passwordHash) {
this.passwordHash = passwordHash;
}
public Date getCreationDate() {
return creationDate;
}
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
public AccountLevel getPermissionLevel() {
return permissionLevel;
}
public void setPermissionLevel(AccountLevel permissionLevel) {
this.permissionLevel = permissionLevel;
}
}

View File

@ -0,0 +1,8 @@
package com.pqt.core.entities.user_account;
/**
* Created by Notmoo on 18/07/2017.
*/
public enum AccountLevel {
GUEST, STAFF, WAITER, MASTER
}