Wiki source code of Java Client - Model-Defined FetchSpecifications
Last modified by David Avendasora on 2008/01/14 15:46
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
1.1 | 1 | Client code: |
2 | |||
![]() |
3.1 | 3 | {{code}} |
4 | |||
![]() |
1.1 | 5 | private static final EODistributedObjectStore dos = (EODistributedObjectStore)(EOEditingContext.defaultParentObjectStore()); |
6 | |||
![]() |
3.1 | 7 | /** |
8 | * Invokes the remote method on session to get a named fetch specification. Needed because | ||
9 | * the whole eoaccess package is excluded from the client side frameworks. | ||
10 | * | ||
11 | @param spec Fetch specification name. | ||
12 | @param entity Name of the entity for which the fetch specification is for. | ||
13 | @return The fetch specification, or null if it is not in the model, or an error occured | ||
14 | */ | ||
15 | public static EOFetchSpecification getFetchSpecification( | ||
16 | String spec, | ||
17 | String entity){ | ||
18 | |||
19 | //invoke! | ||
20 | return (EOFetchSpecification) dos.invokeStatelessRemoteMethodWithKeyPath( | ||
21 | "session", | ||
22 | "clientSideRequestGetFetchSpecification", | ||
23 | new Class[]{String.class, String.class}, | ||
24 | new String[]{spec, entity}); | ||
25 | } | ||
![]() |
1.1 | 26 | |
![]() |
3.1 | 27 | {{/code}} |
![]() |
1.1 | 28 | |
29 | Server code, in the Session class: | ||
30 | |||
![]() |
3.1 | 31 | {{code}} |
![]() |
4.1 | 32 | |
![]() |
3.1 | 33 | /** |
34 | * Loads and returns an <tt>EOFetchSpecification</tt> objects for the given | ||
35 | * specification and entity name. | ||
36 | * | ||
37 | @param spec Name of the specification | ||
38 | @param entity Name of the entitiy | ||
39 | @return A fetch specification, or <tt>null</tt> if it is not found, or an | ||
40 | error occurs | ||
41 | */ | ||
42 | public EOFetchSpecification getFetchSpecification(String spec, String entity){ | ||
43 | try{ | ||
44 | return EOFetchSpecification.fetchSpecificationNamed(spec, entity); | ||
45 | }catch(Exception ex){ | ||
46 | return null; | ||
47 | } | ||
48 | } | ||
![]() |
1.1 | 49 | |
![]() |
3.1 | 50 | {{/code}} |
![]() |
1.1 | 51 | |
![]() |
3.1 | 52 | //courtesy Florijan Stamenkovic// |