Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@jmysql/getsinfo.m @ 16:91f21a0aab35 database-connection-manager
Update utils.jquery
* * *
Update utils.jmysql.getsinfo
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Mon, 05 Dec 2011 16:20:06 +0100 |
parents | f0afece42f48 |
children |
comparison
equal
deleted
inserted
replaced
15:ce3fbb7ebe71 | 16:91f21a0aab35 |
---|---|
1 % GETSINFO This function returns an sinfo object containing many useful information about an object retrieved from the repository | 1 function sinfo = getsinfo(conn, varargin) |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 2 % GETSINFO Retrieved objects submission info from the repository. |
3 % | 3 % |
4 % usage: sinfo = getsinfo(id, conn) | 4 % CALL: |
5 % | 5 % |
6 % inputs: id = obj_id from objmeta table | 6 % sinfo = getsinfo(conn, id, id) |
7 % conn = utils.mysql.connect(server, dbname); | |
8 % | 7 % |
9 % outputs: sinfo cell array object containing info about object having the | 8 % INPUTS: |
10 % given obj_id on the repository. | |
11 % sinfo contains the following fields: | |
12 % - name | |
13 % - experiment_title | |
14 % - experiment_desc | |
15 % - analysis_desc | |
16 % - quantity | |
17 % - additional_authors | |
18 % - additional_comments | |
19 % - keywords and reference_ids | |
20 % | 9 % |
21 % A Monsky 05-02-2009 | 10 % id - object ID |
11 % conn - repository connection implementing java.sql.Connection | |
22 % | 12 % |
23 % version: $Id: getsinfo.m,v 1.2 2011/03/29 13:40:16 hewitson Exp $ | 13 % OUTPUTS: |
24 % | 14 % |
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 15 % sinfo - array of sinfo structures containing fields |
26 function [varargout] = getsinfo(varargin) | 16 % |
27 | 17 % - name |
28 import utils.const.* | 18 % - experiment_title |
29 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | 19 % - experiment_desc |
30 | 20 % - analysis_desc |
31 % Collect input variable names | 21 % - quantity |
32 in_names = cell(size(varargin)); | 22 % - additional_authors |
33 for ii = 1:nargin,in_names{ii} = inputname(ii);end | 23 % - additional_comments |
34 | 24 % - keywords |
35 % Collect all ids and plists and connections | 25 % - reference_ids |
36 pl = utils.helper.collect_objects(varargin(:), 'plist'); | 26 % |
37 id = utils.helper.collect_objects(varargin(:), 'double'); | 27 % VERSION: $Id: getsinfo.m,v 1.2 2011/03/29 13:40:16 hewitson Exp $ |
38 conn = utils.helper.collect_objects(varargin(:), 'mpipeline.repository.RepositoryConnection'); | 28 |
39 | 29 if ~isa(conn, 'java.sql.Connection') |
40 if isempty(conn) | 30 error('### first argument should be a java.sql.Connection object'); |
41 error('### This method needs a java connection (mpipeline.repository.RepositoryConnection).'); | |
42 end | 31 end |
43 | 32 |
44 if isempty(id) | |
45 error('### This method needs at least one object id.'); | |
46 end | |
47 | |
48 if nargout == 0 | |
49 error('### lscov can not be used as a modifier method. Please give at least one output'); | |
50 end | |
51 | |
52 % combine plists | |
53 pl = combine(pl, plist()); | |
54 | |
55 % Algorithm | |
56 % Get complete experiment information for each input id | |
57 sinfo = []; | 33 sinfo = []; |
58 for ii=1:length(id) | 34 for kk = 1:length(varargin) |
59 qall = ['select name,experiment_title,experiment_desc,analysis_desc,quantity, '... | 35 |
60 'additional_authors,additional_comments,keywords,reference_ids FROM objmeta ' ... | 36 q = ['SELECT name, experiment_title, experiment_desc, analysis_desc, ' ... |
61 sprintf('where objmeta.obj_id=%d',id(ii))]; | 37 'quantity, additional_authors, additional_comments, keywords, ' ... |
62 | 38 'reference_ids FROM objmeta WHERE obj_id = ?']; |
63 infoall = utils.jmysql.dbquery(conn, qall); | 39 |
40 info = utils.mysql.execute(conn, q, varargin{kk}); | |
41 | |
64 s.conn = conn; | 42 s.conn = conn; |
65 s.name = infoall{1}; | 43 s.name = info{1}; |
66 s.experiment_title = infoall{2}; | 44 s.experiment_title = info{2}; |
67 s.experiment_description = infoall{3}; | 45 s.experiment_description = info{3}; |
68 s.analysis_description = infoall{4}; | 46 s.analysis_description = info{4}; |
69 s.quantity = infoall{5}; | 47 s.quantity = info{5}; |
70 s.additional_authors = infoall{6}; | 48 s.additional_authors = info{6}; |
71 s.additional_comments = infoall{7}; | 49 s.additional_comments = info{7}; |
72 s.keywords = infoall{8}; | 50 s.keywords = info{8}; |
73 s.reference_ids = infoall{9}; | 51 s.reference_ids = info{9}; |
52 | |
74 sinfo = [sinfo s]; | 53 sinfo = [sinfo s]; |
75 end | 54 end |
76 | 55 |
77 % Set output | |
78 varargout{1} = sinfo; | |
79 end | 56 end |