Ejemplo n.º 1
0
  @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);
    }
  }
Ejemplo n.º 2
0
 @Override
 public void deleteSendSchedule(SendSchedule sendSchedule) {
   try {
     if (sendSchedule.isIDSet())
       rsWrapper.recordStore.delete(
           SEND_SCHEDULE_SCHEMA.createRecordReference(sendSchedule.getID()));
   } catch (DBException e) {
     client.logError("Error upon deleting sendSchedule", e);
   }
 }