Mercurial > hg > ltpda
annotate m-toolbox/classes/@ltpda_uo/retrieve.m @ 7:1e91f84a4be8 database-connection-manager
Make ltpda_up.retrieve work with java.sql.Connection objects
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Mon, 05 Dec 2011 16:20:06 +0100 |
parents | f0afece42f48 |
children | 2f5c9bd7d95d |
rev | line source |
---|---|
0 | 1 % RETRIEVE retrieves a collection of objects from an LTPDA repository. |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: This static method retrieves a collection of objects from an | |
5 % LTPDA repository. | |
6 % | |
7 % CALL: objs = retrieve(conn, obj_id_1, obj_id_2) | |
8 % [o1,o2] = retrieve(conn, obj_id_1, obj_id_2) | |
9 % [o1,o2] = retrieve(conn, 'binary', obj_id_1, obj_id_2) | |
10 % objs = retrieve(conn, 'Collection', coll_id) | |
11 % objs = retrieve(conn, 'binary', 'Collection', coll_id) | |
12 % | |
13 % INPUTS: | |
14 % conn - database connection object | |
15 % obj_id_N - an object ID | |
16 % coll_id - a collection ID | |
17 % 'binary' - to retrieve a binary representation of the object | |
18 % (if stored) | |
19 % | |
20 % OUTPUTS: | |
21 % objs - the retrieved object(s) as a cell array.* | |
22 % o1,o2,...,oN - returns the first N objects | |
23 % | |
24 % | |
25 % If more than one object is retrieved and only one output is specified | |
26 % then the output is a cell array of objects. | |
27 % | |
28 % If only a single object is requested, it is returned as an object, | |
29 % not packed in a cell array. | |
30 % | |
31 % VERSION: $Id: retrieve.m,v 1.28 2011/07/01 14:38:57 ingo Exp $ | |
32 % | |
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
34 | |
35 function varargout = retrieve(varargin) | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
36 |
0 | 37 % Check if this is a call for parameters |
38 if utils.helper.isinfocall(varargin{:}) | |
39 varargout{1} = getInfo(varargin{3}); | |
40 return | |
41 end | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
42 |
0 | 43 import utils.const.* |
44 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
45 |
0 | 46 if nargin == 0 |
47 help(mfilename); | |
48 error('### Incorrect inputs'); | |
49 end | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
50 |
0 | 51 objs = []; |
52 conn = varargin{1}; | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
53 if ~isa(conn, 'java.sql.Connection') |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
54 error('### the first argument should be a java.sql.Connection object'); |
0 | 55 end |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
56 |
0 | 57 try |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
58 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
59 % get username and user id |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
60 username = utils.mysql.execute(conn, 'SELECT SUBSTRING_INDEX(USER(),''@'',1)'); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
61 rows = utils.mysql.execute(conn, 'SELECT id FROM users WHERE username = ?', username{1}); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
62 if isempty(rows) |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
63 error('### could not determine user id'); |
0 | 64 end |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
65 userid = rows{1}; |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
66 |
0 | 67 binary = false; |
68 if nargin >= 3 && ischar(varargin{2}) && strcmpi(varargin{2}, 'binary') | |
69 %%% retrieve(conn, 'binary', obj_id_1, obj_id_2) | |
70 %%% retrieve(conn, 'binary', 'Collection', coll_id) | |
71 binary = true; | |
72 if nargin == 4 && ischar(varargin{3}) && strcmpi(varargin{3}, 'Collection') && isnumeric(varargin{4}) && numel(varargin{4}) == 1 | |
73 cid = varargin{4}; | |
74 % Get a list of object IDs from the collection ID | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
75 rows = utils.mysql.execute(conn, 'SELECT nobjs, obj_ids FROM collections WHERE id = ?', cid); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
76 nobjs = rows{1}; |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
77 ids = strread(rows{2}, '%d', 'delimiter', ','); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
78 if length(ids) ~= nobjs |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
79 error('### inconsistent collection description'); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
80 end |
0 | 81 elseif nargin >= 3 && isnumeric([varargin{3:end}]) |
82 ids = [varargin{3:end}]; | |
83 else | |
84 help(mfilename) | |
85 error('### Incorrect usage'); | |
86 end | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
87 |
0 | 88 elseif nargin == 3 && ischar(varargin{2}) && strcmpi(varargin{2}, 'Collection') && isnumeric(varargin{3}) && numel(varargin{3}) == 1 |
89 %%% retrieve(conn, 'Collection', coll_id) | |
90 cid = varargin{3}; | |
91 % Get a list of object IDs from the collection ID | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
92 rows = utils.mysql.execute(conn, 'SELECT nobjs, obj_ids FROM collections WHERE id = ?', cid); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
93 nobjs = rows{1}; |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
94 ids = strread(rows{2}, '%d', 'delimiter', ','); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
95 if length(ids) ~= nobjs |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
96 error('### inconsistent collection description'); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
97 end |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
98 |
0 | 99 elseif nargin >= 2 && isnumeric([varargin{2:end}]) |
100 %%% retrieve(conn, obj_id_1, obj_id_2) | |
101 ids = [varargin{2:end}]; | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
102 |
0 | 103 else |
104 help(mfilename) | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
105 error('### incorrect usage'); |
0 | 106 end |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
107 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
108 utils.helper.msg(msg.PROC1, ['retrieving objects' sprintf(' %d', ids)]); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
109 |
0 | 110 v = ver('LTPDA'); |
111 for j=1:length(ids) | |
112 | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
113 rows = utils.mysql.execute(conn, 'SELECT version, obj_type FROM objmeta WHERE obj_id = ?', ids(j)); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
114 if isempty(rows) |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
115 error('### object %d not found', ids(j)); |
0 | 116 end |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
117 objver = rows{1}; |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
118 objtype = rows{2}; |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
119 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
120 % it is only possible to download the object if the object in the |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
121 % database was submitted with the same or lower LTPDA version as |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
122 % the current version |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
123 if utils.helper.ver2num(v.Version) < utils.helper.ver2num(objver) |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
124 error(['### object %d was submitted with newer LTPDA version (%s) '... |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
125 'than this one (%s). please update'], ids(j), objver, v.Version); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
126 end |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
127 |
0 | 128 if binary |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
129 % binary download |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
130 |
0 | 131 % Retrieve the bytes |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
132 rows = utils.mysql.execute(conn, 'SELECT mat FROM bobjs WHERE obj_id = ?', ids(j)); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
133 if isempty(rows) |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
134 error('### failed to get binary data for object %d', ids(j)); |
0 | 135 end |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
136 dd = rows{1}; |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
137 |
0 | 138 % Write bytes out to a temp MAT file |
139 fname = [tempname '.mat']; | |
140 fd = fopen(fname, 'w+'); | |
141 fwrite(fd, dd, 'int8'); | |
142 fclose(fd); | |
143 % Load the MAT data to a structure | |
144 obj = load(fname); | |
145 % Delete temp file | |
146 delete(fname); | |
147 % Get the struct out | |
148 obj = obj.objs; | |
149 | |
150 % Check if the retrieved object is a struct | |
151 if isstruct(obj) | |
152 % Call the constructor with this struct | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
153 fcn_name = [objtype '.update_struct']; |
0 | 154 obj = feval(fcn_name, obj, obj.tbxver); |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
155 obj = feval(objtype, obj); |
0 | 156 end |
157 % Add tyo object array | |
158 objs = [objs {obj}]; | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
159 |
0 | 160 else |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
161 % xml download |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
162 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
163 % get xml |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
164 rows = utils.mysql.execute(conn, 'SELECT xml FROM objs WHERE id = ?', ids(j)); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
165 if isempty(rows) |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
166 error('### failed to get data for object %d', ids(j)); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
167 end |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
168 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
169 % parse xml |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
170 stream = java.io.StringBufferInputStream(java.lang.String(rows{1})); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
171 builder = javax.xml.parsers.DocumentBuilderFactory.newInstance.newDocumentBuilder(); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
172 xdoc = builder.parse(stream); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
173 obj = utils.xml.xmlread(xdoc); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
174 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
175 % add to output array |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
176 objs = [objs {obj}]; |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
177 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
178 % make transaction entry |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
179 t = time().format('yyyy-mm-dd HH:MM:SS', 'UTC'); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
180 utils.mysql.execute(conn, ['INSERT INTO transactions (obj_id, user_id, transdate, direction) ' ... |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
181 'VALUES (?, ?, ?, ?)'], ids(j), userid, t, 'out'); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
182 utils.helper.msg(msg.PROC1, 'updated transactions table'); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
183 end |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
184 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
185 end |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
186 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
187 catch ex |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
188 utils.helper.msg(msg.PROC1, '### retrieve error'); |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
189 rethrow(ex) |
0 | 190 end |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
191 |
0 | 192 % Set outputs |
193 if nargout == 1 | |
194 if length(objs) == 1 | |
195 varargout{1} = objs{1}; | |
196 else | |
197 varargout{1} = objs; | |
198 end | |
199 else | |
200 for k=1:nargout | |
201 varargout{k} = objs{k}; | |
202 end | |
203 end | |
204 end | |
205 | |
206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
207 % Local Functions % | |
208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
209 | |
210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
211 % | |
212 function ii = getInfo(varargin) | |
213 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
214 sets = {}; | |
215 pl = []; | |
216 else | |
217 sets = {'Default'}; | |
218 pl = getDefaultPlist; | |
219 end | |
220 % Build info object | |
221 ii = minfo(mfilename, 'ltpda_uo', 'ltpda', utils.const.categories.internal, '$Id: retrieve.m,v 1.28 2011/07/01 14:38:57 ingo Exp $', sets, pl); | |
222 ii.setModifier(false); | |
223 end | |
224 | |
225 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
226 % | |
227 function plout = getDefaultPlist() | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
228 persistent pl; |
0 | 229 if exist('pl', 'var')==0 || isempty(pl) |
230 pl = buildplist(); | |
231 end | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
232 plout = pl; |
0 | 233 end |
234 | |
235 function plo = buildplist() | |
236 plo = plist(); | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
237 |
0 | 238 p = param({'conn', 'A database object'}, paramValue.EMPTY_DOUBLE); |
239 plo.append(p); | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
240 |
0 | 241 p = param({'ids', 'IDs which should be collected'}, paramValue.EMPTY_DOUBLE); |
242 plo.append(p); | |
243 end |