Interface PersistenceService

All Known Implementing Classes:
DefaultPersistenceService

public interface PersistenceService
  • Method Details

    • add

      @Transactional(rollbackFor=java.lang.Exception.class) void add(EmailSchedulingData emailSchedulingData)
      Persist the EmailSchedulingData into the persistence service. The key used to store the instance if the one returned by EmailSchedulingData.getId().

      Observe that in case of duplicate keys, the new values is used to override the oldest without any warning.

      Parameters:
      emailSchedulingData - the data to be stored.
    • get

      @Transactional(readOnly=true) Optional<EmailSchedulingData> get(String id)
      Retrieve an Optional containing the EmailSchedulingData stored for the given emailSchedulingDataId, if the key exists and a value was found.

      In case of no value forund the the given key, an empty Optional is returned.

      Parameters:
      id - the emailSchedulingDataId used to store an EmailSchedulingData.
      Returns:
      an optional containing the scheduling data of an email if any was found for the given emailSchedulingDataId; otherwise, an empty optional.
    • remove

      @Transactional(rollbackFor=java.lang.Exception.class) boolean remove(String id)
      Remove the EmailSchedulingData associated to the given id, returning true if the key was found in the persistence layer, false otherwise.
      Parameters:
      id - the id of stored EmailSchedulingData.
      Returns:
      true if the id exists and the value was successfully removed; false otherwise.
    • addAll

      @Transactional(rollbackFor=java.lang.Exception.class) void addAll(Collection<EmailSchedulingData> emailSchedulingDataList)
      Persist all the EmailSchedulingData contained in the given collection into the persistence service. The key used to store each the instance if the one returned by EmailSchedulingData.getId().

      Observe that in case of duplicate keys, the new values is used to override the oldest without any warning.

      Parameters:
      emailSchedulingDataList - collection of EmailSchedulingData to be persisted
    • getNextBatch

      @Transactional(readOnly=true) Collection<EmailSchedulingData> getNextBatch(int priorityLevel, int batchMaxSize)
      Retrieves a batch of EmailSchedulingData from the persistence layer, such that up to batchMaxSize instances are returned from a specific priority level.

      If no data is persisted, an empty collection is returned. If less than batchMaxSize are persisted, batchMaxSize are returned.

      Parameters:
      priorityLevel - the priority level from which we want to extract the batch.
      batchMaxSize - the desired size of the batch.
      Returns:
      a batch of EmailSchedulingData to be retrieved from the persistence layer.
    • getNextBatch

      @Transactional(readOnly=true) Collection<EmailSchedulingData> getNextBatch(int batchMaxSize)
      Retrieves a batch of EmailSchedulingData from the persistence layer, such that up to batchMaxSize instances are returned from a whatsoever priority level.

      If no data is persisted, an empty collection is returned. If less than batchMaxSize are persisted, batchMaxSize are returned.

      Parameters:
      batchMaxSize - the desired size of the batch.
      Returns:
      a batch of EmailSchedulingData to be retrieved from the persistence layer.
    • removeAll

      @Transactional(rollbackFor=java.lang.Exception.class) void removeAll()
      Remove all the EmailSchedulingData in the peristence layer.
    • removeAll

      @Transactional(rollbackFor=java.lang.Exception.class) void removeAll(int priorityLevel)
      Remove all the EmailSchedulingData associated to the given priority level.
      Parameters:
      priorityLevel - the id of the prioroty level that has to be erased.
    • removeAll

      @Transactional(rollbackFor=java.lang.Exception.class) void removeAll(Collection<String> ids)
      Remove all the EmailSchedulingData associated to the ids in the given collection. If for a specific id no key or value was found in the persistence layer, then the remove operation for that id is simply skipped.
      Parameters:
      ids - a collection of ids of stored EmailSchedulingData.