Mercurial > hg > ltpda
view m-toolbox/classes/+utils/@jmysql/getsinfo.m @ 44:409a22968d5e default
Add unit tests
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Tue, 06 Dec 2011 18:42:11 +0100 |
parents | f0afece42f48 |
children | 91f21a0aab35 |
line wrap: on
line source
% GETSINFO This function returns an sinfo object containing many useful information about an object retrieved from the repository %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % usage: sinfo = getsinfo(id, conn) % % inputs: id = obj_id from objmeta table % conn = utils.mysql.connect(server, dbname); % % outputs: sinfo cell array object containing info about object having the % given obj_id on the repository. % sinfo contains the following fields: % - name % - experiment_title % - experiment_desc % - analysis_desc % - quantity % - additional_authors % - additional_comments % - keywords and reference_ids % % A Monsky 05-02-2009 % % version: $Id: getsinfo.m,v 1.2 2011/03/29 13:40:16 hewitson Exp $ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [varargout] = getsinfo(varargin) import utils.const.* utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); % Collect input variable names in_names = cell(size(varargin)); for ii = 1:nargin,in_names{ii} = inputname(ii);end % Collect all ids and plists and connections pl = utils.helper.collect_objects(varargin(:), 'plist'); id = utils.helper.collect_objects(varargin(:), 'double'); conn = utils.helper.collect_objects(varargin(:), 'mpipeline.repository.RepositoryConnection'); if isempty(conn) error('### This method needs a java connection (mpipeline.repository.RepositoryConnection).'); end if isempty(id) error('### This method needs at least one object id.'); end if nargout == 0 error('### lscov can not be used as a modifier method. Please give at least one output'); end % combine plists pl = combine(pl, plist()); % Algorithm % Get complete experiment information for each input id sinfo = []; for ii=1:length(id) qall = ['select name,experiment_title,experiment_desc,analysis_desc,quantity, '... 'additional_authors,additional_comments,keywords,reference_ids FROM objmeta ' ... sprintf('where objmeta.obj_id=%d',id(ii))]; infoall = utils.jmysql.dbquery(conn, qall); s.conn = conn; s.name = infoall{1}; s.experiment_title = infoall{2}; s.experiment_description = infoall{3}; s.analysis_description = infoall{4}; s.quantity = infoall{5}; s.additional_authors = infoall{6}; s.additional_comments = infoall{7}; s.keywords = infoall{8}; s.reference_ids = infoall{9}; sinfo = [sinfo s]; end % Set output varargout{1} = sinfo; end