1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.wotonomy.access;
20
21 import net.wotonomy.foundation.NSArray;
22 import net.wotonomy.foundation.NSDictionary;
23 import net.wotonomy.foundation.NSMutableArray;
24 import net.wotonomy.foundation.NSMutableDictionary;
25 /***
26 * Represents a stored procedure in a database.
27 *
28 * @author ezamudio@nasoft.com
29 * @author $Author: cgruber $
30 * @version $Revision: 894 $
31 */
32 public class EOStoredProcedure implements EOPropertyListEncoding {
33
34 protected String _name;
35 protected String _externalName;
36 protected EOModel _model;
37 protected NSArray _arguments = NSArray.EmptyArray;
38 protected NSDictionary _userInfo = NSDictionary.EmptyDictionary;
39 protected NSDictionary _internalInfo = NSDictionary.EmptyDictionary;
40
41 /*** Creates a stored procedure from a property list. */
42 public EOStoredProcedure(NSDictionary dict, Object obj) {
43 super();
44 if (obj instanceof EOModel)
45 _model = (EOModel)obj;
46 NSArray a = (NSArray)dict.objectForKey("arguments");
47 if (a != null) {
48 NSMutableArray args = new NSMutableArray(a.count());
49 for (int i = 0; i < a.count(); i++) {
50 NSDictionary ad = (NSDictionary)a.objectAtIndex(i);
51 EOAttribute arg = new EOAttribute(ad, this);
52 args.addObject(arg);
53 }
54 _arguments = args;
55 }
56 setName((String)dict.objectForKey("name"));
57 setExternalName((String)dict.objectForKey("externalName"));
58 if (dict.objectForKey("userInfo") != null)
59 setUserInfo((NSDictionary)dict.objectForKey("userInfo"));
60 if (dict.objectForKey("internalInfo") != null)
61 _internalInfo = (NSDictionary)dict.objectForKey("internalInfo");
62 }
63
64 public EOStoredProcedure(String withName) {
65 super();
66 setName(withName);
67 }
68
69 public void setName(String value) {
70 _name = value;
71 }
72 public String name() {
73 return _name;
74 }
75
76 public void setExternalName(String value) {
77 _externalName = value;
78 }
79 public String externalName() {
80 return _externalName;
81 }
82
83 public void setArguments(NSArray value) {
84 _arguments = value;
85 }
86 public NSArray arguments() {
87 return _arguments;
88 }
89
90 public EOModel model() {
91 return _model;
92 }
93
94 public void setUserInfo(NSDictionary info) {
95 _userInfo = info;
96 }
97 public NSDictionary userInfo() {
98 return _userInfo;
99 }
100
101 public void awakeWithPropertyList(NSDictionary plist) {
102 }
103
104 public void encodeIntoPropertyList(NSMutableDictionary plist) {
105 plist.setObjectForKey(name(), "name");
106 plist.setObjectForKey(externalName(), "externalName");
107 NSMutableArray arr = new NSMutableArray(_arguments.count());
108 NSMutableDictionary d = null;
109 for (int i = 0; i < _arguments.count(); i++) {
110 EOAttribute a = (EOAttribute)_arguments.objectAtIndex(i);
111 d = new NSMutableDictionary();
112 a.encodeIntoPropertyList(d);
113 arr.addObject(d);
114 }
115 plist.setObjectForKey(arr, "arguments");
116 }
117
118 }
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141