Ejemplo n.º 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);
  }
 @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);
 }
    @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;
    }
 @CommandHandler
 public void handleCreateOrderBook(CreateOrderBookCommand command) {
   OrderBook orderBook = new OrderBook(command.getOrderBookIdentifier());
   repository.add(orderBook);
 }