mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2025-07-14 13:59:24 +00:00
Initial commit : ajout des fichiers existants
This commit is contained in:
Documentation
Workspace
.idea
Workspace.imlclient
client.imlpom.xml
src
main
java
com
pqt
client
module
account
AccountService.java
listeners
connection
ConnectionService.java
listeners
log
query
sale
stat
stock
core
core.imlpom.xml
pom.xmlsrc
main
java
com
pqt
core
entities
client
log
product
query
ConnectQuery.javaIQuery.javaLogQuery.javaQueryType.javaSaleQuery.javaSimpleQuery.javaUpdateQuery.java
sale
user_account
BIN
Documentation/Diagrammes/diagrammes.asta
Normal file
BIN
Documentation/Diagrammes/diagrammes.asta
Normal file
Binary file not shown.
BIN
Documentation/Interactions_serveur-clients.ods
Normal file
BIN
Documentation/Interactions_serveur-clients.ods
Normal file
Binary file not shown.
BIN
Documentation/Interface/recherche_docu/12_labventory3.jpg
Normal file
BIN
Documentation/Interface/recherche_docu/12_labventory3.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 674 KiB |
BIN
Documentation/Interface/recherche_docu/Lightstock-screen.jpg
Normal file
BIN
Documentation/Interface/recherche_docu/Lightstock-screen.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 41 KiB |
BIN
Documentation/Interface/recherche_docu/VenteTactile.png
Normal file
BIN
Documentation/Interface/recherche_docu/VenteTactile.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 137 KiB |
BIN
Documentation/Interface/recherche_docu/caisse.jpg
Normal file
BIN
Documentation/Interface/recherche_docu/caisse.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 380 KiB |
BIN
Documentation/Interface/recherche_docu/flx42.jpg
Normal file
BIN
Documentation/Interface/recherche_docu/flx42.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 103 KiB |
1
Workspace/.idea/.name
generated
Normal file
1
Workspace/.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
||||
Main
|
20
Workspace/.idea/compiler.xml
generated
Normal file
20
Workspace/.idea/compiler.xml
generated
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="client" />
|
||||
<module name="core" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="client" target="1.8" />
|
||||
<module name="core" target="1.8" />
|
||||
<module name="server" target="1.5" />
|
||||
<module name="Workspace" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
18
Workspace/.idea/misc.xml
generated
Normal file
18
Workspace/.idea/misc.xml
generated
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="ignoredFiles">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/server/pom.xml" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
10
Workspace/.idea/modules.xml
generated
Normal file
10
Workspace/.idea/modules.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Workspace.iml" filepath="$PROJECT_DIR$/Workspace.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/client/client.iml" filepath="$PROJECT_DIR$/client/client.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/core/core.iml" filepath="$PROJECT_DIR$/core/core.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
1330
Workspace/.idea/workspace.xml
generated
Normal file
1330
Workspace/.idea/workspace.xml
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
Workspace/Workspace.iml
Normal file
15
Workspace/Workspace.iml
Normal 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>
|
16
Workspace/client/client.iml
Normal file
16
Workspace/client/client.iml
Normal file
@ -0,0 +1,16 @@
|
||||
<?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" />
|
||||
<orderEntry type="module" module-name="core" />
|
||||
</component>
|
||||
</module>
|
22
Workspace/client/pom.xml
Normal file
22
Workspace/client/pom.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?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>client</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.pqt</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
@ -0,0 +1,45 @@
|
||||
package com.pqt.client.module.account;
|
||||
|
||||
import com.pqt.core.entities.user_account.Account;
|
||||
import com.pqt.client.module.account.listeners.IAccountListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
//TODO add log lines
|
||||
public class AccountService {
|
||||
|
||||
public Account getCurrentAccount() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setCurrentAccount(Account account) {
|
||||
|
||||
}
|
||||
|
||||
public boolean isAccountLoggedIn(Account account) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void logInCurrentAccount(String password) {
|
||||
|
||||
}
|
||||
|
||||
public void logOutCurrentAccount(String password) {
|
||||
|
||||
}
|
||||
|
||||
public List<Account> getRecentAccounts() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addListener(IAccountListener listener) {
|
||||
|
||||
}
|
||||
|
||||
public void removeListener(IAccountListener listener) {
|
||||
|
||||
}
|
||||
|
||||
}
|
15
Workspace/client/src/main/java/com/pqt/client/module/account/listeners/AccountListenerAdapter.java
Normal file
15
Workspace/client/src/main/java/com/pqt/client/module/account/listeners/AccountListenerAdapter.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.pqt.client.module.account.listeners;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class AccountListenerAdapter implements IAccountListener {
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.account.listeners.IAccountListener#onAccountStatusChanged(boolean)
|
||||
*/
|
||||
public void onAccountStatusChanged(boolean status) {
|
||||
|
||||
}
|
||||
|
||||
}
|
11
Workspace/client/src/main/java/com/pqt/client/module/account/listeners/IAccountFirerer.java
Normal file
11
Workspace/client/src/main/java/com/pqt/client/module/account/listeners/IAccountFirerer.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.pqt.client.module.account.listeners;
|
||||
|
||||
public interface IAccountFirerer {
|
||||
|
||||
public void fireAccountStatusChanged(boolean status);
|
||||
|
||||
public abstract void addListener(IAccountListener listener);
|
||||
|
||||
public abstract void removeListener(IAccountListener listener);
|
||||
|
||||
}
|
9
Workspace/client/src/main/java/com/pqt/client/module/account/listeners/IAccountListener.java
Normal file
9
Workspace/client/src/main/java/com/pqt/client/module/account/listeners/IAccountListener.java
Normal file
@ -0,0 +1,9 @@
|
||||
package com.pqt.client.module.account.listeners;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface IAccountListener extends EventListener {
|
||||
|
||||
public void onAccountStatusChanged(boolean status);
|
||||
|
||||
}
|
31
Workspace/client/src/main/java/com/pqt/client/module/account/listeners/SimpleAccountFirerer.java
Normal file
31
Workspace/client/src/main/java/com/pqt/client/module/account/listeners/SimpleAccountFirerer.java
Normal file
@ -0,0 +1,31 @@
|
||||
package com.pqt.client.module.account.listeners;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class SimpleAccountFirerer implements IAccountFirerer {
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.account.listeners.IAccountFirerer#fireAccountStatusChanged(boolean)
|
||||
*/
|
||||
public void fireAccountStatusChanged(boolean status) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.account.listeners.IAccountFirerer#addListener(com.pqt.client.module.account.listeners.IAccountListener)
|
||||
*/
|
||||
public void addListener(IAccountListener listener) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.account.listeners.IAccountFirerer#removeListener(com.pqt.client.module.account.listeners.IAccountListener)
|
||||
*/
|
||||
public void removeListener(IAccountListener listener) {
|
||||
|
||||
}
|
||||
|
||||
}
|
46
Workspace/client/src/main/java/com/pqt/client/module/connection/ConnectionService.java
Normal file
46
Workspace/client/src/main/java/com/pqt/client/module/connection/ConnectionService.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.pqt.client.module.connection;
|
||||
|
||||
import com.pqt.client.module.connection.listeners.IConnectionListener;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
//TODO add log lines?
|
||||
public class ConnectionService {
|
||||
|
||||
public boolean isConnectedToServer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void connectToServer(String ip_address) {
|
||||
|
||||
}
|
||||
|
||||
public void disconnectFromServer() {
|
||||
|
||||
}
|
||||
|
||||
public String getCurrentServerIpAddress() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
public void sendText(String text) {
|
||||
|
||||
}
|
||||
|
||||
public void addListener(IConnectionListener listener) {
|
||||
|
||||
}
|
||||
|
||||
public void removeListener(IConnectionListener listener) {
|
||||
|
||||
}
|
||||
|
||||
}
|
37
Workspace/client/src/main/java/com/pqt/client/module/connection/listeners/ConnectionListenerAdapter.java
Normal file
37
Workspace/client/src/main/java/com/pqt/client/module/connection/listeners/ConnectionListenerAdapter.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com.pqt.client.module.connection.listeners;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class ConnectionListenerAdapter implements IConnectionListener {
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.connection.listeners.IConnectionListener#onMessageReceivedEvent(String)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void onMessageReceivedEvent(String msg) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.connection.listeners.IConnectionListener#onConnectedEvent()
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void onConnectedEvent() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.connection.listeners.IConnectionListener#onDisconnectedEvent()
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void onDisconnectedEvent() {
|
||||
|
||||
}
|
||||
|
||||
}
|
15
Workspace/client/src/main/java/com/pqt/client/module/connection/listeners/IConnectionFirerer.java
Normal file
15
Workspace/client/src/main/java/com/pqt/client/module/connection/listeners/IConnectionFirerer.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.pqt.client.module.connection.listeners;
|
||||
|
||||
public interface IConnectionFirerer {
|
||||
|
||||
public abstract void fireMessageReceivedEvent(String msg);
|
||||
|
||||
public abstract void fireConnectedEvent();
|
||||
|
||||
public abstract void fireDisconnectedEvent();
|
||||
|
||||
public abstract void addListener(IConnectionListener listener);
|
||||
|
||||
public abstract void removeListener(IConnectionListener listener);
|
||||
|
||||
}
|
13
Workspace/client/src/main/java/com/pqt/client/module/connection/listeners/IConnectionListener.java
Normal file
13
Workspace/client/src/main/java/com/pqt/client/module/connection/listeners/IConnectionListener.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.pqt.client.module.connection.listeners;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface IConnectionListener extends EventListener {
|
||||
|
||||
public abstract void onMessageReceivedEvent(String msg);
|
||||
|
||||
public abstract void onConnectedEvent();
|
||||
|
||||
public abstract void onDisconnectedEvent();
|
||||
|
||||
}
|
49
Workspace/client/src/main/java/com/pqt/client/module/connection/listeners/SimpleConnectionFirerer.java
Normal file
49
Workspace/client/src/main/java/com/pqt/client/module/connection/listeners/SimpleConnectionFirerer.java
Normal file
@ -0,0 +1,49 @@
|
||||
package com.pqt.client.module.connection.listeners;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class SimpleConnectionFirerer implements IConnectionFirerer {
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.connection.listeners.IConnectionFirerer#fireMessageReceivedEvent(String)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void fireMessageReceivedEvent(String msg) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.connection.listeners.IConnectionFirerer#fireConnectedEvent()
|
||||
*/
|
||||
public void fireConnectedEvent() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.connection.listeners.IConnectionFirerer#fireDisconnectedEvent()
|
||||
*/
|
||||
public void fireDisconnectedEvent() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.connection.listeners.IConnectionFirerer#addListener(com.pqt.client.module.connection.listeners.IConnectionListener)
|
||||
*/
|
||||
public void addListener(IConnectionListener listener) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.connection.listeners.IConnectionFirerer#removeListener(com.pqt.client.module.connection.listeners.IConnectionListener)
|
||||
*/
|
||||
public void removeListener(IConnectionListener listener) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.pqt.client.module.log;
|
||||
|
||||
import com.pqt.core.entities.log.LogLine;
|
||||
import com.pqt.core.entities.log.ILoggable;
|
||||
|
||||
public interface ILogLineMaker {
|
||||
LogLine make(ILoggable loggable);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.pqt.client.module.log;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class LogLineMakerManager {
|
||||
|
||||
public ILogLineMaker getMaker(Class clazz) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean setMaker(Class clazz, ILogLineMaker maker) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ILogLineMaker getDefaultMaker() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean setDefaultMaker(ILogLineMaker maker) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.pqt.client.module.log;
|
||||
|
||||
import com.pqt.core.entities.log.ILoggable;
|
||||
import com.pqt.core.entities.log.LogLine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class LogService {
|
||||
|
||||
public void log(ILoggable loggable) {
|
||||
|
||||
}
|
||||
|
||||
public List<LogLine> getAllLogs() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<LogLine> getLastLogs(int number) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<LogLine> getLastLogs(int number, int offset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.pqt.client.module.log.listeners;
|
||||
|
||||
public interface ILogFirerer {
|
||||
|
||||
public abstract void addListener(ILogListener listener);
|
||||
|
||||
public abstract void removeListener(ILogListener listener);
|
||||
|
||||
public abstract void fireLogEvent();
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.pqt.client.module.log.listeners;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface ILogListener extends EventListener {
|
||||
|
||||
public abstract void onLogEvent();
|
||||
|
||||
}
|
17
Workspace/client/src/main/java/com/pqt/client/module/log/listeners/LogListenerAdapter.java
Normal file
17
Workspace/client/src/main/java/com/pqt/client/module/log/listeners/LogListenerAdapter.java
Normal file
@ -0,0 +1,17 @@
|
||||
package com.pqt.client.module.log.listeners;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class LogListenerAdapter implements ILogListener {
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.log.listeners.ILogListener#onLogEvent()
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void onLogEvent() {
|
||||
|
||||
}
|
||||
|
||||
}
|
33
Workspace/client/src/main/java/com/pqt/client/module/log/listeners/SimpleLogFirerer.java
Normal file
33
Workspace/client/src/main/java/com/pqt/client/module/log/listeners/SimpleLogFirerer.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.pqt.client.module.log.listeners;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class SimpleLogFirerer implements ILogFirerer {
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.log.listeners.ILogFirerer#addListener(com.pqt.client.module.log.listeners.ILogListener)
|
||||
*/
|
||||
public void addListener(ILogListener listener) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.log.listeners.ILogFirerer#removeListener(com.pqt.client.module.log.listeners.ILogListener)
|
||||
*/
|
||||
public void removeListener(ILogListener listener) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.log.listeners.ILogFirerer#fireLogEvent()
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void fireLogEvent() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.pqt.client.module.query;
|
||||
|
||||
import com.pqt.client.module.query.query_callback.IUpdateQueryCallback;
|
||||
import com.pqt.core.entities.query.IQuery;
|
||||
import com.pqt.client.module.query.query_callback.ISimpleQueryCallback;
|
||||
import com.pqt.client.module.query.query_callback.IStatQueryCallback;
|
||||
import com.pqt.client.module.query.query_callback.IStockQueryCallback;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class QueryExecutor {
|
||||
|
||||
public static final QueryExecutor INSTANCE = new QueryExecutor();
|
||||
|
||||
private QueryExecutor(){
|
||||
|
||||
}
|
||||
|
||||
public long execute(IQuery query, ISimpleQueryCallback callback) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long execute(IQuery query, IStatQueryCallback callback) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long execute(IQuery query, IStockQueryCallback callback) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long execute(IQuery query, IUpdateQueryCallback callback) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.pqt.client.module.query;
|
||||
|
||||
import com.pqt.core.entities.product.ProductUpdate;
|
||||
import com.pqt.core.entities.query.IQuery;
|
||||
import com.pqt.core.entities.sale.Sale;
|
||||
import com.pqt.core.entities.user_account.Account;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class QueryFactory {
|
||||
|
||||
public static IQuery newConnectQuery(String serverAddress) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IQuery newSaleQuery(Sale sale) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IQuery newStockQuery() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IQuery newStatQuery() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IQuery newLogQuery(Account account, boolean state) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IQuery newUpdateQuery(List<ProductUpdate> updates) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
7
Workspace/client/src/main/java/com/pqt/client/module/query/query_callback/ISimpleQueryCallback.java
Normal file
7
Workspace/client/src/main/java/com/pqt/client/module/query/query_callback/ISimpleQueryCallback.java
Normal file
@ -0,0 +1,7 @@
|
||||
package com.pqt.client.module.query.query_callback;
|
||||
|
||||
public interface ISimpleQueryCallback {
|
||||
public void ack();
|
||||
public void err(Throwable cause);
|
||||
public void ref(Throwable cause);
|
||||
}
|
10
Workspace/client/src/main/java/com/pqt/client/module/query/query_callback/IStatQueryCallback.java
Normal file
10
Workspace/client/src/main/java/com/pqt/client/module/query/query_callback/IStatQueryCallback.java
Normal file
@ -0,0 +1,10 @@
|
||||
package com.pqt.client.module.query.query_callback;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface IStatQueryCallback {
|
||||
public void ack(Map<String,String> stats);
|
||||
public void err(Throwable cause);
|
||||
public void ref(Throwable cause);
|
||||
}
|
11
Workspace/client/src/main/java/com/pqt/client/module/query/query_callback/IStockQueryCallback.java
Normal file
11
Workspace/client/src/main/java/com/pqt/client/module/query/query_callback/IStockQueryCallback.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.pqt.client.module.query.query_callback;
|
||||
|
||||
import com.pqt.core.entities.product.Product;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IStockQueryCallback {
|
||||
public void ack(List<Product> products);
|
||||
public void err(Throwable cause);
|
||||
public void ref(Throwable cause);
|
||||
}
|
7
Workspace/client/src/main/java/com/pqt/client/module/query/query_callback/IUpdateQueryCallback.java
Normal file
7
Workspace/client/src/main/java/com/pqt/client/module/query/query_callback/IUpdateQueryCallback.java
Normal file
@ -0,0 +1,7 @@
|
||||
package com.pqt.client.module.query.query_callback;
|
||||
|
||||
public interface IUpdateQueryCallback {
|
||||
public void ack(long id);
|
||||
public void err(long id, Throwable cause);
|
||||
public void ref(long id, Throwable cause);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.pqt.client.module.sale;
|
||||
|
||||
import com.pqt.core.entities.product.Product;
|
||||
import com.pqt.core.entities.sale.Sale;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class SaleBuilder {
|
||||
|
||||
public boolean addProduct(Product product) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeProduct(Product product) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Map<Product,Integer> getCurrentProductList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Sale build() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.pqt.client.module.sale;
|
||||
|
||||
import com.pqt.client.module.sale.listeners.ISaleListener;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
//TODO add log lines
|
||||
public class SaleService {
|
||||
|
||||
public void getNewSaleBuilder() {
|
||||
|
||||
}
|
||||
|
||||
public void commitSale(SaleBuilder saleBuilder) {
|
||||
|
||||
}
|
||||
|
||||
public void revertSale(int saleId) {
|
||||
|
||||
}
|
||||
|
||||
public void addListener(ISaleListener listener) {
|
||||
|
||||
}
|
||||
|
||||
public void removeListener(ISaleListener listener) {
|
||||
|
||||
}
|
||||
|
||||
}
|
17
Workspace/client/src/main/java/com/pqt/client/module/sale/listeners/ISaleFirerer.java
Normal file
17
Workspace/client/src/main/java/com/pqt/client/module/sale/listeners/ISaleFirerer.java
Normal file
@ -0,0 +1,17 @@
|
||||
package com.pqt.client.module.sale.listeners;
|
||||
|
||||
import com.pqt.core.entities.sale.Sale;
|
||||
|
||||
public interface ISaleFirerer {
|
||||
|
||||
public abstract void fireSaleValidationSuccess(Sale sale);
|
||||
|
||||
public abstract void fireSaleValidationError(Sale sale, Throwable cause);
|
||||
|
||||
public abstract void fireSaleValidationRefused(Sale sale, Throwable cause);
|
||||
|
||||
public abstract void addListener(ISaleListener listener);
|
||||
|
||||
public abstract void removeListener(ISaleListener listener);
|
||||
|
||||
}
|
15
Workspace/client/src/main/java/com/pqt/client/module/sale/listeners/ISaleListener.java
Normal file
15
Workspace/client/src/main/java/com/pqt/client/module/sale/listeners/ISaleListener.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.pqt.client.module.sale.listeners;
|
||||
|
||||
import com.pqt.core.entities.sale.Sale;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface ISaleListener extends EventListener {
|
||||
|
||||
public abstract void onSaleValidationSuccess(Sale sale);
|
||||
|
||||
public abstract void onSaleValidationError(Sale sale, Throwable cause);
|
||||
|
||||
public abstract void onSaleValidationRefused(Sale sale, Throwable cause);
|
||||
|
||||
}
|
35
Workspace/client/src/main/java/com/pqt/client/module/sale/listeners/SaleListenerAdapter.java
Normal file
35
Workspace/client/src/main/java/com/pqt/client/module/sale/listeners/SaleListenerAdapter.java
Normal file
@ -0,0 +1,35 @@
|
||||
package com.pqt.client.module.sale.listeners;
|
||||
|
||||
import com.pqt.core.entities.sale.Sale;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class SaleListenerAdapter implements ISaleListener {
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.sale.listeners.ISaleListener#onSaleValidationSuccess(com.pqt.core.entities.sale.Sale)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void onSaleValidationSuccess(Sale sale) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.sale.listeners.ISaleListener#onSaleValidationError(com.pqt.core.entities.sale.Sale, Throwable)
|
||||
*/
|
||||
public void onSaleValidationError(Sale sale, Throwable cause) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.sale.listeners.ISaleListener#onSaleValidationRefused(com.pqt.core.entities.sale.Sale, Throwable)
|
||||
*/
|
||||
public void onSaleValidationRefused(Sale sale, Throwable cause) {
|
||||
|
||||
}
|
||||
|
||||
}
|
49
Workspace/client/src/main/java/com/pqt/client/module/sale/listeners/SimpleSaleFirerer.java
Normal file
49
Workspace/client/src/main/java/com/pqt/client/module/sale/listeners/SimpleSaleFirerer.java
Normal file
@ -0,0 +1,49 @@
|
||||
package com.pqt.client.module.sale.listeners;
|
||||
|
||||
import com.pqt.core.entities.sale.Sale;
|
||||
|
||||
//TODO écrire contenu méthodes
|
||||
//TODO écrire javadoc
|
||||
public class SimpleSaleFirerer implements ISaleFirerer {
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.sale.listeners.ISaleFirerer#fireSaleValidationSuccess(com.pqt.core.entities.sale.Sale)
|
||||
*/
|
||||
public void fireSaleValidationSuccess(Sale sale) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.sale.listeners.ISaleFirerer#fireSaleValidationError(com.pqt.core.entities.sale.Sale, Throwable)
|
||||
*/
|
||||
public void fireSaleValidationError(Sale sale, Throwable cause) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.sale.listeners.ISaleFirerer#fireSaleValidationRefused(com.pqt.core.entities.sale.Sale, Throwable)
|
||||
*/
|
||||
public void fireSaleValidationRefused(Sale sale, Throwable cause) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.sale.listeners.ISaleFirerer#addListener(com.pqt.client.module.sale.listeners.ISaleListener)
|
||||
*/
|
||||
public void addListener(ISaleListener listener) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.sale.listeners.ISaleFirerer#removeListener(com.pqt.client.module.sale.listeners.ISaleListener)
|
||||
*/
|
||||
public void removeListener(ISaleListener listener) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.pqt.client.module.stat;
|
||||
|
||||
import com.pqt.client.module.query.QueryExecutor;
|
||||
import com.pqt.client.module.query.QueryFactory;
|
||||
import com.pqt.client.module.query.query_callback.IStatQueryCallback;
|
||||
import com.pqt.client.module.stat.listeners.IStatFirerer;
|
||||
import com.pqt.client.module.stat.listeners.IStatListener;
|
||||
import com.pqt.client.module.stat.listeners.SimpleStatFirerer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
//TODO écrire javadoc
|
||||
public class StatDao {
|
||||
|
||||
private Date lastRefreshTimestamp;
|
||||
private Map<String, String> stats;
|
||||
private IStatFirerer eventFirerer;
|
||||
|
||||
public StatDao() {
|
||||
eventFirerer = new SimpleStatFirerer();
|
||||
stats = new HashMap<>();
|
||||
lastRefreshTimestamp = null;
|
||||
}
|
||||
|
||||
public synchronized Map<String, String> getStats() {
|
||||
return new HashMap<>(stats);
|
||||
}
|
||||
|
||||
public void refreshStats() {
|
||||
QueryExecutor.INSTANCE.execute(QueryFactory.newStockQuery(), new IStatQueryCallback() {
|
||||
@Override
|
||||
public void ack(Map<String, String> stats) {
|
||||
replaceStats(stats);
|
||||
eventFirerer.fireGetStatSuccess();
|
||||
//TODO add log line
|
||||
}
|
||||
|
||||
@Override
|
||||
public void err(Throwable cause) {
|
||||
eventFirerer.fireGetStatError(cause);
|
||||
//TODO add log line
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ref(Throwable cause) {
|
||||
eventFirerer.fireGetStatRefused(cause);
|
||||
//TODO add log line
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Date getLastRefreshTimestamp(){
|
||||
return lastRefreshTimestamp;
|
||||
}
|
||||
|
||||
private synchronized void replaceStats(Map<String, String> stats) {
|
||||
this.stats = new HashMap<>(stats);
|
||||
this.lastRefreshTimestamp = new Date();
|
||||
}
|
||||
|
||||
public void removeListener(IStatListener listener) {
|
||||
eventFirerer.removeListener(listener);
|
||||
}
|
||||
|
||||
public void addListener(IStatListener listener) {
|
||||
eventFirerer.addListener(listener);
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.pqt.client.module.stat;
|
||||
|
||||
import com.pqt.client.module.stat.listeners.IStatListener;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
//TODO écrire javadoc
|
||||
//TODO add log lines
|
||||
public class StatService {
|
||||
|
||||
private StatDao dao;
|
||||
|
||||
public StatService() {
|
||||
dao = new StatDao();
|
||||
}
|
||||
|
||||
public Map<String,String> getStats() {
|
||||
return dao.getStats();
|
||||
}
|
||||
|
||||
public void refreshStats() {
|
||||
dao.refreshStats();
|
||||
}
|
||||
|
||||
public void addListener(IStatListener listener) {
|
||||
dao.addListener(listener);
|
||||
}
|
||||
|
||||
public void removeListener(IStatListener listener) {
|
||||
dao.removeListener(listener);
|
||||
}
|
||||
|
||||
}
|
16
Workspace/client/src/main/java/com/pqt/client/module/stat/listeners/IStatFirerer.java
Normal file
16
Workspace/client/src/main/java/com/pqt/client/module/stat/listeners/IStatFirerer.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.pqt.client.module.stat.listeners;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface IStatFirerer {
|
||||
|
||||
public abstract void fireGetStatSuccess();
|
||||
|
||||
public abstract void fireGetStatError(Throwable cause);
|
||||
|
||||
public abstract void fireGetStatRefused(Throwable cause);
|
||||
|
||||
void removeListener(IStatListener listener);
|
||||
|
||||
void addListener(IStatListener listener);
|
||||
}
|
14
Workspace/client/src/main/java/com/pqt/client/module/stat/listeners/IStatListener.java
Normal file
14
Workspace/client/src/main/java/com/pqt/client/module/stat/listeners/IStatListener.java
Normal file
@ -0,0 +1,14 @@
|
||||
package com.pqt.client.module.stat.listeners;
|
||||
|
||||
import java.util.EventListener;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IStatListener extends EventListener {
|
||||
|
||||
public abstract void onGetStatSuccess();
|
||||
|
||||
public abstract void onGetStatError(Throwable cause);
|
||||
|
||||
public abstract void onGetStatRefused(Throwable cause);
|
||||
|
||||
}
|
53
Workspace/client/src/main/java/com/pqt/client/module/stat/listeners/SimpleStatFirerer.java
Normal file
53
Workspace/client/src/main/java/com/pqt/client/module/stat/listeners/SimpleStatFirerer.java
Normal file
@ -0,0 +1,53 @@
|
||||
package com.pqt.client.module.stat.listeners;
|
||||
|
||||
import javax.swing.event.EventListenerList;
|
||||
|
||||
//TODO écrire javadoc
|
||||
public class SimpleStatFirerer implements IStatFirerer {
|
||||
|
||||
private EventListenerList listeners;
|
||||
|
||||
public SimpleStatFirerer() {
|
||||
listeners = new EventListenerList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.stat.listeners.IStatFirerer#fireGetStatSuccess()
|
||||
*/
|
||||
public void fireGetStatSuccess() {
|
||||
for(IStatListener l : listeners.getListeners(IStatListener.class)){
|
||||
l.onGetStatSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.stat.listeners.IStatFirerer#fireGetStatError(Throwable)
|
||||
*/
|
||||
public void fireGetStatError(Throwable cause) {
|
||||
for(IStatListener l : listeners.getListeners(IStatListener.class)){
|
||||
l.onGetStatError(cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.stat.listeners.IStatFirerer#fireGetStatRefused(Throwable)
|
||||
*/
|
||||
public void fireGetStatRefused(Throwable cause) {
|
||||
for(IStatListener l : listeners.getListeners(IStatListener.class)){
|
||||
l.onGetStatRefused(cause);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(IStatListener listener) {
|
||||
listeners.remove(IStatListener.class, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IStatListener listener) {
|
||||
listeners.add(IStatListener.class, listener);
|
||||
}
|
||||
|
||||
}
|
29
Workspace/client/src/main/java/com/pqt/client/module/stat/listeners/StatListenerAdapter.java
Normal file
29
Workspace/client/src/main/java/com/pqt/client/module/stat/listeners/StatListenerAdapter.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.pqt.client.module.stat.listeners;
|
||||
|
||||
public class StatListenerAdapter implements IStatListener {
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.stat.listeners.IStatListener#onGetStatSuccess()
|
||||
*/
|
||||
public void onGetStatSuccess() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.stat.listeners.IStatListener#onGetStatError(Throwable)
|
||||
*/
|
||||
public void onGetStatError(Throwable cause) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.pqt.client.module.stat.listeners.IStatListener#onGetStatRefused(Throwable)
|
||||
*/
|
||||
public void onGetStatRefused(Throwable cause) {
|
||||
|
||||
}
|
||||
|
||||
}
|
16
Workspace/client/src/main/java/com/pqt/client/module/stock/Listeners/IStockFirerer.java
Normal file
16
Workspace/client/src/main/java/com/pqt/client/module/stock/Listeners/IStockFirerer.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.pqt.client.module.stock.Listeners;
|
||||
|
||||
public interface IStockFirerer {
|
||||
void fireGetProductListSuccessEvent();
|
||||
void fireGetProductListErrorEvent(Throwable cause);
|
||||
void fireGetProductListRefusedEvent(Throwable cause);
|
||||
void fireProductListChangedEvent();
|
||||
|
||||
void fireProductListUpdateSuccessEvent(long id);
|
||||
void fireProductListUpdateErrorEvent(long id, Throwable cause);
|
||||
void fireProductListUpdateRefusedEvent(long id, Throwable cause);
|
||||
|
||||
void addListener(IStockListener listener);
|
||||
void removeListener(IStockListener listener);
|
||||
|
||||
}
|
16
Workspace/client/src/main/java/com/pqt/client/module/stock/Listeners/IStockListener.java
Normal file
16
Workspace/client/src/main/java/com/pqt/client/module/stock/Listeners/IStockListener.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.pqt.client.module.stock.Listeners;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface IStockListener extends EventListener {
|
||||
|
||||
void onGetProductListSuccessEvent();
|
||||
void onGetProductListErrorEvent(Throwable cause);
|
||||
void onGetProductListRefusedEvent(Throwable cause);
|
||||
|
||||
void onProductListUpdateSuccessEvent(long id);
|
||||
void onProductListUpdateErrorEvent(long id, Throwable cause);
|
||||
void onProductListUpdateRefusedEvent(long id, Throwable cause);
|
||||
|
||||
void onProductListChangedEvent();
|
||||
}
|
73
Workspace/client/src/main/java/com/pqt/client/module/stock/Listeners/SimpleStockFirerer.java
Normal file
73
Workspace/client/src/main/java/com/pqt/client/module/stock/Listeners/SimpleStockFirerer.java
Normal file
@ -0,0 +1,73 @@
|
||||
package com.pqt.client.module.stock.Listeners;
|
||||
|
||||
|
||||
import javax.swing.event.EventListenerList;
|
||||
|
||||
//TODO écrire javadoc
|
||||
public class SimpleStockFirerer implements IStockFirerer {
|
||||
|
||||
private EventListenerList listeners;
|
||||
|
||||
public SimpleStockFirerer() {
|
||||
listeners = new EventListenerList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireGetProductListSuccessEvent() {
|
||||
for(IStockListener l : listeners.getListeners(IStockListener.class)){
|
||||
l.onGetProductListSuccessEvent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireGetProductListErrorEvent(Throwable cause) {
|
||||
for(IStockListener l : listeners.getListeners(IStockListener.class)){
|
||||
l.onGetProductListErrorEvent(cause);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireGetProductListRefusedEvent(Throwable cause) {
|
||||
for(IStockListener l : listeners.getListeners(IStockListener.class)){
|
||||
l.onGetProductListRefusedEvent(cause);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireProductListChangedEvent() {
|
||||
for(IStockListener l : listeners.getListeners(IStockListener.class)){
|
||||
l.onProductListChangedEvent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireProductListUpdateSuccessEvent(long id) {
|
||||
for(IStockListener l : listeners.getListeners(IStockListener.class)){
|
||||
l.onProductListUpdateSuccessEvent(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireProductListUpdateErrorEvent(long id, Throwable cause) {
|
||||
for(IStockListener l : listeners.getListeners(IStockListener.class)){
|
||||
l.onProductListUpdateErrorEvent(id, cause);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireProductListUpdateRefusedEvent(long id, Throwable cause) {
|
||||
for(IStockListener l : listeners.getListeners(IStockListener.class)){
|
||||
l.onProductListUpdateRefusedEvent(id, cause);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IStockListener listener) {
|
||||
listeners.add(IStockListener.class, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(IStockListener listener) {
|
||||
listeners.remove(IStockListener.class, listener);
|
||||
}
|
||||
}
|
39
Workspace/client/src/main/java/com/pqt/client/module/stock/Listeners/StockListenerAdapter.java
Normal file
39
Workspace/client/src/main/java/com/pqt/client/module/stock/Listeners/StockListenerAdapter.java
Normal file
@ -0,0 +1,39 @@
|
||||
package com.pqt.client.module.stock.Listeners;
|
||||
|
||||
public class StockListenerAdapter implements IStockListener {
|
||||
|
||||
@Override
|
||||
public void onGetProductListSuccessEvent() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetProductListErrorEvent(Throwable cause) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetProductListRefusedEvent(Throwable cause) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProductListUpdateSuccessEvent(long id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProductListUpdateErrorEvent(long id, Throwable cause) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProductListUpdateRefusedEvent(long id, Throwable cause) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProductListChangedEvent() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package com.pqt.client.module.stock;
|
||||
|
||||
import com.pqt.client.module.query.QueryExecutor;
|
||||
import com.pqt.client.module.query.QueryFactory;
|
||||
import com.pqt.client.module.query.query_callback.IStockQueryCallback;
|
||||
import com.pqt.client.module.query.query_callback.IUpdateQueryCallback;
|
||||
import com.pqt.client.module.stock.Listeners.IStockFirerer;
|
||||
import com.pqt.client.module.stock.Listeners.IStockListener;
|
||||
import com.pqt.client.module.stock.Listeners.SimpleStockFirerer;
|
||||
import com.pqt.core.entities.product.Product;
|
||||
import com.pqt.core.entities.product.ProductUpdate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
//TODO écrire javadoc
|
||||
public class StockDao {
|
||||
|
||||
private IStockFirerer eventFirerer;
|
||||
private Date lastRefreshTimestamp;
|
||||
private List<Product> products;
|
||||
|
||||
public StockDao() {
|
||||
eventFirerer = new SimpleStockFirerer();
|
||||
products = new ArrayList<>();
|
||||
lastRefreshTimestamp = null;
|
||||
}
|
||||
|
||||
public synchronized List<Product> getProducts() {
|
||||
return new ArrayList<>(products);
|
||||
}
|
||||
|
||||
public synchronized Product getProduct(final int id) {
|
||||
Optional<Product> match = products.stream().filter((product->product.getId()==id)).findFirst();
|
||||
if(match.isPresent())
|
||||
return match.get();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void refreshProductList() {
|
||||
QueryExecutor.INSTANCE.execute(QueryFactory.newStockQuery(), new IStockQueryCallback() {
|
||||
@Override
|
||||
public void ack(List<Product> products) {
|
||||
replaceProductList(products);
|
||||
eventFirerer.fireGetProductListSuccessEvent();
|
||||
//TODO add log line
|
||||
}
|
||||
|
||||
@Override
|
||||
public void err(Throwable cause) {
|
||||
//TODO add log line
|
||||
eventFirerer.fireGetProductListErrorEvent(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ref(Throwable cause) {
|
||||
//TODO add log line
|
||||
eventFirerer.fireGetProductListRefusedEvent(cause);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Date getLastRefreshTimestamp(){
|
||||
return lastRefreshTimestamp;
|
||||
}
|
||||
|
||||
private synchronized void replaceProductList(List<Product> products){
|
||||
this.products.clear();
|
||||
this.products.addAll(products);
|
||||
this.lastRefreshTimestamp = new Date();
|
||||
eventFirerer.fireProductListChangedEvent();
|
||||
}
|
||||
|
||||
public long commitUpdate(List<ProductUpdate> updates){
|
||||
return QueryExecutor.INSTANCE.execute(QueryFactory.newUpdateQuery(updates),new IUpdateQueryCallback(){
|
||||
|
||||
@Override
|
||||
public void ack(long id) {
|
||||
//TODO add log line
|
||||
refreshProductList();
|
||||
eventFirerer.fireProductListUpdateSuccessEvent(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void err(long id, Throwable cause) {
|
||||
//TODO add log line
|
||||
eventFirerer.fireProductListUpdateErrorEvent(id, cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ref(long id, Throwable cause) {
|
||||
//TODO add log line
|
||||
eventFirerer.fireProductListUpdateRefusedEvent(id, cause);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute un listener à la liste de diffusion des événements pouvant être levé par le service.
|
||||
* @param listener
|
||||
* @see {@link IStockListener}
|
||||
*/
|
||||
public void addListener(IStockListener listener) {
|
||||
eventFirerer.addListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retire un listener d'événement donné de la liste de diffusion des événements.
|
||||
* @param listener
|
||||
* @see {@link IStockListener}
|
||||
*/
|
||||
public void removeListener(IStockListener listener) {
|
||||
eventFirerer.removeListener(listener);
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package com.pqt.client.module.stock;
|
||||
|
||||
import com.pqt.client.module.query.QueryExecutor;
|
||||
import com.pqt.client.module.query.QueryFactory;
|
||||
import com.pqt.client.module.query.query_callback.IUpdateQueryCallback;
|
||||
import com.pqt.client.module.stock.Listeners.IStockFirerer;
|
||||
import com.pqt.client.module.stock.Listeners.SimpleStockFirerer;
|
||||
import com.pqt.core.entities.product.Product;
|
||||
import com.pqt.client.module.stock.Listeners.IStockListener;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
//TODO Add log lines
|
||||
public class StockService {
|
||||
|
||||
public static final StockService INSTANCE = new StockService();
|
||||
|
||||
private StockDao dao;
|
||||
|
||||
private StockService() {
|
||||
dao = new StockDao();
|
||||
}
|
||||
|
||||
/**
|
||||
* Accesseur renvoyant un objet {@link Date} correspondant à la dernière heure où les stocks ont été mis à jour
|
||||
* <p/>
|
||||
* @return {@link Date} représentant l'instant de la dernière mise à jour des stocks.
|
||||
*/
|
||||
public Date getLastRefreshTimestamp(){
|
||||
return dao.getLastRefreshTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Démarre la procédure de mise à jour des stocks.
|
||||
* <p/>
|
||||
* L'exécution de cette méthode ne constitue pas la mise à jour, elle ne fait que démarrer la procédure.
|
||||
* Les événements liées à la mise à jour du stock peuvent être écoutés via la classe de listener {@link IStockListener}.
|
||||
*/
|
||||
public void refreshProductList() {
|
||||
dao.refreshProductList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Accesseur de la liste des produits actuellement en vente.
|
||||
* <p/>
|
||||
* La liste peut être obsolète, voir {@link #getLastRefreshTimestamp()} pour la date du dernier refresh et {@link #refreshProductList()} pour la mettre à jour.
|
||||
*
|
||||
* @return Liste des produits en vente.
|
||||
*/
|
||||
public List<Product> getProducts() {
|
||||
return dao.getProducts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Accesseur récupérant un unique produit présent dans les stocks en se basant sur son id.
|
||||
*
|
||||
* @param id identifiant du produit voulu
|
||||
* @return produit voulu s'il est présent dans le stock, ou null si l'identifiant {@code id} ne correspond à aucun produit présent dans le stock.
|
||||
*/
|
||||
public Product getProduct(int id) {
|
||||
return dao.getProduct(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie un nouveau builder d'update de stock.
|
||||
* <p/>
|
||||
* Un update de stock correspond à un ticket de demande de modification du stock, composé d'ajouts, de suppressions et de modifications de produits.
|
||||
* Un objet {@link UpdateBuilder} permet de générer facilement une update. Pour valider l'update, voir {@link #commitUpdate(UpdateBuilder)}.
|
||||
*
|
||||
* @return nouvelle instance de la classe {@link UpdateBuilder}.
|
||||
*/
|
||||
public UpdateBuilder getNewUpdateBuilder() {
|
||||
return new UpdateBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Propose une modification de stock et lance la procédure de validation. Retourne l'identifiant de la modification, qui sera utilisé dans les notifications pour discriminer les événements.
|
||||
* <p/>
|
||||
* L'exécution de cette méthode ne constitue pas la modification, elle ne fait que démarrer la procédure.
|
||||
* Les événements liées à la valiation des updates du stock peuvent être écoutés via la classe de listener {@link IStockListener}.
|
||||
* <p/>
|
||||
* Une procédure de mise à jour du stock sera automatiquement lancée si la modification est validée (comme si la méthode {@link #refreshProductList()} avait été appelée).
|
||||
* @param updateBuilder
|
||||
* @return l'identifiant de l'update soumise.
|
||||
*/
|
||||
public long commitUpdate(UpdateBuilder updateBuilder) {
|
||||
return dao.commitUpdate(updateBuilder.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute un listener à la liste de diffusion des événements pouvant être levé par le service.
|
||||
* @param listener
|
||||
* @see {@link IStockListener}
|
||||
*/
|
||||
public void addListener(IStockListener listener) {
|
||||
dao.addListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retire un listener d'événement donné de la liste de diffusion des événements.
|
||||
* @param listener
|
||||
* @see {@link IStockListener}
|
||||
*/
|
||||
public void removeListener(IStockListener listener) {
|
||||
dao.removeListener(listener);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.pqt.client.module.stock;
|
||||
|
||||
import com.pqt.core.entities.product.Product;
|
||||
import com.pqt.core.entities.product.ProductUpdate;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class UpdateBuilder {
|
||||
|
||||
private Set<Product> toAdd, toRemove;
|
||||
private Map<Product, Product> toModify;
|
||||
|
||||
public UpdateBuilder() {
|
||||
toAdd = new HashSet<>();
|
||||
toRemove = new HashSet<>();
|
||||
toModify = new HashMap<>();
|
||||
}
|
||||
|
||||
public void addProduct(Product product) {
|
||||
if(!toAdd.contains(product)){
|
||||
toAdd.add(product);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeProduct(Product product) {
|
||||
if(toRemove.contains(product)){
|
||||
toRemove.remove(product);
|
||||
}
|
||||
}
|
||||
|
||||
public void modifyProduct(Product oldVersion, Product newVersion) {
|
||||
toModify.put(oldVersion, newVersion);
|
||||
}
|
||||
|
||||
public List<ProductUpdate> build() {
|
||||
List<ProductUpdate> reply = new ArrayList<>();
|
||||
for(Product product : toAdd){
|
||||
reply.add(new ProductUpdate(null, product));
|
||||
}
|
||||
for(Product product : toRemove){
|
||||
reply.add(new ProductUpdate(product, null));
|
||||
}
|
||||
for(Product product : toModify.keySet()){
|
||||
reply.add(new ProductUpdate(product, toModify.get(product)));
|
||||
}
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
}
|
15
Workspace/core/core.iml
Normal file
15
Workspace/core/core.iml
Normal 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
15
Workspace/core/pom.xml
Normal 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>
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.pqt.core.entities.log;
|
||||
|
||||
/**
|
||||
* Created by Notmoo on 18/07/2017.
|
||||
*/
|
||||
public interface ILoggable {
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.pqt.core.entities.query;
|
||||
|
||||
public interface IQuery {
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.pqt.core.entities.query;
|
||||
|
||||
public enum QueryType {
|
||||
|
||||
CONNECT, SALE, STOCL, STAT, LOG, UPDATE
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
27
Workspace/pom.xml
Normal file
27
Workspace/pom.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.pqt</groupId>
|
||||
<artifactId>Main</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<modules>
|
||||
<module>core</module>
|
||||
<module>client</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
Reference in New Issue
Block a user