From 6a8cb9292d3a41e12e27a8329de9475e466db748 Mon Sep 17 00:00:00 2001 From: "Notmoo-PC\\Notmoo" Date: Sun, 5 Nov 2017 21:29:31 +0100 Subject: [PATCH] =?UTF-8?q?Module=20Client=20:=20Utilisation=20des=20Light?= =?UTF-8?q?weightSale=20dans=20les=20requetes=20HTTP=20pour=20=C3=A9viter?= =?UTF-8?q?=20des=20bugs=20de=20s=C3=A9rialisation/d=C3=A9serialisation=20?= =?UTF-8?q?d'objets=20Product?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pqt/client/module/connection/ConnectionService.java | 2 +- .../java/com/pqt/client/module/query/QueryExecutor.java | 3 ++- .../com/pqt/client/module/query/QueryMessageFactory.java | 5 +++-- .../main/java/com/pqt/client/module/sale/SaleBuilder.java | 7 ++++++- .../main/java/com/pqt/client/module/sale/SaleService.java | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/module/connection/ConnectionService.java b/Workspace/client/src/main/java/com/pqt/client/module/connection/ConnectionService.java index 48ddabc8..c072920e 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/connection/ConnectionService.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/connection/ConnectionService.java @@ -61,6 +61,6 @@ public class ConnectionService { throw new IllegalStateException("No url specified for data server"); if(executor.isShutdown() || executor.isTerminated()) throw new IllegalStateException("Service was shut down : unable to send text"); - executor.submit(()->textSender.send(serverUrl, text, listener)); + executor.submit(()->textSender.send(serverUrl, "message="+text, listener)); } } 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 cd9c7521..8cd70e90 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 @@ -12,6 +12,7 @@ import com.pqt.core.entities.messages.Message; import com.pqt.core.entities.messages.MessageType; import com.pqt.core.entities.product.Product; import com.pqt.core.entities.product.ProductUpdate; +import com.pqt.core.entities.sale.LightweightSale; import com.pqt.core.entities.sale.Sale; import com.pqt.core.entities.user_account.Account; @@ -34,7 +35,7 @@ public class QueryExecutor { messageFactory.setAccountService(accountService); } - public void executeSaleQuery(Sale sale, INoItemMessageCallback callback) { + public void executeSaleQuery(LightweightSale 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 8849e491..1f41d089 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 @@ -5,6 +5,7 @@ import com.pqt.core.communication.IMessageToolFactory; import com.pqt.core.entities.messages.Message; import com.pqt.core.entities.messages.MessageType; import com.pqt.core.entities.product.ProductUpdate; +import com.pqt.core.entities.sale.LightweightSale; import com.pqt.core.entities.sale.Sale; import com.pqt.core.entities.user_account.Account; @@ -27,9 +28,9 @@ class QueryMessageFactory { this.accountService = accountService; } - Message newSaleMessage(Sale sale) { + Message newSaleMessage(LightweightSale sale) { Map fields = new HashMap<>(); - fields.put("sale", messageToolFactory.getObjectFormatter(Sale.class).format(sale)); + fields.put("lightweight_sale", messageToolFactory.getObjectFormatter(LightweightSale.class).format(sale)); return newSimpleMessage(MessageType.QUERY_SALE, fields); } diff --git a/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleBuilder.java b/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleBuilder.java index a70bac00..b6a7b40b 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleBuilder.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleBuilder.java @@ -3,6 +3,7 @@ package com.pqt.client.module.sale; import com.pqt.client.module.stock.StockDao; import com.pqt.core.entities.members.Client; import com.pqt.core.entities.product.Product; +import com.pqt.core.entities.sale.LightweightSale; import com.pqt.core.entities.sale.Sale; import com.pqt.core.entities.sale.SaleStatus; import com.pqt.core.entities.sale.SaleType; @@ -91,7 +92,11 @@ public class SaleBuilder { } public Sale build() { - return new Sale(0, products, new Date(), orderedWith, orderedBy, orderedFor, type, SaleStatus.PENDING); + return new Sale(0, products, orderedWith, orderedBy, orderedFor, type, SaleStatus.PENDING); } + public LightweightSale buildLightweight(){ + return new LightweightSale(build()); + } + } diff --git a/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleService.java b/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleService.java index 7f3235a9..e9a1d0c7 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleService.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/sale/SaleService.java @@ -34,7 +34,7 @@ public class SaleService { else saleId = 0; - executor.executeSaleQuery(saleBuilder.build(), new INoItemMessageCallback() { + executor.executeSaleQuery(saleBuilder.buildLightweight(), new INoItemMessageCallback() { @Override public void ack() { eventFirerer.fireSaleValidationSuccess(currentSaleId);