1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <chapter version=
"5.0" xml:
id=
"service" xmlns=
"http://docbook.org/ns/docbook"
3 xmlns:
ns5=
"http://www.w3.org/1999/xhtml"
4 xmlns:
ns4=
"http://www.w3.org/2000/svg"
5 xmlns:
ns3=
"http://www.w3.org/1998/Math/MathML"
6 xmlns:
ns2=
"http://www.w3.org/1999/xlink"
7 xmlns:
ns=
"http://docbook.org/ns/docbook">
9 <title>Services
</title>
13 <para>The service layer of the CDM contains a set of service objects that
14 are intended to provide basic query, search and persistence functionality
15 for the CDM objects, plus business logic to support common tasks. These
16 objects are intended to be singleton services used across the whole
17 application. As with the persistence layer, the services are strongly
18 typed, generic service objects, with a single service per (significant
19 base) class. All service classes implement
20 <interfacename>IService
</interfacename> and most implement
21 <interfacename>IVersionableService
</interfacename>, providing access to
22 generic base methods to deal with the class.
</para>
25 <title>An overview of the cdm service layer
</title>
28 <imageobject role=
"html">
29 <imagedata fileref=
"resources/images/service.png" format=
"png" />
32 <imageobject role=
"fo">
33 <imagedata contentwidth=
"160mm"
34 fileref=
"resources/images/service.png" format=
"png"
38 <caption>The Service layer in the CDM Java Library. There is a service for each major type of data that the CDM deals with.
</caption>
42 <table frame=
"all" xml:
id=
"iservice-methods">
43 <title><interfacename>IService
</interfacename> methods
</title>
45 <tgroup align=
"left" cols=
"2" colsep=
"1" rowsep=
"1">
46 <colspec colname=
"c1" />
48 <colspec colname=
"c2" />
54 <entry>Description
</entry>
64 <methodname>saveOrUpdate
</methodname>
69 <parameter>newOrTransientEntity
</parameter>
75 <para>Makes a new object persistent, or persists the state of a
76 transient object.
</para>
83 <type>Map
<UUID,T
></type>
85 <methodname>save
</methodname>
88 <type>Collection
<T
></type>
90 <parameter>newEntities
</parameter>
96 <para>Makes a collection of new objects persistent.
</para>
105 <methodname>save
</methodname>
110 <parameter>newEntity
</parameter>
116 <para>Makes a new object persistent.
</para>
125 <methodname>update
</methodname>
130 <parameter>newEntity
</parameter>
136 <para>Makes changes to a transient object persistent.
</para>
145 <methodname>merge
</methodname>
150 <parameter>newEntity
</parameter>
156 <para>Merges the state of a detached object into the persisted
166 <methodname>delete
</methodname>
171 <parameter>persistentEntity
</parameter>
177 <para>Deletes a persistent object.
</para>
184 <type>List
<T
></type>
186 <methodname>list
</methodname>
189 <type>Class
<? extends T
></type>
191 <parameter>clazz
</parameter>
197 <parameter>pageSize
</parameter>
203 <parameter>pageNumber
</parameter>
207 <type>List
<OrderHint
></type>
209 <parameter>orderHints
</parameter>
213 <type>List
<String
></type>
215 <parameter>propertyPaths
</parameter>
221 <para>Returns a (sub-)list of objects matching the type
222 <parameter>clazz
</parameter>, sorted according to the order
223 hints and initialized according to the propertyPaths.
</para>
230 <type>Pager
<T
></type>
232 <methodname>page
</methodname>
235 <type>Class
<? extends T
></type>
237 <parameter>clazz
</parameter>
243 <parameter>pageSize
</parameter>
249 <parameter>pageNumber
</parameter>
253 <type>List
<OrderHint
></type>
255 <parameter>orderHints
</parameter>
259 <type>List
<String
></type>
261 <parameter>propertyPaths
</parameter>
267 <para>Returns a paged (sub-)list of objects matching the type
268 <parameter>clazz
</parameter>, sorted according to the order
269 hints and initialized according to the propertyPaths.
</para>
278 <methodname>count
</methodname>
281 <type>Class
<? extends T
></type>
283 <parameter>clazz
</parameter>
289 <para>Returns a count of objects matching the type
290 <parameter>clazz
</parameter>.
</para>
299 <methodname>find
</methodname>
304 <parameter>uuid
</parameter>
310 <para>Returns an object of type T matching the supplied uuid if
318 <type>Collection
<T
></type>
320 <methodname>find
</methodname>
323 <type>Collection
<UUID
></type>
325 <parameter>uuids
</parameter>
331 <para>Returns a collection of objects of type T matching the
332 uuids supplied, if they exist.
</para>
341 <methodname>load
</methodname>
346 <parameter>uuid
</parameter>
350 <type>Collection
<String
></type>
352 <parameter>propertyPaths
</parameter>
358 <para>Returns an object of type T with properties initialized
359 according to the rules described below.
</para>
366 <type>Set
<T
></type>
368 <methodname>load
</methodname>
371 <type>Collection
<UUID
></type>
373 <parameter>uuids
</parameter>
377 <type>Collection
<String
></type>
379 <parameter>propertyPaths
</parameter>
385 <para>Returns a collection of objects of type T matching the
386 uuids supplied, if they exist, initialized according to the
387 rules described below.
</para>
396 <methodname>exists
</methodname>
401 <parameter>uuid
</parameter>
407 <para>Returns true if there is an object of type T in the
408 database matching the supplied uuid.
</para>
415 <type>Class
<T
></type>
417 <methodname>getType
</methodname>
422 <para>Returns the class of objects that this Service provides
430 <table frame=
"all" xml:
id=
"iversionableservice-methods">
431 <title><interfacename>IVersionableService
</interfacename>
434 <tgroup align=
"left" cols=
"2" colsep=
"1" rowsep=
"1">
435 <colspec colname=
"c1" />
437 <colspec colname=
"c2" />
441 <entry>Method
</entry>
443 <entry>Description
</entry>
451 <type>Pager
<AuditEventRecord
<T
>></type>
453 <methodname>pageAuditEvents
</methodname>
458 <parameter>versionablentity
</parameter>
464 <parameter>pageSize
</parameter>
470 <parameter>pageNumber
</parameter>
474 <type>AuditEventSort
</type>
476 <parameter>sort
</parameter>
482 <para>Makes a new object persistent, or persists the state of a
483 transient object.
</para>
490 <type>AuditEvent
</type>
492 <methodname>getNextAuditEvent
</methodname>
497 <parameter>t
</parameter>
503 <para>Makes a collection of new objects persistent.
</para>
510 <type>AuditEvent
</type>
512 <methodname>getPreviousAuditEvent
</methodname>
517 <parameter>t
</parameter>
523 <para>Makes a new object persistent.
</para>
532 <methodname>existed
</methodname>
537 <parameter>uuid
</parameter>
543 <para>Makes a new object persistent.
</para>
552 <title>Paging Resultsets
</title>
555 <para>In addition to being able to return results as a
556 <interfacename>java.util.List
</interfacename>, service layer methods can
557 return results as a
<interfacename>Pager
</interfacename>. Pagers contain
558 a sublist of the total result set, plus a count of the total number of
559 matching objects. In addition, they contain a number of convenience
560 methods to facilitate the rendering of paged resultsets, including the
561 generation of labels for pages, based upon the matching objects.
</para>