From 5217b6f7827613ba7ba444788d25c547cd1c10cb Mon Sep 17 00:00:00 2001 From: "Notmoo-PC\\Notmoo" Date: Fri, 3 Nov 2017 18:31:14 +0100 Subject: [PATCH] =?UTF-8?q?Module=20Client=20:=20correction=20d'un=20bug?= =?UTF-8?q?=20faisant=20que=20le=20compte=20utilisateur=20n'=C3=A9tait=20p?= =?UTF-8?q?as=20ajout=C3=A9=20au=20message,=20provoquant=20le=20rejet=20sy?= =?UTF-8?q?st=C3=A9matique=20des=20requ=C3=AAtes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/module/ClientBackEndModuleManager.java | 2 ++ .../com/pqt/client/module/query/QueryExecutor.java | 5 +++++ .../client/module/query/QueryMessageFactory.java | 13 +++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/module/ClientBackEndModuleManager.java b/Workspace/client/src/main/java/com/pqt/client/module/ClientBackEndModuleManager.java index b97e7973..d48e8f6a 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/ClientBackEndModuleManager.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/ClientBackEndModuleManager.java @@ -26,6 +26,8 @@ public class ClientBackEndModuleManager { statService = new StatService(queryExecutor); networkService = new NetworkService(queryExecutor, connectionService); + queryExecutor.setAccountService(accountService); + networkService.addListener(new INetworkServiceListener() { @Override public void onPQTPingSuccessEvent(String host, Integer port) { diff --git a/Workspace/client/src/main/java/com/pqt/client/module/query/QueryExecutor.java b/Workspace/client/src/main/java/com/pqt/client/module/query/QueryExecutor.java index 0472a3a5..cd9c7521 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/query/QueryExecutor.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/query/QueryExecutor.java @@ -1,5 +1,6 @@ package com.pqt.client.module.query; +import com.pqt.client.module.account.AccountService; import com.pqt.client.module.connection.ConnectionService; import com.pqt.client.module.connection.listeners.IConnectionListener; import com.pqt.client.module.query.exceptions.HeaderNotFoundException; @@ -29,6 +30,10 @@ public class QueryExecutor { this.messageFactory = new QueryMessageFactory(messageToolFactory); } + public void setAccountService(AccountService accountService){ + messageFactory.setAccountService(accountService); + } + public void executeSaleQuery(Sale sale, INoItemMessageCallback callback) { sendMessage(messageFactory.newSaleMessage(sale), callback, MessageType.ACK_SALE); } diff --git a/Workspace/client/src/main/java/com/pqt/client/module/query/QueryMessageFactory.java b/Workspace/client/src/main/java/com/pqt/client/module/query/QueryMessageFactory.java index 52e934c7..8849e491 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/query/QueryMessageFactory.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/query/QueryMessageFactory.java @@ -1,5 +1,6 @@ package com.pqt.client.module.query; +import com.pqt.client.module.account.AccountService; import com.pqt.core.communication.IMessageToolFactory; import com.pqt.core.entities.messages.Message; import com.pqt.core.entities.messages.MessageType; @@ -15,9 +16,15 @@ import java.util.Map; class QueryMessageFactory { private final IMessageToolFactory messageToolFactory; + private AccountService accountService; QueryMessageFactory(IMessageToolFactory messageToolFactory) { this.messageToolFactory = messageToolFactory; + accountService = null; + } + + void setAccountService(AccountService accountService){ + this.accountService = accountService; } Message newSaleMessage(Sale sale) { @@ -60,8 +67,10 @@ class QueryMessageFactory { } private Message newSimpleMessage(MessageType type, Map fields){ - return new Message(type, null, null, null, null, fields); - } + //TODO add emitter + Account account = accountService!=null?accountService.getCurrentAccount():null; + return new Message(type, null, null, account, null, fields); + } private Message newSimpleMessage(MessageType type){ return newSimpleMessage(type, null);