Table of Contents
The service layer of the CDM contains a set of service objects that
are intended to provide basic query, search and persistence functionality
for the CDM objects, plus business logic to support common tasks. These
objects are intended to be singleton services used across the whole
application. As with the persistence layer, the services are strongly
typed, generic service objects, with a single service per (significant
base) class. All service classes implement
IService
and most implement
IVersionableService
, providing access to
generic base methods to deal with the class.
Table 7.1. IService
methods
Method | Description |
---|---|
UUID saveOrUpdate(T newOrTransientEntity);
|
Makes a new object persistent, or persists the state of a transient object. |
Map<UUID,T> save(Collection<T> newEntities);
|
Makes a collection of new objects persistent. |
UUID save(T newEntity);
|
Makes a new object persistent. |
UUID update(T newEntity);
|
Makes changes to a transient object persistent. |
UUID merge(T newEntity);
|
Merges the state of a detached object into the persisted version. |
UUID delete(T persistentEntity);
|
Deletes a persistent object. |
List<T> list(Class<? extends T> clazz,
|
Returns a (sub-)list of objects matching the type
|
Pager<T> page(Class<? extends T> clazz,
|
Returns a paged (sub-)list of objects matching the type
|
int count(Class<? extends T> clazz);
|
Returns a count of objects matching the type
|
T find(UUID uuid);
|
Returns an object of type T matching the supplied uuid if it exists. |
Collection<T> find(Collection<UUID> uuids);
|
Returns a collection of objects of type T matching the uuids supplied, if they exist. |
T load(UUID uuid,
|
Returns an object of type T with properties initialized according to the rules described below. |
Set<T> load(Collection<UUID> uuids,
|
Returns a collection of objects of type T matching the uuids supplied, if they exist, initialized according to the rules described below. |
boolean exists(UUID uuid);
|
Returns true if there is an object of type T in the database matching the supplied uuid. |
Class<T> getType();
|
Returns the class of objects that this Service provides access to. |
Table 7.2. IVersionableService
methods
Method | Description |
---|---|
Pager<AuditEventRecord<T>> pageAuditEvents(T versionablentity,
|
Makes a new object persistent, or persists the state of a transient object. |
AuditEvent getNextAuditEvent(T t);
|
Makes a collection of new objects persistent. |
AuditEvent getPreviousAuditEvent(T t);
|
Makes a new object persistent. |
boolean existed(UUID uuid);
|
Makes a new object persistent. |
In addition to being able to return results as a
java.util.List
, service layer methods can
return results as a Pager
. Pagers contain
a sublist of the total result set, plus a count of the total number of
matching objects. In addition, they contain a number of convenience
methods to facilitate the rendering of paged resultsets, including the
generation of labels for pages, based upon the matching objects.