Permalink
Browse files

A lot of changes to events and commands to contain the transaction id…

…entifier. Now the saga do their work
  • Loading branch information...
1 parent 7b60d52 commit 3a3e575b1164461aeb083ac5f9ce2eb65bd60e70 @jettro jettro committed Jan 23, 2012
Showing with 362 additions and 193 deletions.
  1. +7 −1 app/src/main/java/org/axonframework/samples/trader/app/api/order/AbstractOrderCommand.java
  2. +7 −1 app/src/main/java/org/axonframework/samples/trader/app/api/order/AbstractOrderPlacedEvent.java
  3. +2 −2 app/src/main/java/org/axonframework/samples/trader/app/api/order/BuyOrderPlacedEvent.java
  4. +2 −2 app/src/main/java/org/axonframework/samples/trader/app/api/order/CreateBuyOrderCommand.java
  5. +2 −2 app/src/main/java/org/axonframework/samples/trader/app/api/order/CreateSellOrderCommand.java
  6. +2 −2 app/src/main/java/org/axonframework/samples/trader/app/api/order/SellOrderPlacedEvent.java
  7. +18 −1 app/src/main/java/org/axonframework/samples/trader/app/api/order/TradeExecutedEvent.java
  8. +10 −1 ...axonframework/samples/trader/app/api/portfolio/item/CancelItemReservationForPortfolioCommand.java
  9. +10 −1 ...xonframework/samples/trader/app/api/portfolio/item/ConfirmItemReservationForPortfolioCommand.java
  10. +9 −1 ...xonframework/samples/trader/app/api/portfolio/item/ItemReservationCancelledForPortfolioEvent.java
  11. +9 −1 ...xonframework/samples/trader/app/api/portfolio/item/ItemReservationConfirmedForPortfolioEvent.java
  12. +8 −1 ...xonframework/samples/trader/app/api/portfolio/item/ItemToReserveNotAvailableInPortfolioEvent.java
  13. +9 −1 app/src/main/java/org/axonframework/samples/trader/app/api/portfolio/item/ItemsReservedEvent.java
  14. +10 −1 ...nframework/samples/trader/app/api/portfolio/item/NotEnoughItemsAvailableToReserveInPortfolio.java
  15. +7 −0 app/src/main/java/org/axonframework/samples/trader/app/api/portfolio/item/ReserveItemsCommand.java
  16. +9 −1 ...nframework/samples/trader/app/api/portfolio/money/CancelMoneyReservationFromPortfolioCommand.java
  17. +8 −1 ...ramework/samples/trader/app/api/portfolio/money/ConfirmMoneyReservationFromPortfolionCommand.java
  18. +8 −1 ...framework/samples/trader/app/api/portfolio/money/MoneyReservationCancelledFromPortfolioEvent.java
  19. +1 −1 ...framework/samples/trader/app/api/portfolio/money/MoneyReservationConfirmedFromPortfolioEvent.java
  20. +7 −1 ...ava/org/axonframework/samples/trader/app/api/portfolio/money/MoneyReservedFromPortfolioEvent.java
  21. +7 −1 ...ework/samples/trader/app/api/portfolio/money/NotEnoughMoneyInPortfolioToMakeReservationEvent.java
  22. +9 −1 ...va/org/axonframework/samples/trader/app/api/portfolio/money/ReserveMoneyFromPortfolioCommand.java
  23. +27 −17 app/src/main/java/org/axonframework/samples/trader/app/command/trading/BuyTradeManagerSaga.java
  24. +7 −1 app/src/main/java/org/axonframework/samples/trader/app/command/trading/Order.java
  25. +9 −7 app/src/main/java/org/axonframework/samples/trader/app/command/trading/OrderBook.java
  26. +2 −2 app/src/main/java/org/axonframework/samples/trader/app/command/trading/OrderBookCommandHandler.java
  27. +15 −15 app/src/main/java/org/axonframework/samples/trader/app/command/trading/Portfolio.java
  28. +6 −6 app/src/main/java/org/axonframework/samples/trader/app/command/trading/PortfolioCommandHandler.java
  29. +17 −10 app/src/main/java/org/axonframework/samples/trader/app/command/trading/SellTradeManagerSaga.java
  30. +0 −9 app/src/main/java/org/axonframework/samples/trader/app/command/trading/TradeManagerSaga.java
  31. +6 −1 app/src/main/java/org/axonframework/samples/trader/app/command/trading/Transaction.java
  32. +2 −0 app/src/main/java/org/axonframework/samples/trader/app/query/transaction/TransactionEntry.java
  33. +14 −11 app/src/test/java/org/axonframework/samples/trader/app/command/trading/BuyTradeManagerSagaTest.java
  34. +19 −10 ...c/test/java/org/axonframework/samples/trader/app/command/trading/OrderBookCommandHandlerTest.java
  35. +26 −45 ...c/test/java/org/axonframework/samples/trader/app/command/trading/PortfolioCommandHandlerTest.java
  36. +13 −11 app/src/test/java/org/axonframework/samples/trader/app/command/trading/SellTradeManagerSagaTest.java
  37. +9 −5 ...t/java/org/axonframework/samples/trader/app/query/orderbook/OrderBookListenerIntegrationTest.java
  38. +4 −3 ...est/java/org/axonframework/samples/trader/app/query/portfolio/PortfolioItemEventListenerTest.java
  39. +7 −7 web-ui/src/main/java/org/axonframework/samples/trader/webui/companies/CompanyController.java
  40. +12 −4 web-ui/src/main/java/org/axonframework/samples/trader/webui/init/DBInit.java
  41. +5 −4 web-ui/src/main/resources/log4j.properties
  42. +1 −0 web-ui/src/main/webapp/WEB-INF/decorators/master.jsp
@@ -27,15 +27,17 @@
private AggregateIdentifier portfolioId;
private AggregateIdentifier orderBookId;
+ private AggregateIdentifier transactionId;
private long tradeCount;
private long itemPrice;
private AggregateIdentifier orderId;
- protected AbstractOrderCommand(AggregateIdentifier portfolioId, AggregateIdentifier orderBookId, long tradeCount, long itemPrice) {
+ protected AbstractOrderCommand(AggregateIdentifier portfolioId, AggregateIdentifier orderBookId, AggregateIdentifier transactionId, long tradeCount, long itemPrice) {
this.portfolioId = portfolioId;
this.orderBookId = orderBookId;
this.tradeCount = tradeCount;
this.itemPrice = itemPrice;
+ this.transactionId = transactionId;
this.orderId = new UUIDAggregateIdentifier();
}
@@ -47,6 +49,10 @@ public AggregateIdentifier getOrderBookId() {
return orderBookId;
}
+ public AggregateIdentifier getTransactionId() {
+ return transactionId;
+ }
+
public long getTradeCount() {
return tradeCount;
}
@@ -26,12 +26,14 @@
public abstract class AbstractOrderPlacedEvent extends DomainEvent {
private final AggregateIdentifier orderId;
+ private AggregateIdentifier transactionId;
private final long tradeCount;
private final long itemPrice;
private final AggregateIdentifier portfolioId;
- protected AbstractOrderPlacedEvent(AggregateIdentifier orderId, long tradeCount, long itemPrice, AggregateIdentifier portfolioId) {
+ protected AbstractOrderPlacedEvent(AggregateIdentifier orderId, AggregateIdentifier transactionId, long tradeCount, long itemPrice, AggregateIdentifier portfolioId) {
this.orderId = orderId;
+ this.transactionId = transactionId;
this.tradeCount = tradeCount;
this.itemPrice = itemPrice;
this.portfolioId = portfolioId;
@@ -41,6 +43,10 @@ public AggregateIdentifier orderBookIdentifier() {
return getAggregateIdentifier();
}
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionId;
+ }
+
public AggregateIdentifier getOrderId() {
return orderId;
}
@@ -24,8 +24,8 @@
*/
public class BuyOrderPlacedEvent extends AbstractOrderPlacedEvent {
- public BuyOrderPlacedEvent(AggregateIdentifier orderId, long tradeCount, long itemPrice, AggregateIdentifier portfolioId) {
- super(orderId, tradeCount, itemPrice, portfolioId);
+ public BuyOrderPlacedEvent(AggregateIdentifier orderId, AggregateIdentifier transactionId, long tradeCount, long itemPrice, AggregateIdentifier portfolioId) {
+ super(orderId, transactionId, tradeCount, itemPrice, portfolioId);
}
}
@@ -24,7 +24,7 @@
*/
public class CreateBuyOrderCommand extends AbstractOrderCommand {
- public CreateBuyOrderCommand(AggregateIdentifier portfolioId, AggregateIdentifier orderBookId, long tradeCount, long itemPrice) {
- super(portfolioId, orderBookId, tradeCount, itemPrice);
+ public CreateBuyOrderCommand(AggregateIdentifier portfolioId, AggregateIdentifier orderBookId, AggregateIdentifier transactionId, long tradeCount, long itemPrice) {
+ super(portfolioId, orderBookId, transactionId, tradeCount, itemPrice);
}
}
@@ -24,7 +24,7 @@
*/
public class CreateSellOrderCommand extends AbstractOrderCommand {
- public CreateSellOrderCommand(AggregateIdentifier portfolioId, AggregateIdentifier orderBookId, long tradeCount, long itemPrice) {
- super(portfolioId, orderBookId, tradeCount, itemPrice);
+ public CreateSellOrderCommand(AggregateIdentifier portfolioId, AggregateIdentifier orderBookId, AggregateIdentifier transactionId, long tradeCount, long itemPrice) {
+ super(portfolioId, orderBookId, transactionId, tradeCount, itemPrice);
}
}
@@ -24,7 +24,7 @@
*/
public class SellOrderPlacedEvent extends AbstractOrderPlacedEvent {
- public SellOrderPlacedEvent(AggregateIdentifier orderId, long tradeCount, long itemPrice, AggregateIdentifier portfolioId) {
- super(orderId, tradeCount, itemPrice, portfolioId);
+ public SellOrderPlacedEvent(AggregateIdentifier orderId, AggregateIdentifier transactionId, long tradeCount, long itemPrice, AggregateIdentifier portfolioId) {
+ super(orderId, transactionId, tradeCount, itemPrice, portfolioId);
}
}
@@ -30,12 +30,21 @@
private final long tradePrice;
private final AggregateIdentifier buyOrderId;
private final AggregateIdentifier sellOrderId;
+ private final AggregateIdentifier buyTransactionId;
+ private final AggregateIdentifier sellTransactionId;
- public TradeExecutedEvent(long tradeCount, long tradePrice, AggregateIdentifier buyOrderId, AggregateIdentifier sellOrderId) {
+ public TradeExecutedEvent(long tradeCount,
+ long tradePrice,
+ AggregateIdentifier buyOrderId,
+ AggregateIdentifier sellOrderId,
+ AggregateIdentifier buyTransactionId,
+ AggregateIdentifier sellTransactionId) {
this.tradeCount = tradeCount;
this.tradePrice = tradePrice;
this.buyOrderId = buyOrderId;
this.sellOrderId = sellOrderId;
+ this.sellTransactionId = sellTransactionId;
+ this.buyTransactionId = buyTransactionId;
}
public AggregateIdentifier getOrderBookIdentifier() {
@@ -57,4 +66,12 @@ public AggregateIdentifier getBuyOrderId() {
public AggregateIdentifier getSellOrderId() {
return sellOrderId;
}
+
+ public AggregateIdentifier getBuyTransactionId() {
+ return buyTransactionId;
+ }
+
+ public AggregateIdentifier getSellTransactionId() {
+ return sellTransactionId;
+ }
}
@@ -26,11 +26,16 @@
public class CancelItemReservationForPortfolioCommand {
private AggregateIdentifier portfolioIdentifier;
private AggregateIdentifier orderBookIdentifier;
+ private AggregateIdentifier transactionIdentifier;
private long amountOfCancelledItems;
- public CancelItemReservationForPortfolioCommand(AggregateIdentifier portfolioIdentifier, AggregateIdentifier orderBookIdentifier, long amountOfCancelledItems) {
+ public CancelItemReservationForPortfolioCommand(AggregateIdentifier portfolioIdentifier,
+ AggregateIdentifier orderBookIdentifier,
+ AggregateIdentifier transactionIdentifier,
+ long amountOfCancelledItems) {
this.portfolioIdentifier = portfolioIdentifier;
this.orderBookIdentifier = orderBookIdentifier;
+ this.transactionIdentifier = transactionIdentifier;
this.amountOfCancelledItems = amountOfCancelledItems;
}
@@ -46,4 +51,8 @@ public AggregateIdentifier getOrderBookIdentifier() {
public AggregateIdentifier getPortfolioIdentifier() {
return portfolioIdentifier;
}
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionIdentifier;
+ }
}
@@ -26,11 +26,16 @@
public class ConfirmItemReservationForPortfolioCommand {
private AggregateIdentifier portfolioIdentifier;
private AggregateIdentifier orderBookIdentifier;
+ private AggregateIdentifier transactionIdentifier;
private long amountOfItemsToConfirm;
- public ConfirmItemReservationForPortfolioCommand(AggregateIdentifier portfolioIdentifier, AggregateIdentifier orderBookIdentifier, long amountOfItemsToConfirm) {
+ public ConfirmItemReservationForPortfolioCommand(AggregateIdentifier portfolioIdentifier,
+ AggregateIdentifier orderBookIdentifier,
+ AggregateIdentifier transactionIdentifier,
+ long amountOfItemsToConfirm) {
this.portfolioIdentifier = portfolioIdentifier;
this.orderBookIdentifier = orderBookIdentifier;
+ this.transactionIdentifier = transactionIdentifier;
this.amountOfItemsToConfirm = amountOfItemsToConfirm;
}
@@ -45,4 +50,8 @@ public AggregateIdentifier getOrderBookIdentifier() {
public AggregateIdentifier getPortfolioIdentifier() {
return portfolioIdentifier;
}
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionIdentifier;
+ }
}
@@ -23,10 +23,14 @@
*/
public class ItemReservationCancelledForPortfolioEvent extends DomainEvent {
private AggregateIdentifier orderBookIdentifier;
+ private AggregateIdentifier transactionIdentifier;
private long amountOfCancelledItems;
- public ItemReservationCancelledForPortfolioEvent(AggregateIdentifier orderBookIdentifier, long amountOfCancelledItems) {
+ public ItemReservationCancelledForPortfolioEvent(AggregateIdentifier orderBookIdentifier,
+ AggregateIdentifier transactionIdentifier,
+ long amountOfCancelledItems) {
this.orderBookIdentifier = orderBookIdentifier;
+ this.transactionIdentifier = transactionIdentifier;
this.amountOfCancelledItems = amountOfCancelledItems;
}
@@ -41,4 +45,8 @@ public AggregateIdentifier getOrderBookIdentifier() {
public AggregateIdentifier getPortfolioIdentifier() {
return getAggregateIdentifier();
}
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionIdentifier;
+ }
}
@@ -23,10 +23,14 @@
*/
public class ItemReservationConfirmedForPortfolioEvent extends DomainEvent {
private AggregateIdentifier orderBookIdentifier;
+ private AggregateIdentifier transactionIdentifier;
private long amountOfConfirmedItems;
- public ItemReservationConfirmedForPortfolioEvent(AggregateIdentifier orderBookIdentifier, long amountOfConfirmedItems) {
+ public ItemReservationConfirmedForPortfolioEvent(AggregateIdentifier orderBookIdentifier,
+ AggregateIdentifier transactionIdentifier,
+ long amountOfConfirmedItems) {
this.orderBookIdentifier = orderBookIdentifier;
+ this.transactionIdentifier = transactionIdentifier;
this.amountOfConfirmedItems = amountOfConfirmedItems;
}
@@ -41,4 +45,8 @@ public AggregateIdentifier getOrderBookIdentifier() {
public AggregateIdentifier getPortfolioIdentifier() {
return getAggregateIdentifier();
}
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionIdentifier;
+ }
}
@@ -23,9 +23,12 @@
*/
public class ItemToReserveNotAvailableInPortfolioEvent extends DomainEvent {
private AggregateIdentifier orderBookIdentifier;
+ private AggregateIdentifier transactionIdentifier;
- public ItemToReserveNotAvailableInPortfolioEvent(AggregateIdentifier orderBookIdentifier) {
+ public ItemToReserveNotAvailableInPortfolioEvent(AggregateIdentifier orderBookIdentifier,
+ AggregateIdentifier transactionIdentifier) {
this.orderBookIdentifier = orderBookIdentifier;
+ this.transactionIdentifier = transactionIdentifier;
}
public AggregateIdentifier getOrderBookIdentifier() {
@@ -35,4 +38,8 @@ public AggregateIdentifier getOrderBookIdentifier() {
public AggregateIdentifier getPortfolioIdentifier() {
return getAggregateIdentifier();
}
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionIdentifier;
+ }
}
@@ -23,10 +23,14 @@
*/
public class ItemsReservedEvent extends DomainEvent {
private AggregateIdentifier orderBookIdentifier;
+ private AggregateIdentifier transactionIdentifier;
private long amountOfItemsReserved;
- public ItemsReservedEvent(AggregateIdentifier orderBookIdentifier, long amountOfItemsReserved) {
+ public ItemsReservedEvent(AggregateIdentifier orderBookIdentifier,
+ AggregateIdentifier transactionIdentifier,
+ long amountOfItemsReserved) {
this.orderBookIdentifier = orderBookIdentifier;
+ this.transactionIdentifier = transactionIdentifier;
this.amountOfItemsReserved = amountOfItemsReserved;
}
@@ -41,4 +45,8 @@ public AggregateIdentifier getOrderBookIdentifier() {
public AggregateIdentifier getPortfolioIdentifier() {
return getAggregateIdentifier();
}
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionIdentifier;
+ }
}
@@ -24,11 +24,16 @@
public class NotEnoughItemsAvailableToReserveInPortfolio extends DomainEvent {
private AggregateIdentifier orderBookIdentifier;
+ private AggregateIdentifier transactionIdentifier;
private long availableAmountOfItems;
private long amountOfItemsToReserve;
- public NotEnoughItemsAvailableToReserveInPortfolio(AggregateIdentifier orderBookIdentifier, long availableAmountOfItems, long amountOfItemsToReserve) {
+ public NotEnoughItemsAvailableToReserveInPortfolio(AggregateIdentifier orderBookIdentifier,
+ AggregateIdentifier transactionIdentifier,
+ long availableAmountOfItems,
+ long amountOfItemsToReserve) {
this.orderBookIdentifier = orderBookIdentifier;
+ this.transactionIdentifier = transactionIdentifier;
this.availableAmountOfItems = availableAmountOfItems;
this.amountOfItemsToReserve = amountOfItemsToReserve;
}
@@ -48,4 +53,8 @@ public AggregateIdentifier getOrderBookIdentifier() {
public AggregateIdentifier getPortfolioIdentifier() {
return getAggregateIdentifier();
}
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionIdentifier;
+ }
}
@@ -22,13 +22,16 @@
*/
public class ReserveItemsCommand {
private AggregateIdentifier portfolioIdentifier;
+ private AggregateIdentifier transactionIdentifier;
private long amountOfItemsToReserve;
private AggregateIdentifier orderBookIdentifier;
public ReserveItemsCommand(AggregateIdentifier portfolioIdentifier,
AggregateIdentifier orderBookIdentifier,
+ AggregateIdentifier transactionIdentifier,
long amountOfItemsToReserve) {
this.portfolioIdentifier = portfolioIdentifier;
+ this.transactionIdentifier = transactionIdentifier;
this.amountOfItemsToReserve = amountOfItemsToReserve;
this.orderBookIdentifier = orderBookIdentifier;
}
@@ -44,4 +47,8 @@ public AggregateIdentifier getPortfolioIdentifier() {
public AggregateIdentifier getOrderBookIdentifier() {
return orderBookIdentifier;
}
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionIdentifier;
+ }
}
@@ -22,10 +22,14 @@
*/
public class CancelMoneyReservationFromPortfolioCommand {
private AggregateIdentifier portfolioIdentifier;
+ private AggregateIdentifier transactionIdentifier;
private long amountOfMoneyToCancel;
- public CancelMoneyReservationFromPortfolioCommand(AggregateIdentifier portfolioIdentifier, long amountOfMoneyToCancel) {
+ public CancelMoneyReservationFromPortfolioCommand(AggregateIdentifier portfolioIdentifier,
+ AggregateIdentifier transactionIdentifier,
+ long amountOfMoneyToCancel) {
this.portfolioIdentifier = portfolioIdentifier;
+ this.transactionIdentifier = transactionIdentifier;
this.amountOfMoneyToCancel = amountOfMoneyToCancel;
}
@@ -36,4 +40,8 @@ public long getAmountOfMoneyToCancel() {
public AggregateIdentifier getPortfolioIdentifier() {
return portfolioIdentifier;
}
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionIdentifier;
+ }
}
@@ -22,11 +22,13 @@
*/
public class ConfirmMoneyReservationFromPortfolionCommand {
private AggregateIdentifier portfolioIdentifier;
+ private AggregateIdentifier transactionIdentifier;
private long amountOfMoneyToConfirmInCents;
- public ConfirmMoneyReservationFromPortfolionCommand(AggregateIdentifier portfolioIdentifier, long amountOfMoneyToConfirmInCents) {
+ public ConfirmMoneyReservationFromPortfolionCommand(AggregateIdentifier portfolioIdentifier, AggregateIdentifier transactionIdentifier, long amountOfMoneyToConfirmInCents) {
this.portfolioIdentifier = portfolioIdentifier;
+ this.transactionIdentifier = transactionIdentifier;
this.amountOfMoneyToConfirmInCents = amountOfMoneyToConfirmInCents;
}
@@ -38,11 +40,16 @@ public AggregateIdentifier getPortfolioIdentifier() {
return portfolioIdentifier;
}
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionIdentifier;
+ }
+
@Override
public String toString() {
return "ConfirmMoneyReservationFromPortfolionCommand{" +
"amountOfMoneyToConfirmInCents=" + amountOfMoneyToConfirmInCents +
", portfolioIdentifier=" + portfolioIdentifier +
+ ", transactionIdentifier=" + transactionIdentifier +
'}';
}
}
Oops, something went wrong.

0 comments on commit 3a3e575

Please sign in to comment.