Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
PersistableBusinessObject |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright 2007 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl2.php | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package org.kuali.rice.kns.bo; | |
17 | ||
18 | import java.util.Collection; | |
19 | import java.util.List; | |
20 | import java.util.UUID; | |
21 | ||
22 | /** | |
23 | * Declares a common interface for all {@link BusinessObject} classes which can have their | |
24 | * state persisted. A business object which is persistable defines some additional methods | |
25 | * which allow for various operations to be executed that relate to the persistent nature of | |
26 | * the business object. A persistable business object also has some additional data | |
27 | * attributes which include the version number, the object id, and the extension. | |
28 | * | |
29 | * <p>The version number indicates the version of the business object when it was retrieved | |
30 | * from persistent storage. This allows for services to check this version number | |
31 | * during persistence operations to prevent silent overwrites of business object state. | |
32 | * These kinds of scenarios might arise as a result of concurrent modification to the business | |
33 | * object in the persistent store (i.e. two web application users updating the same record | |
34 | * in a database). The kind of check which would be performed using the version number is commonly | |
35 | * referred to as "optimistic locking". | |
36 | * | |
37 | * <p>The object id represents a globally unique identifier for the business object. In practice, | |
38 | * this can be used by other portions of the system to link to persistable business objects which | |
39 | * might be stored in different locations or even different persistent data stores. In general, it | |
40 | * is not the responsibility of the client who implements a persistable business object to handle | |
41 | * generating this value. The framework will handle this automatically at the point in time when | |
42 | * the business object is persisted. If the client does need to do this themselves, however, care | |
43 | * should be taken that an appropriate globally unique value generator algorithm is used | |
44 | * (such as the one provided by {@link UUID}). | |
45 | * | |
46 | * <p>The extension object is primarily provided for the purposes of allowing implementer | |
47 | * customization of the business object without requiring the original business object to be | |
48 | * modified. The additional {@link PersistableBusinessObjectExtension} which is linked with the | |
49 | * parent business object can contain additional data attributes and methods. The framework will | |
50 | * automatically request that this extension object be persisted when the parent business object | |
51 | * is persisted. This is generally the most useful in cases where an application is defining | |
52 | * business objects that will be used in redistributable software packages (such as the | |
53 | * actual Kuali Foundation projects themselves). If using the framework for the purposes | |
54 | * of implementing an internal application, the use of a business object extensions | |
55 | * is likely unnecessary. | |
56 | * | |
57 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
58 | */ | |
59 | public interface PersistableBusinessObject extends BusinessObject { | |
60 | ||
61 | /** | |
62 | * Returns the version number of this instance of the business object. | |
63 | * This is generally used by the framework for optimistic locking | |
64 | * purposes. | |
65 | * | |
66 | * @return the version number of the business object | |
67 | */ | |
68 | public Long getVersionNumber(); | |
69 | ||
70 | /** | |
71 | * Sets the business object's version number. It is rarely advisable | |
72 | * for client code to manually set this value as the framework should | |
73 | * generally handle the management of version numbers internally. | |
74 | * | |
75 | * @param versionNumber the version number to set on this business object | |
76 | */ | |
77 | public void setVersionNumber(Long versionNumber); | |
78 | ||
79 | /** | |
80 | * @return objectID, the unique identifier for the object | |
81 | */ | |
82 | public String getObjectId(); | |
83 | ||
84 | /** | |
85 | * Sets the unique identifer for the object | |
86 | * | |
87 | * @param objectId | |
88 | */ | |
89 | public void setObjectId(String objectId); | |
90 | ||
91 | public PersistableBusinessObjectExtension getExtension(); | |
92 | ||
93 | public void setExtension(PersistableBusinessObjectExtension extension); | |
94 | ||
95 | /** | |
96 | * @see BusinessObject#refresh() | |
97 | */ | |
98 | public abstract void refreshNonUpdateableReferences(); | |
99 | ||
100 | /** | |
101 | * This method is used to refresh a reference object that hangs off of a document. For example, if the attribute's keys were | |
102 | * updated for a reference object, but the reference object wasn't, this method would go out and retrieve the reference object. | |
103 | * | |
104 | * @param referenceObjectName | |
105 | */ | |
106 | public abstract void refreshReferenceObject(String referenceObjectName); | |
107 | ||
108 | /** | |
109 | * If this method is not implemented appropriately for PersistableBusinessObject with collections, then PersistableBusinessObject with collections will not persist deletions correctly. | |
110 | * Elements that have been deleted will reappear in the DB after retrieval. | |
111 | * | |
112 | * @return List of collections which need to be monitored for changes by OJB | |
113 | */ | |
114 | public List<Collection<PersistableBusinessObject>> buildListOfDeletionAwareLists(); | |
115 | ||
116 | /** | |
117 | * Returns the boolean indicating whether this record is a new record of a maintenance document collection. | |
118 | * Used to determine whether the record can be deleted on the document. | |
119 | */ | |
120 | public boolean isNewCollectionRecord(); | |
121 | ||
122 | /** | |
123 | * Sets the boolean indicating this record is a new record of a maintenance document collection. | |
124 | * Used to determine whether the record can be deleted on the document. | |
125 | */ | |
126 | public void setNewCollectionRecord(boolean isNewCollectionRecord); | |
127 | ||
128 | /** | |
129 | * Hook to link in any editable user fields. | |
130 | */ | |
131 | public void linkEditableUserFields(); | |
132 | ||
133 | ||
134 | ||
135 | } |