mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-11-26 02:54:15 +00:00
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:
parent
a2cf073de8
commit
6a8cb9292d
@ -61,6 +61,6 @@ public class ConnectionService {
|
|||||||
throw new IllegalStateException("No url specified for data server");
|
throw new IllegalStateException("No url specified for data server");
|
||||||
if(executor.isShutdown() || executor.isTerminated())
|
if(executor.isShutdown() || executor.isTerminated())
|
||||||
throw new IllegalStateException("Service was shut down : unable to send text");
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import com.pqt.core.entities.messages.Message;
|
|||||||
import com.pqt.core.entities.messages.MessageType;
|
import com.pqt.core.entities.messages.MessageType;
|
||||||
import com.pqt.core.entities.product.Product;
|
import com.pqt.core.entities.product.Product;
|
||||||
import com.pqt.core.entities.product.ProductUpdate;
|
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.sale.Sale;
|
||||||
import com.pqt.core.entities.user_account.Account;
|
import com.pqt.core.entities.user_account.Account;
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ public class QueryExecutor {
|
|||||||
messageFactory.setAccountService(accountService);
|
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);
|
sendMessage(messageFactory.newSaleMessage(sale), callback, MessageType.ACK_SALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import com.pqt.core.communication.IMessageToolFactory;
|
|||||||
import com.pqt.core.entities.messages.Message;
|
import com.pqt.core.entities.messages.Message;
|
||||||
import com.pqt.core.entities.messages.MessageType;
|
import com.pqt.core.entities.messages.MessageType;
|
||||||
import com.pqt.core.entities.product.ProductUpdate;
|
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.sale.Sale;
|
||||||
import com.pqt.core.entities.user_account.Account;
|
import com.pqt.core.entities.user_account.Account;
|
||||||
|
|
||||||
@ -27,9 +28,9 @@ class QueryMessageFactory {
|
|||||||
this.accountService = accountService;
|
this.accountService = accountService;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message newSaleMessage(Sale sale) {
|
Message newSaleMessage(LightweightSale sale) {
|
||||||
Map<String, String> fields = new HashMap<>();
|
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);
|
return newSimpleMessage(MessageType.QUERY_SALE, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.pqt.client.module.sale;
|
|||||||
import com.pqt.client.module.stock.StockDao;
|
import com.pqt.client.module.stock.StockDao;
|
||||||
import com.pqt.core.entities.members.Client;
|
import com.pqt.core.entities.members.Client;
|
||||||
import com.pqt.core.entities.product.Product;
|
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.Sale;
|
||||||
import com.pqt.core.entities.sale.SaleStatus;
|
import com.pqt.core.entities.sale.SaleStatus;
|
||||||
import com.pqt.core.entities.sale.SaleType;
|
import com.pqt.core.entities.sale.SaleType;
|
||||||
@ -91,7 +92,11 @@ public class SaleBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Sale build() {
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class SaleService {
|
|||||||
else
|
else
|
||||||
saleId = 0;
|
saleId = 0;
|
||||||
|
|
||||||
executor.executeSaleQuery(saleBuilder.build(), new INoItemMessageCallback() {
|
executor.executeSaleQuery(saleBuilder.buildLightweight(), new INoItemMessageCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void ack() {
|
public void ack() {
|
||||||
eventFirerer.fireSaleValidationSuccess(currentSaleId);
|
eventFirerer.fireSaleValidationSuccess(currentSaleId);
|
||||||
|
Loading…
Reference in New Issue
Block a user