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 4c729663..e8f7d3f8 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 @@ -43,8 +43,8 @@ public class QueryExecutor { sendMessage(messageFactory.newPingMessage(), callback, MessageType.ACK_PING); } - public void executeUpdateQuery(List updates, INoItemMessageCallback callback) { - sendMessage(messageFactory.newUpdateMessage(updates), callback, MessageType.ACK_UPDATE); + public void executeStockUpdateQuery(List updates, INoItemMessageCallback callback) { + sendMessage(messageFactory.newStockUpdateMessage(updates), callback, MessageType.ACK_STOCK_UPDATE); } public void executeConnectAccountQuery(Account account, boolean desiredState, INoItemMessageCallback callback){ 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 1f41d089..4a7ea260 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 @@ -42,10 +42,10 @@ class QueryMessageFactory { return newSimpleMessage(MessageType.QUERY_STAT); } - Message newUpdateMessage(List updates) { + Message newStockUpdateMessage(List updates) { Map fields = new HashMap<>(); fields.put("updates", messageToolFactory.getListFormatter(ProductUpdate.class).format(updates)); - return newSimpleMessage(MessageType.QUERY_UPDATE, fields); + return newSimpleMessage(MessageType.QUERY_STOCK_UPDATE, fields); } Message newAccountListMessage(){ diff --git a/Workspace/client/src/main/java/com/pqt/client/module/stock/StockDao.java b/Workspace/client/src/main/java/com/pqt/client/module/stock/StockDao.java index cb19dd16..c4e8ea5f 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/stock/StockDao.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/stock/StockDao.java @@ -79,7 +79,7 @@ public class StockDao { updateId++; else updateId = 0; - executor.executeUpdateQuery(updates, new INoItemMessageCallback() { + executor.executeStockUpdateQuery(updates, new INoItemMessageCallback() { @Override public void ack() { //TODO Issue #6 : add log line diff --git a/Workspace/client/src/main/java/com/pqt/client/module/stock/StockService.java b/Workspace/client/src/main/java/com/pqt/client/module/stock/StockService.java index 8fb2c54c..08184daf 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/stock/StockService.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/stock/StockService.java @@ -90,12 +90,12 @@ public class StockService { * Renvoie un nouveau builder d'update de stock. *

* Un update de stock correspond à un ticket de demande de modification du stock, composé d'ajouts, de suppressions et de modifications de produits. - * Un objet {@link UpdateBuilder} permet de générer facilement une update. Pour valider l'update, voir {@link #commitUpdate(UpdateBuilder)}. + * Un objet {@link StockUpdateBuilder} permet de générer facilement une update. Pour valider l'update, voir {@link #commitUpdate(StockUpdateBuilder)}. * - * @return nouvelle instance de la classe {@link UpdateBuilder}. + * @return nouvelle instance de la classe {@link StockUpdateBuilder}. */ - public UpdateBuilder getNewUpdateBuilder() { - return new UpdateBuilder(); + public StockUpdateBuilder getNewUpdateBuilder() { + return new StockUpdateBuilder(); } /** @@ -105,11 +105,11 @@ public class StockService { * Les événements liées à la valiation des updates du stock peuvent être écoutés via la classe de listener {@link IStockListener}. *

* Une procédure de mise à jour du stock sera automatiquement lancée si la modification est validée (comme si la méthode {@link #refreshProductList()} avait été appelée). - * @param updateBuilder + * @param stockUpdateBuilder * @return l'identifiant de l'update soumise. */ - public long commitUpdate(UpdateBuilder updateBuilder) { - return dao.commitUpdate(updateBuilder.build()); + public long commitUpdate(StockUpdateBuilder stockUpdateBuilder) { + return dao.commitUpdate(stockUpdateBuilder.build()); } /** diff --git a/Workspace/client/src/main/java/com/pqt/client/module/stock/UpdateBuilder.java b/Workspace/client/src/main/java/com/pqt/client/module/stock/StockUpdateBuilder.java similarity index 80% rename from Workspace/client/src/main/java/com/pqt/client/module/stock/UpdateBuilder.java rename to Workspace/client/src/main/java/com/pqt/client/module/stock/StockUpdateBuilder.java index 7431cfd2..bdb948e6 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/stock/UpdateBuilder.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/stock/StockUpdateBuilder.java @@ -5,32 +5,32 @@ import com.pqt.core.entities.product.ProductUpdate; import java.util.*; -public class UpdateBuilder { +public class StockUpdateBuilder { private Set toAdd, toRemove; private Map toModify; - public UpdateBuilder() { + public StockUpdateBuilder() { toAdd = new HashSet<>(); toRemove = new HashSet<>(); toModify = new HashMap<>(); } - public UpdateBuilder addProduct(Product product) { + public StockUpdateBuilder addProduct(Product product) { if(!toAdd.contains(product)){ toAdd.add(product); } return this; } - public UpdateBuilder removeProduct(Product product) { + public StockUpdateBuilder removeProduct(Product product) { if(!toRemove.contains(product)){ toRemove.add(product); } return this; } - public UpdateBuilder modifyProduct(Product oldVersion, Product newVersion) { + public StockUpdateBuilder modifyProduct(Product oldVersion, Product newVersion) { toModify.put(oldVersion, newVersion); return this; } @@ -49,5 +49,4 @@ public class UpdateBuilder { return reply; } - } diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/messages/MessageType.java b/Workspace/core/src/main/java/com/pqt/core/entities/messages/MessageType.java index 14d4a887..3840fa68 100644 --- a/Workspace/core/src/main/java/com/pqt/core/entities/messages/MessageType.java +++ b/Workspace/core/src/main/java/com/pqt/core/entities/messages/MessageType.java @@ -25,8 +25,11 @@ public enum MessageType { QUERY_CONNECT_ACCOUNT, ACK_CONNECT_ACCOUNT, - QUERY_UPDATE, - ACK_UPDATE, + QUERY_STOCK_UPDATE, + ACK_STOCK_UPDATE, + + QUERY_ACCOUNT_UPDATE, + ACK_ACCOUNT_UPDATE, QUERY_PING, ACK_PING, diff --git a/Workspace/server/src/main/java/com/pqt/server/controller/SimpleMessageHandler.java b/Workspace/server/src/main/java/com/pqt/server/controller/SimpleMessageHandler.java index aec23b0a..729cff1d 100644 --- a/Workspace/server/src/main/java/com/pqt/server/controller/SimpleMessageHandler.java +++ b/Workspace/server/src/main/java/com/pqt/server/controller/SimpleMessageHandler.java @@ -119,11 +119,11 @@ public class SimpleMessageHandler implements IMessageHandler { /* MASTER-restricted queries */ - manager.supportForConnectedAccounts(MessageType.QUERY_UPDATE, (message)->{ + manager.supportForConnectedAccounts(MessageType.QUERY_STOCK_UPDATE, (message)->{ try{ List updates = messageToolFactory.getListParser(ProductUpdate.class).parse(message.getField("updates")); stockService.applyUpdateList(updates); - return new Message(MessageType.ACK_UPDATE, serverStateService.getServer(), message.getEmitter(), message.getUser(), message, null); + return new Message(MessageType.ACK_STOCK_UPDATE, serverStateService.getServer(), message.getEmitter(), message.getUser(), message, null); }catch (ServerQueryException | NullPointerException e){ Map fields = new HashMap<>(); fields.put(header_err_query, e.toString());