11
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 function ids = getCollectionIDs(conn, cid)
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 % GETCOLLECTIONIDS Return the IDs of the object composing a collection.
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % CALL:
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 %
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % ids = utils.repository.getCollectionIDs(conn, cid)
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 %
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % PARAMETERS:
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 %
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % CONN database connection implementing java.sql.Connection
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % CID collection id
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 %
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 rows = utils.mysql.execute(conn, 'SELECT nobjs, obj_ids FROM collections WHERE id = ?', cid);
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 if isempty(rows)
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 error('### collection %d not found', cid);
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 end
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 nobjs = rows{1};
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 ids = strread(rows{2}, '%d', 'delimiter', ',');
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 if length(ids) ~= nobjs
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 error('### inconsistent collection description');
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 end
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 % transform column vector in row vector
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 ids = ids';
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25
|
9174aadb93a5
Add LTPDA Repository utility functions into utils.repository
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 end
|