コード例 #1
0
  @CommandHandler
  public void createLocation(CreateLocationCommand command) {
    checkUniqueName(command.getLocationId(), command.getName(), command.getBusinessUnitId());
    checkInactiveDate(command.getInactiveDate());

    Location location = new Location(command);
    repository.add(location);
  }
コード例 #2
0
 @CommandHandler
 public void handle(GenerateTimesheet command) {
   Map<Integer, TimeEntry> timeEntries =
       timeEntryService.generateTimeEntries(
           HolidayCalendar.BELGIUM, command.getYear(), command.getMonthOfYear());
   TimesheetAR timesheetAR =
       new TimesheetAR(
           command.getTimesheetId(),
           command.getSsn(),
           command.getYear(),
           command.getMonthOfYear(),
           timeEntries);
   timesheetARRepository.add(timesheetAR);
 }
コード例 #3
0
    @Override
    public Object handle(CommandMessage<StubCommand> command, UnitOfWork unitOfWork)
        throws Throwable {
      if (ExceptionCommand.class.isAssignableFrom(command.getPayloadType())) {
        throw ((ExceptionCommand) command.getPayload()).getException();
      } else if (CreateCommand.class.isAssignableFrom(command.getPayloadType())) {
        StubAggregate aggregate =
            new StubAggregate(command.getPayload().getAggregateIdentifier().toString());
        repository.add(aggregate);
        aggregate.doSomething();
      } else {
        StubAggregate aggregate = repository.load(command.getPayload().getAggregateIdentifier());
        if (ErrorCommand.class.isAssignableFrom(command.getPayloadType())) {
          aggregate.createFailingEvent();
        } else {
          aggregate.doSomething();
        }
      }

      return Void.TYPE;
    }
コード例 #4
0
 @CommandHandler
 public void handleCreateOrderBook(CreateOrderBookCommand command) {
   OrderBook orderBook = new OrderBook(command.getOrderBookIdentifier());
   repository.add(orderBook);
 }