view m-toolbox/classes/+utils/@jmysql/getsinfo.m @ 50:7d2e2e065cf1 database-connection-manager

Update unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:24:37 +0100
parents 91f21a0aab35
children
line wrap: on
line source

function sinfo = getsinfo(conn, varargin)
% GETSINFO  Retrieved objects submission info from the repository.
%
% CALL:
%
%   sinfo = getsinfo(conn, id, id)
%
% INPUTS:
%
%      id - object ID
%    conn - repository connection implementing java.sql.Connection
%
% OUTPUTS:
%
%   sinfo - array of sinfo structures containing fields
%
%    - name
%    - experiment_title
%    - experiment_desc
%    - analysis_desc
%    - quantity
%    - additional_authors
%    - additional_comments
%    - keywords
%    - reference_ids
%
% 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

  sinfo = [];
  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                    = 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

end