comparison m-toolbox/classes/@LTPDARepositoryManager/getSinfo.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % GETSINFO gets the submission information of an object in the repository.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: GETSINFO gets the submission information of an object in the
5 % repository.
6 %
7 % CALL: sinfo = LTPDARepositoryManager.getSinfo(pl);
8 % sinfo = LTPDARepositoryManager.getSinfo(ids);
9 % sinfo = LTPDARepositoryManager.getSinfo(ids, 'hostname');
10 % sinfo = LTPDARepositoryManager.getSinfo(ids, 'hostname', 'database');
11 % sinfo = LTPDARepositoryManager.getSinfo(ids, 'hostname', 'database', 'username');
12 %
13 % If all required connection fields are input, the connection will be
14 % silently created and added to the manager. Otherwise, a connection dialog
15 % will be presented and the resulting connection added to the manager.
16 %
17 % <a href="matlab:web(LTPDARepositoryManager.getInfo('LTPDARepositoryManager.getSinfo').tohtml, '-helpbrowser')">Parameters Description</a>
18 %
19 % VERSION: $Id: getSinfo.m,v 1.4 2011/04/08 08:56:35 hewitson Exp $
20 %
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22
23 function varargout = getSinfo(varargin)
24
25 % Check if this is a call for parameters
26 if utils.helper.isinfocall(varargin{:})
27 varargout{1} = getInfo(varargin{3});
28 return
29 end
30
31 import utils.const.*
32 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
33
34 % Collect all plists
35 [pl, invars, rest] = utils.helper.collect_objects(varargin(:), 'plist');
36
37 pl = combine(pl, getDefaultPlist);
38 ids = pl.find('ids');
39 hostname = pl.find('hostname');
40 database = pl.find('database');
41 username = pl.find('username');
42
43 % Check through 'rest'
44 if numel(rest) > 0
45 ids = rest{1};
46 end
47 if numel(rest) > 1
48 hostname = rest{2};
49 end
50 if numel(rest) > 2
51 database = rest{3};
52 end
53 if numel(rest) > 3
54 username = rest{4};
55 end
56
57 % Some plausibility checks
58 if isempty(ids)
59 error('### This method needs at least one object id.');
60 end
61 if nargout == 0
62 error('### This method can not be used as a modifier method. Please give one output');
63 end
64
65 % Get complete experiment information for each input id
66 sinfo = [];
67 for ii=1:length(ids)
68 query = ['select name,experiment_title,experiment_desc,analysis_desc,quantity, '...
69 'additional_authors,additional_comments,keywords,reference_ids FROM objmeta ' ...
70 sprintf('where objmeta.obj_id=%d',ids(ii))];
71
72 infoall = LTPDARepositoryManager.executeQuery(query, hostname, database, username);
73 if ~isempty(infoall)
74 s.name = infoall{1};
75 s.experiment_title = infoall{2};
76 s.experiment_description = infoall{3};
77 s.analysis_description = infoall{4};
78 s.quantity = infoall{5};
79 s.additional_authors = infoall{6};
80 s.additional_comments = infoall{7};
81 s.keywords = infoall{8};
82 s.reference_ids = infoall{9};
83 sinfo = [sinfo s];
84 else
85 warning('!!! Doesn''t find any submission information for the object id %d', ids(ii));
86 end
87 end
88
89 % Set output
90 varargout{1} = sinfo;
91
92 end
93
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 % Local Functions %
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97
98 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99 %
100 % FUNCTION: getInfo
101 %
102 % DESCRIPTION: Returns the method-info object
103 %
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 function ii = getInfo(varargin)
106 if nargin == 1 && strcmpi(varargin{1}, 'None')
107 sets = {};
108 pl = [];
109 else
110 sets = {'Default'};
111 pl = getDefaultPlist;
112 end
113 % Build info object
114 ii = minfo(mfilename, 'LTPDARepositoryManager', 'ltpda', utils.const.categories.helper, '$Id: getSinfo.m,v 1.4 2011/04/08 08:56:35 hewitson Exp $', sets, pl);
115 end
116
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118 %
119 % FUNCTION: getDefaultPlist
120 %
121 % DESCRIPTION: Returns the default PLIST
122 %
123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124 function pl = getDefaultPlist()
125
126 % Initialise plist
127 pl = plist();
128
129 % ids
130 p = param({'ids', 'Object identifications of which you need the submission information.'}, paramValue.EMPTY_DOUBLE);
131 pl.append(p);
132
133 % hostname
134 p = param({'hostname', 'The hostname of the repository to connect to.'}, paramValue.EMPTY_STRING);
135 pl.append(p);
136
137 % database
138 p = param({'database', 'The database on the repository.'}, paramValue.EMPTY_STRING);
139 pl.append(p);
140
141 % username
142 p = param({'username', 'The username to connect with.'}, paramValue.EMPTY_STRING);
143 pl.append(p);
144
145 end
146