diff 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
line wrap: on
line diff
--- a/m-toolbox/classes/+utils/@jmysql/getsinfo.m	Mon Dec 05 16:20:06 2011 +0100
+++ b/m-toolbox/classes/+utils/@jmysql/getsinfo.m	Mon Dec 05 16:20:06 2011 +0100
@@ -1,79 +1,56 @@
-% GETSINFO This function returns an sinfo object containing many useful information about an object retrieved from the repository
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function sinfo = getsinfo(conn, varargin)
+% GETSINFO  Retrieved objects submission info from the repository.
+%
+% CALL:
 %
-% usage:   sinfo = getsinfo(id, conn)
+%   sinfo = getsinfo(conn, id, id)
 %
-% inputs:  id    = obj_id from objmeta table
-%          conn  = utils.mysql.connect(server, dbname);
+% INPUTS:
+%
+%      id - object ID
+%    conn - repository connection implementing java.sql.Connection
 %
-% 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
+% OUTPUTS:
+%
+%   sinfo - array of sinfo structures containing fields
 %
-%          A Monsky 05-02-2009
-%
-% version: $Id: getsinfo.m,v 1.2 2011/03/29 13:40:16 hewitson Exp $
+%    - name
+%    - experiment_title
+%    - experiment_desc
+%    - analysis_desc
+%    - quantity
+%    - additional_authors
+%    - additional_comments
+%    - keywords
+%    - reference_ids
 %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-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.');
+% VERSION: $Id: getsinfo.m,v 1.2 2011/03/29 13:40:16 hewitson Exp $
+
+  if ~isa(conn, 'java.sql.Connection')
+    error('### first argument should be a java.sql.Connection object');
   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);
+  for kk = 1:length(varargin)
+
+    q = ['SELECT name, experiment_title, experiment_desc, analysis_desc, ' ...
+         'quantity, additional_authors, additional_comments, keywords, ' ...
+         'reference_ids FROM objmeta WHERE obj_id = ?'];
+
+    info = utils.mysql.execute(conn, q, varargin{kk});
+
     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};
+    s.name                    = info{1};
+    s.experiment_title        = info{2};
+    s.experiment_description  = info{3};
+    s.analysis_description    = info{4};
+    s.quantity                = info{5};
+    s.additional_authors      = info{6};
+    s.additional_comments     = info{7};
+    s.keywords                = info{8};
+    s.reference_ids           = info{9};
+
     sinfo = [sinfo s];
   end
-  
-  % Set output
-  varargout{1} = sinfo;
+
 end