comparison m-toolbox/classes/+utils/@jmysql/getsinfo.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children 91f21a0aab35
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % GETSINFO This function returns an sinfo object containing many useful information about an object retrieved from the repository
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % usage: sinfo = getsinfo(id, conn)
5 %
6 % inputs: id = obj_id from objmeta table
7 % conn = utils.mysql.connect(server, dbname);
8 %
9 % outputs: sinfo cell array object containing info about object having the
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 %
21 % A Monsky 05-02-2009
22 %
23 % version: $Id: getsinfo.m,v 1.2 2011/03/29 13:40:16 hewitson Exp $
24 %
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 function [varargout] = getsinfo(varargin)
27
28 import utils.const.*
29 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
30
31 % Collect input variable names
32 in_names = cell(size(varargin));
33 for ii = 1:nargin,in_names{ii} = inputname(ii);end
34
35 % Collect all ids and plists and connections
36 pl = utils.helper.collect_objects(varargin(:), 'plist');
37 id = utils.helper.collect_objects(varargin(:), 'double');
38 conn = utils.helper.collect_objects(varargin(:), 'mpipeline.repository.RepositoryConnection');
39
40 if isempty(conn)
41 error('### This method needs a java connection (mpipeline.repository.RepositoryConnection).');
42 end
43
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 = [];
58 for ii=1:length(id)
59 qall = ['select name,experiment_title,experiment_desc,analysis_desc,quantity, '...
60 'additional_authors,additional_comments,keywords,reference_ids FROM objmeta ' ...
61 sprintf('where objmeta.obj_id=%d',id(ii))];
62
63 infoall = utils.jmysql.dbquery(conn, qall);
64 s.conn = conn;
65 s.name = infoall{1};
66 s.experiment_title = infoall{2};
67 s.experiment_description = infoall{3};
68 s.analysis_description = infoall{4};
69 s.quantity = infoall{5};
70 s.additional_authors = infoall{6};
71 s.additional_comments = infoall{7};
72 s.keywords = infoall{8};
73 s.reference_ids = infoall{9};
74 sinfo = [sinfo s];
75 end
76
77 % Set output
78 varargout{1} = sinfo;
79 end