Mercurial > hg > ltpda
annotate m-toolbox/classes/@ltpda_uo/retrieve.m @ 22:b11e88004fca database-connection-manager
Update collection.fromRepository
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Mon, 05 Dec 2011 16:20:06 +0100 |
parents | 86aabb42dd84 |
children | a59cdb8aaf31 |
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 import utils.const.* |
8
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
38 utils.helper.msg(msg.MNAME, '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
|
39 |
8
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
40 if numel(varargin) < 2 |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
41 error('### invalid usage'); |
0 | 42 end |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
43 |
8
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
44 % connection |
0 | 45 conn = varargin{1}; |
8
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
46 varargin = 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
|
47 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
|
48 error('### the first argument should be a java.sql.Connection object'); |
0 | 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 |
8
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
51 binary = false; |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
52 if ischar(varargin{1}) && strcmpi(varargin{1}, 'binary') |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
53 % binary |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
54 binary = true; |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
55 varargin = varargin(2:end); |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
56 utils.helper.msg(msg.PROC1, 'binary retrieve'); |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
57 end |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
58 |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
59 if ischar(varargin{1}) && strcmpi(varargin{1}, 'collection') |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
60 % collection |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
61 cid = varargin{2}; |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
62 varargin = varargin(3:end); |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
63 if ~isempty(varargin) |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
64 error('### wrong number of arguments'); |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
65 end |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
66 utils.helper.msg(msg.PROC1, 'retrieving collection %d', cid); |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
67 |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
68 % get list of object IDs from the collection ID |
12
86aabb42dd84
Use utils.repository utilities
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
10
diff
changeset
|
69 ids = utils.repository.getCollectionIDs(conn, cid); |
86aabb42dd84
Use utils.repository utilities
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
10
diff
changeset
|
70 |
8
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
71 else |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
72 % IDs list |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
73 if isnumeric([varargin{:}]) |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
74 ids = [varargin{:}]; |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
75 else |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
76 error('### invalid usage'); |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
77 end |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
78 end |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
79 |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
80 utils.helper.msg(msg.PROC1, ['retrieving objects' sprintf(' %d', ids)]); |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
81 |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
82 % output vector |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
83 objs = []; |
2f5c9bd7d95d
Clarify ltpda_uo.retrieve parameters handling
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
7
diff
changeset
|
84 |
0 | 85 try |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
86 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
87 % get username and user id |
12
86aabb42dd84
Use utils.repository utilities
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
10
diff
changeset
|
88 [username, userid] = utils.repository.getUser(conn); |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
89 |
0 | 90 v = ver('LTPDA'); |
91 for j=1:length(ids) | |
92 | |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
93 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
|
94 if isempty(rows) |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
95 error('### object %d not found', ids(j)); |
0 | 96 end |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
97 objver = rows{1}; |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
98 objtype = rows{2}; |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
99 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
100 % 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
|
101 % 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
|
102 % the current version |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
103 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
|
104 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
|
105 '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
|
106 end |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
107 |
0 | 108 if binary |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
109 % binary download |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
110 |
0 | 111 % 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
|
112 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
|
113 if isempty(rows) |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
114 error('### failed to get binary data for object %d', ids(j)); |
0 | 115 end |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
116 dd = rows{1}; |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
117 |
0 | 118 % Write bytes out to a temp MAT file |
119 fname = [tempname '.mat']; | |
120 fd = fopen(fname, 'w+'); | |
121 fwrite(fd, dd, 'int8'); | |
122 fclose(fd); | |
123 % Load the MAT data to a structure | |
124 obj = load(fname); | |
125 % Delete temp file | |
126 delete(fname); | |
127 % Get the struct out | |
128 obj = obj.objs; | |
129 | |
130 % Check if the retrieved object is a struct | |
131 if isstruct(obj) | |
132 % 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
|
133 fcn_name = [objtype '.update_struct']; |
0 | 134 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
|
135 obj = feval(objtype, obj); |
0 | 136 end |
137 % Add tyo object array | |
138 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
|
139 |
0 | 140 else |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
141 % xml download |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
142 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
143 % get xml |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
144 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
|
145 if isempty(rows) |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
146 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
|
147 end |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
148 |
10
75007001cbfe
Check for binary only objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
9
diff
changeset
|
149 % check xml |
75007001cbfe
Check for binary only objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
9
diff
changeset
|
150 if strcmp(rows{1}(1:13), 'binary submit') |
75007001cbfe
Check for binary only objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
9
diff
changeset
|
151 error('### object %d has binary representation only', ids(j)); |
75007001cbfe
Check for binary only objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
9
diff
changeset
|
152 end |
75007001cbfe
Check for binary only objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
9
diff
changeset
|
153 |
75007001cbfe
Check for binary only objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
9
diff
changeset
|
154 % parse xml |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
155 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
|
156 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
|
157 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
|
158 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
|
159 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
160 % 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
|
161 objs = [objs {obj}]; |
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 % make transaction entry |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
164 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
|
165 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
|
166 '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
|
167 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
|
168 end |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
169 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
170 end |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
171 |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
172 catch ex |
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
173 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
|
174 rethrow(ex) |
0 | 175 end |
7
1e91f84a4be8
Make ltpda_up.retrieve work with java.sql.Connection objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
0
diff
changeset
|
176 |
0 | 177 % Set outputs |
178 if nargout == 1 | |
179 if length(objs) == 1 | |
180 varargout{1} = objs{1}; | |
181 else | |
182 varargout{1} = objs; | |
183 end | |
184 else | |
185 for k=1:nargout | |
186 varargout{k} = objs{k}; | |
187 end | |
188 end | |
189 end |