comparison m-toolbox/classes/@ltpda_uo/retrieve.m @ 12:86aabb42dd84 database-connection-manager

Use utils.repository utilities
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents 75007001cbfe
children a59cdb8aaf31
comparison
equal deleted inserted replaced
11:9174aadb93a5 12:86aabb42dd84
64 error('### wrong number of arguments'); 64 error('### wrong number of arguments');
65 end 65 end
66 utils.helper.msg(msg.PROC1, 'retrieving collection %d', cid); 66 utils.helper.msg(msg.PROC1, 'retrieving collection %d', cid);
67 67
68 % get list of object IDs from the collection ID 68 % get list of object IDs from the collection ID
69 rows = utils.mysql.execute(conn, 'SELECT nobjs, obj_ids FROM collections WHERE id = ?', cid); 69 ids = utils.repository.getCollectionIDs(conn, cid);
70 nobjs = rows{1}; 70
71 ids = strread(rows{2}, '%d', 'delimiter', ',');
72 if length(ids) ~= nobjs
73 error('### inconsistent collection description');
74 end
75
76 else 71 else
77 % IDs list 72 % IDs list
78 if isnumeric([varargin{:}]) 73 if isnumeric([varargin{:}])
79 ids = [varargin{:}]; 74 ids = [varargin{:}];
80 else 75 else
88 objs = []; 83 objs = [];
89 84
90 try 85 try
91 86
92 % get username and user id 87 % get username and user id
93 username = utils.mysql.execute(conn, 'SELECT SUBSTRING_INDEX(USER(),''@'',1)'); 88 [username, userid] = utils.repository.getUser(conn);
94 rows = utils.mysql.execute(conn, 'SELECT id FROM users WHERE username = ?', username{1});
95 if isempty(rows)
96 error('### could not determine user id');
97 end
98 userid = rows{1};
99 89
100 v = ver('LTPDA'); 90 v = ver('LTPDA');
101 for j=1:length(ids) 91 for j=1:length(ids)
102 92
103 rows = utils.mysql.execute(conn, 'SELECT version, obj_type FROM objmeta WHERE obj_id = ?', ids(j)); 93 rows = utils.mysql.execute(conn, 'SELECT version, obj_type FROM objmeta WHERE obj_id = ?', ids(j));