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);