private void executeCommand(
      CreateEntity command,
      CreateResult result,
      Authentication authentication,
      AsyncCallback<CreateResult> callback) {
    if (ProjectDTO.ENTITY_NAME.equals(command.getEntityName())) {
      exception(command, callback != null);

    } else if (PersonalEventDTO.ENTITY_NAME.equals(command.getEntityName())) {
      insertPersonalEvent(command, callback);

    } else if (ProjectReportDTO.ENTITY_NAME.equals(command.getEntityName())) {
      exception(command, callback != null);

    } else if (ReminderDTO.ENTITY_NAME.equals(command.getEntityName())) {
      if (result != null) {
        reminderAsyncDAO.saveOrUpdate((ReminderDTO) result.getEntity());
      } else {
        insertReminder(command, authentication, callback);
      }

    } else if (MonitoredPointDTO.ENTITY_NAME.equals(command.getEntityName())) {
      if (result != null) {
        monitoredPointAsyncDAO.saveOrUpdate((MonitoredPointDTO) result.getEntity());
      } else {
        insertMonitoredPoint(command, authentication, callback);
      }

    } else {
      exception(command, callback != null);
    }
  }
  private void insertReminder(
      final CreateEntity command,
      final Authentication authentication,
      final AsyncCallback<CreateResult> callback) {
    final ReminderDTO reminder = buildReminderDTO(command.getProperties(), authentication);

    final RequestManager<CreateResult> requestManager =
        new RequestManager<CreateResult>(new CreateResult(reminder), callback);

    final int futureRequest = requestManager.prepareRequest();
    final RequestManager<ReminderDTO> objectRequestManager =
        new RequestManager<ReminderDTO>(
            reminder,
            new RequestManagerCallback<CreateResult, ReminderDTO>(requestManager) {

              @Override
              public void onRequestSuccess(ReminderDTO result) {
                reminderAsyncDAO.saveOrUpdate(
                    result,
                    new RequestManagerCallback<CreateResult, ReminderDTO>(
                        requestManager, futureRequest) {

                      @Override
                      public void onRequestSuccess(ReminderDTO result) {
                        // Reminder has been saved successfully.
                      }
                    });
              }
            });

    // Retrieves project.
    final Integer projectId = (Integer) command.getProperties().get(ReminderDTO.PROJECT_ID);
    projectAsyncDAO.get(
        projectId,
        new RequestManagerCallback<ReminderDTO, ProjectDTO>(objectRequestManager) {

          @Override
          public void onRequestSuccess(ProjectDTO result) {
            final Integer remindersListId = result.getRemindersList().getId();
            reminder.setParentListId(remindersListId);
          }
        });

    // Generates a negative ID
    reminderAsyncDAO.generateNegativeId(
        new RequestManagerCallback<ReminderDTO, Integer>(objectRequestManager) {

          @Override
          public void onRequestSuccess(Integer result) {
            reminder.setId(result);
          }
        });

    objectRequestManager.ready();
    requestManager.ready();
  }