1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.wotonomy.control;
20
21 import java.util.List;
22 import java.util.Map;
23
24
25
26
27 /***
28 * EditingContext provides transactional support for
29 * fetching, editing, and committing changes made on a
30 * collection of objects to a parent object store.
31 * This subclasses EOEditingContext to provide
32 * java-friendly conveniences.
33 *
34 * @author michael@mpowers.net
35 * @author $Author: cgruber $
36 * @version $Revision: 894 $
37 */
38 public class EditingContext extends EOEditingContext
39 {
40 /***
41 * Default constructor creates a new editing context
42 * that uses the default object store. If the default
43 * object store has not been set, an exception is thrown.
44 */
45 public EditingContext()
46 {
47 this( defaultParentObjectStore() );
48 }
49
50 /***
51 * Creates a new editing context that uses the specified
52 * object store as its parent object store.
53 */
54 public EditingContext( EOObjectStore anObjectStore )
55 {
56 super( anObjectStore );
57 }
58
59 /***
60 * Returns a List of objects associated with the object
61 * with the specified id for the specified property
62 * relationship, or may return a placeholder array that
63 * will defer the fetch until needed (aka an array fault).
64 * All objects must be registered in the specified editing context.
65 * This implementation calls to its parent object store's
66 * implementation if the requested source object is not
67 * registered in this editing context.
68 * The specified relationship key must produce a result of
69 * type Collection for the source object or an exception is thrown.
70 */
71 public List getArrayFaultWithSourceGlobalID (
72 EOGlobalID aGlobalID,
73 String aRelationshipKey,
74 EOEditingContext aContext )
75 {
76 return arrayFaultWithSourceGlobalID(
77 aGlobalID, aRelationshipKey, aContext );
78 }
79
80 /***
81 * Returns a snapshot of the specified object as it
82 * existed when it was last read or committed to the
83 * parent object store.
84 */
85 public Map getCommittedSnapshotForObject (
86 Object anObject )
87 {
88 return committedSnapshotForObject( anObject );
89 }
90
91 /***
92 * Returns a snapshot of the specified object as it
93 * existed before the edits triggered by the current
94 * event loop were processed.
95 */
96 public Map getCurrentEventSnapshotForObject (
97 Object anObject )
98 {
99 return currentEventSnapshotForObject( anObject );
100 }
101
102 /***
103 * Returns the delegate for this editing context,
104 * or null if no delegate has been set.
105 */
106 public Object getDelegate ()
107 {
108 return delegate();
109 }
110
111 /***
112 * Returns a List of all objects marked as deleted
113 * in this editing context.
114 */
115 public List getDeletedObjects ()
116 {
117 return deletedObjects();
118 }
119
120 /***
121 * Returns a List of registered editors of this
122 * editing context.
123 */
124 public List getEditors()
125 {
126 return editors();
127 }
128
129 /***
130 * Returns the object for the specified id.
131 * If the object's data has not been fetched,
132 * it will be fetched when needed.
133 */
134 public Object getFaultForGlobalID (
135 EOGlobalID aGlobalID )
136 {
137 return faultForGlobalID( aGlobalID, this );
138 }
139
140 /***
141 * Returns a fault representing an object of
142 * the specified entity type with values from
143 * the specified dictionary.
144 */
145 public Object getFaultForRawRow (
146 Map aDictionary,
147 String anEntityName )
148 {
149 return faultForRawRow( aDictionary, anEntityName );
150 }
151
152 /***
153 * Returns the fetch timestamp for this editing context.
154 */
155 public double getFetchTimestamp()
156 {
157 return fetchTimestamp();
158 }
159
160 /***
161 * Returns the id for the specified object, or null
162 * if the object is not registered in this context.
163 */
164 public EOGlobalID getGlobalIDForObject (
165 Object anObject )
166 {
167 return globalIDForObject( anObject );
168 }
169
170 /***
171 * Returns a List of the objects that have been
172 * inserted into this editing context.
173 */
174 public List getInsertedObjects ()
175 {
176 return insertedObjects();
177 }
178
179 /***
180 * Returns the message handler for this editing context,
181 * or null if no message handler has been set.
182 */
183 public Object getMessageHandler ()
184 {
185 return messageHandler();
186 }
187
188 /***
189 * Returns the object registered in this editing context
190 * for the specified id, or null if that id is not
191 * registered.
192 */
193 public Object getObjectForGlobalID (
194 EOGlobalID aGlobalID )
195 {
196 return objectForGlobalID( aGlobalID );
197 }
198
199 /***
200 * Returns a List of objects the meet the criteria of
201 * the supplied specification.
202 */
203 public List getObjectsWithFetchSpecification (
204 EOFetchSpecification aFetchSpec )
205 {
206 return objectsWithFetchSpecification( aFetchSpec );
207 }
208
209 /***
210 * Returns the parent object store for this editing context.
211 * The result will not be null.
212 */
213 public EOObjectStore getParentObjectStore ()
214 {
215 return parentObjectStore();
216 }
217
218 /***
219 * Returns a List of all objects registered in this
220 * editing context.
221 */
222 public List geRegisteredObjects ()
223 {
224 return registeredObjects();
225 }
226
227 /***
228 * Returns the root object store, which is the parent
229 * of all parent object stores of this editing context.
230 */
231 public EOObjectStore getRootObjectStore ()
232 {
233 return rootObjectStore();
234 }
235
236 /***
237 * Returns a list of all objects marked as modified,
238 * but not inserted or deleted, in this editing context.
239 */
240 public List getUpdatedObjects ()
241 {
242 return updatedObjects();
243 }
244
245
246
247 public static double getDefaultFetchTimestampLag()
248 {
249 return defaultFetchTimestampLag();
250 }
251
252 /***
253 * Returns the default parent object store for all
254 * object stores created with the parameterless
255 * constructor.
256 */
257 public static EOObjectStore getDefaultParentObjectStore()
258 {
259 return defaultParentObjectStore();
260 }
261
262 }
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283