Module Client : Utilisation des LightweightSale dans les requetes HTTP pour éviter des bugs de sérialisation/déserialisation d'objets Product

This commit is contained in:
Notmoo-PC\Notmoo 2017-11-05 21:29:31 +01:00
parent a2cf073de8
commit 6a8cb9292d
5 changed files with 13 additions and 6 deletions

View File

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

View File

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

View File

@ -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<String, String> 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);
}

View File

@ -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());
}
}

View File

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