@Override
  public void storeSendSchedule(SendSchedule schedule) {
    try {
      // Get record representation:
      Record rec = SEND_SCHEDULE_SCHEMA.createRecord();
      if (schedule.isIDSet()) SEND_SCHEDULE_COLUMN_ID.storeValue(rec, schedule.getID());
      SEND_SCHEDULE_COLUMN_PROJECT.storeValue(
          rec, getProjectRecordReference(schedule.getProject()));
      SEND_SCHEDULE_COLUMN_RECEIVER.storeValue(
          rec,
          transmissionStore.getCorrespondentRecordReference(schedule.getReceiver(), true, false));
      SEND_SCHEDULE_COLUMN_INTERVAL.storeValue(rec, schedule.getTransmitIntervalS());
      SEND_SCHEDULE_COLUMN_ENCRYPT.storeValue(rec, schedule.isEncrypt());
      SEND_SCHEDULE_COLUMN_ENABLED.storeValue(rec, schedule.isEnabled());
      SEND_SCHEDULE_COLUMN_HEARTBEAT_INTERVAL.storeValue(rec, schedule.getHeartbeatInterval());
      SEND_SCHEDULE_COLUMN_NO_DATA_COUNTER.storeValue(rec, schedule.getNoDataToSendCounter());

      // Store/update the record in the db:
      rsWrapper.recordStore.store(rec);

      // Check/set id on the object:
      if (schedule.isIDSet()) // if the object already had an ID...
      { // then it should match the ID on the record, so let's verify:
        if (schedule.getID() != SEND_SCHEDULE_COLUMN_ID.retrieveValue(rec).intValue())
          throw new IllegalStateException("Non-matching schedule ID"); // this should never happen
      } else
        // Set id in object as on the record:
        schedule.setID(SEND_SCHEDULE_COLUMN_ID.retrieveValue(rec).intValue());
    } catch (DBException e) {
      client.logError("Error upon storing send schedule", e);
    }
  }
 /**
  * Note: may return SendSchedules with a null of userDeleted receiver.
  *
  * @param transmissionStore
  * @param sendScheduleRecord
  * @return
  */
 private SendSchedule getSendScheduleFromRecord(
     TransmissionStore transmissionStore, Record sendScheduleRecord) {
   if (sendScheduleRecord == null) return null;
   Project project =
       retrieveProject(SEND_SCHEDULE_COLUMN_PROJECT.retrieveValue(sendScheduleRecord));
   Correspondent receiver =
       transmissionStore.retrieveCorrespondentByQuery(
           SEND_SCHEDULE_COLUMN_RECEIVER.retrieveValue(sendScheduleRecord).getRecordQuery());
   return new SendSchedule(
       project,
       SEND_SCHEDULE_COLUMN_ID.retrieveValue(sendScheduleRecord).intValue(),
       receiver /* may be null or userDeleted*/,
       SEND_SCHEDULE_COLUMN_INTERVAL.retrieveValue(sendScheduleRecord).intValue(),
       SEND_SCHEDULE_COLUMN_ENCRYPT.retrieveValue(sendScheduleRecord),
       SEND_SCHEDULE_COLUMN_ENABLED.retrieveValue(sendScheduleRecord),
       SEND_SCHEDULE_COLUMN_HEARTBEAT_INTERVAL.retrieveValue(sendScheduleRecord).intValue(),
       SEND_SCHEDULE_COLUMN_NO_DATA_COUNTER.retrieveValue(sendScheduleRecord).intValue());
 }