Interface PersistenceService
- All Known Implementing Classes:
DefaultPersistenceService
public interface PersistenceService
-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(EmailSchedulingData emailSchedulingData) Persist the EmailSchedulingData into the persistence service.voidaddAll(Collection<EmailSchedulingData> emailSchedulingDataList) Persist all the EmailSchedulingData contained in the given collection into the persistence service.Retrieve an Optional containing the EmailSchedulingData stored for the given emailSchedulingDataId, if the key exists and a value was found.getNextBatch(int batchMaxSize) Retrieves a batch of EmailSchedulingData from the persistence layer, such that up tobatchMaxSizeinstances are returned from a whatsoever priority level.getNextBatch(int priorityLevel, int batchMaxSize) Retrieves a batch of EmailSchedulingData from the persistence layer, such that up tobatchMaxSizeinstances are returned from a specific priority level.booleanRemove the EmailSchedulingData associated to the given id, returningtrueif the key was found in the persistence layer,falseotherwise.voidRemove all the EmailSchedulingData in the peristence layer.voidremoveAll(int priorityLevel) Remove all the EmailSchedulingData associated to the given priority level.voidremoveAll(Collection<String> ids) Remove all the EmailSchedulingData associated to the ids in the given collection.
-
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
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
Remove the EmailSchedulingData associated to the given id, returningtrueif the key was found in the persistence layer,falseotherwise.- Parameters:
id- the id of stored EmailSchedulingData.- Returns:
trueif the id exists and the value was successfully removed;falseotherwise.
-
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 tobatchMaxSizeinstances are returned from a specific priority level.If no data is persisted, an empty collection is returned. If less than
batchMaxSizeare persisted,batchMaxSizeare 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
Retrieves a batch of EmailSchedulingData from the persistence layer, such that up tobatchMaxSizeinstances are returned from a whatsoever priority level.If no data is persisted, an empty collection is returned. If less than
batchMaxSizeare persisted,batchMaxSizeare returned.- Parameters:
batchMaxSize- the desired size of the batch.- Returns:
- a batch of EmailSchedulingData to be retrieved from the persistence layer.
-
removeAll
Remove all the EmailSchedulingData in the peristence layer. -
removeAll
Remove all the EmailSchedulingData associated to the given priority level.- Parameters:
priorityLevel- the id of the prioroty level that has to be erased.
-
removeAll
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.
-